backup map is now based on casualpool

This commit is contained in:
jenz 2026-03-14 17:39:25 +01:00
parent 1bbed31610
commit 5855e49f78

View File

@ -1035,17 +1035,46 @@ public Action unfreeze_players2(Handle hTimer, Handle dp)
public Action Timer_fall_back_map_switch(Handle hTimer, Handle dp)
{
char map_line[256];
File f = OpenFile("cfg/defaultmap.cfg", "r");
if (f != null)
static char map[PLATFORM_MAX_PATH];
Handle tempMaps = CloneArray(g_MapList);
//if we stop using the casual pool feature we instead just rely on the default map to be used.
if (g_iMapsFromCasualPool > 0)
{
f.ReadLine(map_line, sizeof(map_line));
CloseHandle(f);
int b;
for(int j = 0; j < 1000; j++)
{
b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
GetArrayString(tempMaps, b, map, PLATFORM_MAX_PATH);
if (!InternalGetCasualPool(map))
{
continue;
}
if (InternalGetMapCooldownTime(map) > GetTime())
{
continue;
}
//found a map from casual pool to force to.
break;
}
ForceChangeLevel(map, "nobody voted at mapvote");
}
else
{
char map_line[256];
File f = OpenFile("cfg/defaultmap.cfg", "r");
if (f != null)
{
f.ReadLine(map_line, sizeof(map_line));
CloseHandle(f);
}
ReplaceString(map_line, sizeof(map_line), "map ", "");
TrimString(map_line);
//LogMessage("map_line: %s", map_line);
ForceChangeLevel(map_line, "nobody voted at mapvote");
}
ReplaceString(map_line, sizeof(map_line), "map ", "");
TrimString(map_line);
//LogMessage("map_line: %s", map_line);
ForceChangeLevel(map_line, "nobody voted at mapvote");
return Plugin_Handled;
}