|
23 | 23 | #include <CCINIClass.h> |
24 | 24 | #include <MixFileClass.h> |
25 | 25 |
|
26 | | -constexpr const char* NONE_STR = "<none>"; |
27 | | - |
28 | | -inline void ReadFiles(CCINIClass* pINI, const char* pSection, std::list<std::pair<int, std::string>>& files) |
| 26 | +inline void ReadListFromSection(CCINIClass* pINI, const char* pSection, std::list<std::string>& strings) |
29 | 27 | { |
30 | 28 | if (!pINI->GetSection(pSection)) |
31 | 29 | return; |
32 | 30 |
|
33 | 31 | const int itemsCount = pINI->GetKeyCount(pSection); |
34 | 32 | for (int i = 0; i < itemsCount; ++i) |
35 | 33 | { |
36 | | - auto pKey = pINI->GetKeyName(pSection, i); |
37 | | - char* pEnd = nullptr; |
38 | | - auto index = std::strtol(pKey, &pEnd, 10); |
39 | | - if (pEnd == pKey || *pEnd != 0) |
40 | | - continue; |
41 | | - |
42 | | - char fileName[0x80]; |
43 | | - pINI->ReadString(pSection, pKey, "", fileName); |
| 34 | + auto pKey = pINI->GetKeyName(pSection, i); |
| 35 | + std::string& str = strings.emplace_back(); str.resize(0x80); |
| 36 | + pINI->ReadString(pSection, pKey, NONE_STR, (char*) str.c_str(), str.size()); str.resize(strlen(str.c_str())); |
44 | 37 |
|
45 | | - if (fileName[0] != 0 || _strcmpi(fileName, NONE_STR) != 0) |
46 | | - files.emplace_back(index, fileName); |
| 38 | + if (str == NONE_STR) |
| 39 | + strings.remove(str); |
47 | 40 | } |
48 | 41 | } |
49 | 42 |
|
@@ -135,16 +128,8 @@ void SpawnerConfig::LoadFromINIFile(CCINIClass* pINI) |
135 | 128 | // RunAutoSS = pINI->ReadBool(pSettingsSection, "RunAutoSS", RunAutoSS); |
136 | 129 |
|
137 | 130 | // Custom Mixes |
138 | | - ReadFiles(pINI, "mixes_preload", PreloadMixes); |
139 | | - ReadFiles(pINI, "mixes_postload", PostloadMixes); |
140 | | - |
141 | | - auto predicate = [](std::pair<int, std::string> const& a, std::pair<int, std::string> const& b) -> bool |
142 | | - { |
143 | | - return a.first < b.first; |
144 | | - }; |
145 | | - |
146 | | - PreloadMixes.sort(predicate); |
147 | | - PostloadMixes.sort(predicate); |
| 131 | + ReadListFromSection(pINI, "PreloadMixes", PreloadMixes); |
| 132 | + ReadListFromSection(pINI, "PostloadMixes", PostloadMixes); |
148 | 133 | } |
149 | 134 |
|
150 | 135 | constexpr char* PlayerSectionArray[8] = { |
|
0 commit comments