mapchooser_extended: add reserved/random nomination slots

This commit is contained in:
BotoX 2018-08-10 03:23:39 +02:00
parent 40033e9dab
commit ef5e739376

View File

@ -111,6 +111,7 @@ ConVar g_Cvar_ExtendRoundStep;
ConVar g_Cvar_ExtendFragStep; ConVar g_Cvar_ExtendFragStep;
ConVar g_Cvar_ExcludeMaps; ConVar g_Cvar_ExcludeMaps;
ConVar g_Cvar_IncludeMaps; ConVar g_Cvar_IncludeMaps;
ConVar g_Cvar_IncludeMapsReserved;
ConVar g_Cvar_NoVoteMode; ConVar g_Cvar_NoVoteMode;
ConVar g_Cvar_Extend; ConVar g_Cvar_Extend;
ConVar g_Cvar_DontChange; ConVar g_Cvar_DontChange;
@ -141,6 +142,7 @@ bool g_HasIntermissionStarted = false;
int g_mapFileSerial = -1; int g_mapFileSerial = -1;
int g_NominateCount = 0; int g_NominateCount = 0;
int g_NominateReservedCount = 0;
MapChange g_ChangeTime; MapChange g_ChangeTime;
Handle g_NominationsResetForward = INVALID_HANDLE; Handle g_NominationsResetForward = INVALID_HANDLE;
@ -238,7 +240,8 @@ public void OnPluginStart()
g_Cvar_ExtendRoundStep = CreateConVar("mce_extend_roundstep", "5", "Specifies how many more rounds each extension makes", _, true, 1.0); g_Cvar_ExtendRoundStep = CreateConVar("mce_extend_roundstep", "5", "Specifies how many more rounds each extension makes", _, true, 1.0);
g_Cvar_ExtendFragStep = CreateConVar("mce_extend_fragstep", "10", "Specifies how many more frags are allowed when map is extended.", _, true, 5.0); g_Cvar_ExtendFragStep = CreateConVar("mce_extend_fragstep", "10", "Specifies how many more frags are allowed when map is extended.", _, true, 5.0);
g_Cvar_ExcludeMaps = CreateConVar("mce_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0); g_Cvar_ExcludeMaps = CreateConVar("mce_exclude", "5", "Specifies how many past maps to exclude from the vote.", _, true, 0.0);
g_Cvar_IncludeMaps = CreateConVar("mce_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 6.0); g_Cvar_IncludeMaps = CreateConVar("mce_include", "5", "Specifies how many maps to include in the vote.", _, true, 2.0, true, 7.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_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_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); g_Cvar_DontChange = CreateConVar("mce_dontchange", "1", "Specifies if a 'Don't Change' option should be added to early votes", _, true, 0.0);
@ -249,7 +252,7 @@ public void OnPluginStart()
g_Cvar_RunOff = CreateConVar("mce_runoff", "1", "Hold run off votes if winning choice has less than a certain percentage of votes", _, true, 0.0, true, 1.0); g_Cvar_RunOff = CreateConVar("mce_runoff", "1", "Hold run off votes if winning choice has less than a certain percentage of votes", _, true, 0.0, true, 1.0);
g_Cvar_RunOffPercent = CreateConVar("mce_runoffpercent", "50", "If winning choice has less than this percent of votes, hold a runoff", _, true, 0.0, true, 100.0); g_Cvar_RunOffPercent = CreateConVar("mce_runoffpercent", "50", "If winning choice has less than this percent of votes, hold a runoff", _, true, 0.0, true, 100.0);
g_Cvar_BlockSlots = CreateConVar("mce_blockslots", "1", "Block slots to prevent accidental votes. Only applies when Voice Command style menus are in use.", _, true, 0.0, true, 1.0); g_Cvar_BlockSlots = CreateConVar("mce_blockslots", "0", "Block slots to prevent accidental votes. Only applies when Voice Command style menus are in use.", _, true, 0.0, true, 1.0);
//g_Cvar_BlockSlotsCount = CreateConVar("mce_blockslots_count", "2", "Number of slots to block.", _, true, 1.0, true, 3.0); //g_Cvar_BlockSlotsCount = CreateConVar("mce_blockslots_count", "2", "Number of slots to block.", _, true, 1.0, true, 3.0);
g_Cvar_MaxRunOffs = CreateConVar("mce_maxrunoffs", "1", "Number of run off votes allowed each map.", _, true, 0.0); g_Cvar_MaxRunOffs = CreateConVar("mce_maxrunoffs", "1", "Number of run off votes allowed each map.", _, true, 0.0);
g_Cvar_StartTimePercent = CreateConVar("mce_start_percent", "35.0", "Specifies when to start the vote based on percents.", _, true, 0.0, true, 100.0); g_Cvar_StartTimePercent = CreateConVar("mce_start_percent", "35.0", "Specifies when to start the vote based on percents.", _, true, 0.0, true, 100.0);
@ -497,6 +500,7 @@ public void OnConfigsExecuted()
g_MapVoteCompleted = false; g_MapVoteCompleted = false;
g_NominateCount = 0; g_NominateCount = 0;
g_NominateReservedCount = 0;
ClearArray(g_NominateList); ClearArray(g_NominateList);
ClearArray(g_NominateOwners); ClearArray(g_NominateOwners);
@ -1072,7 +1076,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
int nominateCount = GetArraySize(g_NominateList); int nominateCount = GetArraySize(g_NominateList);
int voteSize = GetVoteSize(); int voteSize = GetVoteSize(2);
// The if and else if could be combined, but it looks extremely messy // 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 // This is a hack to lower the vote menu size by 1 when Don't Change or Extend Map should appear
@ -1181,6 +1185,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
/* Wipe out our nominations list - Nominations have already been informed of this */ /* Wipe out our nominations list - Nominations have already been informed of this */
g_NominateCount = 0; g_NominateCount = 0;
g_NominateReservedCount = 0;
ClearArray(g_NominateOwners); ClearArray(g_NominateOwners);
ClearArray(g_NominateList); ClearArray(g_NominateList);
@ -1228,7 +1233,7 @@ void InitiateVote(MapChange when, Handle inputlist=INVALID_HANDLE)
{ {
//SetMenuExitButton(g_VoteMenu, false); //SetMenuExitButton(g_VoteMenu, false);
if(GetVoteSize() <= GetMaxPageItems(GetMenuStyle(g_VoteMenu))) if(GetVoteSize(2) <= GetMaxPageItems(GetMenuStyle(g_VoteMenu)))
{ {
//This is necessary to get items 9 and 0 as usable voting items //This is necessary to get items 9 and 0 as usable voting items
SetMenuPagination(g_VoteMenu, MENU_NO_PAGINATION); SetMenuPagination(g_VoteMenu, MENU_NO_PAGINATION);
@ -1651,7 +1656,7 @@ void CreateNextVote()
delete OldMapListSnapshot; delete OldMapListSnapshot;
} }
int voteSize = GetVoteSize(); int voteSize = GetVoteSize(2);
int limit = (voteSize < GetArraySize(tempMaps) ? voteSize : GetArraySize(tempMaps)); int limit = (voteSize < GetArraySize(tempMaps) ? voteSize : GetArraySize(tempMaps));
StringMap groups = new StringMap(); StringMap groups = new StringMap();
@ -1733,19 +1738,26 @@ NominateResult InternalNominateMap(char[] map, bool force, int owner)
PushArrayString(g_NominateList, map); PushArrayString(g_NominateList, map);
PushArrayCell(g_NominateOwners, owner); PushArrayCell(g_NominateOwners, owner);
if(owner == 0 && g_NominateReservedCount < GetVoteSize(1))
g_NominateReservedCount++;
else
g_NominateCount++; g_NominateCount++;
while(GetArraySize(g_NominateList) > GetVoteSize()) while(GetArraySize(g_NominateList) > GetVoteSize(2))
{ {
char oldmap[PLATFORM_MAX_PATH]; char oldmap[PLATFORM_MAX_PATH];
GetArrayString(g_NominateList, 0, oldmap, PLATFORM_MAX_PATH); GetArrayString(g_NominateList, 0, oldmap, PLATFORM_MAX_PATH);
Call_StartForward(g_NominationsResetForward); Call_StartForward(g_NominationsResetForward);
Call_PushString(oldmap); Call_PushString(oldmap);
Call_PushCell(GetArrayCell(g_NominateOwners, 0)); int owner_ = GetArrayCell(g_NominateOwners, 0);
Call_PushCell(owner_);
Call_Finish(); Call_Finish();
RemoveFromArray(g_NominateList, 0); RemoveFromArray(g_NominateList, 0);
RemoveFromArray(g_NominateOwners, 0); RemoveFromArray(g_NominateOwners, 0);
if(owner_ == 0)
g_NominateReservedCount--;
else
g_NominateCount--; g_NominateCount--;
} }
@ -2276,19 +2288,32 @@ stock void AddExtendToMenu(Handle menu, MapChange when)
} }
} }
stock int GetVoteSize() // 0 = IncludeMaps, 1 = Reserved, 2 = IncludeMaps+Reserved
stock int GetVoteSize(int what=0)
{ {
int voteSize = GetConVarInt(g_Cvar_IncludeMaps); int voteSize = 0;
int includeMaps = GetConVarInt(g_Cvar_IncludeMaps);
int includeMapsReserved = GetConVarInt(g_Cvar_IncludeMapsReserved);
if(what == 0 || what == 2)
voteSize += includeMaps;
if(what == 1 || what == 2)
voteSize += includeMapsReserved;
// New in 1.9.5 to let us bump up the included maps count // New in 1.9.5 to let us bump up the included maps count
if(g_NativeVotes) if(g_NativeVotes)
{ {
int max = NativeVotes_GetMaxItems(); int max = NativeVotes_GetMaxItems();
if(max < voteSize) if(voteSize > max)
voteSize = max; voteSize = max;
if(includeMaps > max)
includeMaps = max;
} }
if(what == 1)
return voteSize - includeMaps;
return voteSize; return voteSize;
} }