| 219 | } |
| 220 | |
| 221 | void CoreConfig::Initialize() |
| 222 | { |
| 223 | SMCError err; |
| 224 | char filePath[PLATFORM_MAX_PATH]; |
| 225 | |
| 226 | /* Try to get command line value of core config convar */ |
| 227 | const char *corecfg = icvar->GetCommandLineValue("sm_corecfgfile"); |
| 228 | |
| 229 | /* If sm_corecfgfile is on the command line, use that |
| 230 | * If sm_corecfgfile isn't there, check sm_basepath on the command line and build the path off that |
| 231 | * If sm_basepath isn't there, just use the default path for the cfg |
| 232 | */ |
| 233 | if (corecfg) |
| 234 | { |
| 235 | ke::path::Format(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), corecfg); |
| 236 | } |
| 237 | else |
| 238 | { |
| 239 | const char *basepath = icvar->GetCommandLineValue("sm_basepath"); |
| 240 | |
| 241 | /* Format path to config file */ |
| 242 | if (basepath) |
| 243 | { |
| 244 | ke::path::Format(filePath, sizeof(filePath), "%s/%s/%s", g_SourceMod.GetGamePath(), basepath, "configs/core.cfg"); |
| 245 | } |
| 246 | else |
| 247 | { |
| 248 | ke::path::Format(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetGamePath(), sm_corecfgfile.GetDefault()); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | /* Reset cached key values */ |
| 253 | m_KeyValues.clear(); |
| 254 | |
| 255 | /* Parse config file */ |
| 256 | if ((err=textparsers->ParseFile_SMC(filePath, this, NULL)) != SMCError_Okay) |
| 257 | { |
| 258 | /* :TODO: This won't actually log or print anything :( - So fix that somehow */ |
| 259 | const char *error = textparsers->GetSMCErrorString(err); |
| 260 | logger->LogFatal("[SM] Error encountered parsing core config file: %s", error ? error : ""); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | SMCResult CoreConfig::ReadSMC_KeyValue(const SMCStates *states, const char *key, const char *value) |
| 265 | { |
nothing calls this directly
no test coverage detected