| 477 | } |
| 478 | |
| 479 | void Game_DynRpg::Save(int slot) { |
| 480 | if (!Player::IsPatchDynRpg()) { |
| 481 | return; |
| 482 | } |
| 483 | |
| 484 | InitPlugins(); |
| 485 | |
| 486 | std::string filename = get_filename(slot); |
| 487 | |
| 488 | auto out = FileFinder::Save().OpenOutputStream(filename); |
| 489 | |
| 490 | if (!out) { |
| 491 | Output::Warning("Couldn't write DynRPG save: {}", filename); |
| 492 | return; |
| 493 | } |
| 494 | |
| 495 | std::string header = "DYNSAVE1"; |
| 496 | |
| 497 | out.write(header.c_str(), 8); |
| 498 | |
| 499 | for (auto &plugin : plugins) { |
| 500 | uint32_t len = plugin->GetIdentifier().size(); |
| 501 | Utils::SwapByteOrder(len); |
| 502 | |
| 503 | out.write((char*)&len, 4); |
| 504 | out.write(plugin->GetIdentifier().data(), len); |
| 505 | |
| 506 | std::vector<uint8_t> data = plugin->Save(); |
| 507 | len = data.size(); |
| 508 | Utils::SwapByteOrder(len); |
| 509 | |
| 510 | out.write((char*)&len, 4); |
| 511 | out.write((char*)data.data(), data.size()); |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | void Game_DynRpg::Update() { |
| 516 | for (auto& plugin : plugins) { |
nothing calls this directly
no test coverage detected