From 65267ec2507d86945ffb9be6aa527d1f20f8df37 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Sat, 3 Nov 2012 03:07:46 +0000 Subject: [PATCH] - Use an FString to store demoname instead of a fixed-size array. Fixes crashes when passing really long names to -record. On the other hand, if it's long enough to overflow the old buffer, it'll probably fail to be created now because the name is too long for the OS functions. SVN r3936 (trunk) --- src/g_game.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/g_game.cpp b/src/g_game.cpp index 74189eadb..d96e37fcf 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -161,7 +161,7 @@ int consoleplayer; // player taking events int gametic; CVAR(Bool, demo_compress, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG); -char demoname[256]; +FString demoname; bool demorecording; bool demoplayback; bool netdemo; @@ -2271,7 +2271,7 @@ void G_WriteDemoTiccmd (ticcmd_t *cmd, int player, int buf) void G_RecordDemo (const char* name) { usergame = false; - strcpy (demoname, name); + demoname = name; FixPathSeperator (demoname); DefaultExtension (demoname, ".lmp"); maxdemosize = 0x20000; @@ -2710,11 +2710,18 @@ bool G_CheckDemoStatus (void) formlen = demobuffer + 4; WriteLong (int(demo_p - demobuffer - 8), &formlen); - M_WriteFile (demoname, demobuffer, int(demo_p - demobuffer)); + bool saved = M_WriteFile (demoname, demobuffer, int(demo_p - demobuffer)); M_Free (demobuffer); demorecording = false; stoprecording = false; - Printf ("Demo %s recorded\n", demoname); + if (saved) + { + Printf ("Demo %s recorded\n", demoname.GetChars()); + } + else + { + Printf ("Demo %s could not be saved\n", demoname.GetChars()); + } } return false;