this should now catch the player count correctly to set the cooldown and shared cooldowns

This commit is contained in:
jenz 2026-04-02 20:47:46 +02:00
parent ef537b8826
commit ff012d2df5

View File

@ -143,7 +143,6 @@ int g_iNextmapState = 0; //0 = nothing. 1 = rtv succesfull. 2 = admin used setne
int g_mapFileSerial = -1;
int g_iSkipAllRestrictions;
int g_iDontCooldownMap;
int g_iClientCount;
int g_iMapsFromCasualPool;
@ -249,7 +248,6 @@ public void OnPluginEnd()
public void OnPluginStart()
{
g_iClientCount = 0;
LoadTranslations("mapchooser_extended.phrases");
LoadTranslations("basevotes.phrases");
LoadTranslations("common.phrases");
@ -552,19 +550,6 @@ public void OnMapStart()
return;
}
g_Config.Rewind();
if (g_iDontCooldownMap < g_iClientCount)
{
static char map[PLATFORM_MAX_PATH];
GetCurrentMap(map, PLATFORM_MAX_PATH);
int Cooldown = InternalGetMapCooldown(map);
g_OldMapList.SetValue(map, Cooldown, true);
Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime());
g_TimeMapList.SetValue(map, Cooldown, true);
//2026 march 18th: set cooldown on all maps that share a cooldown with this one including itself.
SetSharedCooldowns(map);
}
}
public void OnConfigsExecuted()
@ -671,51 +656,39 @@ public void OnMapEnd()
g_WarningTimer = INVALID_HANDLE;
g_RunoffCount = 0;
g_iClientCount = GetClientCount(false);
if (g_iDontCooldownMap < g_iClientCount)
static char map[PLATFORM_MAX_PATH];
GetCurrentMap(map, PLATFORM_MAX_PATH);
int Cooldown = InternalGetMapCooldown(map);
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
for(int i = 0; i < OldMapListSnapshot.Length; i++)
{
static char map[PLATFORM_MAX_PATH];
int Cooldown;
OldMapListSnapshot.GetKey(i, map, sizeof(map));
g_OldMapList.GetValue(map, Cooldown);
GetCurrentMap(map, PLATFORM_MAX_PATH);
Cooldown = InternalGetMapCooldown(map);
g_OldMapList.SetValue(map, Cooldown, true);
Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime());
g_TimeMapList.SetValue(map, Cooldown, true);
//2026 march 18th: set cooldown on all maps that share cooldown with this one.
//why do it again? because obviously people will make the mistake of giving the map its own specific cooldown despite being part of a sharedcooldown group.
SetSharedCooldowns(map);
StringMapSnapshot OldMapListSnapshot = g_OldMapList.Snapshot();
for(int i = 0; i < OldMapListSnapshot.Length; i++)
{
OldMapListSnapshot.GetKey(i, map, sizeof(map));
g_OldMapList.GetValue(map, Cooldown);
Cooldown--;
if(Cooldown > 0)
g_OldMapList.SetValue(map, Cooldown, true);
else
g_OldMapList.Remove(map);
}
delete OldMapListSnapshot;
StringMapSnapshot TimeMapListSnapshot = g_TimeMapList.Snapshot();
for(int i = 0; i < TimeMapListSnapshot.Length; i++)
{
TimeMapListSnapshot.GetKey(i, map, sizeof(map));
g_TimeMapList.GetValue(map, Cooldown);
if(Cooldown < GetTime())
g_TimeMapList.Remove(map);
}
delete TimeMapListSnapshot;
delete OldMapListSnapshot;
InternalStoreMapCooldowns();
Cooldown--;
if(Cooldown > 0)
g_OldMapList.SetValue(map, Cooldown, true);
else
g_OldMapList.Remove(map);
}
delete OldMapListSnapshot;
StringMapSnapshot TimeMapListSnapshot = g_TimeMapList.Snapshot();
Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime());
for(int i = 0; i < TimeMapListSnapshot.Length; i++)
{
TimeMapListSnapshot.GetKey(i, map, sizeof(map));
g_TimeMapList.GetValue(map, Cooldown);
if(Cooldown < GetTime())
g_TimeMapList.Remove(map);
}
delete TimeMapListSnapshot;
delete OldMapListSnapshot;
InternalStoreMapCooldowns();
}
public void OnClientPutInServer(int client)
@ -1009,6 +982,20 @@ public Action CS_OnTerminateRound(float &delay, CSRoundEndReason &reason)
//0 timeleft and all extends used or map was not extended. (we do the map vote at map end)
//0 timeleft and rtv is ongoing still
//yeah sure why not just do it on every round end anyways.
if (GetClientCount(false) > g_iDontCooldownMap)
{
static char map[PLATFORM_MAX_PATH];
GetCurrentMap(map, PLATFORM_MAX_PATH);
int Cooldown = InternalGetMapCooldown(map);
g_OldMapList.SetValue(map, Cooldown, true);
Cooldown = GetTime() + InternalGetMapCooldownTime(map) - RoundToFloor(GetGameTime());
g_TimeMapList.SetValue(map, Cooldown, true);
//2026 march 18th: set cooldown on all maps that share a cooldown with this one including itself.
SetSharedCooldowns(map);
}
if (timeleft <= 0 && g_RtvInitiated && g_iNextmapState < 4) //last round was terminated, rtv is going on and we did not set g_i Nextmapstate yet.
{
//extra time in case of rtv, rtv run-off (there is no dont change option here as we already used all extends or people voted dont extend)