Skip to content

Commit e250854

Browse files
committed
Convert adminsystem vector to std::vector
1 parent a960161 commit e250854

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

src/adminsystem.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1531,7 +1531,7 @@ void CAdminSystem::AddOrUpdateAdmin(uint64 iSteamID, uint64 iFlags, int iAdminIm
15311531

15321532
bool CAdminSystem::LoadInfractions()
15331533
{
1534-
m_vecInfractions.PurgeAndDeleteElements();
1534+
m_vecInfractions.clear();
15351535
KeyValues* pKV = new KeyValues("infractions");
15361536
KeyValues::AutoDelete autoDelete(pKV);
15371537

@@ -1592,7 +1592,7 @@ void CAdminSystem::SaveInfractions()
15921592
KeyValues* pSubKey;
15931593
KeyValues::AutoDelete autoDelete(pKV);
15941594

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

16211621
void CAdminSystem::AddInfraction(CInfractionBase* infraction)
16221622
{
1623-
m_vecInfractions.AddToTail(infraction);
1623+
m_vecInfractions.push_back(infraction);
16241624
}
16251625

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

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

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

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

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

16851685
return true;
16861686
}

src/adminsystem.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
#pragma once
2121
#include "platform.h"
2222
#include "playermanager.h"
23-
#include "utlvector.h"
2423
#include <ctime>
2524

2625
// clang-format off
@@ -196,7 +195,7 @@ class CAdminSystem
196195
private:
197196
std::map<std::string, CAdminBase> m_mapAdminGroups;
198197
std::map<uint64, CAdmin> m_mapAdmins;
199-
CUtlVector<CInfractionBase*> m_vecInfractions;
198+
std::vector<CInfractionBase*> m_vecInfractions;
200199

201200
// Implemented as a circular buffer.
202201
std::tuple<std::string, uint64, std::string> m_rgDCPly[20];

0 commit comments

Comments
 (0)