Get "cancel" working correctly.

First, it was segging due to closing the file handle prematurely, then it
wasn't deleting the mvd (only the text).
This commit is contained in:
Bill Currie 2012-07-13 14:41:10 +09:00
parent 02de92abb0
commit 16520e4aaf

View file

@ -152,40 +152,29 @@ SV_Stop (int reason)
return; return;
} }
if (reason == 2) {
// stop and remove
if (demo_disk)
Qclose (demo_file);
QFS_Remove (demo_name->str);
QFS_Remove (demo_text->str);
demo_file = NULL;
SVR_RemoveUser (recorder);
recorder = 0;
sv.recording_demo = 0;
SV_BroadcastPrintf (PRINT_CHAT,
"Server recording canceled, demo removed\n");
Cvar_Set (serverdemo, "");
return;
}
// clearup to be sure message will fit
SVR_RemoveUser (recorder); SVR_RemoveUser (recorder);
//if (demo_disk)
Qclose (demo_file); Qclose (demo_file);
demo_file = NULL; demo_file = NULL;
recorder = 0; recorder = 0;
sv.recording_demo = 0; sv.recording_demo = 0;
if (!reason) switch (reason) {
SV_BroadcastPrintf (PRINT_CHAT, "Server recording completed\n"); case 0:
else SV_BroadcastPrintf (PRINT_CHAT, "Server recording completed\n");
SV_BroadcastPrintf (PRINT_CHAT, "Server recording stoped\n" break;
"Max demo size exceeded\n"); case 2:
SV_BroadcastPrintf (PRINT_CHAT,
"Server recording canceled, demo removed\n");
Sys_Printf ("%s %s\n", demo_name->str, demo_text->str);
QFS_Remove (demo_name->str);
QFS_Remove (demo_text->str);
break;
default:
SV_BroadcastPrintf (PRINT_CHAT, "Server recording stoped\n"
"Max demo size exceeded\n");
break;
}
/* /*
if (sv_onrecordfinish->string[0]) { if (sv_onrecordfinish->string[0]) {
extern redirect_t sv_redirected; extern redirect_t sv_redirected;
@ -384,13 +373,11 @@ SV_Record (char *name)
SV_InitRecord (); SV_InitRecord ();
s = name + strlen (name); dstring_copystr (demo_name, name);
while (s > name && *s != '/')
s--;
dstring_copystr (demo_name, s + (*s == '/'));
SV_BroadcastPrintf (PRINT_CHAT, "Server started recording (%s):\n%s\n", SV_BroadcastPrintf (PRINT_CHAT, "Server started recording (%s):\n%s\n",
demo_disk ? "disk" : "memory", demo_name->str); demo_disk ? "disk" : "memory",
QFS_SkipPath (demo_name->str));
Cvar_Set (serverdemo, demo_name->str); Cvar_Set (serverdemo, demo_name->str);
dstring_copystr (demo_text, name); dstring_copystr (demo_text, name);