MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DemoToggleRecording

Function DemoToggleRecording

Descent3/demofile.cpp:339–383  ·  view source on GitHub ↗

Prompts user for filename and starts recording if successfull

Source from the content-addressed store, hash-verified

337
338// Prompts user for filename and starts recording if successfull
339void DemoToggleRecording() {
340 char szfile[_MAX_PATH * 2];
341 szfile[0] = '\0';
342 if (Demo_flags == DF_RECORDING) {
343 // Stop recording and close the file
344 cfclose(Demo_cfp);
345 Demo_flags = DF_NONE;
346 AddBlinkingHUDMessage(TXT_DEMOSAVED);
347
348 Demo_fname[0] = '\0';
349 return;
350 } else if (Demo_flags == DF_PLAYBACK) {
351 // We can't record a demo while we are playing back a demo
352 return;
353 }
354
355 // hand coded 128 because long filenames were failing in cfopen(which called fopen, which failed on very
356 // long filenames. instead of printing a message out to the user, just don't allow filenames that long)
357 if (DoEditDialog(TXT_DEMOFILENAME, szfile, 128)) {
358 if (stricmp(szfile + (strlen(szfile) - 4), ".dem") != 0) {
359 strcat(szfile, ".dem");
360 }
361 ddio_MakePath(Demo_fname, Base_directory, "demo", szfile, NULL);
362 mprintf(0, "Saving demo to file: %s\n", Demo_fname);
363 // Try to create the file
364 Demo_cfp = cfopen(Demo_fname, "wb");
365 if (Demo_cfp) {
366 // Setup the demo variables
367 if (!(Game_mode & GM_MULTI)) {
368 MultiBuildMatchTables();
369 }
370 // Male sure we write the player info the first frame
371 Demo_last_pinfo = timer_GetTime() - (DEMO_PINFO_UPDATE * 2);
372 Demo_flags = DF_RECORDING;
373 // Write the header
374 DemoWriteHeader();
375 DemoStartNewFrame();
376 } else {
377 // cfopen failed
378 AddBlinkingHUDMessage(TXT_DEMOCANTCREATE);
379 Demo_fname[0] = '\0';
380 return;
381 }
382 }
383}
384
385void DemoWriteHeader() {
386 char szsig[10];

Callers 2

RunGameMenuFunction · 0.85
DemoPlaybackFileFunction · 0.85

Calls 8

cfcloseFunction · 0.85
AddBlinkingHUDMessageFunction · 0.85
DoEditDialogFunction · 0.85
cfopenFunction · 0.85
MultiBuildMatchTablesFunction · 0.85
DemoWriteHeaderFunction · 0.85
DemoStartNewFrameFunction · 0.85
ddio_MakePathFunction · 0.50

Tested by

no test coverage detected