| 357 | } |
| 358 | |
| 359 | bool setupPath() |
| 360 | { |
| 361 | // Replay Initialization - it will set the current game and level name |
| 362 | IGame* s_game = TFE_SaveSystem::getCurrentGame(); |
| 363 | |
| 364 | char timeDate[256]; |
| 365 | TFE_System::getDateTimeString(timeDate); |
| 366 | |
| 367 | char levelName[256]; |
| 368 | s_game->getLevelName(levelName); |
| 369 | |
| 370 | char levelId[256]; |
| 371 | s_game->getLevelId(levelId); |
| 372 | strcpy(levelId, TFE_A11Y::toLower(string(levelId)).c_str()); |
| 373 | |
| 374 | char modPath[TFE_MAX_PATH]; |
| 375 | s_game->getModList(modPath); |
| 376 | strcpy(modPath, TFE_A11Y::toLower(string(modPath)).c_str()); |
| 377 | |
| 378 | char modName[TFE_MAX_PATH]; |
| 379 | |
| 380 | // If you are not using a mod |
| 381 | if (strlen(modPath) == 0 ) |
| 382 | { |
| 383 | // For now assume all replays are Dark Forces replays |
| 384 | strcpy(modName, "dark_forces"); |
| 385 | } |
| 386 | else |
| 387 | { |
| 388 | FileUtil::getFileNameFromPath(modPath, modName, true); |
| 389 | } |
| 390 | |
| 391 | int offset = 0; |
| 392 | int offsetMax = 10000; |
| 393 | |
| 394 | // Create the demo file path |
| 395 | sprintf(s_replayPath, "%s%s_%s.demo", s_replayDir, modName, levelId); |
| 396 | |
| 397 | while (FileUtil::exists(s_replayPath) || offset > offsetMax) |
| 398 | { |
| 399 | offset++; |
| 400 | sprintf(s_replayPath, "%s%s_%s_%d.demo", s_replayDir, modName, levelId, offset); |
| 401 | if (offset > offsetMax) |
| 402 | { |
| 403 | TFE_System::logWrite(LOG_MSG, "REPLAY", "Failed to create replay file. Too many files with the same level name."); |
| 404 | return false; |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | // Store the demo name in the header |
| 409 | sprintf(s_headerName, "%s.demo", levelName); |
| 410 | return true; |
| 411 | } |
| 412 | |
| 413 | s32 getFileHandler(Stream* stream, bool writeFlag) |
| 414 | { |
no test coverage detected