forked from UNLOZE/sm-plugins
fixing handle and index errors, also added so mapgroup restrictions are respected
This commit is contained in:
@@ -1022,6 +1022,7 @@ public Handle get_most_nominated_maps()
|
||||
sm.SetValue(map_iteration, nominate_count_for_particular_map, true);
|
||||
}
|
||||
}
|
||||
static char map_[PLATFORM_MAX_PATH];
|
||||
|
||||
for (int i = 0; i < voteSize; i++)
|
||||
{
|
||||
@@ -1056,6 +1057,43 @@ public Handle get_most_nominated_maps()
|
||||
continue;
|
||||
}
|
||||
sm.Remove(picked_map);
|
||||
|
||||
//2023 edit: respecting that only right amount of maps per group is allowed in vote
|
||||
int groups_[32];
|
||||
int groups[32];
|
||||
int groupsfound = InternalGetMapGroups(picked_map, groups, sizeof(groups));
|
||||
bool skip_nomination = false;
|
||||
for (int group = 0; group < groupsfound; group ++)
|
||||
{
|
||||
int groupcur = 0;
|
||||
int groupmax = InternalGetGroupMax(groups[group]);
|
||||
if (groupmax >= 0)
|
||||
{
|
||||
for (int j = 0; j < GetArraySize(most_nominated_maps); j++)
|
||||
{
|
||||
//Native_GetMapGroupRestriction
|
||||
GetArrayString(most_nominated_maps, j, map_, PLATFORM_MAX_PATH);
|
||||
int tmp = InternalGetMapGroups(map_, groups_, sizeof(groups_));
|
||||
if (FindIntInArray(groups_, tmp, groups[group]) != -1)
|
||||
{
|
||||
groupcur++;
|
||||
}
|
||||
if (groupcur >= groupmax)
|
||||
{
|
||||
skip_nomination = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (skip_nomination)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (skip_nomination)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
PushArrayString(most_nominated_maps, picked_map);
|
||||
//PrintToChatAll("picked_map: %s", picked_map);
|
||||
}
|
||||
@@ -1807,7 +1845,7 @@ NominateResult InternalNominateMap(char[] map, int owner)
|
||||
}
|
||||
*/
|
||||
|
||||
if (owner != 0)
|
||||
if (owner != 0 && g_NominateList[owner] != INVALID_HANDLE)
|
||||
{
|
||||
for (int j = 0; j < GetArraySize(g_NominateList[owner]); j++)
|
||||
{
|
||||
@@ -2360,9 +2398,10 @@ public int Native_GetMapGroups(Handle plugin, int numParams)
|
||||
return found;
|
||||
}
|
||||
|
||||
//GetMapGroupRestriction
|
||||
public int Native_GetMapGroupRestriction(Handle plugin, int numParams)
|
||||
{
|
||||
int client = GetNativeCell(2);
|
||||
GetNativeCell(2);
|
||||
int len;
|
||||
GetNativeStringLength(1, len);
|
||||
|
||||
@@ -2401,28 +2440,6 @@ public int Native_GetMapGroupRestriction(Handle plugin, int numParams)
|
||||
}
|
||||
}
|
||||
delete kv;
|
||||
|
||||
if(groupcur >= groupmax)
|
||||
{
|
||||
// Check if client has nominated a map in the same group and can change their nomination
|
||||
bool okay = false;
|
||||
if(client >= 1 && client <= MaxClients)
|
||||
{
|
||||
int index = FindValueInArray(g_NominateOwners, client);
|
||||
if(index != -1)
|
||||
{
|
||||
static char oldmap[PLATFORM_MAX_PATH];
|
||||
GetArrayString(g_NominateList[client], index, oldmap, PLATFORM_MAX_PATH);
|
||||
static int oldgroups[32];
|
||||
int tmp = InternalGetMapGroups(oldmap, oldgroups, sizeof(oldgroups));
|
||||
if(FindIntInArray(groups_, tmp, groups[group]) != -1)
|
||||
okay = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!okay)
|
||||
return groupmax;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user