| 34 | } |
| 35 | |
| 36 | void 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 |
| 63 | void ScenarioExt::ExtData::SaveVariablesToFile(bool isGlobal) |
no test coverage detected