Revert "MapAdmin: Split configs per map, instead of one big one."

This reverts commit 485542f317.
This commit is contained in:
zaCade 2019-01-05 18:48:30 +01:00
parent 064ca594ac
commit 992822ba97

View File

@ -5,6 +5,7 @@
#include <sdktools> #include <sdktools>
KeyValues g_Config; KeyValues g_Config;
bool g_Enabled = false;
public Plugin myinfo = public Plugin myinfo =
{ {
@ -19,30 +20,16 @@ public void OnPluginStart()
{ {
LoadTranslations("common.phrases"); LoadTranslations("common.phrases");
RegAdminCmd("sm_adminroom", Command_AdminRoom, ADMFLAG_GENERIC, "sm_adminroom [#userid|name]");
RegAdminCmd("sm_stage", Command_Stage, ADMFLAG_GENERIC, "sm_stage <stage>");
}
public void OnMapStart()
{
if(g_Config)
delete g_Config;
char sMapName[PLATFORM_MAX_PATH];
GetCurrentMap(sMapName, sizeof(sMapName));
char sConfigFile[PLATFORM_MAX_PATH]; char sConfigFile[PLATFORM_MAX_PATH];
BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/mapadmin/%s.cfg", sMapName); BuildPath(Path_SM, sConfigFile, sizeof(sConfigFile), "configs/MapAdmin.cfg");
if(!FileExists(sConfigFile)) if(!FileExists(sConfigFile))
{ {
LogMessage("Could not find mapconfig: \"%s\"", sConfigFile); SetFailState("Could not find config: \"%s\"", sConfigFile);
return; return;
} }
LogMessage("Found mapconfig: \"%s\"", sConfigFile); g_Config = new KeyValues("maps");
g_Config = new KeyValues("mapadmin");
if(!g_Config.ImportFromFile(sConfigFile)) if(!g_Config.ImportFromFile(sConfigFile))
{ {
delete g_Config; delete g_Config;
@ -50,11 +37,26 @@ public void OnMapStart()
return; return;
} }
g_Config.Rewind(); g_Config.Rewind();
RegAdminCmd("sm_adminroom", Command_AdminRoom, ADMFLAG_GENERIC, "sm_adminroom [#userid|name]");
RegAdminCmd("sm_stage", Command_Stage, ADMFLAG_GENERIC, "sm_stage <stage>");
}
public void OnMapStart()
{
g_Enabled = false;
g_Config.Rewind();
char sMapName[PLATFORM_MAX_PATH];
GetCurrentMap(sMapName, sizeof(sMapName));
if(g_Config.JumpToKey(sMapName, false))
g_Enabled = true;
} }
public Action Command_AdminRoom(int client, int argc) public Action Command_AdminRoom(int client, int argc)
{ {
if(!g_Config) if(!g_Enabled)
{ {
ReplyToCommand(client, "[SM] The current map is not supported."); ReplyToCommand(client, "[SM] The current map is not supported.");
return Plugin_Handled; return Plugin_Handled;
@ -116,7 +118,7 @@ public Action Command_AdminRoom(int client, int argc)
public Action Command_Stage(int client, int argc) public Action Command_Stage(int client, int argc)
{ {
if(!g_Config) if(!g_Enabled)
{ {
ReplyToCommand(client, "[SM] The current map is not supported."); ReplyToCommand(client, "[SM] The current map is not supported.");
return Plugin_Handled; return Plugin_Handled;