Remove non-deterministic loop from rockthevote.sp

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401540
This commit is contained in:
Michael McKoy 2007-10-08 22:13:17 +00:00
parent 3fb88f9178
commit 936d90a93c

View File

@ -340,36 +340,45 @@ public Action:Timer_StartRTV(Handle:timer)
new Handle:MapVoteMenu = CreateMenu(Handler_MapMapVoteMenu, MenuAction:MENU_ACTIONS_ALL); new Handle:MapVoteMenu = CreateMenu(Handler_MapMapVoteMenu, MenuAction:MENU_ACTIONS_ALL);
SetMenuTitle(MapVoteMenu, "Rock The Vote"); SetMenuTitle(MapVoteMenu, "Rock The Vote");
new limit = (GetArraySize(g_RTVMapList) < GetConVarInt(g_Cvar_Maps) ? GetArraySize(g_RTVMapList) : GetConVarInt(g_Cvar_Maps)); new Handle:tempMaps = CreateArray(33);
for (new i = 0; i < limit; i++) decl String:map[32];
for (new i = 0; i < GetArraySize(g_MapList); i++)
{ {
decl String:rtvmap[64]; GetArrayString(g_MapList, i, map, sizeof(map));
GetArrayString(g_RTVMapList, i, rtvmap, sizeof(rtvmap)); PushArrayString(tempMaps, map);
AddMenuItem(MapVoteMenu, rtvmap, rtvmap);
} }
limit = (GetArraySize(g_MapList) < GetConVarInt(g_Cvar_Maps) ? GetArraySize(g_MapList) : GetConVarInt(g_Cvar_Maps)); // We assume that g_RTVMapList is within the correct limits, based on the logic for nominations
limit -= GetMenuItemCount(MapVoteMenu); for (new i = 0; i < GetArraySize(g_RTVMapList); i++)
if (limit < 0)
{ {
limit = 0; GetArrayString(g_RTVMapList, i, map, sizeofmap));
AddMenuItem(MapVoteMenu, map, map);
for (new j = 0; j < GetArraySize(tempMaps); j++)
{
decl String:temp[32];
GetArrayString(tempMaps, j, temp, sizeof(temp));
if (strcmp(map, temp) == 0)
{
RemoveFromArray(tempMaps, j);
break;
}
}
}
new limit = GetConVarInt(g_Cvar_Maps) - GetArraySize(g_RTVMapList);
if (limit > GetArraySize(tempMaps))
{
limit = GetArraySize(tempMaps);
} }
for (new i = 0; i < limit; i++) for (new i = 0; i < limit; i++)
{ {
decl String:map[64]; new b = GetRandomInt(0, GetArraySize(tempMaps) - 1);
new b = GetRandomInt(0, GetArraySize(g_MapList) - 1); GetArrayString(tempMaps, b, map, sizeof(map));
GetArrayString(g_MapList, b, map, sizeof(map));
while (IsStringInArray(g_RTVMapList, map))
{
b = GetRandomInt(0, GetArraySize(g_MapList) - 1);
GetArrayString(g_MapList, b, map, sizeof(map));
}
PushArrayString(g_RTVMapList, map); PushArrayString(g_RTVMapList, map);
AddMenuItem(MapVoteMenu, map, map); AddMenuItem(MapVoteMenu, map, map);
RemoveFromArray(tempMaps, b);
} }
AddMenuItem(MapVoteMenu, "Don't Change", "Don't Change"); AddMenuItem(MapVoteMenu, "Don't Change", "Don't Change");