# HG changeset patch # User Adam Kaminski # Date 1632014156 14400 # Sat Sep 18 21:15:56 2021 -0400 # Node ID 168e3f77285689f3d9585387081ea8a6d7c64f87 # Parent ec067ae019cda545aaef3a9dd3eb1da5058568a2 Fixed a player's last sent chat messages being lost in a savegame. diff -r ec067ae019cd -r 168e3f772856 src/chat.cpp --- a/src/chat.cpp Sat Sep 18 20:16:32 2021 -0400 +++ b/src/chat.cpp Sat Sep 18 21:15:56 2021 -0400 @@ -78,6 +78,7 @@ #include "sectinfo.h" #include "g_level.h" #include "p_acs.h" +#include "farchive.h" //***************************************************************************** // @@ -869,6 +870,29 @@ //***************************************************************************** // +void CHAT_SerializeMessages( FArchive &arc ) +{ + FString serializedMessages[MAX_SAVED_MESSAGES]; + + // [AK] We only need to save the local player's messages, as they'll be the only + // player left when the save is loaded. We don't need to save anybody else's. + for ( unsigned int i = 0; i < MAX_SAVED_MESSAGES; i++ ) + { + if ( arc.IsStoring( )) + { + serializedMessages[i] = g_SavedChatMessages[consoleplayer].getOldestEntry( i ); + arc << serializedMessages[i]; + } + else + { + arc << serializedMessages[i]; + g_SavedChatMessages[consoleplayer].put( serializedMessages[i] ); + } + } +} + +//***************************************************************************** +// void CHAT_PrintChatString( ULONG ulPlayer, ULONG ulMode, const char *pszString ) { ULONG ulChatLevel = 0; diff -r ec067ae019cd -r 168e3f772856 src/chat.h --- a/src/chat.h Sat Sep 18 20:16:32 2021 -0400 +++ b/src/chat.h Sat Sep 18 21:15:56 2021 -0400 @@ -88,6 +88,7 @@ const char *CHAT_GetChatMessage( ULONG ulPlayer, ULONG ulOffset ); // [AK] void CHAT_AddChatMessage( ULONG ulPlayer, const char *pszString ); // [AK] void CHAT_ClearChatMessages( ULONG ulPlayer ); // [AK] +void CHAT_SerializeMessages( FArchive &arc ); // [AK] void CHAT_PrintChatString( ULONG ulPlayer, ULONG ulMode, const char *pszString ); //***************************************************************************** diff -r ec067ae019cd -r 168e3f772856 src/g_level.cpp --- a/src/g_level.cpp Sat Sep 18 20:16:32 2021 -0400 +++ b/src/g_level.cpp Sat Sep 18 21:15:56 2021 -0400 @@ -2225,6 +2225,7 @@ AM_SerializeMarkers(arc); P_SerializePlayers (arc, hubLoad); + CHAT_SerializeMessages (arc); // [AK] P_SerializeSounds (arc); if (arc.IsLoading()) {