From aa36b0413025c3355c85a7e78c64491261d5c26d Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 17 Dec 2010 00:17:26 -0700 Subject: [PATCH] Increase health required for autosave to 40. Don't require the player to be dead for the 'autoload' console function to work. Reset autoload info on 'map' and 'changelevel'. Add future ideas for autosave criteria. --- Quake/host.c | 12 ++++++++++-- Quake/host_cmd.c | 26 ++++++++++++++++++++------ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/Quake/host.c b/Quake/host.c index c0903b5e..850da97a 100644 --- a/Quake/host.c +++ b/Quake/host.c @@ -664,8 +664,16 @@ void Host_ServerFrame (void) lastautosave = 0; } - if ((sv.time - lastautosave) > 30 - && (sv_player->v.health >= 25 || sv_player->v.health > oldhealth)) + // FIXME: have a sliding scale where autosaving after: + // 30 seconds requires a health of 60 + // 45 seconds requires a health of 50 + // 60 seconds requires a health of 45 + // etc.. or something along those lines + + // FIXME: don't autosave if the player's health dropped vs. 3 seconds ago + + if ((sv.time - lastautosave) > 30.0 + && (sv_player->v.health >= 40 || sv_player->v.health > oldhealth)) { char command[MAX_QPATH + 10]; sprintf(command, "save auto_%s", sv.name); diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index 403ebbf3..11164f74 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -38,6 +38,9 @@ char lastsavemapname[MAX_QPATH]; // autosave void Mod_Print (void); +static qboolean _autoloadIfPossible(); +static void _resetAutoload(); + /* ================== Host_Quit_f @@ -830,6 +833,8 @@ void Host_Map_f (void) key_dest = key_game; // remove console or menu SCR_BeginLoadingPlaque (); + _resetAutoload(); // autosave + svs.serverflags = 0; // haven't completed an episode yet strcpy (name, Cmd_Argv(1)); // remove (any) trailing ".bsp" from mapname S.A. @@ -889,6 +894,7 @@ void Host_Changelevel_f (void) SV_SaveSpawnparms (); strcpy (level, Cmd_Argv(1)); fprintf(stderr, "Host_Changelevel_f '%s'\n", level); + _resetAutoload(); // autosave SV_SpawnServer (level); } @@ -898,8 +904,7 @@ static qboolean _autoloadIfPossible() !coop.value && sv.active && !cl.intermission && - svs.maxclients == 1 && - sv_player->v.deadflag != DEAD_NO) + svs.maxclients == 1) { if (0 == strcmp(sv.name, lastsavemapname)) { @@ -913,6 +918,12 @@ static qboolean _autoloadIfPossible() return false; } +static void _resetAutoload() +{ + lastsavemapname[0] = '\0'; // autosave - we are explicitly restarting the level, so don't autoload + lastsavename[0] = '\0'; +} + /* ================== Host_Autoload_f @@ -947,13 +958,16 @@ void Host_Restart_f (void) strcpy (mapname, sv.name); // must copy out, because it gets cleared // in sv_spawnserver - if (_autoloadIfPossible()) // autosave + if (sv_player->v.deadflag != DEAD_NO) // autosave { - return; + // If we are dead, attempt to autoload + if (_autoloadIfPossible()) + { + return; + } } - lastsavemapname[0] = '\0'; // autosave - we are explicitly restarting the level, so don't autoload - lastsavename[0] = '\0'; + _resetAutoload(); SV_SpawnServer (mapname); }