MCPcopy Create free account
hub / github.com/WolfireGames/overgrowth / Load

Method Load

Source/XML/Parsers/levelxmlparser.cpp:33–143  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31#include <tinyxml.h>
32
33uint32_t LevelXMLParser::Load(const std::string& path) {
34 Clear();
35 TiXmlDocument doc(path.c_str());
36 doc.LoadFile();
37
38 if (!doc.Error()) {
39 TiXmlElement* eType = doc.FirstChildElement("Type");
40 const char* c_type = "";
41 if (eType) {
42 c_type = eType->GetText();
43 }
44
45 if (strmtch(c_type, "level_info_cache")) {
46 TiXmlElement* eVersion = doc.FirstChildElement("Version");
47 if (eVersion) {
48 const char* c_version = eVersion->GetText();
49 if (strmtch(c_version, "1") == false) {
50 LOGI << "level info cache file " << path << " is out of date" << std::endl;
51 return false;
52 }
53 }
54
55 TiXmlElement* eLevelHash = doc.FirstChildElement("LevelHash");
56 if (eLevelHash) {
57 const char* c_level_hash = eLevelHash->GetText();
58 if (c_level_hash) {
59 hash = c_level_hash;
60 }
61 }
62 } else {
63 FileHashAssetRef level_hash = Engine::Instance()->GetAssetManager()->LoadSync<FileHashAsset>(path);
64 if (level_hash.valid()) {
65 hash = level_hash->hash.ToString();
66 }
67 }
68
69 TiXmlElement* eName = doc.FirstChildElement("Name");
70 if (eName) {
71 const char* c_name = eName->GetText();
72 if (c_name) {
73 name = c_name;
74 } else {
75 LOGE << "Element \"Name\" in " << path << " is null." << std::endl;
76 }
77 } else {
78 LOGE << "Missing element \"Name\" in " << path << std::endl;
79 }
80
81 TiXmlElement* eDescription = doc.FirstChildElement("Description");
82 if (eDescription) {
83 const char* c_description = eDescription->GetText();
84 if (c_description) {
85 description = c_description;
86 }
87 }
88
89 TiXmlElement* eShader = doc.FirstChildElement("Shader");
90 if (eShader) {

Callers

nothing calls this directly

Calls 11

strmtchFunction · 0.85
GetAssetManagerMethod · 0.80
ErrorDescMethod · 0.80
ClearFunction · 0.50
c_strMethod · 0.45
LoadFileMethod · 0.45
ErrorMethod · 0.45
FirstChildElementMethod · 0.45
GetTextMethod · 0.45
validMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected