MCPcopy Create free account
hub / github.com/Phobos-developers/Phobos / ReadVariables

Method ReadVariables

src/Ext/Scenario/Body.cpp:36–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

34}
35
36void ScenarioExt::ExtData::ReadVariables(bool bIsGlobal, CCINIClass* pINI)
37{
38 if (!bIsGlobal) // Local variables need to be read again
39 Global()->Variables[false].clear();
40 else if (Global()->Variables[true].size() != 0) // Global variables had been loaded, DO NOT CHANGE THEM
41 return;
42
43 int nCount = pINI->GetKeyCount("VariableNames");
44 for (int i = 0; i < nCount; ++i)
45 {
46 auto pKey = pINI->GetKeyName("VariableNames", i);
47 int nIndex;
48 if (sscanf_s(pKey, "%d", &nIndex) == 1)
49 {
50 auto& var = Global()->Variables[bIsGlobal][nIndex];
51 pINI->ReadString("VariableNames", pKey, pKey, Phobos::readBuffer);
52 char* buffer;
53 strcpy_s(var.Name, strtok_s(Phobos::readBuffer, ",", &buffer));
54 if (auto pState = strtok_s(nullptr, ",", &buffer))
55 var.Value = atoi(pState);
56 else
57 var.Value = 0;
58 }
59 }
60}
61
62// you've inspired something controversial
63void ScenarioExt::ExtData::SaveVariablesToFile(bool isGlobal)

Callers 1

Calls 3

ReadStringMethod · 0.80
clearMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected