From 65cb267d56d4fb1d013ad388cfe216f650e4291d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 17 Aug 2020 22:05:14 +0200 Subject: [PATCH] - save the cookie texts in a savegame and clear them on level exit. Also handle them on a per-player basis. Fixes #196 --- source/sw/src/game.cpp | 2 ++ source/sw/src/game.h | 6 ++++-- source/sw/src/player.cpp | 6 ++++++ source/sw/src/sbar.cpp | 20 +++----------------- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/source/sw/src/game.cpp b/source/sw/src/game.cpp index 27fecd5cd..bf65b4296 100644 --- a/source/sw/src/game.cpp +++ b/source/sw/src/game.cpp @@ -625,6 +625,8 @@ void TerminateLevel(void) // Free panel sprites for players pClearSpriteList(pp); + pp->cookieTime = 0; + memset(pp->cookieQuote, 0, sizeof(pp->cookieQuote)); pp->DoPlayerAction = NULL; pp->SpriteP = NULL; diff --git a/source/sw/src/game.h b/source/sw/src/game.h index b92f0d5f2..a40fa8aaf 100644 --- a/source/sw/src/game.h +++ b/source/sw/src/game.h @@ -810,8 +810,6 @@ SWBOOL DLL_ExecFunc(int procHandle, char *fName); // /////////////////////////////////////////////////////////////////////////////////////////// -void adduserquote(const char *daquote); - /////////////////////////////////////////////////////////////////////////////////////////// // // Weapon @@ -1168,6 +1166,10 @@ struct PLAYERstruct short Reverb; // Player's current reverb setting short Heads; // Number of Accursed Heads orbiting player int PlayerVersion; + + char cookieQuote[256]; // Should be an FString but must be POD for now to be storable in a savegame. + int cookieTime; + }; extern PLAYER Player[MAX_SW_PLAYERS_REG+1]; diff --git a/source/sw/src/player.cpp b/source/sw/src/player.cpp index 7c3b57236..8ee7b5c3c 100644 --- a/source/sw/src/player.cpp +++ b/source/sw/src/player.cpp @@ -8060,6 +8060,12 @@ void CheckFootPrints(PLAYERp pp) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + #include "saveable.h" diff --git a/source/sw/src/sbar.cpp b/source/sw/src/sbar.cpp index d1aba8f79..d04765c29 100644 --- a/source/sw/src/sbar.cpp +++ b/source/sw/src/sbar.cpp @@ -992,21 +992,6 @@ static void UpdateFrame(void) // //--------------------------------------------------------------------------- -static FString cookieQuote; -static int cookieTime; - -void adduserquote(const char* daquote) -{ - cookieQuote = daquote; - cookieTime = totalclock + 540; -} - -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - void UpdateStatusBar(ClockTicks arg) { DSWStatusBar sbar; @@ -1017,10 +1002,11 @@ void UpdateStatusBar(ClockTicks arg) } sbar.UpdateStatusBar(arg); - if (totalclock < cookieTime) + PLAYERp pp = &Player[screenpeek]; + if (totalclock < pp->cookieTime) { const int MESSAGE_LINE = 142; // Used to be 164 - MNU_DrawSmallString(160, MESSAGE_LINE, cookieQuote, 0, 0, 0, clamp((cookieTime - totalclock) / 60., 0., 1.)); + MNU_DrawSmallString(160, MESSAGE_LINE, pp->cookieQuote, 0, 0, 0, clamp((pp->cookieTime - totalclock) / 60., 0., 1.)); } }