mapchooser_extended: use new MenuShufflePerClient native for per-client randomized map vote menu
This commit is contained in:
		
							parent
							
								
									b35952b21f
								
							
						
					
					
						commit
						a44af8d9bd
					
				| @ -53,7 +53,7 @@ | ||||
| #pragma semicolon 1 | ||||
| #pragma newdecls required | ||||
| 
 | ||||
| #define MCE_VERSION "1.13.0" | ||||
| #define MCE_VERSION "1.2.0" | ||||
| 
 | ||||
| enum RoundCounting | ||||
| { | ||||
| @ -81,10 +81,10 @@ enum | ||||
| public Plugin myinfo = | ||||
| { | ||||
| 	name = "MapChooser Extended", | ||||
| 	author = "Powerlord, Zuko, and AlliedModders LLC", | ||||
| 	author = "Powerlord, Zuko, BotoX and AlliedModders LLC", | ||||
| 	description = "Automated Map Voting with Extensions", | ||||
| 	version = MCE_VERSION, | ||||
| 	url = "https://forums.alliedmods.net/showthread.php?t=156974" | ||||
| 	url = "" | ||||
| }; | ||||
| 
 | ||||
| /* Valve ConVars */ | ||||
| @ -159,6 +159,7 @@ ConVar g_Cvar_MarkCustomMaps; | ||||
| ConVar g_Cvar_RandomizeNominations; | ||||
| ConVar g_Cvar_HideTimer; | ||||
| ConVar g_Cvar_NoVoteOption; | ||||
| ConVar g_Cvar_ShufflePerClient; | ||||
| 
 | ||||
| /* Mapchooser Extended Data Handles */ | ||||
| Handle g_OfficialList = INVALID_HANDLE; | ||||
| @ -258,6 +259,7 @@ public void OnPluginStart() | ||||
| 	g_Cvar_RandomizeNominations = CreateConVar("mce_randomizeorder", "0", "Randomize map order?", _, true, 0.0, true, 1.0); | ||||
| 	g_Cvar_HideTimer = CreateConVar("mce_hidetimer", "0", "Hide the MapChooser Extended warning timer", _, true, 0.0, true, 1.0); | ||||
| 	g_Cvar_NoVoteOption = CreateConVar("mce_addnovote", "1", "Add \"No Vote\" to vote menu?", _, true, 0.0, true, 1.0); | ||||
| 	g_Cvar_ShufflePerClient = CreateConVar("mce_shuffle_per_client", "1", "Random shuffle map vote menu per client?", _, true, 0.0, true, 1.0); | ||||
| 
 | ||||
| 	RegAdminCmd("sm_mapvote", Command_Mapvote, ADMFLAG_CHANGEMAP, "sm_mapvote - Forces MapChooser to attempt to run a map vote now."); | ||||
| 	RegAdminCmd("sm_setnextmap", Command_SetNextmap, ADMFLAG_CHANGEMAP, "sm_setnextmap <map>"); | ||||
| @ -955,6 +957,8 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) | ||||
| { | ||||
| 	g_WaitingForVote = true; | ||||
| 	g_WarningInProgress = false; | ||||
| 	int MenuRandomShuffleStart = 0; | ||||
| 	int MenuRandomShuffleStop = 0; | ||||
| 
 | ||||
| 	// Check if a vote is in progress first | ||||
| 	if(IsVoteInProgress()) | ||||
| @ -1008,9 +1012,12 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) | ||||
| 			g_BlockedSlots = true; | ||||
| 			AddMenuItem(g_VoteMenu, LINE_ONE, "Choose something...", ITEMDRAW_DISABLED); | ||||
| 			AddMenuItem(g_VoteMenu, LINE_TWO, "...will ya?", ITEMDRAW_DISABLED); | ||||
| 			MenuRandomShuffleStart += 2; | ||||
| 
 | ||||
| 			if(!g_AddNoVote) | ||||
| 			if(!g_AddNoVote) { | ||||
| 				AddMenuItem(g_VoteMenu, LINE_SPACER, "", ITEMDRAW_SPACER); | ||||
| 				MenuRandomShuffleStart++; | ||||
| 			} | ||||
| 		} | ||||
| 		else | ||||
| 			g_BlockedSlots = false; | ||||
| @ -1051,8 +1058,10 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) | ||||
| 
 | ||||
| 		bool extendFirst = GetConVarBool(g_Cvar_ExtendPosition); | ||||
| 
 | ||||
| 		if(extendFirst) | ||||
| 		if(extendFirst) { | ||||
| 			AddExtendToMenu(g_VoteMenu, when); | ||||
| 			MenuRandomShuffleStart++; | ||||
| 		} | ||||
| 
 | ||||
| 		for(int i = 0; i < nominationsToAdd; i++) | ||||
| 		{ | ||||
| @ -1147,8 +1156,10 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) | ||||
| 		ClearArray(g_NominateOwners); | ||||
| 		ClearArray(g_NominateList); | ||||
| 
 | ||||
| 		if(!extendFirst) | ||||
| 		if(!extendFirst) { | ||||
| 			AddExtendToMenu(g_VoteMenu, when); | ||||
| 			MenuRandomShuffleStop++; | ||||
| 		} | ||||
| 	} | ||||
| 	else //We were given a list of maps to start the vote with | ||||
| 	{ | ||||
| @ -1185,6 +1196,9 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE) | ||||
| 		SetMenuPagination(g_VoteMenu, MENU_NO_PAGINATION); | ||||
| 	} | ||||
| 
 | ||||
| 	if(GetConVarInt(g_Cvar_ShufflePerClient)) | ||||
| 		MenuShufflePerClient(g_VoteMenu, MenuRandomShuffleStart, GetMenuItemCount(g_VoteMenu) - MenuRandomShuffleStop); | ||||
| 
 | ||||
| 	VoteMenuToAll(g_VoteMenu, voteDuration); | ||||
| 
 | ||||
| 	/* Call OnMapVoteStarted() Forward */ | ||||
| @ -1389,7 +1403,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p | ||||
| 			char buffer[255]; | ||||
| 			int mark = GetConVarInt(g_Cvar_MarkCustomMaps); | ||||
| 
 | ||||
| 			GetMenuItem(menu, param2, map, PLATFORM_MAX_PATH); | ||||
| 			GetMenuItem(menu, param2, map, PLATFORM_MAX_PATH, _, _, _, param1); | ||||
| 
 | ||||
| 			if(StrEqual(map, VOTE_EXTEND, false)) | ||||
| 			{ | ||||
| @ -1458,7 +1472,7 @@ public int Handler_MapVoteMenu(Handle menu, MenuAction action, int param1, int p | ||||
| 					} | ||||
| 					item = GetRandomInt(startInt, count - 1); | ||||
| 
 | ||||
| 					GetMenuItem(menu, item, map, PLATFORM_MAX_PATH); | ||||
| 					GetMenuItem(menu, item, map, PLATFORM_MAX_PATH, _, _, _, param1); | ||||
| 				} | ||||
| 				while(strcmp(map, VOTE_EXTEND, false) == 0); | ||||
| 
 | ||||
| @ -2212,7 +2226,7 @@ stock void AddMapItem(const char[] map) | ||||
| 
 | ||||
| stock void GetMapItem(Handle menu, int position, char[] map, int mapLen) | ||||
| { | ||||
| 	GetMenuItem(menu, position, map, mapLen); | ||||
| 	GetMenuItem(menu, position, map, mapLen, _, _, _, -1); | ||||
| } | ||||
| 
 | ||||
| stock void AddExtendToMenu(Handle menu, MapChange when) | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user