MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / deserializeManifest

Method deserializeManifest

game/state/savemanager.cpp:327–375  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

325}
326
327bool SaveMetadata::deserializeManifest(SerializationArchive *archive, const UString &saveFileName)
328{
329 auto root = archive->getRoot("", saveManifestName.c_str());
330 if (!root)
331 {
332 return false;
333 }
334
335 auto nameNode = root->getNodeOpt("name");
336 if (!nameNode)
337 {
338 return false;
339 }
340 this->name = nameNode->getValue();
341
342 auto difficultyNode = root->getNodeOpt("difficulty");
343 if (difficultyNode)
344 {
345 this->difficulty = difficultyNode->getValue();
346 }
347
348 auto saveDateNode = root->getNodeOpt("save_date");
349 if (saveDateNode)
350 {
351 std::istringstream stream(saveDateNode->getValue());
352 time_t timestamp;
353 stream >> timestamp;
354 this->creationDate = timestamp;
355 }
356
357 auto gameTicksNode = root->getNodeOpt("game_ticks");
358 if (gameTicksNode)
359 {
360 gameTicks = gameTicksNode->getValueUInt();
361 }
362
363 auto typeNode = root->getNodeOpt("type");
364 if (typeNode)
365 {
366 this->type = static_cast<SaveType>(Strings::toInteger(typeNode->getValue()));
367 }
368 else
369 {
370 this->type = SaveType::Manual;
371 }
372
373 this->file = saveFileName;
374 return true;
375}
376
377bool SaveMetadata::serializeManifest(SerializationArchive *archive) const
378{

Callers 1

getSaveListMethod · 0.80

Calls 4

getRootMethod · 0.80
getNodeOptMethod · 0.80
getValueUIntMethod · 0.80
getValueMethod · 0.45

Tested by

no test coverage detected