MCPcopy Create free account
hub / github.com/EasyRPG/Player / Save

Method Save

src/game_dynrpg.cpp:479–513  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

477}
478
479void 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
515void Game_DynRpg::Update() {
516 for (auto& plugin : plugins) {

Callers

nothing calls this directly

Calls 5

get_filenameFunction · 0.85
OpenOutputStreamMethod · 0.80
GetIdentifierMethod · 0.80
dataMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected