From 01816792ae4ac7c560118338e3455fa8d6ee58f3 Mon Sep 17 00:00:00 2001 From: jenz Date: Fri, 17 Apr 2026 20:29:12 +0200 Subject: [PATCH] removing a bunch of unneeded things and assuring the nomlist wont confuse leader and regular nominations any more when displaying them --- .../mapchooser_extended_avg_mapend.sp | 143 ++++-------------- .../scripting/nominations_extended_avg.sp | 21 ++- 2 files changed, 40 insertions(+), 124 deletions(-) diff --git a/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp b/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp index a687087..2a74bfe 100755 --- a/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp +++ b/mapchooser_extended/scripting/mapchooser_extended_avg_mapend.sp @@ -110,7 +110,6 @@ ConVar g_Cvar_ExtendFragStep; ConVar g_Cvar_ExcludeMaps; ConVar g_Cvar_ExcludeMapsTime; ConVar g_Cvar_IncludeMaps; -ConVar g_Cvar_IncludeMapsReserved; ConVar g_Cvar_NoVoteMode; ConVar g_Cvar_Extend; ConVar g_Cvar_DontChange; @@ -124,7 +123,6 @@ Handle g_WarningTimer = INVALID_HANDLE; /* Data Handles */ Handle g_MapList = INVALID_HANDLE; Handle g_NominateList[MAXPLAYERS + 1]; -Handle g_NominateOwners = INVALID_HANDLE; StringMap g_OldMapList; StringMap g_TimeMapList; Handle g_NextMapList = INVALID_HANDLE; @@ -145,9 +143,6 @@ int g_iSkipAllRestrictions; int g_iDontCooldownMap; int g_iMapsFromCasualPool; - -int g_NominateCount = 0; -int g_NominateReservedCount = 0; int g_iInterval; char player_mapvote[MAXPLAYERS + 1][PLATFORM_MAX_PATH]; MapChange g_ChangeTime; @@ -232,8 +227,6 @@ public void OnPluginEnd() { 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++) { char oldmap[PLATFORM_MAX_PATH]; @@ -254,7 +247,6 @@ public void OnPluginStart() int arraySize = ByteCountToCells(PLATFORM_MAX_PATH); g_MapList = CreateArray(arraySize); - g_NominateOwners = CreateArray(1); g_OldMapList = new StringMap(); g_TimeMapList = new StringMap(); 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_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_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_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); @@ -465,7 +456,6 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max CreateNative("NominateMap", Native_NominateMap); CreateNative("RemoveNominationByMap", Native_RemoveNominationByMap); - CreateNative("RemoveNominationByOwner", Native_RemoveNominationByOwner); CreateNative("InitiateMapChooserVote", Native_InitiateVote); CreateNative("CanMapChooserStartVote", Native_CanVoteStart); CreateNative("HasEndOfMapVoteFinished", Native_CheckVoteDone); @@ -576,8 +566,6 @@ public void OnConfigsExecuted() g_MapVoteCompleted = false; - g_NominateCount = 0; - g_NominateReservedCount = 0; for (int i = 0; i <= MaxClients; i++) { if (g_NominateList[i] != INVALID_HANDLE) @@ -586,8 +574,6 @@ public void OnConfigsExecuted() } } - ClearArray(g_NominateOwners); - for(int i = 0; i < MAXTEAMS; i++) g_winCount[i] = 0; @@ -705,11 +691,6 @@ public void OnClientDisconnect(int client) { is_bot_player[client] = false; Format(player_mapvote[client], 128, ""); - int index = FindValueInArray(g_NominateOwners, client); - - if(index == -1) - return; - //2023 edit for handling multiple nominations -jenz for (int i = 0; i < GetArraySize(g_NominateList[client]); i++) { @@ -721,14 +702,7 @@ public void OnClientDisconnect(int client) 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]); - g_NominateCount--; } 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 */ - g_NominateCount = 0; - g_NominateReservedCount = 0; - ClearArray(g_NominateOwners); for (int j = 0; j <= MaxClients; j++) { ClearArray(g_NominateList[j]); @@ -2299,11 +2270,10 @@ NominateResult InternalNominateMap(char[] map, int owner) return Nominate_InvalidMap; } - /* 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 //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]; GetArrayString(g_NominateList[owner], 0, oldmap, PLATFORM_MAX_PATH); @@ -2317,16 +2287,6 @@ NominateResult InternalNominateMap(char[] map, int owner) 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) { for (int j = 0; j < GetArraySize(g_NominateList[owner]); j++) @@ -2348,31 +2308,34 @@ NominateResult InternalNominateMap(char[] map, int owner) } return Nominate_InvalidMap; } + //april 14th 2026: if leader nominates a map already nominated by somebody else remove the other persons nomination entirely. + if (owner != 0 && Leader_Is(owner)) + { + for (int client = 0; client <= MaxClients; client++) + { + if (client == owner) + { + //not removing it from the leader himself. + continue; + } + for(int i = 0; i < GetArraySize(g_NominateList[client]); i++) + { + char oldmap[PLATFORM_MAX_PATH]; + GetArrayString(g_NominateList[client], i, oldmap, PLATFORM_MAX_PATH); + + if(strcmp(map, oldmap, false) == 0) + { + Call_StartForward(g_NominationsResetForward); + Call_PushString(oldmap); + Call_PushCell(client); + Call_Finish(); + RemoveFromArray(g_NominateList[client], i); + } + } + } + } PushArrayString(g_NominateList[owner], map); - 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)) - g_NominateReservedCount++; - else - g_NominateCount++; - - while(GetArraySize(g_NominateList[owner]) > GetVoteSize(0)) - { - char oldmap[PLATFORM_MAX_PATH]; - GetArrayString(g_NominateList[owner], 0, oldmap, PLATFORM_MAX_PATH); - Call_StartForward(g_NominationsResetForward); - Call_PushString(oldmap); - Call_PushCell(owner); - int owner_ = GetArrayCell(g_NominateOwners, 0); - Call_Finish(); - - RemoveFromArray(g_NominateList[owner], 0); - RemoveFromArray(g_NominateOwners, 0); - if(owner_ == 0) - g_NominateReservedCount--; - else - g_NominateCount--; - } return Nominate_Added; } @@ -2412,15 +2375,7 @@ bool InternalRemoveNominationByMap(char[] map) Call_PushCell(client); Call_Finish(); - int owner = GetArrayCell(g_NominateOwners, i); - if(owner) - g_NominateCount--; - else - g_NominateReservedCount--; - RemoveFromArray(g_NominateList[client], i); - RemoveFromArray(g_NominateOwners, i); //maybe this is only meant to be done once? - removed_at_least_once = true; } } @@ -2443,37 +2398,6 @@ public int Native_RemoveNominationByMap(Handle plugin, int numParams) return view_as(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(InternalRemoveNominationByOwner(GetNativeCell(1))); -} - /* native InitiateMapChooserVote(); */ 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(ownerarray != INVALID_HANDLE) { - //int index = GetArrayCell(g_NominateOwners, i); PushArrayCell(ownerarray, client); } } @@ -2677,11 +2600,6 @@ public int Native_CanNominate(Handle plugin, int numParams) return view_as(CanNominate_No_VoteComplete); } - if(g_NominateCount >= GetVoteSize()) - { - return view_as(CanNominate_No_VoteFull); - } - return view_as(CanNominate_Yes); } @@ -3085,15 +3003,8 @@ stock void AddExtendToMenu(Handle menu, MapChange when) stock int GetVoteSize(int what=0) { int includeMaps = GetConVarInt(g_Cvar_IncludeMaps); - int includeMapsReserved = GetConVarInt(g_Cvar_IncludeMapsReserved); - if(what == 0) return includeMaps; - else if(what == 1) - return includeMapsReserved; - else if(what == 2) - return includeMaps + includeMapsReserved; - return 0; } diff --git a/mapchooser_extended/scripting/nominations_extended_avg.sp b/mapchooser_extended/scripting/nominations_extended_avg.sp index 4139bea..af6e5c9 100755 --- a/mapchooser_extended/scripting/nominations_extended_avg.sp +++ b/mapchooser_extended/scripting/nominations_extended_avg.sp @@ -779,6 +779,7 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "") } StringMap sm = new StringMap(); + StringMap sm_special_noms = new StringMap(); //storing leaders and admin noms. static char map[PLATFORM_MAX_PATH]; static char display[PLATFORM_MAX_PATH]; 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)) { 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 { @@ -825,24 +827,26 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "") { int nominate_count_for_particular_map = 0; 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); bool VIPRestriction = GetMapVIPRestriction(map); if((VIPRestriction) && AreRestrictionsActive()) Format(display, sizeof(display), "%s (%T)", display, "VIP Nomination", client); - int owner = GetArrayCell(OwnerList, i); char spelling[8]; - Format(spelling, sizeof(spelling), nominate_count_for_particular_map == 1 ? "Vote" : "Votes"); - - if(!owner) - Format(display, sizeof(display), "%s (Admin)", display); - else if (Leader_Is(owner)) - Format(display, sizeof(display), "%s (Leader)", display); + if (leader_or_admin_map_owner != -1) + { + if(!leader_or_admin_map_owner) + Format(display, sizeof(display), "%s (Admin)", display); + else + Format(display, sizeof(display), "%s (Leader)", display); + } else Format(display, sizeof(display), "%s (%i %s)", display, nominate_count_for_particular_map, spelling); - AddMenuItem(menu, map, display); } } @@ -851,6 +855,7 @@ bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "") delete OwnerList; delete SortedList; delete sm; + delete sm_special_noms; delete sm_snapshot; return true; }