nextmap reloads the map list on map change, IF the file has changed.
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401445
This commit is contained in:
parent
53d5b04016
commit
315f20d0c8
@ -53,6 +53,7 @@ new Handle:g_Cvar_Mapcycle;
|
|||||||
|
|
||||||
new g_MapPos = -1;
|
new g_MapPos = -1;
|
||||||
new Handle:g_MapList = INVALID_HANDLE;
|
new Handle:g_MapList = INVALID_HANDLE;
|
||||||
|
new g_mapFileTime;
|
||||||
|
|
||||||
public OnPluginStart()
|
public OnPluginStart()
|
||||||
{
|
{
|
||||||
@ -71,9 +72,7 @@ public OnPluginStart()
|
|||||||
|
|
||||||
g_MapList = CreateArray(32);
|
g_MapList = CreateArray(32);
|
||||||
|
|
||||||
decl String:mapCycle[64];
|
if (!LoadMaps())
|
||||||
GetConVarString(g_Cvar_Mapcycle, mapCycle, 64);
|
|
||||||
if (LoadMaps(mapCycle) < 1)
|
|
||||||
{
|
{
|
||||||
LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
|
LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
|
||||||
SetFailState("Mapcycle Not Found");
|
SetFailState("Mapcycle Not Found");
|
||||||
@ -107,6 +106,12 @@ public OnMapStart()
|
|||||||
// not in mapcyclefile. So we keep it set to the last expected nextmap. - ferret
|
// not in mapcyclefile. So we keep it set to the last expected nextmap. - ferret
|
||||||
if (strcmp(lastMap, currentMap) == 0)
|
if (strcmp(lastMap, currentMap) == 0)
|
||||||
{
|
{
|
||||||
|
if (!LoadMaps())
|
||||||
|
{
|
||||||
|
LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
|
||||||
|
SetFailState("Mapcycle Not Found");
|
||||||
|
}
|
||||||
|
|
||||||
FindAndSetNextMap();
|
FindAndSetNextMap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -120,7 +125,7 @@ public ConVarChange_Mapcyclefile(Handle:convar, const String:oldValue[], const S
|
|||||||
{
|
{
|
||||||
if (strcmp(oldValue, newValue, false) != 0)
|
if (strcmp(oldValue, newValue, false) != 0)
|
||||||
{
|
{
|
||||||
if (LoadMaps(newValue) < 1)
|
if (!LoadMaps())
|
||||||
{
|
{
|
||||||
LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
|
LogError("FATAL: Cannot load map cycle. Nextmap not loaded.");
|
||||||
SetFailState("Mapcycle Not Found");
|
SetFailState("Mapcycle Not Found");
|
||||||
@ -244,23 +249,37 @@ public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
|
|||||||
return Plugin_Stop;
|
return Plugin_Stop;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoadMaps(const String:path[])
|
LoadMaps()
|
||||||
{
|
{
|
||||||
if (!FileExists(path))
|
decl String:mapCycle[64];
|
||||||
|
GetConVarString(g_Cvar_Mapcycle, mapCycle, 64);
|
||||||
|
|
||||||
|
if (!FileExists(mapCycle))
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
new Handle:file = OpenFile(path, "r");
|
new fileTime = GetFileTime(mapCycle, FileTime_LastChange);
|
||||||
|
if (g_mapFileTime == fileTime)
|
||||||
|
{
|
||||||
|
return GetArraySize(g_MapList);
|
||||||
|
}
|
||||||
|
|
||||||
|
g_mapFileTime = fileTime;
|
||||||
|
|
||||||
|
new Handle:file = OpenFile(mapCycle, "r");
|
||||||
|
|
||||||
if (file == INVALID_HANDLE)
|
if (file == INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
LogError("[SM] Could not open file: %s", path);
|
LogError("[SM] Could not open file: %s", mapCycle);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ClearArray(g_MapList);
|
|
||||||
g_MapPos = -1;
|
g_MapPos = -1;
|
||||||
|
if (g_MapList != INVALID_HANDLE)
|
||||||
|
{
|
||||||
|
ClearArray(g_MapList);
|
||||||
|
}
|
||||||
|
|
||||||
decl String:buffer[255];
|
decl String:buffer[255];
|
||||||
while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
|
while (!IsEndOfFile(file) && ReadFileLine(file, buffer, sizeof(buffer)))
|
||||||
|
Loading…
Reference in New Issue
Block a user