From 581d645558baedd01bbb94262736ed9bdec74a11 Mon Sep 17 00:00:00 2001 From: Roman Fomin Date: Fri, 10 Dec 2021 03:02:55 +0700 Subject: [PATCH] netgame: enable -loadgame (#371) * netgame: enable -loadgame * fix -record -loadgame --- Source/d_main.c | 30 +++++++++++++++++++++++------- Source/d_net.c | 4 ++-- Source/doomstat.h | 3 +++ Source/g_game.c | 1 - 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/Source/d_main.c b/Source/d_main.c index 985938ca..514ca267 100644 --- a/Source/d_main.c +++ b/Source/d_main.c @@ -133,6 +133,7 @@ int startepisode; int startmap; boolean autostart; FILE *debugfile; +int startloadgame; boolean advancedemo; @@ -2232,6 +2233,17 @@ void D_DoomMain(void) if (*startup5) puts(startup5); // End new startup strings + p = M_CheckParmWithArgs("-loadgame", 1); + if (p) + { + startloadgame = atoi(myargv[p+1]); + } + else + { + // Not loading a game + startloadgame = -1; + } + puts("M_Init: Init miscellaneous info."); M_Init(); @@ -2315,13 +2327,17 @@ void D_DoomMain(void) demowarp = -1; if (slot && ++slot < myargc) - { - char *file; - slot = atoi(myargv[slot]); // killough 3/16/98: add slot info - file = G_SaveGameName(slot); // killough 3/22/98 - G_LoadGame(file, slot, true); // killough 5/15/98: add command flag - (free)(file); - } + { + startloadgame = atoi(myargv[slot]); + } + + if (startloadgame >= 0) + { + char *file; + file = G_SaveGameName(startloadgame); + G_LoadGame(file, startloadgame, true); // killough 5/15/98: add command flag + (free)(file); + } else if (!singledemo) // killough 12/98 { diff --git a/Source/d_net.c b/Source/d_net.c index 95263136..2449e06d 100644 --- a/Source/d_net.c +++ b/Source/d_net.c @@ -106,7 +106,7 @@ static void LoadGameSettings(net_gamesettings_t *settings) startepisode = settings->episode; startmap = settings->map; startskill = settings->skill; - //startloadgame = settings->loadgame; + startloadgame = settings->loadgame; lowres_turn = settings->lowres_turn; nomonsters = settings->nomonsters; fastparm = settings->fast_monsters; @@ -159,7 +159,7 @@ static void SaveGameSettings(net_gamesettings_t *settings) settings->episode = startepisode; settings->map = startmap; settings->skill = startskill; - //settings->loadgame = startloadgame; + settings->loadgame = startloadgame; settings->gameversion = gameversion; settings->nomonsters = nomonsters; settings->fast_monsters = fastparm; diff --git a/Source/doomstat.h b/Source/doomstat.h index a01604f0..6d49379a 100644 --- a/Source/doomstat.h +++ b/Source/doomstat.h @@ -149,6 +149,9 @@ extern skill_t startskill; extern int startepisode; extern int startmap; +// the -loadgame option. If this has not been provided, this is -1. +extern int startloadgame; + extern boolean autostart; // Selected by user. diff --git a/Source/g_game.c b/Source/g_game.c index d2208579..b077651d 100644 --- a/Source/g_game.c +++ b/Source/g_game.c @@ -1711,7 +1711,6 @@ static void G_DoLoadGame(void) // killough 2/14/98: load compatibility mode compatibility = *save_p++; - demo_version = complevel; gameskill = *save_p++; gameepisode = *save_p++;