Looks good.

This commit is contained in:
BotoX
2019-09-18 16:58:30 +02:00
parent add15450df
commit 04eb96b0e2
6 changed files with 156 additions and 105 deletions
@@ -53,7 +53,7 @@
#pragma semicolon 1
#pragma newdecls required
#define MCE_VERSION "1.2.0"
#define MCE_VERSION "1.3.0"
enum RoundCounting
{
@@ -241,7 +241,7 @@ public void OnPluginStart()
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_ExcludeMapsTime = CreateConVar("mce_exclude_time", "5", "Specifies how long in minutes an old map is excluded from the vote.", _, true, 0.0);
g_Cvar_ExcludeMapsTime = CreateConVar("mce_exclude_time", "5h", "Specifies how long in minutes an old map is excluded from the vote.");
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);
@@ -541,7 +541,7 @@ public void OnMapEnd()
Cooldown = InternalGetMapCooldown(map);
g_OldMapList.SetValue(map, Cooldown, true);
Cooldown = InternalGetMapCooldownTime(map);
Cooldown = GetTime() + InternalGetMapCooldownTime(map);
g_TimeMapList.SetValue(map, Cooldown, true);
}
@@ -1573,7 +1573,7 @@ void CreateNextVote()
GetCurrentMap(map, PLATFORM_MAX_PATH);
RemoveStringFromArray(tempMaps, map);
if(GetConVarInt(g_Cvar_ExcludeMaps) && GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps) && InternalAreRestrictionsActive())
if(GetArraySize(tempMaps) > GetConVarInt(g_Cvar_ExcludeMaps) && InternalAreRestrictionsActive())
{
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
for(int i = 0; i < OldMapListSnapshot.Length; i++)
@@ -1584,7 +1584,7 @@ void CreateNextVote()
delete OldMapListSnapshot;
}
if(GetConVarInt(g_Cvar_ExcludeMapsTime) && InternalAreRestrictionsActive())
if(InternalAreRestrictionsActive())
{
StringMapSnapshot TimeMapListSnapshot = g_TimeMapList.Snapshot();
for(int i = 0; i < TimeMapListSnapshot.Length; i++)
@@ -2090,14 +2090,14 @@ public int Native_ExcludeMapTime(Handle plugin, int numParams)
}
else if(Mode == 1)
{
Cooldown = GetNativeCell(2) * 60;
Cooldown = GetNativeCell(2);
}
else if(Mode == 2)
{
g_TimeMapList.GetValue(map, Cooldown);
int NewCooldown = GetTime() + GetNativeCell(2) * 60;
int NewCooldown = GetTime() + GetNativeCell(2);
if(NewCooldown > Cooldown)
Cooldown = GetNativeCell(2) * 60;
Cooldown = GetNativeCell(2);
}
Cooldown += GetTime();
@@ -2405,11 +2405,15 @@ stock int InternalGetMapCooldown(const char[] map)
stock int InternalGetMapCooldownTime(const char[] map)
{
int Cooldown = g_Cvar_ExcludeMapsTime.IntValue;
char time[16];
g_Cvar_ExcludeMapsTime.GetString(time, sizeof(time));
int Cooldown = TimeStrToSeconds(time);
if(g_Config && g_Config.JumpToKey(map))
{
Cooldown = g_Config.GetNum("CooldownTime", Cooldown);
g_Config.GetString("CooldownTime", time, sizeof(time), "");
Cooldown = TimeStrToSeconds(time);
g_Config.Rewind();
}
@@ -2790,4 +2794,22 @@ stock void InternalStoreMapCooldowns()
}
delete Cooldowns;
}
}
stock int TimeStrToSeconds(const char[] str)
{
int seconds = 0;
int maxlen = strlen(str);
for(int i = 0; i < maxlen; i++)
{
int val = 0;
i += StringToIntEx(str[i], val);
if(str[i] == 'h')
{
val *= 60;
i++;
}
seconds += val * 60;
}
return seconds;
}