added missing phrase file and hopefully fixed errors thrown by mapchooser

This commit is contained in:
jenz 2023-03-23 19:47:48 +01:00
parent 709a07a62b
commit 5840846119
3 changed files with 158 additions and 72 deletions

View File

@ -1242,10 +1242,14 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
RemoveStringFromArray(g_NextMapList, map); RemoveStringFromArray(g_NextMapList, map);
/* Notify Nominations that this map is now free */ /* Notify Nominations that this map is now free */
Call_StartForward(g_NominationsResetForward); //2023-03-23 edit to prevent index going out of range
Call_PushString(map); if (GetArraySize(g_NominateOwners) > i)
Call_PushCell(GetArrayCell(g_NominateOwners, i)); {
Call_Finish(); Call_StartForward(g_NominationsResetForward);
Call_PushString(map);
Call_PushCell(GetArrayCell(g_NominateOwners, i));
Call_Finish();
}
} }
/* Clear out the rest of the nominations array */ /* Clear out the rest of the nominations array */
@ -1256,10 +1260,14 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
/* These maps shouldn't be excluded from the vote as they weren't really nominated at all */ /* These maps shouldn't be excluded from the vote as they weren't really nominated at all */
/* Notify Nominations that this map is now free */ /* Notify Nominations that this map is now free */
Call_StartForward(g_NominationsResetForward); //2023-03-23 edit to prevent index going out of range
Call_PushString(map); if (GetArraySize(g_NominateOwners) > i)
Call_PushCell(GetArrayCell(g_NominateOwners, i)); {
Call_Finish(); Call_StartForward(g_NominationsResetForward);
Call_PushString(map);
Call_PushCell(GetArrayCell(g_NominateOwners, i));
Call_Finish();
}
} }
/* There should currently be 'nominationsToAdd' unique maps in the vote */ /* There should currently be 'nominationsToAdd' unique maps in the vote */
@ -2620,14 +2628,17 @@ void CheckMapRestrictions(bool time = false, bool players = false)
if (remove) if (remove)
{ {
Call_StartForward(g_NominationsResetForward); if (GetArraySize(g_NominateOwners) > i)
Call_PushString(map); {
Call_PushCell(GetArrayCell(g_NominateOwners, i)); Call_StartForward(g_NominationsResetForward);
Call_Finish(); Call_PushString(map);
Call_PushCell(GetArrayCell(g_NominateOwners, i));
Call_Finish();
RemoveFromArray(g_NominateList[client], i); RemoveFromArray(g_NominateList[client], i);
RemoveFromArray(g_NominateOwners, i); RemoveFromArray(g_NominateOwners, i);
g_NominateCount--; g_NominateCount--;
}
} }
} }
} }

View File

@ -696,15 +696,15 @@ void AttemptNominate(int client, const char[] filter = "")
void AttemptAdminNominate(int client, const char[] filter = "") void AttemptAdminNominate(int client, const char[] filter = "")
{ {
if(!client) if(!client)
return; 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);
} }
void AttemptAdminRemoveMap(int client, const char[] filter = "") void AttemptAdminRemoveMap(int client, const char[] filter = "")
@ -932,58 +932,62 @@ public int Handler_MapSelectMenu(Menu menu, MenuAction action, int param1, int p
} }
case MenuAction_Select: case MenuAction_Select:
{ {
if(g_Player_NominationDelay[param1] > GetTime()) //2023-03-22 edit since client sometimes is 0 which fucks up mapchooser
if (param1 > 0 && param1 <= MaxClients && IsClientConnected(param1) && IsClientInGame(param1))
{ {
PrintToChat(param1, "[NE] Please wait %d seconds before you can nominate again", g_Player_NominationDelay[param1] - GetTime()); if(g_Player_NominationDelay[param1] > GetTime())
DisplayMenuAtItem(menu, param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER); {
return 0; PrintToChat(param1, "[NE] Please wait %d seconds before you can nominate again", g_Player_NominationDelay[param1] - GetTime());
DisplayMenuAtItem(menu, param1, GetMenuSelectionPosition(), MENU_TIME_FOREVER);
return 0;
}
static char map[PLATFORM_MAX_PATH];
char name[MAX_NAME_LENGTH];
GetMenuItem(menu, param2, map, sizeof(map));
GetClientName(param1, name, MAX_NAME_LENGTH);
if(AreRestrictionsActive() && (
GetMapCooldownTime(map) > GetTime() ||
GetMapTimeRestriction(map) ||
GetMapPlayerRestriction(map) ||
GetMapVIPRestriction(map, param1)))
{
PrintToChat(param1, "[NE] You cant nominate this map right now.");
return 0;
}
NominateResult result = NominateMap(map, false, param1);
if (result == Nominate_InvalidMap)
{
PrintToChat(param1, "[NE] You already nominated the map %s", map);
return 0;
}
/* Dont need to check for InvalidMap because the menu did that already */
if(result == Nominate_AlreadyInVote)
{
PrintToChat(param1, "[NE] %t", "Map Already Nominated");
return 0;
}
else if(result == Nominate_VoteFull)
{
PrintToChat(param1, "[NE] %t", "Max Nominations");
return 0;
}
//SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
if(result == Nominate_Added)
PrintToChatAll("[NE] %t", "Map Nominated", name, map);
else if(result == Nominate_Replaced)
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map);
LogMessage("%s nominated %s", name, map);
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
} }
static char map[PLATFORM_MAX_PATH];
char name[MAX_NAME_LENGTH];
GetMenuItem(menu, param2, map, sizeof(map));
GetClientName(param1, name, MAX_NAME_LENGTH);
if(AreRestrictionsActive() && (
GetMapCooldownTime(map) > GetTime() ||
GetMapTimeRestriction(map) ||
GetMapPlayerRestriction(map) ||
GetMapVIPRestriction(map, param1)))
{
PrintToChat(param1, "[NE] You cant nominate this map right now.");
return 0;
}
NominateResult result = NominateMap(map, false, param1);
if (result == Nominate_InvalidMap)
{
PrintToChat(param1, "[NE] You already nominated the map %s", map);
return 0;
}
/* Dont need to check for InvalidMap because the menu did that already */
if(result == Nominate_AlreadyInVote)
{
PrintToChat(param1, "[NE] %t", "Map Already Nominated");
return 0;
}
else if(result == Nominate_VoteFull)
{
PrintToChat(param1, "[NE] %t", "Max Nominations");
return 0;
}
//SetTrieValue(g_mapTrie, map, MAPSTATUS_DISABLED|MAPSTATUS_EXCLUDE_NOMINATED);
if(result == Nominate_Added)
PrintToChatAll("[NE] %t", "Map Nominated", name, map);
else if(result == Nominate_Replaced)
PrintToChatAll("[NE] %t", "Map Nomination Changed", name, map);
LogMessage("%s nominated %s", name, map);
g_Player_NominationDelay[param1] = GetTime() + GetConVarInt(g_Cvar_NominateDelay);
} }
case MenuAction_DrawItem: case MenuAction_DrawItem:

View File

@ -0,0 +1,71 @@
"Phrases"
{
"Already Nominated"
{
"en" "You have already nominated a map."
}
"Max Nominations"
{
"en" "The maximum allowed nominations has been reached."
}
"Map Already In Vote"
{
"#format" "{1:s}"
"en" "Map '{1}' already in the nominations list."
}
"Map Inserted"
{
"#format" "{1:s}"
"en" "Map '{1}' added to the nominations list."
}
"Map Already Nominated"
{
"en" "The map you chose has already been nominated."
}
"Map Nominated"
{
"#format" "{1:s},{2:s}"
"en" "{1} has nominated {2}."
}
"Map Nomination Changed"
{
"#format" "{1:s},{2:s}"
"en" "{1} has changed their nomination to {2}."
}
"Nominate Title"
{
"en" "Nominate Map:"
}
"Can't Nominate Current Map"
{
"en" "The map you chose is the current map and cannot be nominated"
}
"Map in Exclude List"
{
"en" "The map you chose was recently played and cannot be nominated"
}
"Current Map"
{
"en" "Current Map"
}
"Recently Played"
{
"en" "Recently Played"
}
"Nominated"
{
"en" "Nominated"
}
}