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

Method Load

Source/XML/Parsers/activemodsparser.cpp:39–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37}
38
39uint32_t ActiveModsParser::Load(const std::string& path) {
40 load_checksum = Checksum(path);
41
42 Clear();
43 TiXmlDocument doc(path.c_str());
44 doc.LoadFile();
45 if (!doc.Error()) {
46 TiXmlElement* pRoot = doc.RootElement();
47 if (pRoot) {
48 TiXmlElement* eModInstance = pRoot->FirstChildElement("ModInstance");
49 bool parse_error;
50 while (eModInstance) {
51 ModInstance mi;
52 int err;
53 parse_error = false;
54
55 err = strscpy(mi.id, eModInstance->Attribute("id"), MOD_ID_MAX_LENGTH);
56 if (err == SOURCE_TOO_LONG) {
57 parse_error = true;
58 } else if (err == SOURCE_IS_NULL) {
59 parse_error = true;
60 }
61
62 int saystrue = saysTrue(eModInstance->Attribute("activated"));
63 if (saystrue == 1) {
64 mi.activated = true;
65 } else if (saystrue == 0) {
66 mi.activated = false;
67 } else if (saystrue == SAYS_TRUE_NULL_INPUT) {
68 parse_error = true;
69 } else if (saystrue == SAYS_TRUE_NO_MATCH) {
70 parse_error = true;
71 } else {
72 parse_error = true;
73 }
74
75 const char* modsource = eModInstance->Attribute("modsource");
76 if (modsource) {
77 if (strmtch(modsource, "steamworks")) {
78 mi.modsource = ModSourceSteamworks;
79 } else if (strmtch(modsource, "local")) {
80 mi.modsource = ModSourceLocalModFolder;
81 } else {
82 LOGE << "Unknown modsource " << modsource << " on " << mi.id << std::endl;
83 parse_error = true;
84 }
85 } else {
86 LOGE << "Missing modsource attribute" << std::endl;
87 parse_error = true;
88 }
89
90 err = strscpy(mi.version, eModInstance->Attribute("version"), MOD_VERSION_MAX_LENGTH);
91 if (err == SOURCE_TOO_LONG) {
92 parse_error = true;
93 } else if (err == SOURCE_IS_NULL) {
94 parse_error = true;
95 }
96

Callers

nothing calls this directly

Calls 13

ChecksumFunction · 0.85
strscpyFunction · 0.85
saysTrueFunction · 0.85
strmtchFunction · 0.85
RootElementMethod · 0.80
ClearFunction · 0.50
c_strMethod · 0.45
LoadFileMethod · 0.45
ErrorMethod · 0.45
FirstChildElementMethod · 0.45
AttributeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected