mapchooser_extended: Fix bug with full nomination when addmap and removemap. Add nominate_removemap menu.
This commit is contained in:
parent
d21b81a2b8
commit
bd1c3bb24d
@ -53,7 +53,7 @@
|
|||||||
#pragma semicolon 1
|
#pragma semicolon 1
|
||||||
#pragma newdecls required
|
#pragma newdecls required
|
||||||
|
|
||||||
#define MCE_VERSION "1.3.0"
|
#define MCE_VERSION "1.3.1"
|
||||||
|
|
||||||
enum RoundCounting
|
enum RoundCounting
|
||||||
{
|
{
|
||||||
@ -1719,7 +1719,7 @@ NominateResult InternalNominateMap(char[] map, bool force, int owner)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Too many nominated maps. */
|
/* Too many nominated maps. */
|
||||||
if(g_NominateCount >= GetVoteSize() && !force)
|
if(g_NominateCount >= GetVoteSize(0) && !force)
|
||||||
{
|
{
|
||||||
return Nominate_VoteFull;
|
return Nominate_VoteFull;
|
||||||
}
|
}
|
||||||
@ -1783,9 +1783,14 @@ bool InternalRemoveNominationByMap(char[] map)
|
|||||||
Call_PushCell(GetArrayCell(g_NominateOwners, i));
|
Call_PushCell(GetArrayCell(g_NominateOwners, i));
|
||||||
Call_Finish();
|
Call_Finish();
|
||||||
|
|
||||||
|
int owner = GetArrayCell(g_NominateOwners, i);
|
||||||
|
if(owner)
|
||||||
|
g_NominateCount--;
|
||||||
|
else
|
||||||
|
g_NominateReservedCount--;
|
||||||
|
|
||||||
RemoveFromArray(g_NominateList, i);
|
RemoveFromArray(g_NominateList, i);
|
||||||
RemoveFromArray(g_NominateOwners, i);
|
RemoveFromArray(g_NominateOwners, i);
|
||||||
g_NominateCount--;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2376,19 +2381,17 @@ stock void AddExtendToMenu(Handle menu, MapChange when)
|
|||||||
// 0 = IncludeMaps, 1 = Reserved, 2 = IncludeMaps+Reserved
|
// 0 = IncludeMaps, 1 = Reserved, 2 = IncludeMaps+Reserved
|
||||||
stock int GetVoteSize(int what=0)
|
stock int GetVoteSize(int what=0)
|
||||||
{
|
{
|
||||||
int voteSize = 0;
|
|
||||||
int includeMaps = GetConVarInt(g_Cvar_IncludeMaps);
|
int includeMaps = GetConVarInt(g_Cvar_IncludeMaps);
|
||||||
int includeMapsReserved = GetConVarInt(g_Cvar_IncludeMapsReserved);
|
int includeMapsReserved = GetConVarInt(g_Cvar_IncludeMapsReserved);
|
||||||
|
|
||||||
if(what == 0 || what == 2)
|
if(what == 0)
|
||||||
voteSize += includeMaps;
|
return includeMaps;
|
||||||
if(what == 1 || what == 2)
|
else if(what == 1)
|
||||||
voteSize += includeMapsReserved;
|
return includeMapsReserved;
|
||||||
|
else if(what == 2)
|
||||||
|
return includeMaps + includeMapsReserved;
|
||||||
|
|
||||||
if(what == 1)
|
return 0;
|
||||||
return voteSize - includeMaps;
|
|
||||||
|
|
||||||
return voteSize;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stock int InternalGetMapCooldown(const char[] map)
|
stock int InternalGetMapCooldown(const char[] map)
|
||||||
@ -2431,6 +2434,9 @@ void CheckMapRestrictions(bool time = false, bool players = false)
|
|||||||
for(int i = 0; i < GetArraySize(g_NominateList); i++)
|
for(int i = 0; i < GetArraySize(g_NominateList); i++)
|
||||||
{
|
{
|
||||||
int client = GetArrayCell(g_NominateOwners, i);
|
int client = GetArrayCell(g_NominateOwners, i);
|
||||||
|
if(!client)
|
||||||
|
continue;
|
||||||
|
|
||||||
if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
if(CheckCommandAccess(client, "sm_nominate_ignore", ADMFLAG_CHEATS, true))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@
|
|||||||
#include <multicolors>
|
#include <multicolors>
|
||||||
#include <basecomm>
|
#include <basecomm>
|
||||||
|
|
||||||
#define MCE_VERSION "1.3.0"
|
#define MCE_VERSION "1.3.1"
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
@ -362,6 +362,12 @@ public Action Command_Addmap(int client, int args)
|
|||||||
|
|
||||||
public Action Command_Removemap(int client, int args)
|
public Action Command_Removemap(int client, int args)
|
||||||
{
|
{
|
||||||
|
if(args == 0 && client > 0)
|
||||||
|
{
|
||||||
|
AttemptAdminRemoveMap(client);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
if(args != 1)
|
if(args != 1)
|
||||||
{
|
{
|
||||||
CReplyToCommand(client, "[NE] Usage: sm_nominate_removemap <mapname>");
|
CReplyToCommand(client, "[NE] Usage: sm_nominate_removemap <mapname>");
|
||||||
@ -375,6 +381,7 @@ public Action Command_Removemap(int client, int args)
|
|||||||
if(/*!GetTrieValue(g_mapTrie, mapname, status)*/!IsMapValid(mapname))
|
if(/*!GetTrieValue(g_mapTrie, mapname, status)*/!IsMapValid(mapname))
|
||||||
{
|
{
|
||||||
CReplyToCommand(client, "%t", "Map was not found", mapname);
|
CReplyToCommand(client, "%t", "Map was not found", mapname);
|
||||||
|
AttemptAdminRemoveMap(client, mapname);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,46 +650,38 @@ public Action Command_Nominate(int client, int args)
|
|||||||
|
|
||||||
public Action Command_NominateList(int client, int args)
|
public Action Command_NominateList(int client, int args)
|
||||||
{
|
{
|
||||||
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
|
||||||
ArrayList MapList = CreateArray(arraySize);
|
|
||||||
|
|
||||||
GetNominatedMapList(MapList);
|
|
||||||
if(!GetArraySize(MapList))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[NE] No maps have been nominated.");
|
|
||||||
delete MapList;
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
static char map[PLATFORM_MAX_PATH];
|
|
||||||
|
|
||||||
if (client == 0)
|
if (client == 0)
|
||||||
{
|
{
|
||||||
|
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||||
|
ArrayList MapList = CreateArray(arraySize);
|
||||||
|
GetNominatedMapList(MapList);
|
||||||
|
|
||||||
char aBuf[2048];
|
char aBuf[2048];
|
||||||
StrCat(aBuf, sizeof(aBuf), "[NE] Nominated Maps:");
|
StrCat(aBuf, sizeof(aBuf), "[NE] Nominated Maps:");
|
||||||
|
static char map[PLATFORM_MAX_PATH];
|
||||||
for(int i = 0; i < GetArraySize(MapList); i++)
|
for(int i = 0; i < GetArraySize(MapList); i++)
|
||||||
{
|
{
|
||||||
StrCat(aBuf, sizeof(aBuf), "\n");
|
StrCat(aBuf, sizeof(aBuf), "\n");
|
||||||
GetArrayString(MapList, i, map, sizeof(map));
|
GetArrayString(MapList, i, map, sizeof(map));
|
||||||
StrCat(aBuf, sizeof(aBuf), map);
|
StrCat(aBuf, sizeof(aBuf), map);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplyToCommand(client, aBuf);
|
ReplyToCommand(client, aBuf);
|
||||||
delete MapList;
|
delete MapList;
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
Handle NominateListMenu = CreateMenu(Handler_NominateListMenu, MENU_ACTIONS_DEFAULT|MenuAction_DisplayItem);
|
Menu NominateListMenu = CreateMenu(Handler_NominateListMenu, MENU_ACTIONS_DEFAULT|MenuAction_DisplayItem);
|
||||||
|
|
||||||
for(int i = 0; i < GetArraySize(MapList); i++)
|
if(!PopulateNominateListMenu(NominateListMenu, client))
|
||||||
{
|
{
|
||||||
GetArrayString(MapList, i, map, sizeof(map));
|
ReplyToCommand(client, "[NE] No maps have been nominated.");
|
||||||
AddMenuItem(NominateListMenu, map, map);
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetMenuTitle(NominateListMenu, "Nominated Maps", client);
|
SetMenuTitle(NominateListMenu, "Nominated Maps", client);
|
||||||
DisplayMenu(NominateListMenu, client, MENU_TIME_FOREVER);
|
DisplayMenu(NominateListMenu, client, MENU_TIME_FOREVER);
|
||||||
|
|
||||||
delete MapList;
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -694,22 +693,6 @@ public int Handler_NominateListMenu(Menu menu, MenuAction action, int param1, in
|
|||||||
{
|
{
|
||||||
delete menu;
|
delete menu;
|
||||||
}
|
}
|
||||||
|
|
||||||
case MenuAction_DisplayItem:
|
|
||||||
{
|
|
||||||
static char display[150];
|
|
||||||
static char map[PLATFORM_MAX_PATH];
|
|
||||||
GetMenuItem(menu, param2, map, sizeof(map));
|
|
||||||
|
|
||||||
bool VIPRestriction = GetMapVIPRestriction(map);
|
|
||||||
if((VIPRestriction) && AreRestrictionsActive())
|
|
||||||
{
|
|
||||||
Format(display, sizeof(display), "%s (%T)", map, "VIP Nomination", param1);
|
|
||||||
return RedrawMenuItem(display);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -717,26 +700,87 @@ public int Handler_NominateListMenu(Menu menu, MenuAction action, int param1, in
|
|||||||
|
|
||||||
void AttemptNominate(int client, const char[] filter = "")
|
void AttemptNominate(int client, const char[] filter = "")
|
||||||
{
|
{
|
||||||
|
if(!client)
|
||||||
|
return;
|
||||||
|
|
||||||
Menu menu = g_MapMenu;
|
Menu menu = g_MapMenu;
|
||||||
if(filter[0])
|
if(filter[0])
|
||||||
menu = BuildMapMenu(filter);
|
menu = BuildMapMenu(filter);
|
||||||
|
|
||||||
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AttemptAdminNominate(int client, const char[] filter = "")
|
void AttemptAdminNominate(int client, const char[] filter = "")
|
||||||
{
|
{
|
||||||
|
if(!client)
|
||||||
|
return;
|
||||||
|
|
||||||
Menu menu = g_AdminMapMenu;
|
Menu menu = g_AdminMapMenu;
|
||||||
if(filter[0])
|
if(filter[0])
|
||||||
menu = BuildAdminMapMenu(filter);
|
menu = BuildAdminMapMenu(filter);
|
||||||
|
|
||||||
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
SetMenuTitle(menu, "%T", "Nominate Title", client);
|
||||||
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
void AttemptAdminRemoveMap(int client, const char[] filter = "")
|
||||||
|
{
|
||||||
|
if(!client)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Menu AdminRemoveMapMenu = CreateMenu(Handler_AdminRemoveMapMenu, MENU_ACTIONS_DEFAULT|MenuAction_DisplayItem);
|
||||||
|
|
||||||
|
if(!PopulateNominateListMenu(AdminRemoveMapMenu, client, filter))
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[NE] No maps have been nominated.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SetMenuTitle(AdminRemoveMapMenu, "Remove nomination", client);
|
||||||
|
DisplayMenu(AdminRemoveMapMenu, client, MENU_TIME_FOREVER);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PopulateNominateListMenu(Menu menu, int client, const char[] filter = "")
|
||||||
|
{
|
||||||
|
int arraySize = ByteCountToCells(PLATFORM_MAX_PATH);
|
||||||
|
ArrayList MapList = CreateArray(arraySize);
|
||||||
|
ArrayList OwnerList = CreateArray();
|
||||||
|
|
||||||
|
GetNominatedMapList(MapList, OwnerList);
|
||||||
|
if(!GetArraySize(MapList))
|
||||||
|
{
|
||||||
|
delete MapList;
|
||||||
|
delete OwnerList;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
static char map[PLATFORM_MAX_PATH];
|
||||||
|
static char display[PLATFORM_MAX_PATH];
|
||||||
|
for(int i = 0; i < GetArraySize(MapList); i++)
|
||||||
|
{
|
||||||
|
GetArrayString(MapList, i, map, sizeof(map));
|
||||||
|
|
||||||
|
if(!filter[0] || StrContains(map, filter, false) != -1)
|
||||||
|
{
|
||||||
|
int owner = GetArrayCell(OwnerList, i);
|
||||||
|
if(!owner)
|
||||||
|
Format(display, sizeof(display), "%s (Admin)", map);
|
||||||
|
else
|
||||||
|
Format(display, sizeof(display), "%s (%N)", map, owner);
|
||||||
|
|
||||||
|
bool VIPRestriction = GetMapVIPRestriction(map);
|
||||||
|
if((VIPRestriction) && AreRestrictionsActive())
|
||||||
|
Format(display, sizeof(display), "%s (%T)", map, "VIP Nomination", client);
|
||||||
|
|
||||||
|
AddMenuItem(menu, map, display);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete MapList;
|
||||||
|
delete OwnerList;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu BuildMapMenu(const char[] filter)
|
Menu BuildMapMenu(const char[] filter)
|
||||||
@ -1118,6 +1162,35 @@ public int Handler_AdminMapSelectMenu(Menu menu, MenuAction action, int param1,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Handler_AdminRemoveMapMenu(Menu menu, MenuAction action, int param1, int param2)
|
||||||
|
{
|
||||||
|
switch(action)
|
||||||
|
{
|
||||||
|
case MenuAction_End:
|
||||||
|
{
|
||||||
|
delete menu;
|
||||||
|
}
|
||||||
|
case MenuAction_Select:
|
||||||
|
{
|
||||||
|
static char map[PLATFORM_MAX_PATH];
|
||||||
|
GetMenuItem(menu, param2, map, sizeof(map));
|
||||||
|
|
||||||
|
if(!RemoveNominationByMap(map))
|
||||||
|
{
|
||||||
|
CReplyToCommand(param1, "This map isn't nominated.", map);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
CReplyToCommand(param1, "Map '%s' removed from the nominations list.", map);
|
||||||
|
LogAction(param1, -1, "\"%L\" removed map \"%s\" from nominations.", param1, map);
|
||||||
|
|
||||||
|
PrintToChatAll("[NE] %N has removed %s from nominations", param1, map);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
public int Native_GetNominationPool(Handle plugin, int numArgs)
|
public int Native_GetNominationPool(Handle plugin, int numArgs)
|
||||||
{
|
{
|
||||||
SetNativeCellRef(1, g_MapList);
|
SetNativeCellRef(1, g_MapList);
|
||||||
|
Loading…
Reference in New Issue
Block a user