Main replay serialization function The demo file contains all the information needed to replay the game ----------------------------------------------------------- 1. It will contain the metadata of the replay such as then name and modname 2. It will contain the agent data for the replay 3. It will contain the input events for the replay 4. It will contain the game and graphical settings 5. It wi
| 517 | // |
| 518 | // ----------------------------------------------------------- |
| 519 | void serializeDemo(FileStream* stream, bool writeFlag) |
| 520 | { |
| 521 | // Initalize the events and frametick obj |
| 522 | int eventCounter = 0; |
| 523 | fixed16_16 frameTicks[13]; |
| 524 | |
| 525 | // Pause everything while we serialize |
| 526 | TFE_DarkForces::time_pause(JTRUE); |
| 527 | |
| 528 | // Handle the header and agent data |
| 529 | int fileHandler = serializeHeaderAgentInfo(stream, writeFlag); |
| 530 | |
| 531 | if (fileHandler > 0) |
| 532 | { |
| 533 | |
| 534 | // Handle Tick timing |
| 535 | SERIALIZE(ReplayVersionInit, inputEvents[0].prevTick, 0); |
| 536 | SERIALIZE(ReplayVersionInit, inputEvents[0].deltaTime, 0); |
| 537 | SERIALIZE(ReplayVersionInit, inputEvents[0].timeAccum, 0); |
| 538 | SERIALIZE(ReplayVersionInit, inputEvents[0].plTick, 0); |
| 539 | SERIALIZE(ReplayVersionInit, inputEvents[0].plPrevTick, 0); |
| 540 | |
| 541 | // Handle the frame ticks |
| 542 | if (writeFlag) |
| 543 | { |
| 544 | replayStartTime = TFE_System::getStartTime(); |
| 545 | memcpy(frameTicks, inputEvents[0].frameTicks, sizeof(fixed16_16) * TFE_ARRAYSIZE(inputEvents[0].frameTicks)); |
| 546 | } |
| 547 | |
| 548 | // Store the replay seed and start time |
| 549 | SERIALIZE(ReplayVersionInit, replayStartTime, 0); |
| 550 | SERIALIZE(ReplayVersionInit, replay_seed, 0); |
| 551 | |
| 552 | SERIALIZE_BUF(SaveVersionInit, frameTicks, sizeof(fixed16_16) * TFE_ARRAYSIZE(frameTicks)); |
| 553 | |
| 554 | // Handle events list size |
| 555 | s32 eventListsSize = inputMapping_getCounter(); |
| 556 | SERIALIZE(ReplayVersionInit, eventListsSize, 0); |
| 557 | |
| 558 | // Settings and Input Handling |
| 559 | TFE_Settings_Game* gameSettings = TFE_Settings::getGameSettings(); |
| 560 | TFE_Settings_A11y* allySettings = TFE_Settings::getA11ySettings(); |
| 561 | InputConfig* inputConfig = inputMapping_get(); |
| 562 | int mouseMode = inputConfig->mouseMode; |
| 563 | |
| 564 | // If you are not recording first store all the original values |
| 565 | if (!writeFlag) |
| 566 | { |
| 567 | copyGameSettings(gameSettings , &replayGameSettings); |
| 568 | playerHeadwave = allySettings->enableHeadwave; |
| 569 | s_mouseMode = inputConfig->mouseMode; |
| 570 | s_mouseFlags = inputConfig->mouseFlags; |
| 571 | s_mouseSensitivity[0] = inputConfig->mouseSensitivity[0]; |
| 572 | s_mouseSensitivity[1] = inputConfig->mouseSensitivity[1]; |
| 573 | } |
| 574 | |
| 575 | // Serialize game and input settings |
| 576 | SERIALIZE(ReplayVersionInit, gameSettings->df_airControl, 0); |
no test coverage detected