MCE: replace map-based CD system with time-based one

This commit is contained in:
neon
2019-09-16 20:13:12 +02:00
parent 544112da92
commit a818cd24bf
3 changed files with 53 additions and 13 deletions
@@ -237,7 +237,7 @@ public void OnPluginStart()
g_Cvar_ExtendTimeStep = CreateConVar("mce_extend_timestep", "15", "Specifies how much many more minutes each extension makes", _, true, 5.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_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 for how many hours past maps should be excluded 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, 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);
@@ -378,6 +378,8 @@ public void OnPluginStart()
g_MapVoteRunoffStartForward = CreateGlobalForward("OnMapVoteRunnoffWarningStart", ET_Ignore);
InternalRestoreMapCooldowns();
CreateTimer(60.0, UpdateCooldowns, INVALID_HANDLE, TIMER_REPEAT);
}
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
@@ -526,15 +528,20 @@ public void OnMapEnd()
g_WarningTimer = INVALID_HANDLE;
g_RunoffCount = 0;
static char map[PLATFORM_MAX_PATH];
int Cooldown;
if(g_SaveCDOnMapEnd)
{
static char map[PLATFORM_MAX_PATH];
GetCurrentMap(map, PLATFORM_MAX_PATH);
Cooldown = InternalGetMapCooldown(map);
int Cooldown = InternalGetMapCooldown(map);
g_OldMapList.SetValue(map, Cooldown, true);
InternalStoreMapCooldowns();
}
}
public Action UpdateCooldowns(Handle timer)
{
static char map[PLATFORM_MAX_PATH];
int Cooldown;
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
for(int i = 0; i < OldMapListSnapshot.Length; i++)
@@ -542,7 +549,7 @@ public void OnMapEnd()
OldMapListSnapshot.GetKey(i, map, sizeof(map));
g_OldMapList.GetValue(map, Cooldown);
Cooldown--;
Cooldown --;
if(Cooldown > 0)
g_OldMapList.SetValue(map, Cooldown, true);
else
@@ -2301,7 +2308,7 @@ stock int InternalGetMapCooldown(const char[] map)
g_Config.Rewind();
}
return Cooldown;
return RoundToNearest(Cooldown * 60.0);
}
void CheckMapRestrictions(bool time = false, bool players = false)