# HG changeset patch # User Adam Kaminski # Date 1604382523 18000 # Tue Nov 03 00:48:43 2020 -0500 # Node ID 5fd19a2b17a7eb58224b076db9d6a45a4638540c # Parent 61b0668dceb72be21b07cae694ded53dc1dbcbc5 Fixed desaturated translations created with CreateTranslation() not syncing with clients in an online game. [Kaminsky] diff -r 61b0668dceb7 -r 5fd19a2b17a7 docs/zandronum-history.txt --- a/docs/zandronum-history.txt Fri Oct 30 16:11:39 2020 -0400 +++ b/docs/zandronum-history.txt Tue Nov 03 00:48:43 2020 -0500 @@ -40,6 +40,7 @@ - - Fixed jittery model interpolation, partly based on dpJudas's fix for GZDoom. [StrikerMan780] - - Fixed an integer overflow crash related to decals. [eagle, Torr Samaho] - - Fixed the obituary for the BFG tracer not being used if a player was killed by them. [Kaminsky] +- - Fixed desaturated translations created with CreateTranslation() not syncing with clients in an online game. [Kaminsky] ! - sv_forcegldefaults renamed to sv_forcevideodefaults. The old name still exists for compatibility. [Dusk] ! - r_3dfloors is now forced to be true when sv_forcevideodefaults is true. [Dusk] ! - When the wad authentication fails for a connecting client, the client only reports the missing and incompatible PWADS instead of all of them. [Pol Marcet] diff -r 61b0668dceb7 -r 5fd19a2b17a7 src/cl_main.cpp --- a/src/cl_main.cpp Fri Oct 30 16:11:39 2020 -0400 +++ b/src/cl_main.cpp Tue Nov 03 00:48:43 2020 -0500 @@ -8952,13 +8952,28 @@ } 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; + 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; + } } // [BB] We need to do this check here, otherwise the client could be crashed @@ -8985,7 +9000,14 @@ if ( Translation.ulType == DLevelScript::PCD_TRANSLATIONRANGE1 ) pTranslation->AddIndexRange( Translation.ulStart, Translation.ulEnd, Translation.ulPal1, Translation.ulPal2 ); else - pTranslation->AddColorRange( Translation.ulStart, Translation.ulEnd, Translation.ulR1, Translation.ulG1, Translation.ulB1, Translation.ulR2, Translation.ulG2, Translation.ulB2 ); + { + // [AK] We also need to check if this is a desaturated translation. + if ( Translation.ulType == DLevelScript::PCD_TRANSLATIONRANGE2 ) + pTranslation->AddColorRange( Translation.ulStart, Translation.ulEnd, Translation.ulR1, Translation.ulG1, Translation.ulB1, Translation.ulR2, Translation.ulG2, Translation.ulB2 ); + else + pTranslation->AddDesaturation( Translation.ulStart, Translation.ulEnd, Translation.fR1, Translation.fG1, Translation.fB1, Translation.fR2, Translation.fG2, Translation.fB2 ); + } + pTranslation->UpdateNative(); } diff -r 61b0668dceb7 -r 5fd19a2b17a7 src/p_acs.cpp --- a/src/p_acs.cpp Fri Oct 30 16:11:39 2020 -0400 +++ b/src/p_acs.cpp Tue Nov 03 00:48:43 2020 -0500 @@ -10313,6 +10313,24 @@ translation->AddDesaturation(start, end, FIXED2DBL(r1), FIXED2DBL(g1), FIXED2DBL(b1), FIXED2DBL(r2), FIXED2DBL(g2), FIXED2DBL(b2)); + + // [AK] If we're the server, send the new translation off to clients, and + // store it in our list so we can tell new clients who connect about the + // translation. + if ( NETWORK_GetState( ) == NETSTATE_SERVER ) + { + // [AK] Obtain the index of the translation. + const int translationindex = ACS_GetTranslationIndex( translation ); + float fR1 = FIXED2FLOAT( r1 ); + float fG1 = FIXED2FLOAT( g1 ); + float fB1 = FIXED2FLOAT( b1 ); + float fR2 = FIXED2FLOAT( r2 ); + float fG2 = FIXED2FLOAT( g2 ); + float fB2 = FIXED2FLOAT( b2 ); + + SERVERCOMMANDS_CreateDesaturatedTranslation( translationindex, start, end, fR1, fG1, fB1, fR2, fG2, fB2 ); + SERVER_AddEditedDesaturatedTranslation( translationindex, start, end, fR1, fG1, fB1, fR2, fG2, fB2 ); + } } break; diff -r 61b0668dceb7 -r 5fd19a2b17a7 src/sv_commands.cpp --- a/src/sv_commands.cpp Fri Oct 30 16:11:39 2020 -0400 +++ b/src/sv_commands.cpp Tue Nov 03 00:48:43 2020 -0500 @@ -4470,12 +4470,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 ); command.addShort ( ulTranslation ); command.addByte ( bIsEdited ); command.addByte ( ulStart ); command.addByte ( ulEnd ); + command.addByte ( bIsDesaturated ); command.addByte ( ulR1 ); command.addByte ( ulG1 ); command.addByte ( ulB1 ); @@ -4487,6 +4490,29 @@ //***************************************************************************** // +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 ); + command.addShort ( ulTranslation ); + command.addByte ( bIsEdited ); + command.addByte ( ulStart ); + command.addByte ( ulEnd ); + command.addByte ( bIsDesaturated ); + command.addFloat ( fR1 ); + command.addFloat ( fG1 ); + command.addFloat ( fB1 ); + command.addFloat ( fR2 ); + command.addFloat ( fG2 ); + command.addFloat ( fB2 ); + command.sendCommandToClients ( ulPlayerExtra, flags ); +} + +//***************************************************************************** +// void SERVERCOMMANDS_ReplaceTextures( const char *Fromname, const char *Toname, int iTexFlags, ULONG ulPlayerExtra, ServerCommandFlags flags ) { ServerCommands::ReplaceTextures command; diff -r 61b0668dceb7 -r 5fd19a2b17a7 src/sv_commands.h --- a/src/sv_commands.h Fri Oct 30 16:11:39 2020 -0400 +++ b/src/sv_commands.h Tue Nov 03 00:48:43 2020 -0500 @@ -426,6 +426,7 @@ void SERVERCOMMANDS_SetCameraToTexture( AActor *pCamera, char *pszTexture, LONG lFOV, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_CreateTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, ULONG ulPal1, ULONG ulPal2, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_CreateTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, ULONG ulR1, ULONG ulG1, ULONG ulB1, ULONG ulR2, ULONG ulG2, ULONG ulB2, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); +void SERVERCOMMANDS_CreateDesaturatedTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, float fR1, float fG1, float fB1, float fR2, float fG2, float fB2, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_ReplaceTextures( const char *Fromname, const char *Toname, int iTexFlags, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_SetSectorLink( ULONG ulSector, int iArg1, int iArg2, int iArg3, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); void SERVERCOMMANDS_DoPusher( ULONG ulType, line_t *pLine, int iMagnitude, int iAngle, AActor *pSource, int iAffectee, ULONG ulPlayerExtra = MAXPLAYERS, ServerCommandFlags flags = 0 ); diff -r 61b0668dceb7 -r 5fd19a2b17a7 src/sv_main.cpp --- a/src/sv_main.cpp Fri Oct 30 16:11:39 2020 -0400 +++ b/src/sv_main.cpp Tue Nov 03 00:48:43 2020 -0500 @@ -2640,7 +2640,13 @@ if ( g_EditedTranslationList[ulIdx].ulType == DLevelScript::PCD_TRANSLATIONRANGE1 ) SERVERCOMMANDS_CreateTranslation( g_EditedTranslationList[ulIdx].ulIdx, g_EditedTranslationList[ulIdx].ulStart, g_EditedTranslationList[ulIdx].ulEnd, g_EditedTranslationList[ulIdx].ulPal1, g_EditedTranslationList[ulIdx].ulPal2 ); else - SERVERCOMMANDS_CreateTranslation( g_EditedTranslationList[ulIdx].ulIdx, g_EditedTranslationList[ulIdx].ulStart, g_EditedTranslationList[ulIdx].ulEnd, g_EditedTranslationList[ulIdx].ulR1, g_EditedTranslationList[ulIdx].ulG1, g_EditedTranslationList[ulIdx].ulB1, g_EditedTranslationList[ulIdx].ulR2, g_EditedTranslationList[ulIdx].ulG2, g_EditedTranslationList[ulIdx].ulB2 ); + { + // [AK] We also need to check if this is a desaturated translation. + if( g_EditedTranslationList[ulIdx].ulType == DLevelScript::PCD_TRANSLATIONRANGE2 ) + SERVERCOMMANDS_CreateTranslation( g_EditedTranslationList[ulIdx].ulIdx, g_EditedTranslationList[ulIdx].ulStart, g_EditedTranslationList[ulIdx].ulEnd, g_EditedTranslationList[ulIdx].ulR1, g_EditedTranslationList[ulIdx].ulG1, g_EditedTranslationList[ulIdx].ulB1, g_EditedTranslationList[ulIdx].ulR2, g_EditedTranslationList[ulIdx].ulG2, g_EditedTranslationList[ulIdx].ulB2 ); + else + SERVERCOMMANDS_CreateDesaturatedTranslation( g_EditedTranslationList[ulIdx].ulIdx, g_EditedTranslationList[ulIdx].ulStart, g_EditedTranslationList[ulIdx].ulEnd, g_EditedTranslationList[ulIdx].fR1, g_EditedTranslationList[ulIdx].fG1, g_EditedTranslationList[ulIdx].fB1, g_EditedTranslationList[ulIdx].fR2, g_EditedTranslationList[ulIdx].fG2, g_EditedTranslationList[ulIdx].fB2 ); + } } // [BB] If the sky differs from the standard sky, let the client know about it. @@ -3932,6 +3938,26 @@ //***************************************************************************** // +void SERVER_AddEditedDesaturatedTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, float fR1, float fG1, float fB1, float fR2, float fG2, float fB2 ) +{ + EDITEDTRANSLATION_s Translation; + + Translation.ulIdx = ulTranslation; + Translation.ulStart = ulStart; + Translation.ulEnd = ulEnd; + Translation.fR1 = fR1; + Translation.fG1 = fG1; + Translation.fB1 = fB1; + Translation.fR2 = fR2; + Translation.fG2 = fG2; + Translation.fB2 = fB2; + Translation.ulType = DLevelScript::PCD_TRANSLATIONRANGE3; + + g_EditedTranslationList.Push( Translation ); +} + +//***************************************************************************** +// void SERVER_RemoveEditedTranslation( ULONG ulTranslation ) { const int numEntries = g_EditedTranslationList.Size(); diff -r 61b0668dceb7 -r 5fd19a2b17a7 src/sv_main.h --- a/src/sv_main.h Fri Oct 30 16:11:39 2020 -0400 +++ b/src/sv_main.h Tue Nov 03 00:48:43 2020 -0500 @@ -408,7 +408,13 @@ ULONG ulG2; ULONG ulB2; - + // [AK] translations like PCD_TRANSLATIONRANGE3 + float fR1; + float fG1; + float fB1; + float fR2; + float fG2; + float fB2; }; //***************************************************************************** @@ -493,6 +499,7 @@ void SERVER_ResetInventory( ULONG ulClient, const bool bChangeClientWeapon = true ); void SERVER_AddEditedTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, ULONG ulPal1, ULONG ulPal2 ); void SERVER_AddEditedTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, ULONG ulR1, ULONG ulG1, ULONG ulB1, ULONG ulR2, ULONG ulG2, ULONG ulB2 ); +void SERVER_AddEditedDesaturatedTranslation( ULONG ulTranslation, ULONG ulStart, ULONG ulEnd, float fR1, float fG1, float fB1, float fR2, float fG2, float fB2 ); void SERVER_RemoveEditedTranslation( ULONG ulTranslation ); bool SERVER_IsTranslationEdited( ULONG ulTranslation ); void SERVER_ClearEditedTranslations( void );