mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-03-03 23:41:13 +00:00
- take down the level outside the LoadGame function in ShadowWarrior.
With the new savegame system it was done too late which could cause crashes.
This commit is contained in:
parent
12d4f12da5
commit
9c423ae6a3
5 changed files with 24 additions and 14 deletions
|
@ -123,6 +123,7 @@ struct GameInterface
|
||||||
virtual void DrawMenuCaption(const DVector2& origin, const char* text) {}
|
virtual void DrawMenuCaption(const DVector2& origin, const char* text) {}
|
||||||
virtual bool SaveGame(FSaveGameNode*) { return false; }
|
virtual bool SaveGame(FSaveGameNode*) { return false; }
|
||||||
virtual bool LoadGame(FSaveGameNode*) { return false; }
|
virtual bool LoadGame(FSaveGameNode*) { return false; }
|
||||||
|
virtual bool CleanupForLoad() { return true; }
|
||||||
virtual void DoPrintMessage(int prio, const char*) {}
|
virtual void DoPrintMessage(int prio, const char*) {}
|
||||||
void PrintMessage(int prio, const char*fmt, ...)
|
void PrintMessage(int prio, const char*fmt, ...)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,6 +57,8 @@
|
||||||
FSavegameManager savegameManager;
|
FSavegameManager savegameManager;
|
||||||
|
|
||||||
void FSavegameManager::LoadGame(FSaveGameNode* node)
|
void FSavegameManager::LoadGame(FSaveGameNode* node)
|
||||||
|
{
|
||||||
|
if (gi->CleanupForLoad())
|
||||||
{
|
{
|
||||||
if (OpenSaveGameForRead(node->Filename))
|
if (OpenSaveGameForRead(node->Filename))
|
||||||
{
|
{
|
||||||
|
@ -66,6 +68,7 @@ void FSavegameManager::LoadGame(FSaveGameNode* node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void FSavegameManager::SaveGame(FSaveGameNode* node, bool ok4q, bool forceq)
|
void FSavegameManager::SaveGame(FSaveGameNode* node, bool ok4q, bool forceq)
|
||||||
{
|
{
|
||||||
|
|
|
@ -2444,6 +2444,7 @@ struct GameInterface : ::GameInterface
|
||||||
FSavegameInfo GetSaveSig() override;
|
FSavegameInfo GetSaveSig() override;
|
||||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||||
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
|
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
|
||||||
|
bool CleanupForLoad() override;
|
||||||
bool LoadGame(FSaveGameNode* sv) override;
|
bool LoadGame(FSaveGameNode* sv) override;
|
||||||
bool SaveGame(FSaveGameNode* sv) override;
|
bool SaveGame(FSaveGameNode* sv) override;
|
||||||
void DoPrintMessage(int prio, const char* text) override;
|
void DoPrintMessage(int prio, const char* text) override;
|
||||||
|
|
|
@ -687,6 +687,20 @@ bool GameInterface::SaveGame(FSaveGameNode *sv)
|
||||||
extern SWBOOL LoadGameOutsideMoveLoop;
|
extern SWBOOL LoadGameOutsideMoveLoop;
|
||||||
extern SWBOOL InMenuLevel;
|
extern SWBOOL InMenuLevel;
|
||||||
|
|
||||||
|
bool GameInterface::CleanupForLoad()
|
||||||
|
{
|
||||||
|
// Don't terminate until you've made sure conditions are valid for loading.
|
||||||
|
if (InMenuLevel)
|
||||||
|
Mus_Stop();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
PauseAction();
|
||||||
|
TerminateLevel();
|
||||||
|
}
|
||||||
|
Terminate3DSounds();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool GameInterface::LoadGame(FSaveGameNode* sv)
|
bool GameInterface::LoadGame(FSaveGameNode* sv)
|
||||||
{
|
{
|
||||||
MFILE_READ fil;
|
MFILE_READ fil;
|
||||||
|
@ -710,8 +724,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
|
||||||
int StateNdx;
|
int StateNdx;
|
||||||
int StateEndNdx;
|
int StateEndNdx;
|
||||||
|
|
||||||
if (!InMenuLevel) PauseAction();
|
|
||||||
|
|
||||||
Saveable_Init();
|
Saveable_Init();
|
||||||
|
|
||||||
auto filr = ReadSavegameChunk("snapshot.sw");
|
auto filr = ReadSavegameChunk("snapshot.sw");
|
||||||
|
@ -725,13 +737,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't terminate until you've made sure conditions are valid for loading.
|
|
||||||
if (InMenuLevel)
|
|
||||||
Mus_Stop();
|
|
||||||
else
|
|
||||||
TerminateLevel();
|
|
||||||
Terminate3DSounds();
|
|
||||||
|
|
||||||
MREAD(&Level,sizeof(Level),1,fil);
|
MREAD(&Level,sizeof(Level),1,fil);
|
||||||
MREAD(&Skill,sizeof(Skill),1,fil);
|
MREAD(&Skill,sizeof(Skill),1,fil);
|
||||||
|
|
||||||
|
|
|
@ -745,7 +745,7 @@ KillSprite(int16_t SpriteNum)
|
||||||
{
|
{
|
||||||
mu = User[i];
|
mu = User[i];
|
||||||
|
|
||||||
if (mu->WpnGoal == SpriteNum)
|
if (mu && mu->WpnGoal == SpriteNum)
|
||||||
{
|
{
|
||||||
mu->WpnGoal = -1;
|
mu->WpnGoal = -1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue