mapchooser_extended: remove nativevotes (nobody uses that shit)

This commit is contained in:
BotoX
2019-08-13 20:46:30 +02:00
parent 83cab5941a
commit a7a4acdcc4
2 changed files with 47 additions and 1126 deletions
@@ -50,15 +50,10 @@
#include <sdktools>
#include <multicolors>
#undef REQUIRE_PLUGIN
#include <nativevotes>
#define REQUIRE_PLUGIN
#pragma semicolon 1
#pragma newdecls required
#define MCE_VERSION "1.13.0"
#define NV "nativevotes"
enum RoundCounting
{
@@ -158,7 +153,6 @@ ConVar g_Cvar_StartTimePercent;
ConVar g_Cvar_StartTimePercentEnable;
ConVar g_Cvar_WarningTime;
ConVar g_Cvar_RunOffWarningTime;
ConVar g_Cvar_MenuStyle;
ConVar g_Cvar_TimerLocation;
ConVar g_Cvar_ExtendPosition;
ConVar g_Cvar_MarkCustomMaps;
@@ -179,7 +173,6 @@ Handle g_MapVoteRunoffStartForward = INVALID_HANDLE;
/* Mapchooser Extended Globals */
int g_RunoffCount = 0;
int g_mapOfficialFileSerial = -1;
bool g_NativeVotes = false;
char g_GameModName[64];
bool g_WarningInProgress = false;
bool g_AddNoVote = false;
@@ -259,7 +252,6 @@ public void OnPluginStart()
g_Cvar_StartTimePercentEnable = CreateConVar("mce_start_percent_enable", "0", "Enable or Disable percentage calculations when to start vote.", _, true, 0.0, true, 1.0);
g_Cvar_WarningTime = CreateConVar("mce_warningtime", "15.0", "Warning time in seconds.", _, true, 0.0, true, 60.0);
g_Cvar_RunOffWarningTime = CreateConVar("mce_runoffvotewarningtime", "5.0", "Warning time for runoff vote in seconds.", _, true, 0.0, true, 30.0);
g_Cvar_MenuStyle = CreateConVar("mce_menustyle", "0", "Menu Style. 0 is the game's default, 1 is the older Valve style that requires you to press Escape to see the menu, 2 is the newer 1-9 button Voice Command style, unavailable in some games. Ignored on TF2 if NativeVotes Plugin is loaded.", _, true, 0.0, true, 2.0);
g_Cvar_TimerLocation = CreateConVar("mce_warningtimerlocation", "0", "Location for the warning timer text. 0 is HintBox, 1 is Center text, 2 is Chat. Defaults to HintBox.", _, true, 0.0, true, 2.0);
g_Cvar_MarkCustomMaps = CreateConVar("mce_markcustommaps", "1", "Mark custom maps in the vote list. 0 = Disabled, 1 = Mark with *, 2 = Mark with phrase.", _, true, 0.0, true, 2.0);
g_Cvar_ExtendPosition = CreateConVar("mce_extendposition", "0", "Position of Extend/Don't Change options. 0 = at end, 1 = at start.", _, true, 0.0, true, 1.0);
@@ -420,23 +412,6 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
return APLRes_Success;
}
public void OnAllPluginsLoaded()
{
g_NativeVotes = LibraryExists(NV) && NativeVotes_IsVoteTypeSupported(NativeVotesType_NextLevelMult);
}
public void OnLibraryAdded(const char[] name)
{
if(StrEqual(name, NV) && NativeVotes_IsVoteTypeSupported(NativeVotesType_NextLevelMult))
g_NativeVotes = true;
}
public void OnLibraryRemoved(const char[] name)
{
if(StrEqual(name, NV))
g_NativeVotes = false;
}
public void OnMapStart()
{
static char folder[64];
@@ -981,10 +956,8 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
g_WaitingForVote = true;
g_WarningInProgress = false;
// Check if a nativevotes vots is in progress first
// NativeVotes running at the same time as a regular vote can cause hintbox problems,
// so always check for a standard vote
if(IsVoteInProgress() || (g_NativeVotes && NativeVotes_IsVoteInProgress()))
// Check if a vote is in progress first
if(IsVoteInProgress())
{
// Can't start a vote, try again in 5 seconds.
//g_RetryTimer = CreateTimer(5.0, Timer_StartMapVote, _, TIMER_FLAG_NO_MAPCHANGE);
@@ -1021,52 +994,34 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
g_HasVoteStarted = true;
if(g_NativeVotes)
{
g_VoteMenu = NativeVotes_Create(Handler_MapVoteMenu, NativeVotesType_NextLevelMult, MenuAction_End | MenuAction_VoteCancel | MenuAction_Display | MenuAction_DisplayItem);
NativeVotes_SetResultCallback(g_VoteMenu, Handler_NativeVoteFinished);
}
else
{
Handle menuStyle = GetMenuStyleHandle(view_as<MenuStyle>(GetConVarInt(g_Cvar_MenuStyle)));
g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction_End | MenuAction_Display | MenuAction_DisplayItem | MenuAction_VoteCancel);
if(menuStyle != INVALID_HANDLE)
g_AddNoVote = GetConVarBool(g_Cvar_NoVoteOption);
// Block Vote Slots
if(GetConVarBool(g_Cvar_BlockSlots))
{
Handle radioStyle = GetMenuStyleHandle(MenuStyle_Radio);
if(GetMenuStyle(g_VoteMenu) == radioStyle)
{
g_VoteMenu = CreateMenuEx(menuStyle, Handler_MapVoteMenu, MenuAction_End | MenuAction_Display | MenuAction_DisplayItem | MenuAction_VoteCancel);
g_BlockedSlots = true;
AddMenuItem(g_VoteMenu, LINE_ONE, "Choose something...", ITEMDRAW_DISABLED);
AddMenuItem(g_VoteMenu, LINE_TWO, "...will ya?", ITEMDRAW_DISABLED);
if(!g_AddNoVote)
AddMenuItem(g_VoteMenu, LINE_SPACER, "", ITEMDRAW_SPACER);
}
else
{
// You chose... poorly
g_VoteMenu = CreateMenu(Handler_MapVoteMenu, MenuAction_End | MenuAction_Display | MenuAction_DisplayItem | MenuAction_VoteCancel);
}
g_AddNoVote = GetConVarBool(g_Cvar_NoVoteOption);
// Block Vote Slots
if(GetConVarBool(g_Cvar_BlockSlots))
{
Handle radioStyle = GetMenuStyleHandle(MenuStyle_Radio);
if(GetMenuStyle(g_VoteMenu) == radioStyle)
{
g_BlockedSlots = true;
AddMenuItem(g_VoteMenu, LINE_ONE, "Choose something...", ITEMDRAW_DISABLED);
AddMenuItem(g_VoteMenu, LINE_TWO, "...will ya?", ITEMDRAW_DISABLED);
if(!g_AddNoVote)
AddMenuItem(g_VoteMenu, LINE_SPACER, "", ITEMDRAW_SPACER);
}
else
g_BlockedSlots = false;
}
if(g_AddNoVote)
SetMenuOptionFlags(g_VoteMenu, MENUFLAG_BUTTON_NOVOTE);
SetMenuTitle(g_VoteMenu, "Vote Nextmap");
SetVoteResultCallback(g_VoteMenu, Handler_MapVoteFinished);
g_BlockedSlots = false;
}
if(g_AddNoVote)
SetMenuOptionFlags(g_VoteMenu, MENUFLAG_BUTTON_NOVOTE);
SetMenuTitle(g_VoteMenu, "Vote Nextmap");
SetVoteResultCallback(g_VoteMenu, Handler_MapVoteFinished);
/* Call OnMapVoteStarted() Forward */
// Call_StartForward(g_MapVoteStartedForward);
// Call_Finish();
@@ -1091,16 +1046,6 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
int voteSize = GetVoteSize(2);
// The if and else if could be combined, but it looks extremely messy
// This is a hack to lower the vote menu size by 1 when Don't Change or Extend Map should appear
if(g_NativeVotes)
{
if((when == MapChange_Instant || when == MapChange_RoundEnd) && GetConVarBool(g_Cvar_DontChange))
voteSize--;
else if(GetConVarBool(g_Cvar_Extend) && g_Extends < GetConVarInt(g_Cvar_Extend))
voteSize--;
}
/* Smaller of the two - It should be impossible for nominations to exceed the size though (cvar changed mid-map?) */
int nominationsToAdd = nominateCount >= voteSize ? voteSize : nominateCount;
@@ -1220,17 +1165,11 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
// New in Mapchooser Extended
else if(StrEqual(map, VOTE_DONTCHANGE))
{
if(g_NativeVotes)
NativeVotes_AddItem(g_VoteMenu, VOTE_DONTCHANGE, "Don't Change");
else
AddMenuItem(g_VoteMenu, VOTE_DONTCHANGE, "Don't Change");
AddMenuItem(g_VoteMenu, VOTE_DONTCHANGE, "Don't Change");
}
else if(StrEqual(map, VOTE_EXTEND))
{
if(g_NativeVotes)
NativeVotes_AddItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
else
AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
AddMenuItem(g_VoteMenu, VOTE_EXTEND, "Extend Map");
}
}
delete inputlist;
@@ -1238,23 +1177,16 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
int voteDuration = GetConVarInt(g_Cvar_VoteDuration);
if(g_NativeVotes)
{
NativeVotes_DisplayToAll(g_VoteMenu, voteDuration);
}
else
{
//SetMenuExitButton(g_VoteMenu, false);
//SetMenuExitButton(g_VoteMenu, false);
if(GetVoteSize(2) <= GetMaxPageItems(GetMenuStyle(g_VoteMenu)))
{
//This is necessary to get items 9 and 0 as usable voting items
SetMenuPagination(g_VoteMenu, MENU_NO_PAGINATION);
}
VoteMenuToAll(g_VoteMenu, voteDuration);
if(GetVoteSize(2) <= GetMaxPageItems(GetMenuStyle(g_VoteMenu)))
{
//This is necessary to get items 9 and 0 as usable voting items
SetMenuPagination(g_VoteMenu, MENU_NO_PAGINATION);
}
VoteMenuToAll(g_VoteMenu, voteDuration);
/* Call OnMapVoteStarted() Forward */
Call_StartForward(g_MapVoteStartForward); // Deprecated
Call_Finish();
@@ -1266,23 +1198,6 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
CPrintToChatAll("[MCE] %t", "Nextmap Voting Started");
}
public int Handler_NativeVoteFinished(Handle vote,
int num_votes,
int num_clients,
const int[] client_indexes,
const int[] client_votes,
int num_items,
const int[] item_indexes,
const int[] item_votes)
{
int[][] client_info = new int[num_clients][2];
int[][] item_info = new int[num_items][2];
NativeVotes_FixResults(num_clients, client_indexes, client_votes, num_items, item_indexes, item_votes, client_info, item_info);
Handler_MapVoteFinished(vote, num_votes, num_clients, client_info, num_items, item_info);
}
public void Handler_VoteFinishedGeneric(Handle menu,
int num_votes,
int num_clients,
@@ -1329,9 +1244,6 @@ public void Handler_VoteFinishedGeneric(Handle menu,
SetConVarInt(g_Cvar_Fraglimit, fraglimit + GetConVarInt(g_Cvar_ExtendFragStep));
}
if(g_NativeVotes)
NativeVotes_DisplayPassEx(menu, NativeVotesPass_Extend);
CPrintToChatAll("[MCE] %t", "Current Map Extended", RoundToFloor(float(item_info[0][VOTEINFO_ITEM_VOTES])/float(num_votes)*100), num_votes);
LogAction(-1, -1, "Voting for next map has finished. The current map has been extended.");
@@ -1343,9 +1255,6 @@ public void Handler_VoteFinishedGeneric(Handle menu,
}
else if(strcmp(map, VOTE_DONTCHANGE, false) == 0)
{
if(g_NativeVotes)
NativeVotes_DisplayPassEx(menu, NativeVotesPass_Extend);
CPrintToChatAll("[MCE] %t", "Current Map Stays", RoundToFloor(float(item_info[0][VOTEINFO_ITEM_VOTES])/float(num_votes)*100), num_votes);
LogAction(-1, -1, "Voting for next map has finished. 'No Change' was the winner");
@@ -1358,9 +1267,6 @@ public void Handler_VoteFinishedGeneric(Handle menu,
if(g_ChangeTime == MapChange_MapEnd)
{
SetNextMap(map);
if(g_NativeVotes)
NativeVotes_DisplayPass(menu, map);
}
else if(g_ChangeTime == MapChange_Instant)
{
@@ -1368,17 +1274,11 @@ public void Handler_VoteFinishedGeneric(Handle menu,
CreateDataTimer(4.0, Timer_ChangeMap, data);
WritePackString(data, map);
g_ChangeMapInProgress = false;
if(g_NativeVotes)
NativeVotes_DisplayPassEx(menu, NativeVotesPass_ChgLevel, map);
}
else // MapChange_RoundEnd
{
SetNextMap(map);
g_ChangeMapAtRoundEnd = true;
if(g_NativeVotes)
NativeVotes_DisplayPass(menu, map);
}
g_HasVoteStarted = false;
@@ -1425,9 +1325,6 @@ public void Handler_MapVoteFinished(Handle menu,
break;
}
if(g_NativeVotes)
NativeVotes_DisplayFail(menu, NativeVotesFail_NotEnoughVotes);
CPrintToChatAll("[MCE] %t", "Tie Vote", GetArraySize(mapList));
SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList);
return;
@@ -1458,9 +1355,6 @@ public void Handler_MapVoteFinished(Handle menu,
break;
}
if(g_NativeVotes)
NativeVotes_DisplayFail(menu, NativeVotesFail_NotEnoughVotes);
CPrintToChatAll("[MCE] %t", "Revote Is Needed", required_percent);
SetupWarningTimer(WarningType_Revote, view_as<MapChange>(g_ChangeTime), mapList);
return;
@@ -1471,7 +1365,6 @@ public void Handler_MapVoteFinished(Handle menu,
Handler_VoteFinishedGeneric(menu, num_votes, num_clients, client_info, num_items, item_info);
}
// This is shared by NativeVotes now, but NV doesn't support Display or DisplayItem
public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int param2)
{
switch(action)
@@ -1479,22 +1372,15 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
case MenuAction_End:
{
g_VoteMenu = INVALID_HANDLE;
if(g_NativeVotes)
NativeVotes_Close(menu);
else
delete menu;
delete menu;
}
case MenuAction_Display:
{
// NativeVotes uses the standard TF2/CSGO vote screen
if(!g_NativeVotes)
{
static char buffer[255];
Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1);
Handle panel = view_as<Handle>(param2);
SetPanelTitle(panel, buffer);
}
static char buffer[255];
Format(buffer, sizeof(buffer), "%T", "Vote Nextmap", param1);
Handle panel = view_as<Handle>(param2);
SetPanelTitle(panel, buffer);
}
case MenuAction_DisplayItem:
@@ -1503,10 +1389,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
char buffer[255];
int mark = GetConVarInt(g_Cvar_MarkCustomMaps);
if(g_NativeVotes)
NativeVotes_GetItem(menu, param2, map, PLATFORM_MAX_PATH);
else
GetMenuItem(menu, param2, map, PLATFORM_MAX_PATH);
GetMenuItem(menu, param2, map, PLATFORM_MAX_PATH);
if(StrEqual(map, VOTE_EXTEND, false))
{
@@ -1544,13 +1427,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
if(buffer[0] != '\0')
{
if(g_NativeVotes)
{
NativeVotes_RedrawVoteItem(buffer);
return view_as<int>(Plugin_Continue);
}
else
return RedrawMenuItem(buffer);
return RedrawMenuItem(buffer);
}
// End Mapchooser Extended
}
@@ -1560,11 +1437,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
// If we receive 0 votes, pick at random.
if(param1 == VoteCancel_NoVotes && GetConVarBool(g_Cvar_NoVoteMode))
{
int count;
if(g_NativeVotes)
count = NativeVotes_GetItemCount(menu);
else
count = GetMenuItemCount(menu);
int count = GetMenuItemCount(menu);
int item;
static char map[PLATFORM_MAX_PATH];
@@ -1572,7 +1445,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
do
{
int startInt = 0;
if(!g_NativeVotes && g_BlockedSlots)
if(g_BlockedSlots)
{
if(g_AddNoVote)
{
@@ -1585,26 +1458,12 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p
}
item = GetRandomInt(startInt, count - 1);
if(g_NativeVotes)
NativeVotes_GetItem(menu, item, map, PLATFORM_MAX_PATH);
else
GetMenuItem(menu, item, map, PLATFORM_MAX_PATH);
GetMenuItem(menu, item, map, PLATFORM_MAX_PATH);
}
while(strcmp(map, VOTE_EXTEND, false) == 0);
SetNextMap(map);
g_MapVoteCompleted = true;
if(g_NativeVotes)
NativeVotes_DisplayPass(menu, map);
}
else if(g_NativeVotes)
{
NativeVotesFailType reason = NativeVotesFail_Generic;
if(param1 == VoteCancel_NoVotes)
reason = NativeVotesFail_NotEnoughVotes;
NativeVotes_DisplayFail(menu, reason);
}
g_HasVoteStarted = false;
@@ -2348,18 +2207,12 @@ public int Native_GetExtendsLeft(Handle plugin, int numParams)
stock void AddMapItem(const char[] map)
{
if(g_NativeVotes)
NativeVotes_AddItem(g_VoteMenu, map, map);
else
AddMenuItem(g_VoteMenu, map, map);
AddMenuItem(g_VoteMenu, map, map);
}
stock void GetMapItem(Handle menu, int position, char[] map, int mapLen)
{
if(g_NativeVotes)
NativeVotes_GetItem(menu, position, map, mapLen);
else
GetMenuItem(menu, position, map, mapLen);
GetMenuItem(menu, position, map, mapLen);
}
stock void AddExtendToMenu(Handle menu, MapChange when)
@@ -2370,17 +2223,11 @@ stock void AddExtendToMenu(Handle menu, MapChange when)
if((when == MapChange_Instant || when == MapChange_RoundEnd) && GetConVarBool(g_Cvar_DontChange))
{
// Built-in votes doesn't have "Don't Change", send Extend instead
if(g_NativeVotes)
NativeVotes_AddItem(menu, VOTE_DONTCHANGE, "Don't Change");
else
AddMenuItem(menu, VOTE_DONTCHANGE, "Don't Change");
AddMenuItem(menu, VOTE_DONTCHANGE, "Don't Change");
}
else if(GetConVarBool(g_Cvar_Extend) && g_Extends < GetConVarInt(g_Cvar_Extend))
{
if(g_NativeVotes)
NativeVotes_AddItem(menu, VOTE_EXTEND, "Extend Map");
else
AddMenuItem(menu, VOTE_EXTEND, "Extend Map");
AddMenuItem(menu, VOTE_EXTEND, "Extend Map");
}
}
@@ -2396,17 +2243,6 @@ stock int GetVoteSize(int what=0)
if(what == 1 || what == 2)
voteSize += includeMapsReserved;
// New in 1.9.5 to let us bump up the included maps count
if(g_NativeVotes)
{
int max = NativeVotes_GetMaxItems();
if(voteSize > max)
voteSize = max;
if(includeMaps > max)
includeMaps = max;
}
if(what == 1)
return voteSize - includeMaps;