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