# HG changeset patch # User Adam Kaminski # Date 1630935813 14400 # Mon Sep 06 09:43:33 2021 -0400 # Node ID 8a02e90d236cbf56b3024e23dd514d149a653a8d # Parent 05f4bfcd25062015acb60a6ac408d0eecb46fb12 Merged SVC_CREATETRANSLATION2 into SVC_CREATETRANSLATION, so now a single server command handles all the different translation types. diff -r 05f4bfcd2506 -r 8a02e90d236c src/cl_main.cpp --- a/src/cl_main.cpp Mon Sep 06 07:39:11 2021 -0400 +++ b/src/cl_main.cpp Mon Sep 06 09:43:33 2021 -0400 @@ -287,7 +287,7 @@ static void client_DoFlashFader( BYTESTREAM_s *pByteStream ); static void client_GenericCheat( BYTESTREAM_s *pByteStream ); static void client_SetCameraToTexture( BYTESTREAM_s *pByteStream ); -static void client_CreateTranslation( BYTESTREAM_s *pByteStream, bool bIsTypeTwo ); +static void client_CreateTranslation( BYTESTREAM_s *pByteStream ); static void client_DoPusher( BYTESTREAM_s *pByteStream ); static void client_AdjustPusher( BYTESTREAM_s *pByteStream ); @@ -1891,11 +1891,7 @@ break; case SVC_CREATETRANSLATION: - client_CreateTranslation( pByteStream, false ); - break; - case SVC_CREATETRANSLATION2: - - client_CreateTranslation( pByteStream, true ); + client_CreateTranslation( pByteStream ); break; case SVC_DOPUSHER: @@ -9130,7 +9126,7 @@ //***************************************************************************** // -static void client_CreateTranslation( BYTESTREAM_s *pByteStream, bool bIsTypeTwo ) +static void client_CreateTranslation( BYTESTREAM_s *pByteStream ) { EDITEDTRANSLATION_s Translation; FRemapTable *pTranslation; @@ -9138,7 +9134,11 @@ // Read in which translation is being created. Translation.ulIdx = pByteStream->ReadShort(); - const bool bIsEdited = !!pByteStream->ReadByte(); + // [AK] Read in the booleans that tell us if this translation is edited, if it's + // a type-two translation, and if it's a desaturated translation. + const bool bIsEdited = pByteStream->ReadBit(); + const bool bIsTypeTwo = pByteStream->ReadBit(); + const bool bIsDesaturated = pByteStream->ReadBit(); // Read in the range that's being translated. Translation.ulStart = pByteStream->ReadByte(); @@ -9150,30 +9150,25 @@ Translation.ulPal2 = pByteStream->ReadByte(); Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE1; } + else if ( bIsDesaturated == false ) + { + Translation.ulR1 = pByteStream->ReadByte(); + Translation.ulG1 = pByteStream->ReadByte(); + Translation.ulB1 = pByteStream->ReadByte(); + Translation.ulR2 = pByteStream->ReadByte(); + Translation.ulG2 = pByteStream->ReadByte(); + Translation.ulB2 = pByteStream->ReadByte(); + Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE2; + } else { - const bool bIsDesaturated = !!pByteStream->ReadByte(); - - if ( bIsDesaturated ) - { - Translation.fR1 = pByteStream->ReadFloat(); - Translation.fG1 = pByteStream->ReadFloat(); - Translation.fB1 = pByteStream->ReadFloat(); - Translation.fR2 = pByteStream->ReadFloat(); - Translation.fG2 = pByteStream->ReadFloat(); - Translation.fB2 = pByteStream->ReadFloat(); - Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE3; - } - else - { - Translation.ulR1 = pByteStream->ReadByte(); - Translation.ulG1 = pByteStream->ReadByte(); - Translation.ulB1 = pByteStream->ReadByte(); - Translation.ulR2 = pByteStream->ReadByte(); - Translation.ulG2 = pByteStream->ReadByte(); - Translation.ulB2 = pByteStream->ReadByte(); - Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE2; - } + Translation.fR1 = pByteStream->ReadFloat(); + Translation.fG1 = pByteStream->ReadFloat(); + Translation.fB1 = pByteStream->ReadFloat(); + Translation.fR2 = pByteStream->ReadFloat(); + Translation.fG2 = pByteStream->ReadFloat(); + Translation.fB2 = pByteStream->ReadFloat(); + Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE3; } // [BB] We need to do this check here, otherwise the client could be crashed diff -r 05f4bfcd2506 -r 8a02e90d236c src/network_enums.h --- a/src/network_enums.h Mon Sep 06 07:39:11 2021 -0400 +++ b/src/network_enums.h Mon Sep 06 09:43:33 2021 -0400 @@ -312,7 +312,6 @@ ENUM_ELEMENT ( SVC_IGNOREPLAYER ), ENUM_ELEMENT ( SVC_SPAWNBLOODSPLATTER ), ENUM_ELEMENT ( SVC_SPAWNBLOODSPLATTER2 ), - ENUM_ELEMENT ( SVC_CREATETRANSLATION2 ), ENUM_ELEMENT ( SVC_REPLACETEXTURES ), ENUM_ELEMENT ( SVC_SETSECTORLINK ), ENUM_ELEMENT ( SVC_DOPUSHER ), diff -r 05f4bfcd2506 -r 8a02e90d236c src/sv_commands.cpp --- a/src/sv_commands.cpp Mon Sep 06 07:39:11 2021 -0400 +++ b/src/sv_commands.cpp Mon Sep 06 09:43:33 2021 -0400 @@ -4714,7 +4714,7 @@ NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addBit ( bIsEdited ); command.addByte ( ulStart ); command.addByte ( ulEnd ); command.addByte ( ulPal1 ); @@ -4727,15 +4727,16 @@ void SERVERCOMMANDS_CreateTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, ULONG ulR1, ULONG ulG1, ULONG ulB1, ULONG ulR2, ULONG ulG2, ULONG ulB2, ULONG ulPlayerExtra, ServerCommandFlags flags ) { const bool bIsEdited = SERVER_IsTranslationEdited ( ulTranslation ); - // [AK] We need some reliable way of indicating if this is a desaturated translation or not. - const bool bIsDesaturated = false; - - NetCommand command ( SVC_CREATETRANSLATION2 ); + // [AK] This is a translation that uses RGB values, so we'll send an extra bit indicating + // that this is a type-two translation. + const bool bIsTypeTwo = true; + + NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addBit ( bIsEdited ); + command.addBit ( bIsTypeTwo ); command.addByte ( ulStart ); command.addByte ( ulEnd ); - command.addByte ( bIsDesaturated ); command.addByte ( ulR1 ); command.addByte ( ulG1 ); command.addByte ( ulB1 ); @@ -4750,15 +4751,18 @@ void SERVERCOMMANDS_CreateDesaturatedTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, float fR1, float fG1, float fB1, float fR2, float fG2, float fB2, ULONG ulPlayerExtra, ServerCommandFlags flags ) { const bool bIsEdited = SERVER_IsTranslationEdited ( ulTranslation ); - // [AK] We need some reliable way of indicating if this is a desaturated translation or not. + // [AK] This is a desaturated translation, so we're going to send two extra bits that will + // indicate that this is both a type-two and a desaturated translation. + const bool bIsTypeTwo = true; const bool bIsDesaturated = true; - NetCommand command ( SVC_CREATETRANSLATION2 ); + NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addBit ( bIsEdited ); + command.addBit ( bIsTypeTwo ); + command.addBit ( bIsDesaturated ); command.addByte ( ulStart ); command.addByte ( ulEnd ); - command.addByte ( bIsDesaturated ); command.addFloat ( fR1 ); command.addFloat ( fG1 ); command.addFloat ( fB1 );