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.
This commit is contained in:
Eric Wasylishen 2010-12-17 00:17:26 -07:00
parent 4f70e43b95
commit aa36b04130
2 changed files with 30 additions and 8 deletions

View file

@ -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);

View file

@ -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);
}