mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +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 bool SaveGame(FSaveGameNode*) { return false; }
|
||||
virtual bool LoadGame(FSaveGameNode*) { return false; }
|
||||
virtual bool CleanupForLoad() { return true; }
|
||||
virtual void DoPrintMessage(int prio, const char*) {}
|
||||
void PrintMessage(int prio, const char*fmt, ...)
|
||||
{
|
||||
|
|
|
@ -58,11 +58,14 @@ FSavegameManager savegameManager;
|
|||
|
||||
void FSavegameManager::LoadGame(FSaveGameNode* node)
|
||||
{
|
||||
if (OpenSaveGameForRead(node->Filename))
|
||||
if (gi->CleanupForLoad())
|
||||
{
|
||||
if (gi->LoadGame(node))
|
||||
if (OpenSaveGameForRead(node->Filename))
|
||||
{
|
||||
// do something here?
|
||||
if (gi->LoadGame(node))
|
||||
{
|
||||
// do something here?
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2444,7 +2444,8 @@ struct GameInterface : ::GameInterface
|
|||
FSavegameInfo GetSaveSig() override;
|
||||
void DrawMenuCaption(const DVector2& origin, const char* text) override;
|
||||
void DrawCenteredTextScreen(const DVector2& origin, const char* text, int position, bool bg) override;
|
||||
bool LoadGame(FSaveGameNode* sv) override;
|
||||
bool CleanupForLoad() override;
|
||||
bool LoadGame(FSaveGameNode* sv) override;
|
||||
bool SaveGame(FSaveGameNode* sv) override;
|
||||
void DoPrintMessage(int prio, const char* text) override;
|
||||
void SetAmbience(bool on) override { if (on) StartAmbientSound(); else StopAmbientSound(); }
|
||||
|
|
|
@ -687,6 +687,20 @@ bool GameInterface::SaveGame(FSaveGameNode *sv)
|
|||
extern SWBOOL LoadGameOutsideMoveLoop;
|
||||
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)
|
||||
{
|
||||
MFILE_READ fil;
|
||||
|
@ -710,8 +724,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
|
|||
int StateNdx;
|
||||
int StateEndNdx;
|
||||
|
||||
if (!InMenuLevel) PauseAction();
|
||||
|
||||
Saveable_Init();
|
||||
|
||||
auto filr = ReadSavegameChunk("snapshot.sw");
|
||||
|
@ -725,13 +737,6 @@ bool GameInterface::LoadGame(FSaveGameNode* sv)
|
|||
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(&Skill,sizeof(Skill),1,fil);
|
||||
|
||||
|
|
|
@ -745,7 +745,7 @@ KillSprite(int16_t SpriteNum)
|
|||
{
|
||||
mu = User[i];
|
||||
|
||||
if (mu->WpnGoal == SpriteNum)
|
||||
if (mu && mu->WpnGoal == SpriteNum)
|
||||
{
|
||||
mu->WpnGoal = -1;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue