# HG changeset patch # User Adam Kaminski # Date 1631541189 14400 # Mon Sep 13 09:53:09 2021 -0400 # Node ID 96ae55abf5e2f1896c9b91394a029e3df0080583 # Parent 6786231f2a22f1d99d19a224709b38785d50cf19 Merged SVC_CREATETRANSLATION2 into SVC_CREATETRANSLATION, so now a single server command handles all the different translation types. diff -r 6786231f2a22 -r 96ae55abf5e2 src/cl_main.cpp --- a/src/cl_main.cpp Mon Sep 13 23:16:37 2021 -0400 +++ b/src/cl_main.cpp Mon Sep 13 09:53:09 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: @@ -9119,7 +9115,7 @@ //***************************************************************************** // -static void client_CreateTranslation( BYTESTREAM_s *pByteStream, bool bIsTypeTwo ) +static void client_CreateTranslation( BYTESTREAM_s *pByteStream ) { EDITEDTRANSLATION_s Translation; FRemapTable *pTranslation; @@ -9127,42 +9123,40 @@ // Read in which translation is being created. Translation.ulIdx = pByteStream->ReadShort(); - const bool bIsEdited = !!pByteStream->ReadByte(); + // [AK] Read in the boolean that tell us if this translation is edited, and the + // type of translation this is supposed to be. + const bool bIsEdited = pByteStream->ReadBit(); + const LONG lType = pByteStream->ReadShortByte( 7 ); // Read in the range that's being translated. Translation.ulStart = pByteStream->ReadByte(); Translation.ulEnd = pByteStream->ReadByte(); - if ( bIsTypeTwo == false ) + if ( lType == CREATETRANSLATION_PALETTE ) { Translation.ulPal1 = pByteStream->ReadByte(); Translation.ulPal2 = pByteStream->ReadByte(); Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE1; } + else if ( lType == CREATETRANSLATION_RGB ) + { + 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 6786231f2a22 -r 96ae55abf5e2 src/network.h --- a/src/network.h Mon Sep 13 23:16:37 2021 -0400 +++ b/src/network.h Mon Sep 13 09:53:09 2021 -0400 @@ -207,6 +207,14 @@ ACTORSCALE_Y = 2 }; +// [AK] What kind of translation are we sending to clients? +enum CreateTranslationType +{ + CREATETRANSLATION_PALETTE, + CREATETRANSLATION_RGB, + CREATETRANSLATION_DESATURATED, +}; + // [AK] What kind of player status are we trying to update? enum PlayerStatusType { diff -r 6786231f2a22 -r 96ae55abf5e2 src/network_enums.h --- a/src/network_enums.h Mon Sep 13 23:16:37 2021 -0400 +++ b/src/network_enums.h Mon Sep 13 09:53:09 2021 -0400 @@ -308,7 +308,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 6786231f2a22 -r 96ae55abf5e2 src/sv_commands.cpp --- a/src/sv_commands.cpp Mon Sep 13 23:16:37 2021 -0400 +++ b/src/sv_commands.cpp Mon Sep 13 09:53:09 2021 -0400 @@ -4701,7 +4701,8 @@ NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addBit ( bIsEdited ); + command.addShortByte ( CREATETRANSLATION_PALETTE, 7 ); command.addByte ( ulStart ); command.addByte ( ulEnd ); command.addByte ( ulPal1 ); @@ -4714,15 +4715,13 @@ 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 ); + + NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addBit ( bIsEdited ); + command.addShortByte ( CREATETRANSLATION_RGB, 7 ); command.addByte ( ulStart ); command.addByte ( ulEnd ); - command.addByte ( bIsDesaturated ); command.addByte ( ulR1 ); command.addByte ( ulG1 ); command.addByte ( ulB1 ); @@ -4737,15 +4736,13 @@ 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. - const bool bIsDesaturated = true; - - NetCommand command ( SVC_CREATETRANSLATION2 ); + + NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addBit ( bIsEdited ); + command.addShortByte ( CREATETRANSLATION_DESATURATED, 7 ); command.addByte ( ulStart ); command.addByte ( ulEnd ); - command.addByte ( bIsDesaturated ); command.addFloat ( fR1 ); command.addFloat ( fG1 ); command.addFloat ( fB1 );