mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-27 20:20:40 +00:00
- implemented reloading from the last saved game, like in GZDoom.
Fixes #352
This commit is contained in:
parent
f829bc96c8
commit
52cbb5c9dc
2 changed files with 36 additions and 15 deletions
|
@ -90,6 +90,7 @@
|
|||
CVAR(Bool, vid_activeinbackground, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, r_ticstability, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, cl_capfps, false, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
|
||||
CVAR(Bool, cl_resumesavegame, true, CVAR_ARCHIVE)
|
||||
|
||||
ticcmd_t playercmds[MAXPLAYERS];
|
||||
|
||||
|
@ -102,6 +103,10 @@ int entertic;
|
|||
int oldentertics;
|
||||
int gametic;
|
||||
|
||||
extern FString BackupSaveGame;
|
||||
|
||||
void DoLoadGame(const char* name);
|
||||
|
||||
|
||||
//==========================================================================
|
||||
//
|
||||
|
@ -137,14 +142,21 @@ static void GameTicker()
|
|||
switch (ga)
|
||||
{
|
||||
case ga_autoloadgame:
|
||||
// todo: for now just handle the restart case
|
||||
g_nextmap = currentLevel;
|
||||
FX_StopAllSounds();
|
||||
FX_SetReverb(0);
|
||||
gi->FreeLevelData();
|
||||
C_ClearMessages();
|
||||
gameaction = ga_level;
|
||||
gi->NewGame(g_nextmap, -1);
|
||||
if (BackupSaveGame.IsNotEmpty() && cl_resumesavegame)
|
||||
{
|
||||
DoLoadGame(BackupSaveGame);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_nextmap = currentLevel;
|
||||
FX_StopAllSounds();
|
||||
FX_SetReverb(0);
|
||||
gi->FreeLevelData();
|
||||
C_ClearMessages();
|
||||
gameaction = ga_level;
|
||||
gi->NewGame(g_nextmap, -1);
|
||||
BackupSaveGame = "";
|
||||
}
|
||||
break;
|
||||
|
||||
case ga_completed:
|
||||
|
@ -178,6 +190,7 @@ static void GameTicker()
|
|||
gi->FreeLevelData();
|
||||
C_ClearMessages();
|
||||
gameaction = ga_level;
|
||||
BackupSaveGame = "";
|
||||
gi->NewGame(g_nextmap, g_nextskill);
|
||||
break;
|
||||
|
||||
|
|
|
@ -57,28 +57,35 @@
|
|||
|
||||
|
||||
FSavegameManager savegameManager;
|
||||
FString BackupSaveGame;
|
||||
|
||||
void FSavegameManager::LoadGame(FSaveGameNode* node)
|
||||
void DoLoadGame(const char* name)
|
||||
{
|
||||
inputState.ClearAllInput();
|
||||
gi->FreeLevelData();
|
||||
if (OpenSaveGameForRead(node->Filename))
|
||||
if (OpenSaveGameForRead(name))
|
||||
{
|
||||
if (gi->LoadGame(node))
|
||||
if (gi->LoadGame(nullptr))
|
||||
{
|
||||
gameaction = ga_level;
|
||||
}
|
||||
else
|
||||
{
|
||||
I_Error("%s: Failed to load savegame", node->Filename.GetChars());
|
||||
I_Error("%s: Failed to load savegame", name);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
I_Error("%s: Failed to open savegame", node->Filename.GetChars());
|
||||
I_Error("%s: Failed to open savegame", name);
|
||||
}
|
||||
}
|
||||
|
||||
void FSavegameManager::LoadGame(FSaveGameNode* node)
|
||||
{
|
||||
inputState.ClearAllInput();
|
||||
gi->FreeLevelData();
|
||||
DoLoadGame(node->Filename);
|
||||
BackupSaveGame = node->Filename;
|
||||
}
|
||||
|
||||
void FSavegameManager::SaveGame(FSaveGameNode* node, bool ok4q, bool forceq)
|
||||
{
|
||||
if (OpenSaveGameForWrite(node->Filename, node->SaveTitle))
|
||||
|
@ -89,6 +96,7 @@ void FSavegameManager::SaveGame(FSaveGameNode* node, bool ok4q, bool forceq)
|
|||
FString desc = node->SaveTitle;
|
||||
NotifyNewSave(fn, desc, ok4q, forceq);
|
||||
Printf(PRINT_NOTIFY, "%s\n", GStrings("GAME SAVED"));
|
||||
BackupSaveGame = node->Filename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue