Removed nondeterministic loop in mapchooser.sp
--HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401539
This commit is contained in:
parent
41ba6db2d6
commit
3fb88f9178
@ -500,30 +500,41 @@ CreateNextVote()
|
||||
if(g_NextMapList != INVALID_HANDLE)
|
||||
{
|
||||
ClearArray(g_NextMapList);
|
||||
}
|
||||
|
||||
decl String:map[32];
|
||||
new limit = (GetConVarInt(g_Cvar_IncludeMaps) < GetArraySize(g_MapList) ? GetConVarInt(g_Cvar_IncludeMaps) : GetArraySize(g_MapList));
|
||||
|
||||
new bool:oldMaps = false;
|
||||
if (limit > GetConVarInt(g_Cvar_ExcludeMaps))
|
||||
{
|
||||
limit -= GetArraySize(g_OldMapList);
|
||||
oldMaps = true;
|
||||
}
|
||||
|
||||
new Handle:tempMaps = CreateArray(33);
|
||||
decl String:map[32];
|
||||
for (new i = 0; i < GetArraySize(g_MapList); i++)
|
||||
{
|
||||
GetArrayString(g_MapList, i, map, sizeof(map));
|
||||
PushArrayString(tempMaps, map);
|
||||
}
|
||||
|
||||
if (GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps))
|
||||
{
|
||||
for (new i = 0; i < GetArraySize(g_OldMapList); i++)
|
||||
{
|
||||
GetArrayString(g_OldMapList, i, map, sizeof(map));
|
||||
for (new j = 0; j < GetArraySize(tempMaps); j++)
|
||||
{
|
||||
decl String:temp[32];
|
||||
GetArrayString(tempMaps, j, temp, sizeof(temp));
|
||||
if (strcmp(temp, map) == 0)
|
||||
{
|
||||
RemoveFromArray(tempMaps, j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
new limit = (GetConVarInt(g_Cvar_IncludeMaps) < GetArraySize(tempMaps) ? GetConVarInt(g_Cvar_IncludeMaps) : GetArraySize(tempMaps));
|
||||
for (new i = 0; i < limit; i++)
|
||||
{
|
||||
new b = GetRandomInt(0, GetArraySize(g_MapList) - 1);
|
||||
GetArrayString(g_MapList, b, map, sizeof(map));
|
||||
|
||||
while (IsStringInArray(g_NextMapList, map) || (oldMaps && IsStringInArray(g_OldMapList, map)))
|
||||
{
|
||||
b = GetRandomInt(0, GetArraySize(g_MapList) - 1);
|
||||
GetArrayString(g_MapList, b, map, sizeof(map));
|
||||
}
|
||||
|
||||
PushArrayString(g_NextMapList, map);
|
||||
new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
|
||||
GetArrayString(tempMaps, b, map, sizeof(map));
|
||||
PushArrayString(g_NextMapList, map);
|
||||
RemoveFromArray(tempMaps, b);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user