attempted fix for
amb243, timers now simulate ticks if gameframe doesn't give changed curtimes
3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #include "CoreConfig.h"
16 #include "sourcemod.h"
17 #include "sourcemm_api.h"
18 #include "sm_srvcmds.h"
19 #include "LibrarySys.h"
20 #include "TextParsers.h"
23 #ifdef PLATFORM_WINDOWS
24 ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
25 #elif defined PLATFORM_LINUX
26 ConVar sm_corecfgfile("sm_corecfgfile", "addons/sourcemod/configs/core.cfg", 0, "SourceMod core configuration file");
29 CoreConfig g_CoreConfig;
31 void CoreConfig::OnSourceModAllInitialized()
33 g_RootMenu.AddRootConsoleCommand("config", "Set core configuration options", this);
36 void CoreConfig::OnSourceModShutdown()
38 g_RootMenu.RemoveRootConsoleCommand("config", this);
41 void CoreConfig::OnRootConsoleCommand(const char *command, unsigned int argcount)
45 const char *option = engine->Cmd_Argv(2);
46 const char *value = engine->Cmd_Argv(3);
50 ConfigResult res = SetConfigOption(option, value, ConfigSource_Console, error, sizeof(error));
52 if (res == ConfigResult_Reject)
54 g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\" (%s)", option, value, error);
55 } else if (res == ConfigResult_Ignore) {
56 g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
58 g_RootMenu.ConsolePrint("Config option \"%s\" successfully set to \"%s.\"", option, value);
64 g_RootMenu.ConsolePrint("[SM] Usage: sm config <option> <value>");
67 void CoreConfig::Initialize()
70 char filePath[PLATFORM_MAX_PATH];
72 /* Try to get command line value of core config convar */
73 const char *corecfg = icvar->GetCommandLineValue("sm_corecfgfile");
75 /* If sm_corecfgfile not specified on command line, use default value */
78 corecfg = sm_corecfgfile.GetDefault();
81 /* Format path to config file */
82 g_LibSys.PathFormat(filePath, sizeof(filePath), "%s/%s", g_SourceMod.GetModPath(), corecfg);
84 /* Parse config file */
85 if ((err=g_TextParser.ParseFile_SMC(filePath, this, NULL, NULL)) != SMCParse_Okay)
87 /* :TODO: This won't actually log or print anything :( - So fix that somehow */
88 const char *error = g_TextParser.GetSMCErrorString(err);
89 g_Logger.LogFatal("[SM] Error encountered parsing core config file: %s", error ? error : "");
93 SMCParseResult CoreConfig::ReadSMC_KeyValue(const char *key, const char *value, bool key_quotes, bool value_quotes)
96 ConfigResult err = SetConfigOption(key, value, ConfigSource_File, error, sizeof(error));
98 if (err == ConfigResult_Reject)
100 /* This is a fatal error */
101 g_Logger.LogFatal("Config error (key: %s) (value: %s) %s", key, value, error);
104 return SMCParse_Continue;
107 ConfigResult CoreConfig::SetConfigOption(const char *option, const char *value, ConfigSource source, char *error, size_t maxlength)
112 SMGlobalClass *pBase = SMGlobalClass::head;
115 if ((result = pBase->OnSourceModConfigChanged(option, value, source, error, maxlength)) != ConfigResult_Ignore)
119 pBase = pBase->m_pGlobalClassNext;
122 return ConfigResult_Ignore;