1.1 --- a/plugins/rockthevote.sp Thu Oct 18 01:08:48 2007 +0000
1.2 +++ b/plugins/rockthevote.sp Thu Oct 18 01:16:42 2007 +0000
1.3 @@ -88,7 +88,7 @@
1.4 AutoExecConfig(true, "rtv");
1.5 }
1.6
1.7 -public OnMapStart()
1.8 +public OnConfigsExecuted()
1.9 {
1.10 if (g_RTVMapList != INVALID_HANDLE)
1.11 {
1.12 @@ -101,16 +101,12 @@
1.13 g_RTVStarted = false;
1.14 g_RTVEnded = false;
1.15
1.16 - if (LoadMaps())
1.17 + if (LoadMaps(g_MapList, g_mapFileTime, g_Cvar_File))
1.18 {
1.19 BuildMapMenu();
1.20 g_CanRTV = true;
1.21 CreateTimer(30.0, Timer_DelayRTV);
1.22 }
1.23 - else
1.24 - {
1.25 - LogMessage("[SM] Cannot find map cycle file, RTV not active.");
1.26 - }
1.27 }
1.28
1.29 public OnMapEnd()
1.30 @@ -528,82 +524,4 @@
1.31 }
1.32
1.33 SetMenuExitButton(g_MapMenu, false);
1.34 -}
1.35 -
1.36 -LoadMaps()
1.37 -{
1.38 - new bool:fileFound;
1.39 -
1.40 - decl String:mapPath[256], String:mapFile[64];
1.41 - GetConVarString(g_Cvar_File, mapFile, 64);
1.42 - BuildPath(Path_SM, mapPath, sizeof(mapPath), mapFile);
1.43 - fileFound = FileExists(mapPath);
1.44 - if (!fileFound)
1.45 - {
1.46 - new Handle:mapCycleFile = FindConVar("mapcyclefile");
1.47 - GetConVarString(mapCycleFile, mapPath, sizeof(mapPath));
1.48 - fileFound = FileExists(mapPath);
1.49 - }
1.50 -
1.51 - if (!fileFound)
1.52 - {
1.53 - LogError("Unable to locate sm_rtv_file or mapcyclefile, no maps loaded.");
1.54 -
1.55 - if (g_MapList != INVALID_HANDLE)
1.56 - {
1.57 - ClearArray(g_MapList);
1.58 - }
1.59 -
1.60 - return 0;
1.61 - }
1.62 -
1.63 - // If the file hasn't changed, there's no reason to reload
1.64 - // all of the maps.
1.65 - new fileTime = GetFileTime(mapPath, FileTime_LastChange);
1.66 - if (g_mapFileTime == fileTime)
1.67 - {
1.68 - return GetArraySize(g_MapList);
1.69 - }
1.70 -
1.71 - g_mapFileTime = fileTime;
1.72 -
1.73 - // Reset the array
1.74 - if (g_MapList != INVALID_HANDLE)
1.75 - {
1.76 - ClearArray(g_MapList);
1.77 - }
1.78 -
1.79 - LogMessage("[SM] Loading RTV map file [%s]", mapPath);
1.80 -
1.81 - decl String:currentMap[32];
1.82 - GetCurrentMap(currentMap, sizeof(currentMap));
1.83 -
1.84 - new Handle:file = OpenFile(mapPath, "rt");
1.85 - if (file == INVALID_HANDLE)
1.86 - {
1.87 - LogError("[SM] Could not open file: %s", mapPath);
1.88 - return 0;
1.89 - }
1.90 -
1.91 - decl String:buffer[64], len;
1.92 - while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
1.93 - {
1.94 - TrimString(buffer);
1.95 -
1.96 - if ((len = StrContains(buffer, ".bsp", false)) != -1)
1.97 - {
1.98 - buffer[len] = '\0';
1.99 - }
1.100 -
1.101 - if (buffer[0] == '\0' || !IsValidConVarChar(buffer[0]) || !IsMapValid(buffer)
1.102 - || strcmp(currentMap, buffer, false) == 0)
1.103 - {
1.104 - continue;
1.105 - }
1.106 -
1.107 - PushArrayString(g_MapList, buffer);
1.108 - }
1.109 -
1.110 - CloseHandle(file);
1.111 - return GetArraySize(g_MapList);
1.112 }
1.113 \ No newline at end of file