mirror of
https://github.com/ZDoom/Raze.git
synced 2025-01-18 14:41:55 +00:00
Fix crash when recording demo, stooping it, going to title screen, and exiting.
A macro MAYBE_FCLOSE_AND_NULL(fileptr) is introduced in compat.h that does what it says. git-svn-id: https://svn.eduke32.com/eduke32@2995 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
667de29e01
commit
9311432cbf
3 changed files with 12 additions and 7 deletions
|
@ -650,5 +650,9 @@ char *Bstrupr(char *);
|
|||
}
|
||||
#endif
|
||||
|
||||
#define MAYBE_FCLOSE_AND_NULL(fileptr) do { \
|
||||
if (fileptr) { Bfclose(fileptr); fileptr=NULL; } \
|
||||
} while (0)
|
||||
|
||||
#endif // __compat_h__
|
||||
|
||||
|
|
|
@ -193,7 +193,7 @@ void G_OpenDemoWrite(void)
|
|||
if (g_demo_filePtr == NULL)
|
||||
break;
|
||||
|
||||
Bfclose(g_demo_filePtr);
|
||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
||||
}
|
||||
while (1);
|
||||
|
||||
|
@ -205,7 +205,7 @@ void G_OpenDemoWrite(void)
|
|||
demorec_synccompress_cvar|(demorec_seeds_cvar<<1));
|
||||
if (i)
|
||||
{
|
||||
Bfclose(g_demo_filePtr), g_demo_filePtr=NULL;
|
||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
||||
error_wopen_demo:
|
||||
Bstrcpy(ScriptQuotes[QUOTE_RESERVED4], "FAILED STARTING DEMO RECORDING. SEE OSD FOR DETAILS.");
|
||||
P_DoQuote(QUOTE_RESERVED4, g_player[myconnectindex].ps);
|
||||
|
@ -292,7 +292,7 @@ void G_CloseDemoWrite(void)
|
|||
fwrite(&g_demo_cnt, sizeof(g_demo_cnt), 1, g_demo_filePtr);
|
||||
|
||||
ud.recstat = ud.m_recstat = 0;
|
||||
fclose(g_demo_filePtr);
|
||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
||||
|
||||
sv_freemem();
|
||||
|
||||
|
|
|
@ -2077,11 +2077,12 @@ void G_GameExit(const char *msg)
|
|||
#endif
|
||||
if (*msg != 0) g_player[myconnectindex].ps->palette = BASEPAL;
|
||||
|
||||
if (ud.recstat == 1) G_CloseDemoWrite();
|
||||
if (ud.recstat == 1)
|
||||
G_CloseDemoWrite();
|
||||
else if (ud.recstat == 2)
|
||||
{
|
||||
if (g_demo_filePtr) fclose(g_demo_filePtr);
|
||||
} // JBF: fixes crash on demo playback
|
||||
MAYBE_FCLOSE_AND_NULL(g_demo_filePtr);
|
||||
// JBF: fixes crash on demo playback
|
||||
// PK: modified from original
|
||||
|
||||
if (!g_quickExit)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue