Prompts user for filename and starts recording if successfull
| 337 | |
| 338 | // Prompts user for filename and starts recording if successfull |
| 339 | void 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 | |
| 385 | void DemoWriteHeader() { |
| 386 | char szsig[10]; |
no test coverage detected