1.1 --- a/plugins/nextmap.sp Thu Oct 18 01:08:48 2007 +0000
1.2 +++ b/plugins/nextmap.sp Thu Oct 18 01:16:42 2007 +0000
1.3 @@ -49,7 +49,6 @@
1.4
1.5 new Handle:g_Cvar_Chattime;
1.6 new Handle:g_Cvar_Nextmap;
1.7 -new Handle:g_Cvar_Mapcycle;
1.8
1.9 new g_MapPos = -1;
1.10 new Handle:g_MapList = INVALID_HANDLE;
1.11 @@ -67,21 +66,18 @@
1.12 SetFailState("VGUIMenu Not Found");
1.13 }
1.14
1.15 - g_Cvar_Chattime = FindConVar("mp_chattime");
1.16 - g_Cvar_Mapcycle = FindConVar("mapcyclefile");
1.17 -
1.18 g_MapList = CreateArray(32);
1.19
1.20 - if (!LoadMaps())
1.21 + if (!LoadMaps(g_MapList, g_mapFileTime))
1.22 {
1.23 LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
1.24 SetFailState("Mapcycle Not Found");
1.25 }
1.26
1.27 HookUserMessage(g_VGUIMenu, UserMsg_VGUIMenu);
1.28 - HookConVarChange(g_Cvar_Mapcycle, ConVarChange_Mapcyclefile);
1.29
1.30 g_Cvar_Nextmap = CreateConVar("sm_nextmap", "", "Sets the Next Map", FCVAR_NOTIFY);
1.31 + g_Cvar_Chattime = FindConVar("mp_chattime");
1.32
1.33 RegConsoleCmd("say", Command_Say);
1.34 RegConsoleCmd("say_team", Command_Say);
1.35 @@ -106,7 +102,7 @@
1.36 // not in mapcyclefile. So we keep it set to the last expected nextmap. - ferret
1.37 if (strcmp(lastMap, currentMap) == 0)
1.38 {
1.39 - if (!LoadMaps())
1.40 + if (!LoadMaps(g_MapList, g_mapFileTime))
1.41 {
1.42 LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
1.43 SetFailState("Mapcycle Not Found");
1.44 @@ -120,21 +116,7 @@
1.45 {
1.46 g_IntermissionCalled = false;
1.47 }
1.48 -
1.49 -public ConVarChange_Mapcyclefile(Handle:convar, const String:oldValue[], const String:newValue[])
1.50 -{
1.51 - if (strcmp(oldValue, newValue, false) != 0)
1.52 - {
1.53 - if (!LoadMaps())
1.54 - {
1.55 - LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
1.56 - SetFailState("Mapcycle Not Found");
1.57 - }
1.58 -
1.59 - FindAndSetNextMap();
1.60 - }
1.61 -}
1.62 -
1.63 +
1.64 public Action:Command_Say(client, args)
1.65 {
1.66 decl String:text[192];
1.67 @@ -254,59 +236,6 @@
1.68 return Plugin_Stop;
1.69 }
1.70
1.71 -LoadMaps()
1.72 -{
1.73 - decl String:mapCycle[64];
1.74 - GetConVarString(g_Cvar_Mapcycle, mapCycle, 64);
1.75 -
1.76 - if (!FileExists(mapCycle))
1.77 - {
1.78 - LogError("[SM] Could not find file: %s", mapCycle);
1.79 - return 0;
1.80 - }
1.81 -
1.82 - new fileTime = GetFileTime(mapCycle, FileTime_LastChange);
1.83 - if (g_mapFileTime == fileTime)
1.84 - {
1.85 - return GetArraySize(g_MapList);
1.86 - }
1.87 -
1.88 - g_mapFileTime = fileTime;
1.89 -
1.90 - new Handle:file = OpenFile(mapCycle, "r");
1.91 -
1.92 - if (file == INVALID_HANDLE)
1.93 - {
1.94 - LogError("[SM] Could not open file: %s", mapCycle);
1.95 - return 0;
1.96 - }
1.97 -
1.98 - g_MapPos = -1;
1.99 - if (g_MapList != INVALID_HANDLE)
1.100 - {
1.101 - ClearArray(g_MapList);
1.102 - }
1.103 -
1.104 - decl String:buffer[255];
1.105 - while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
1.106 - {
1.107 - TrimString(buffer);
1.108 - if (buffer[0] == '\0' || buffer[0] == ';')
1.109 - {
1.110 - continue;
1.111 - }
1.112 -
1.113 - if (IsMapValid(buffer))
1.114 - {
1.115 - PushArrayString(g_MapList, buffer);
1.116 - }
1.117 - }
1.118 -
1.119 - CloseHandle(file);
1.120 -
1.121 - return GetArraySize(g_MapList);
1.122 -}
1.123 -
1.124 FindAndSetNextMap()
1.125 {
1.126 new mapCount = GetArraySize(g_MapList);