# HG changeset patch # User Adam Kaminski # Date 1630714338 14400 # Fri Sep 03 20:12:18 2021 -0400 # Node ID ed97432933c3c9bf9c879f84884651f60fe0cb9c # Parent 321de913a0d859bef2b0f5c31a4f7b0937b2fe0e Merged SVC_CREATETRANSLATION2 into SVC_CREATETRANSLATION, so now a single server command handles all the different translation types. diff -r 321de913a0d8 -r ed97432933c3 src/cl_main.cpp --- a/src/cl_main.cpp Fri Sep 03 11:26:36 2021 -0400 +++ b/src/cl_main.cpp Fri Sep 03 20:12:18 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 ); @@ -1883,11 +1883,7 @@ break; case SVC_CREATETRANSLATION: - client_CreateTranslation( pByteStream, false ); - break; - case SVC_CREATETRANSLATION2: - - client_CreateTranslation( pByteStream, true ); + client_CreateTranslation( pByteStream ); break; case SVC_DOPUSHER: @@ -9122,7 +9118,7 @@ //***************************************************************************** // -static void client_CreateTranslation( BYTESTREAM_s *pByteStream, bool bIsTypeTwo ) +static void client_CreateTranslation( BYTESTREAM_s *pByteStream ) { EDITEDTRANSLATION_s Translation; FRemapTable *pTranslation; @@ -9130,42 +9126,37 @@ // Read in which translation is being created. Translation.ulIdx = pByteStream->ReadShort(); - const bool bIsEdited = !!pByteStream->ReadByte(); + ULONG ulFlags = pByteStream->ReadByte(); // Read in the range that's being translated. Translation.ulStart = pByteStream->ReadByte(); Translation.ulEnd = pByteStream->ReadByte(); - if ( bIsTypeTwo == false ) + if ( ulFlags & CREATETRANSLATION_PALETTE ) { Translation.ulPal1 = pByteStream->ReadByte(); Translation.ulPal2 = pByteStream->ReadByte(); Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE1; } + else if ( ulFlags & 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 @@ -9186,7 +9177,7 @@ pTranslation->MakeIdentity(); } - if ( bIsEdited == false ) + if ( ulFlags & CREATETRANSLATION_ISEDITED ) pTranslation->MakeIdentity(); if ( Translation.ulType == DLevelScript::PCD_TRANSLATIONRANGE1 ) diff -r 321de913a0d8 -r ed97432933c3 src/network.h --- a/src/network.h Fri Sep 03 11:26:36 2021 -0400 +++ b/src/network.h Fri Sep 03 20:12:18 2021 -0400 @@ -207,6 +207,15 @@ ACTORSCALE_Y = 2 }; +// [AK] If we're creating a translation, what kind of translation is it? +enum CreateTranslationFlag +{ + CREATETRANSLATION_PALETTE = 1, + CREATETRANSLATION_RGB = 2, + CREATETRANSLATION_DESATURATED = 4, + CREATETRANSLATION_ISEDITED = 8, +}; + // [AK] If we're updating the map rotation then what exactly are we doing? enum UpdateMapRotationType { diff -r 321de913a0d8 -r ed97432933c3 src/network_enums.h --- a/src/network_enums.h Fri Sep 03 11:26:36 2021 -0400 +++ b/src/network_enums.h Fri Sep 03 20:12:18 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 321de913a0d8 -r ed97432933c3 src/sv_commands.cpp --- a/src/sv_commands.cpp Fri Sep 03 11:26:36 2021 -0400 +++ b/src/sv_commands.cpp Fri Sep 03 20:12:18 2021 -0400 @@ -4709,11 +4709,13 @@ // void SERVERCOMMANDS_CreateTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, ULONG ulPal1, ULONG ulPal2, ULONG ulPlayerExtra, ServerCommandFlags flags ) { - const bool bIsEdited = SERVER_IsTranslationEdited ( ulTranslation ); + ULONG ulFlags = CREATETRANSLATION_PALETTE; + if ( SERVER_IsTranslationEdited( ulTranslation )) + ulFlags |= CREATETRANSLATION_ISEDITED; NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addByte ( ulFlags ); command.addByte ( ulStart ); command.addByte ( ulEnd ); command.addByte ( ulPal1 ); @@ -4725,16 +4727,15 @@ // 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 ); + ULONG ulFlags = CREATETRANSLATION_RGB; + if ( SERVER_IsTranslationEdited( ulTranslation )) + ulFlags |= CREATETRANSLATION_ISEDITED; + + NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addByte ( ulFlags ); command.addByte ( ulStart ); command.addByte ( ulEnd ); - command.addByte ( bIsDesaturated ); command.addByte ( ulR1 ); command.addByte ( ulG1 ); command.addByte ( ulB1 ); @@ -4748,16 +4749,15 @@ // 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 ); + ULONG ulFlags = CREATETRANSLATION_DESATURATED; + if ( SERVER_IsTranslationEdited( ulTranslation )) + ulFlags |= CREATETRANSLATION_ISEDITED; + + NetCommand command ( SVC_CREATETRANSLATION ); command.addShort ( ulTranslation ); - command.addByte ( bIsEdited ); + command.addByte ( ulFlags ); command.addByte ( ulStart ); command.addByte ( ulEnd ); - command.addByte ( bIsDesaturated ); command.addFloat ( fR1 ); command.addFloat ( fG1 ); command.addFloat ( fB1 );