Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions src/adminsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1531,7 +1531,7 @@ void CAdminSystem::AddOrUpdateAdmin(uint64 iSteamID, uint64 iFlags, int iAdminIm

bool CAdminSystem::LoadInfractions()
{
m_vecInfractions.PurgeAndDeleteElements();
m_vecInfractions.clear();
KeyValues* pKV = new KeyValues("infractions");
KeyValues::AutoDelete autoDelete(pKV);

Expand Down Expand Up @@ -1592,7 +1592,7 @@ void CAdminSystem::SaveInfractions()
KeyValues* pSubKey;
KeyValues::AutoDelete autoDelete(pKV);

FOR_EACH_VEC(m_vecInfractions, i)
for (int i = 0; i < m_vecInfractions.size(); i++)
{
time_t timestamp = m_vecInfractions[i]->GetTimestamp();
if (timestamp != 0 && timestamp < std::time(0))
Expand Down Expand Up @@ -1620,15 +1620,15 @@ void CAdminSystem::SaveInfractions()

void CAdminSystem::AddInfraction(CInfractionBase* infraction)
{
m_vecInfractions.AddToTail(infraction);
m_vecInfractions.push_back(infraction);
}

// This function can run at least twice when a player connects: Immediately upon client connection, and also upon getting authenticated by steam.
// It's also run when we're periodically checking for infraction expiry in the case of mutes/gags.
// This returns false only when called from ClientConnect and the player is banned in order to reject them.
bool CAdminSystem::ApplyInfractions(ZEPlayer* player)
{
FOR_EACH_VEC(m_vecInfractions, i)
for (int i = m_vecInfractions.size() - 1; i >= 0; i--)
{
// Because this can run without the player being authenticated, and the fact that we're applying a ban/mute here,
// we can immediately just use the steamid we got from the connecting player.
Expand All @@ -1644,7 +1644,7 @@ bool CAdminSystem::ApplyInfractions(ZEPlayer* player)
time_t timestamp = m_vecInfractions[i]->GetTimestamp();
if (timestamp != 0 && timestamp <= std::time(0))
{
m_vecInfractions.Remove(i);
m_vecInfractions.erase(m_vecInfractions.begin() + i);
continue;
}

Expand All @@ -1660,12 +1660,12 @@ bool CAdminSystem::ApplyInfractions(ZEPlayer* player)

bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer* player, CInfractionBase::EInfractionType type)
{
FOR_EACH_VEC_BACK(m_vecInfractions, i)
for (int i = m_vecInfractions.size() - 1; i >= 0; i--)
{
if (m_vecInfractions[i]->GetSteamId64() == player->GetSteamId64() && m_vecInfractions[i]->GetType() == type)
{
m_vecInfractions[i]->UndoInfraction(player);
m_vecInfractions.Remove(i);
m_vecInfractions.erase(m_vecInfractions.begin() + i);

return true;
}
Expand All @@ -1676,11 +1676,11 @@ bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer* player, CInfractionBase::EI

bool CAdminSystem::FindAndRemoveInfractionSteamId64(uint64 steamid64, CInfractionBase::EInfractionType type)
{
FOR_EACH_VEC_BACK(m_vecInfractions, i)
for (int i = m_vecInfractions.size() - 1; i >= 0; i--)
{
if (m_vecInfractions[i]->GetSteamId64() == steamid64 && m_vecInfractions[i]->GetType() == type)
{
m_vecInfractions.Remove(i);
m_vecInfractions.erase(m_vecInfractions.begin() + i);

return true;
}
Expand Down
3 changes: 1 addition & 2 deletions src/adminsystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#pragma once
#include "platform.h"
#include "playermanager.h"
#include "utlvector.h"
#include <ctime>

// clang-format off
Expand Down Expand Up @@ -196,7 +195,7 @@ class CAdminSystem
private:
std::map<std::string, CAdminBase> m_mapAdminGroups;
std::map<uint64, CAdmin> m_mapAdmins;
CUtlVector<CInfractionBase*> m_vecInfractions;
std::vector<CInfractionBase*> m_vecInfractions;

// Implemented as a circular buffer.
std::tuple<std::string, uint64, std::string> m_rgDCPly[20];
Expand Down
6 changes: 3 additions & 3 deletions src/discord.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ void DiscordHttpCallback(HTTPRequestHandle request, json response)

void CDiscordBotManager::PostDiscordMessage(const char* sDiscordBotName, const char* sMessage)
{
FOR_EACH_VEC(m_vecDiscordBots, i)
for (int i = 0; i < m_vecDiscordBots.size(); i++)
{
CDiscordBot bot = m_vecDiscordBots[i];

Expand Down Expand Up @@ -74,7 +74,7 @@ void CDiscordBot::PostMessage(const char* sMessage)

bool CDiscordBotManager::LoadDiscordBotsConfig()
{
m_vecDiscordBots.Purge();
m_vecDiscordBots.clear();
KeyValues* pKV = new KeyValues("discordbots");
KeyValues::AutoDelete autoDelete(pKV);

Expand Down Expand Up @@ -105,7 +105,7 @@ bool CDiscordBotManager::LoadDiscordBotsConfig()
ConMsg("Loaded DiscordBot config %s\n", bot.GetName());
ConMsg(" - Webhook URL: %s\n", bot.GetWebhookUrl());
ConMsg(" - Avatar URL: %s\n", bot.GetAvatarUrl());
m_vecDiscordBots.AddToTail(bot);
m_vecDiscordBots.push_back(bot);
}

return true;
Expand Down
3 changes: 1 addition & 2 deletions src/discord.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
*/

#include "httpmanager.h"
#include "utlvector.h"

class CDiscordBot
{
Expand Down Expand Up @@ -55,7 +54,7 @@ class CDiscordBotManager
bool LoadDiscordBotsConfig();

private:
CUtlVector<CDiscordBot> m_vecDiscordBots;
std::vector<CDiscordBot> m_vecDiscordBots;
};

extern CDiscordBotManager* g_pDiscordBotManager;