From 7023e1e99267f27f9ae70cfd9320f016e6ac8b04 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Oct 2019 00:29:46 +0200 Subject: [PATCH] - store game vars in the new config file. --- source/duke3d/src/gameexec.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index 8a367fbd9..34a835948 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "savegame.h" #include "scriplib.h" #include "gamecvars.h" +#include "gameconfigfile.h" #include "vfs.h" @@ -4258,16 +4259,25 @@ badindex: insptr++; dispatch(); } + extern FString currentGame; + FString section = currentGame + ".Gamevars"; + GameConfig->SetSection(section); switch (VM_DECODE_INST(tw)) { case CON_SAVEGAMEVAR: - nValue = Gv_GetVar(*insptr); - SCRIPT_PutNumber(ud.config.scripthandle, "Gamevars", aGameVars[*insptr++].szLabel, nValue, FALSE, FALSE); - break; + { + nValue = Gv_GetVar(*insptr); + FStringf vs("%d", nValue); + GameConfig->SetValueForKey(aGameVars[*insptr++].szLabel, vs); + break; + } case CON_READGAMEVAR: - SCRIPT_GetNumber(ud.config.scripthandle, "Gamevars", aGameVars[*insptr].szLabel, &nValue); - Gv_SetVar(*insptr++, nValue); - break; + { + auto str = GameConfig->GetValueForKey(aGameVars[*insptr].szLabel); + if (str) nValue = (int)strtoll(str, nullptr, 0); + Gv_SetVar(*insptr++, nValue); + break; + } } dispatch(); }