@@ -1529,7 +1529,7 @@ void CAdminSystem::AddOrUpdateAdmin(uint64 iSteamID, uint64 iFlags, int iAdminIm
15291529
15301530bool CAdminSystem::LoadInfractions ()
15311531{
1532- m_vecInfractions.PurgeAndDeleteElements ();
1532+ m_vecInfractions.clear ();
15331533 KeyValues* pKV = new KeyValues (" infractions" );
15341534 KeyValues::AutoDelete autoDelete (pKV);
15351535
@@ -1568,13 +1568,13 @@ bool CAdminSystem::LoadInfractions()
15681568 switch (iType)
15691569 {
15701570 case CInfractionBase::Ban:
1571- AddInfraction (new CBanInfraction (iEndTime, iSteamId, true ));
1571+ AddInfraction (std::make_shared< CBanInfraction> (iEndTime, iSteamId, true ));
15721572 break ;
15731573 case CInfractionBase::Mute:
1574- AddInfraction (new CMuteInfraction (iEndTime, iSteamId, true ));
1574+ AddInfraction (std::make_shared< CMuteInfraction> (iEndTime, iSteamId, true ));
15751575 break ;
15761576 case CInfractionBase::Gag:
1577- AddInfraction (new CGagInfraction (iEndTime, iSteamId, true ));
1577+ AddInfraction (std::make_shared< CGagInfraction> (iEndTime, iSteamId, true ));
15781578 break ;
15791579 default :
15801580 Warning (" Invalid infraction type %d\n " , iType);
@@ -1590,7 +1590,7 @@ void CAdminSystem::SaveInfractions()
15901590 KeyValues* pSubKey;
15911591 KeyValues::AutoDelete autoDelete (pKV);
15921592
1593- FOR_EACH_VEC ( m_vecInfractions, i )
1593+ for ( int i = 0 ; i < m_vecInfractions. size (); i++ )
15941594 {
15951595 time_t timestamp = m_vecInfractions[i]->GetTimestamp ();
15961596 if (timestamp != 0 && timestamp < std::time (0 ))
@@ -1616,17 +1616,17 @@ void CAdminSystem::SaveInfractions()
16161616 Warning (" Failed to save infractions to %s\n " , szPath);
16171617}
16181618
1619- void CAdminSystem::AddInfraction (CInfractionBase* infraction )
1619+ void CAdminSystem::AddInfraction (std::shared_ptr< CInfractionBase> pInfraction )
16201620{
1621- m_vecInfractions.AddToTail (infraction );
1621+ m_vecInfractions.push_back (pInfraction );
16221622}
16231623
16241624// This function can run at least twice when a player connects: Immediately upon client connection, and also upon getting authenticated by steam.
16251625// It's also run when we're periodically checking for infraction expiry in the case of mutes/gags.
16261626// This returns false only when called from ClientConnect and the player is banned in order to reject them.
16271627bool CAdminSystem::ApplyInfractions (ZEPlayer* player)
16281628{
1629- FOR_EACH_VEC ( m_vecInfractions, i )
1629+ for ( int i = m_vecInfractions. size () - 1 ; i >= 0 ; i-- )
16301630 {
16311631 // Because this can run without the player being authenticated, and the fact that we're applying a ban/mute here,
16321632 // we can immediately just use the steamid we got from the connecting player.
@@ -1642,7 +1642,7 @@ bool CAdminSystem::ApplyInfractions(ZEPlayer* player)
16421642 time_t timestamp = m_vecInfractions[i]->GetTimestamp ();
16431643 if (timestamp != 0 && timestamp <= std::time (0 ))
16441644 {
1645- m_vecInfractions.Remove ( i);
1645+ m_vecInfractions.erase (m_vecInfractions. begin () + i);
16461646 continue ;
16471647 }
16481648
@@ -1658,12 +1658,12 @@ bool CAdminSystem::ApplyInfractions(ZEPlayer* player)
16581658
16591659bool CAdminSystem::FindAndRemoveInfraction (ZEPlayer* player, CInfractionBase::EInfractionType type)
16601660{
1661- FOR_EACH_VEC_BACK ( m_vecInfractions, i )
1661+ for ( int i = m_vecInfractions. size () - 1 ; i >= 0 ; i-- )
16621662 {
16631663 if (m_vecInfractions[i]->GetSteamId64 () == player->GetSteamId64 () && m_vecInfractions[i]->GetType () == type)
16641664 {
16651665 m_vecInfractions[i]->UndoInfraction (player);
1666- m_vecInfractions.Remove ( i);
1666+ m_vecInfractions.erase (m_vecInfractions. begin () + i);
16671667
16681668 return true ;
16691669 }
@@ -1674,11 +1674,11 @@ bool CAdminSystem::FindAndRemoveInfraction(ZEPlayer* player, CInfractionBase::EI
16741674
16751675bool CAdminSystem::FindAndRemoveInfractionSteamId64 (uint64 steamid64, CInfractionBase::EInfractionType type)
16761676{
1677- FOR_EACH_VEC_BACK ( m_vecInfractions, i )
1677+ for ( int i = m_vecInfractions. size () - 1 ; i >= 0 ; i-- )
16781678 {
16791679 if (m_vecInfractions[i]->GetSteamId64 () == steamid64 && m_vecInfractions[i]->GetType () == type)
16801680 {
1681- m_vecInfractions.Remove ( i);
1681+ m_vecInfractions.erase (m_vecInfractions. begin () + i);
16821682
16831683 return true ;
16841684 }
@@ -1961,31 +1961,31 @@ void ParseInfraction(const CCommand& args, CCSPlayerController* pAdmin, bool bAd
19611961 g_pAdminSystem->FindAndRemoveInfraction (zpTarget, infType);
19621962 else
19631963 {
1964- CInfractionBase* infraction ;
1964+ std::shared_ptr< CInfractionBase> pInfraction ;
19651965 switch (infType)
19661966 {
19671967 case CInfractionBase::Mute:
1968- infraction = new CMuteInfraction (iDuration, zpTarget->GetSteamId64 ());
1968+ pInfraction = std::make_shared< CMuteInfraction> (iDuration, zpTarget->GetSteamId64 ());
19691969 break ;
19701970 case CInfractionBase::Gag:
1971- infraction = new CGagInfraction (iDuration, zpTarget->GetSteamId64 ());
1971+ pInfraction = std::make_shared< CGagInfraction> (iDuration, zpTarget->GetSteamId64 ());
19721972 break ;
19731973 case CInfractionBase::Ban:
1974- infraction = new CBanInfraction (iDuration, zpTarget->GetSteamId64 ());
1974+ pInfraction = std::make_shared< CBanInfraction> (iDuration, zpTarget->GetSteamId64 ());
19751975 break ;
19761976 case CInfractionBase::Eban:
1977- infraction = new CEbanInfraction (iDuration, zpTarget->GetSteamId64 ());
1977+ pInfraction = std::make_shared< CEbanInfraction> (iDuration, zpTarget->GetSteamId64 ());
19781978 break ;
19791979 default :
1980- // This should never be reached, since we it means we are trying to apply an unimplemented block type
1980+ // This should never be reached, since it means we are trying to apply an unimplemented block type
19811981 ClientPrint (pAdmin, HUD_PRINTTALK, CHAT_PREFIX " Improper block type... Send to a dev with the command used." );
19821982 return ;
19831983 }
19841984
19851985 // We're overwriting the infraction, so remove the previous one first
19861986 g_pAdminSystem->FindAndRemoveInfraction (zpTarget, infType);
1987- g_pAdminSystem->AddInfraction (infraction );
1988- infraction ->ApplyInfraction (zpTarget);
1987+ g_pAdminSystem->AddInfraction (pInfraction );
1988+ pInfraction ->ApplyInfraction (zpTarget);
19891989 }
19901990
19911991 if (iNumClients == 1 || (bAdding && iDuration == 0 ))
0 commit comments