removing a bunch of unneeded things and assuring the nomlist wont confuse leader and regular nominations any more when displaying them

This commit is contained in:
jenz 2026-04-17 20:29:12 +02:00
parent f37711fbdf
commit 01816792ae
2 changed files with 40 additions and 124 deletions

View File

@ -110,7 +110,6 @@ ConVar g_Cvar_ExtendFragStep;
ConVar g_Cvar_ExcludeMaps; ConVar g_Cvar_ExcludeMaps;
ConVar g_Cvar_ExcludeMapsTime; ConVar g_Cvar_ExcludeMapsTime;
ConVar g_Cvar_IncludeMaps; ConVar g_Cvar_IncludeMaps;
ConVar g_Cvar_IncludeMapsReserved;
ConVar g_Cvar_NoVoteMode; ConVar g_Cvar_NoVoteMode;
ConVar g_Cvar_Extend; ConVar g_Cvar_Extend;
ConVar g_Cvar_DontChange; ConVar g_Cvar_DontChange;
@ -124,7 +123,6 @@ Handle g_WarningTimer = INVALID_HANDLE;
/* Data Handles */ /* Data Handles */
Handle g_MapList = INVALID_HANDLE; Handle g_MapList = INVALID_HANDLE;
Handle g_NominateList[MAXPLAYERS + 1]; Handle g_NominateList[MAXPLAYERS + 1];
Handle g_NominateOwners = INVALID_HANDLE;
StringMap g_OldMapList; StringMap g_OldMapList;
StringMap g_TimeMapList; StringMap g_TimeMapList;
Handle g_NextMapList = INVALID_HANDLE; Handle g_NextMapList = INVALID_HANDLE;
@ -145,9 +143,6 @@ int g_iSkipAllRestrictions;
int g_iDontCooldownMap; int g_iDontCooldownMap;
int g_iMapsFromCasualPool; int g_iMapsFromCasualPool;
int g_NominateCount = 0;
int g_NominateReservedCount = 0;
int g_iInterval; int g_iInterval;
char player_mapvote[MAXPLAYERS + 1][PLATFORM_MAX_PATH]; char player_mapvote[MAXPLAYERS + 1][PLATFORM_MAX_PATH];
MapChange g_ChangeTime; MapChange g_ChangeTime;
@ -232,8 +227,6 @@ public void OnPluginEnd()
{ {
for (int i = 0; i <= MaxClients; i++) for (int i = 0; i <= MaxClients; i++)
{ {
int index = FindValueInArray(g_NominateOwners, i);
if (index == -1) continue;
for (int j = 0; j < GetArraySize(g_NominateList[i]); j++) for (int j = 0; j < GetArraySize(g_NominateList[i]); j++)
{ {
char oldmap[PLATFORM_MAX_PATH]; char oldmap[PLATFORM_MAX_PATH];
@ -254,7 +247,6 @@ public void OnPluginStart()
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH); int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
g_MapList = CreateArray(arraySize); g_MapList = CreateArray(arraySize);
g_NominateOwners = CreateArray(1);
g_OldMapList = new StringMap(); g_OldMapList = new StringMap();
g_TimeMapList = new StringMap(); g_TimeMapList = new StringMap();
g_NextMapList = CreateArray(arraySize); g_NextMapList = CreateArray(arraySize);
@ -282,7 +274,6 @@ public void OnPluginStart()
g_Cvar_ExcludeMaps = CreateConVar("mce_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0); g_Cvar_ExcludeMaps = CreateConVar("mce_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
g_Cvar_ExcludeMapsTime = CreateConVar("mce_exclude_time", "5h", "Specifies how long in minutes an old map is excluded from the vote."); g_Cvar_ExcludeMapsTime = CreateConVar("mce_exclude_time", "5h", "Specifies how long in minutes an old map is excluded from the vote.");
g_Cvar_IncludeMaps = CreateConVar("mce_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 9.0); g_Cvar_IncludeMaps = CreateConVar("mce_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 9.0);
g_Cvar_IncludeMapsReserved = CreateConVar("mce_include_reserved", "2", "Specifies how many private/random maps to include in the vote.", _, true, 0.0, true, 5.0);
g_Cvar_NoVoteMode = CreateConVar("mce_novote", "1", "Specifies whether or not MapChooser should pick a map if no votes are received.", _, true, 0.0, true, 1.0); g_Cvar_NoVoteMode = CreateConVar("mce_novote", "1", "Specifies whether or not MapChooser should pick a map if no votes are received.", _, true, 0.0, true, 1.0);
g_Cvar_Extend = CreateConVar("mce_extend", "0", "Number of extensions allowed each map.", _, true, 0.0); g_Cvar_Extend = CreateConVar("mce_extend", "0", "Number of extensions allowed each map.", _, true, 0.0);
g_Cvar_DontChange = CreateConVar("mce_dontchange", "1", "Specifies if a 'Don't Change option should be added to early votes", _, true, 0.0); g_Cvar_DontChange = CreateConVar("mce_dontchange", "1", "Specifies if a 'Don't Change option should be added to early votes", _, true, 0.0);
@ -465,7 +456,6 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
CreateNative("NominateMap", Native_NominateMap); CreateNative("NominateMap", Native_NominateMap);
CreateNative("RemoveNominationByMap", Native_RemoveNominationByMap); CreateNative("RemoveNominationByMap", Native_RemoveNominationByMap);
CreateNative("RemoveNominationByOwner", Native_RemoveNominationByOwner);
CreateNative("InitiateMapChooserVote", Native_InitiateVote); CreateNative("InitiateMapChooserVote", Native_InitiateVote);
CreateNative("CanMapChooserStartVote", Native_CanVoteStart); CreateNative("CanMapChooserStartVote", Native_CanVoteStart);
CreateNative("HasEndOfMapVoteFinished", Native_CheckVoteDone); CreateNative("HasEndOfMapVoteFinished", Native_CheckVoteDone);
@ -576,8 +566,6 @@ public void OnConfigsExecuted()
g_MapVoteCompleted = false; g_MapVoteCompleted = false;
g_NominateCount = 0;
g_NominateReservedCount = 0;
for (int i = 0; i <= MaxClients; i++) for (int i = 0; i <= MaxClients; i++)
{ {
if (g_NominateList[i] != INVALID_HANDLE) if (g_NominateList[i] != INVALID_HANDLE)
@ -586,8 +574,6 @@ public void OnConfigsExecuted()
} }
} }
ClearArray(g_NominateOwners);
for(int i = 0; i < MAXTEAMS; i++) for(int i = 0; i < MAXTEAMS; i++)
g_winCount[i] = 0; g_winCount[i] = 0;
@ -705,11 +691,6 @@ public void OnClientDisconnect(int client)
{ {
is_bot_player[client] = false; is_bot_player[client] = false;
Format(player_mapvote[client], 128, ""); Format(player_mapvote[client], 128, "");
int index = FindValueInArray(g_NominateOwners, client);
if(index == -1)
return;
//2023 edit for handling multiple nominations -jenz //2023 edit for handling multiple nominations -jenz
for (int i = 0; i < GetArraySize(g_NominateList[client]); i++) for (int i = 0; i < GetArraySize(g_NominateList[client]); i++)
{ {
@ -721,14 +702,7 @@ public void OnClientDisconnect(int client)
Call_Finish(); Call_Finish();
} }
RemoveFromArray(g_NominateOwners, index);
for (int i = 0; i < GetArraySize(g_NominateList[client]); i++)
{
RemoveFromArray(g_NominateList[client], i);
}
ClearArray(g_NominateList[client]); ClearArray(g_NominateList[client]);
g_NominateCount--;
} }
public Action Command_SetNextmap(int client, int args) public Action Command_SetNextmap(int client, int args)
@ -1556,9 +1530,6 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
} }
/* Wipe out our nominations list - Nominations have already been informed of this */ /* Wipe out our nominations list - Nominations have already been informed of this */
g_NominateCount = 0;
g_NominateReservedCount = 0;
ClearArray(g_NominateOwners);
for (int j = 0; j <= MaxClients; j++) for (int j = 0; j <= MaxClients; j++)
{ {
ClearArray(g_NominateList[j]); ClearArray(g_NominateList[j]);
@ -2299,11 +2270,10 @@ NominateResult InternalNominateMap(char[] map, int owner)
return Nominate_InvalidMap; return Nominate_InvalidMap;
} }
/* Look to replace an existing nomination by this client - Nominations made with owner = 0 arent replaced */ /* Look to replace an existing nomination by this client - Nominations made with owner = 0 arent replaced */
//2023 edit: change clients first nomination out of the clients multiple nominations, make a check if client filled all his nomination slots //2023 edit: change clients first nomination out of the clients multiple nominations, make a check if client filled all his nomination slots
//currently hard coded to 3 maps, just add a cvar to replace it with in the future //currently hard coded to 3 maps, just add a cvar to replace it with in the future
if(owner && ((FindValueInArray(g_NominateOwners, owner)) != -1) && GetArraySize(g_NominateList[owner]) > 2) if(owner && GetArraySize(g_NominateList[owner]) > 2)
{ {
char oldmap[PLATFORM_MAX_PATH]; char oldmap[PLATFORM_MAX_PATH];
GetArrayString(g_NominateList[owner], 0, oldmap, PLATFORM_MAX_PATH); GetArrayString(g_NominateList[owner], 0, oldmap, PLATFORM_MAX_PATH);
@ -2317,16 +2287,6 @@ NominateResult InternalNominateMap(char[] map, int owner)
return Nominate_Replaced; return Nominate_Replaced;
} }
/* Too many nominated maps. */
//2023 edit: we dont want this check
/*
if(g_NominateCount >= GetVoteSize(0) && !force)
{
return Nominate_VoteFull;
}
*/
if (owner != 0 && g_NominateList[owner] != INVALID_HANDLE) if (owner != 0 && g_NominateList[owner] != INVALID_HANDLE)
{ {
for (int j = 0; j < GetArraySize(g_NominateList[owner]); j++) for (int j = 0; j < GetArraySize(g_NominateList[owner]); j++)
@ -2348,31 +2308,34 @@ NominateResult InternalNominateMap(char[] map, int owner)
} }
return Nominate_InvalidMap; return Nominate_InvalidMap;
} }
//april 14th 2026: if leader nominates a map already nominated by somebody else remove the other persons nomination entirely.
PushArrayString(g_NominateList[owner], map); if (owner != 0 && Leader_Is(owner))
PushArrayCell(g_NominateOwners, owner); //maybe i only want to do this for the first nomination of each client {
if(owner == 0 && g_NominateReservedCount < GetVoteSize(0)) for (int client = 0; client <= MaxClients; client++)
g_NominateReservedCount++; {
else if (client == owner)
g_NominateCount++; {
//not removing it from the leader himself.
while(GetArraySize(g_NominateList[owner]) > GetVoteSize(0)) continue;
}
for(int i = 0; i < GetArraySize(g_NominateList[client]); i++)
{ {
char oldmap[PLATFORM_MAX_PATH]; char oldmap[PLATFORM_MAX_PATH];
GetArrayString(g_NominateList[owner], 0, oldmap, PLATFORM_MAX_PATH); GetArrayString(g_NominateList[client], i, oldmap, PLATFORM_MAX_PATH);
if(strcmp(map, oldmap, false) == 0)
{
Call_StartForward(g_NominationsResetForward); Call_StartForward(g_NominationsResetForward);
Call_PushString(oldmap); Call_PushString(oldmap);
Call_PushCell(owner); Call_PushCell(client);
int owner_ = GetArrayCell(g_NominateOwners, 0);
Call_Finish(); Call_Finish();
RemoveFromArray(g_NominateList[client], i);
RemoveFromArray(g_NominateList[owner], 0);
RemoveFromArray(g_NominateOwners, 0);
if(owner_ == 0)
g_NominateReservedCount--;
else
g_NominateCount--;
} }
}
}
}
PushArrayString(g_NominateList[owner], map);
return Nominate_Added; return Nominate_Added;
} }
@ -2412,15 +2375,7 @@ bool InternalRemoveNominationByMap(char[] map)
Call_PushCell(client); Call_PushCell(client);
Call_Finish(); Call_Finish();
int owner = GetArrayCell(g_NominateOwners, i);
if(owner)
g_NominateCount--;
else
g_NominateReservedCount--;
RemoveFromArray(g_NominateList[client], i); RemoveFromArray(g_NominateList[client], i);
RemoveFromArray(g_NominateOwners, i); //maybe this is only meant to be done once?
removed_at_least_once = true; removed_at_least_once = true;
} }
} }
@ -2443,37 +2398,6 @@ public int Native_RemoveNominationByMap(Handle plugin, int numParams)
return view_as<int>(InternalRemoveNominationByMap(map)); return view_as<int>(InternalRemoveNominationByMap(map));
} }
bool InternalRemoveNominationByOwner(int owner)
{
int index;
if(owner && ((index = FindValueInArray(g_NominateOwners, owner)) != -1))
{
char oldmap[PLATFORM_MAX_PATH];
GetArrayString(g_NominateList[owner], index, oldmap, PLATFORM_MAX_PATH);
Call_StartForward(g_NominationsResetForward);
Call_PushString(oldmap);
Call_PushCell(owner);
Call_Finish();
RemoveFromArray(g_NominateList[owner], index);
//maybe only do once or change g_NominateOwners
RemoveFromArray(g_NominateOwners, index);
g_NominateCount--;
return true;
}
return false;
}
/* native bool RemoveNominationByOwner(owner); */
public int Native_RemoveNominationByOwner(Handle plugin, int numParams)
{
return view_as<int>(InternalRemoveNominationByOwner(GetNativeCell(1)));
}
/* native InitiateMapChooserVote(); */ /* native InitiateMapChooserVote(); */
public int Native_InitiateVote(Handle plugin, int numParams) public int Native_InitiateVote(Handle plugin, int numParams)
{ {
@ -2547,7 +2471,6 @@ public int Native_GetNominatedMapList(Handle plugin, int numParams)
// If the optional parameter for an owner list was passed, then we need to fill that out as well // If the optional parameter for an owner list was passed, then we need to fill that out as well
if(ownerarray != INVALID_HANDLE) if(ownerarray != INVALID_HANDLE)
{ {
//int index = GetArrayCell(g_NominateOwners, i);
PushArrayCell(ownerarray, client); PushArrayCell(ownerarray, client);
} }
} }
@ -2677,11 +2600,6 @@ public int Native_CanNominate(Handle plugin, int numParams)
return view_as<int>(CanNominate_No_VoteComplete); return view_as<int>(CanNominate_No_VoteComplete);
} }
if(g_NominateCount >= GetVoteSize())
{
return view_as<int>(CanNominate_No_VoteFull);
}
return view_as<int>(CanNominate_Yes); return view_as<int>(CanNominate_Yes);
} }
@ -3085,15 +3003,8 @@ stock void AddExtendToMenu(Handle menu, MapChange when)
stock int GetVoteSize(int what=0) stock int GetVoteSize(int what=0)
{ {
int includeMaps = GetConVarInt(g_Cvar_IncludeMaps); int includeMaps = GetConVarInt(g_Cvar_IncludeMaps);
int includeMapsReserved = GetConVarInt(g_Cvar_IncludeMapsReserved);
if(what == 0) if(what == 0)
return includeMaps; return includeMaps;
else if(what == 1)
return includeMapsReserved;
else if(what == 2)
return includeMaps + includeMapsReserved;
return 0; return 0;
} }

View File

@ -779,6 +779,7 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
} }
StringMap sm = new StringMap(); StringMap sm = new StringMap();
StringMap sm_special_noms = new StringMap(); //storing leaders and admin noms.
static char map[PLATFORM_MAX_PATH]; static char map[PLATFORM_MAX_PATH];
static char display[PLATFORM_MAX_PATH]; static char display[PLATFORM_MAX_PATH];
for(int i = 0; i < GetArraySize(MapList); i++) for(int i = 0; i < GetArraySize(MapList); i++)
@ -795,6 +796,7 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
if (!owner || Leader_Is(owner)) if (!owner || Leader_Is(owner))
{ {
nominate_count_for_particular_map = 1999; nominate_count_for_particular_map = 1999;
sm_special_noms.SetValue(map, owner); //admin noms and leaders are unique per each map, so cant be overwritten.
} }
else else
{ {
@ -825,24 +827,26 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
{ {
int nominate_count_for_particular_map = 0; int nominate_count_for_particular_map = 0;
sm.GetValue(map, nominate_count_for_particular_map); sm.GetValue(map, nominate_count_for_particular_map);
int leader_or_admin_map_owner = -1;
sm_special_noms.GetValue(map, leader_or_admin_map_owner);
strcopy(display, sizeof(display), map); strcopy(display, sizeof(display), map);
bool VIPRestriction = GetMapVIPRestriction(map); bool VIPRestriction = GetMapVIPRestriction(map);
if((VIPRestriction) && AreRestrictionsActive()) if((VIPRestriction) && AreRestrictionsActive())
Format(display, sizeof(display), "%s (%T)", display, "VIP Nomination", client); Format(display, sizeof(display), "%s (%T)", display, "VIP Nomination", client);
int owner = GetArrayCell(OwnerList, i);
char spelling[8]; char spelling[8];
Format(spelling, sizeof(spelling), nominate_count_for_particular_map == 1 ? "Vote" : "Votes"); Format(spelling, sizeof(spelling), nominate_count_for_particular_map == 1 ? "Vote" : "Votes");
if (leader_or_admin_map_owner != -1)
if(!owner) {
if(!leader_or_admin_map_owner)
Format(display, sizeof(display), "%s (Admin)", display); Format(display, sizeof(display), "%s (Admin)", display);
else if (Leader_Is(owner)) else
Format(display, sizeof(display), "%s (Leader)", display); Format(display, sizeof(display), "%s (Leader)", display);
}
else else
Format(display, sizeof(display), "%s (%i %s)", display, nominate_count_for_particular_map, spelling); Format(display, sizeof(display), "%s (%i %s)", display, nominate_count_for_particular_map, spelling);
AddMenuItem(menu, map, display); AddMenuItem(menu, map, display);
} }
} }
@ -851,6 +855,7 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
delete OwnerList; delete OwnerList;
delete SortedList; delete SortedList;
delete sm; delete sm;
delete sm_special_noms;
delete sm_snapshot; delete sm_snapshot;
return true; return true;
} }