diff -r 000000000000 -r b7aa2b626807 core/CoreConfig.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/CoreConfig.cpp Sun Mar 30 07:00:22 2008 +0000
@@ -0,0 +1,420 @@
+/**
+ * vim: set ts=4 :
+ * =============================================================================
+ * SourceMod
+ * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
+ * =============================================================================
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, version 3.0, as published by the
+ * Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program. If not, see .
+ *
+ * As a special exception, AlliedModders LLC gives you permission to link the
+ * code of this program (as well as its derivative works) to "Half-Life 2," the
+ * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
+ * by the Valve Corporation. You must obey the GNU General Public License in
+ * all respects for all other code used. Additionally, AlliedModders LLC grants
+ * this exception to all derivative works. AlliedModders LLC defines further
+ * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
+ * or .
+ *
+ * Version: $Id$
+ */
+
+#include
+#include "CoreConfig.h"
+#include "sourcemod.h"
+#include "sourcemm_api.h"
+#include "sm_srvcmds.h"
+#include "sm_version.h"
+#include "sm_stringutil.h"
+#include "LibrarySys.h"
+#include "Logger.h"
+#include "PluginSys.h"
+#include "ForwardSys.h"
+
+#ifdef PLATFORM_WINDOWS
+ConVar sm_corecfgfile("sm_corecfgfile", "addons\\sourcemod\\configs\\core.cfg", 0, "SourceMod core configuration file");
+#elif defined PLATFORM_LINUX
+ConVar sm_corecfgfile("sm_corecfgfile", "addons/sourcemod/configs/core.cfg", 0, "SourceMod core configuration file");
+#endif
+
+IForward *g_pOnServerCfg = NULL;
+IForward *g_pOnConfigsExecuted = NULL;
+CoreConfig g_CoreConfig;
+bool g_bConfigsExecd = false;
+
+void CoreConfig::OnSourceModAllInitialized()
+{
+ g_RootMenu.AddRootConsoleCommand("config", "Set core configuration options", this);
+ g_pOnServerCfg = g_Forwards.CreateForward("OnServerCfg", ET_Ignore, 0, NULL);
+ g_pOnConfigsExecuted = g_Forwards.CreateForward("OnConfigsExecuted", ET_Ignore, 0, NULL);
+}
+
+void CoreConfig::OnSourceModShutdown()
+{
+ g_RootMenu.RemoveRootConsoleCommand("config", this);
+ g_Forwards.ReleaseForward(g_pOnServerCfg);
+ g_Forwards.ReleaseForward(g_pOnConfigsExecuted);
+}
+
+void CoreConfig::OnSourceModLevelChange(const char *mapName)
+{
+ g_bConfigsExecd = false;
+}
+
+void CoreConfig::OnRootConsoleCommand(const char *cmdname, const CCommand &command)
+{
+ int argcount = command.ArgC();
+ if (argcount >= 4)
+ {
+ const char *option = command.Arg(2);
+ const char *value = command.Arg(3);
+
+ char error[255];
+
+ ConfigResult res = SetConfigOption(option, value, ConfigSource_Console, error, sizeof(error));
+
+ if (res == ConfigResult_Reject)
+ {
+ g_RootMenu.ConsolePrint("[SM] Could not set config option \"%s\" to \"%s\" (%s)", option, value, error);
+ } else if (res == ConfigResult_Ignore) {
+ g_RootMenu.ConsolePrint("[SM] No such config option \"%s\" exists.", option);
+ } else {
+ g_RootMenu.ConsolePrint("Config option \"%s\" successfully set to \"%s.\"", option, value);
+ }
+
+ return;
+ }
+
+ g_RootMenu.ConsolePrint("[SM] Usage: sm config