diff --git a/src/map_votes.cpp b/src/map_votes.cpp index 2a441804..9457842c 100644 --- a/src/map_votes.cpp +++ b/src/map_votes.cpp @@ -805,4 +805,29 @@ bool CMapVoteSystem::WriteMapCooldownsToFile() } return true; +} + +void CMapVoteSystem::ClearInvalidNominations() +{ + if (!g_bVoteManagerEnable || m_bIsVoteOngoing) + return; + + for (int i = 0; i < gpGlobals->maxClients; i++) { + int iNominatedMapIndex = m_arrPlayerNominations[i]; + + // Ignore unset nominations (negative index) + if (iNominatedMapIndex < 0) + continue; + + // Check if nominated index still meets criteria for nomination + if (!IsMapIndexEnabled(iNominatedMapIndex)) + { + ClearPlayerInfo(i); + CCSPlayerController* pPlayer = CCSPlayerController::FromSlot(i); + if (!pPlayer) + continue; + + ClientPrint(pPlayer, HUD_PRINTTALK, CHAT_PREFIX "Your nomination for \x06%s \x01has been removed because the player count requirements are no longer met.", GetMapName(iNominatedMapIndex)); + } + } } \ No newline at end of file diff --git a/src/map_votes.h b/src/map_votes.h index 3a2fdb37..b9263ce2 100644 --- a/src/map_votes.h +++ b/src/map_votes.h @@ -134,6 +134,7 @@ class CMapVoteSystem bool GetMapEnabledStatus(int iMapIndex) { return m_vecMapList[iMapIndex].IsEnabled(); } int GetDefaultMapCooldown() { return m_iDefaultMapCooldown; } void SetDefaultMapCooldown(int iMapCooldown) { m_iDefaultMapCooldown = iMapCooldown; } + void ClearInvalidNominations(); private: int WinningMapIndex(); diff --git a/src/playermanager.cpp b/src/playermanager.cpp index 9a8c64f7..f57c6f61 100644 --- a/src/playermanager.cpp +++ b/src/playermanager.cpp @@ -610,6 +610,7 @@ bool CPlayerManager::OnClientConnected(CPlayerSlot slot, uint64 xuid, const char ResetPlayerFlags(slot.Get()); g_pMapVoteSystem->ClearPlayerInfo(slot.Get()); + g_pMapVoteSystem->ClearInvalidNominations(); return true; } @@ -627,6 +628,7 @@ void CPlayerManager::OnClientDisconnect(CPlayerSlot slot) ResetPlayerFlags(slot.Get()); g_pMapVoteSystem->ClearPlayerInfo(slot.Get()); + g_pMapVoteSystem->ClearInvalidNominations(); g_pPanoramaVoteHandler->RemovePlayerFromVote(slot.Get()); }