MCPcopy Create free account
hub / github.com/codereader/DarkRadiant / operator()

Method operator()

plugins/dm.objectives/ObjectiveKeyExtractor.cpp:14–181  ·  view source on GitHub ↗

Required entity visit function

Source from the content-addressed store, hash-verified

12
13// Required entity visit function
14void ObjectiveKeyExtractor::operator()(const std::string& key,
15 const std::string& value)
16{
17 // Quick discard of any non-objective keys
18 if (key.substr(0, 3) != "obj")
19 return;
20
21 // Extract the objective number
22 static const std::regex reObjNum("obj(\\d+)_(.*)");
23 std::smatch results;
24 int iNum;
25
26 if (std::regex_match(key, results, reObjNum)) {
27 // Get the objective number
28 iNum = string::convert<int>(results[1].str());
29 }
30 else {
31 // No match, abort
32 return;
33 }
34
35 // We now have the objective number and the substring (everything after
36 // "obj<n>_" which applies to this objective.
37 std::string objSubString = results[2];
38
39 // Switch on the substring
40 if (objSubString == "desc") {
41 _objMap[iNum].description = value;
42 }
43 else if (objSubString == "ongoing") {
44 _objMap[iNum].ongoing = (value == "1");
45 }
46 else if (objSubString == "mandatory") {
47 _objMap[iNum].mandatory = (value == "1");
48 }
49 else if (objSubString == "visible") {
50 _objMap[iNum].visible = (value == "1");
51 }
52 else if (objSubString == "irreversible") {
53 _objMap[iNum].irreversible = (value == "1");
54 }
55 else if (objSubString == "state") {
56 _objMap[iNum].state =
57 static_cast<Objective::State>(string::convert<int>(value));
58 }
59 else if (objSubString == "difficulty") {
60 _objMap[iNum].difficultyLevels = value;
61 }
62 else if (objSubString == "enabling_objs") {
63 _objMap[iNum].enablingObjs = value;
64 }
65 else if (objSubString == "script_complete") {
66 _objMap[iNum].completionScript = value;
67 }
68 else if (objSubString == "script_failed") {
69 _objMap[iNum].failureScript = value;
70 }
71 else if (objSubString == "target_complete") {

Callers

nothing calls this directly

Calls 15

splitFunction · 0.85
rErrorFunction · 0.85
setSatisfiedMethod · 0.80
setInvertedMethod · 0.80
setIrreversibleMethod · 0.80
setPlayerResponsibleMethod · 0.80
clearArgumentsMethod · 0.80
addArgumentMethod · 0.80
setClockIntervalMethod · 0.80
starts_withFunction · 0.50
strMethod · 0.45
setTypeMethod · 0.45

Tested by

no test coverage detected