Skip to content
Permalink
Browse files

Remove IterBegin and IterEnd from CVehicleManager

  • Loading branch information...
botder committed Oct 23, 2019
1 parent 3525964 commit d37833637b881d10f04a4482a28d2073fe24e8a3
@@ -133,10 +133,9 @@ void CMapManager::BroadcastMapInformation()
}

// Add the vehicles to the packet
list<CVehicle*>::const_iterator iterVehicles = m_pVehicleManager->IterBegin();
for (; iterVehicles != m_pVehicleManager->IterEnd(); iterVehicles++)
for (CVehicle* vehicle : m_pVehicleManager->GetVehicles())
{
EntityPacket.Add(*iterVehicles);
EntityPacket.Add(vehicle);
}

// Add the teams to the packet
@@ -216,10 +215,9 @@ void CMapManager::SendMapInformation(CPlayer& Player)
marker.Set("Pickups");

// Add the vehicles to the packet
list<CVehicle*>::const_iterator iterVehicles = m_pVehicleManager->IterBegin();
for (; iterVehicles != m_pVehicleManager->IterEnd(); iterVehicles++)
for (CVehicle* vehicle : m_pVehicleManager->GetVehicles())
{
EntityPacket.Add(*iterVehicles);
EntityPacket.Add(vehicle);
}

marker.Set("Vehicles");
@@ -277,17 +275,13 @@ void CMapManager::SendMapInformation(CPlayer& Player)
marker.Set("SendPerPlayerEntities");

// Send the trailer attachments
CVehicle* pVehicle;
CVehicle* pTowedVehicle;
iterVehicles = m_pVehicleManager->IterBegin();
for (; iterVehicles != m_pVehicleManager->IterEnd(); iterVehicles++)
for (CVehicle* vehicle : m_pVehicleManager->GetVehicles())
{
pVehicle = *iterVehicles;
pTowedVehicle = pVehicle->GetTowedVehicle();
CVehicle* towedVehicle = vehicle->GetTowedVehicle();

if (pTowedVehicle)
if (towedVehicle)
{
CVehicleTrailerPacket AttachPacket(pVehicle, pTowedVehicle, true);
CVehicleTrailerPacket AttachPacket(vehicle, towedVehicle, true);
Player.Send(AttachPacket);
}
}
@@ -952,17 +946,16 @@ bool CMapManager::HandleNode(CResource& Loader, CXMLNode& Node, CElement* pParen
void CMapManager::LinkupElements()
{
// * Link up all the attaching elements
list<CVehicle*>::const_iterator iterVehicles = m_pVehicleManager->IterBegin();
for (; iterVehicles != m_pVehicleManager->IterEnd(); iterVehicles++)
for (CVehicle* vehicle : m_pVehicleManager->GetVehicles())
{
CVehicle* pVehicle = *iterVehicles;
const char* szAttachToID = vehicle->GetAttachToID();

const char* szAttachToID = pVehicle->GetAttachToID();
if (szAttachToID[0])
{
CElement* pElement = g_pGame->GetMapManager()->GetRootElement()->FindChild(szAttachToID, 0, true);

if (pElement)
pVehicle->AttachTo(pElement);
vehicle->AttachTo(pElement);
}
}

@@ -199,17 +199,16 @@ void CResourceMapItem::LinkupElements()
{
CDummy* const pRootElement = g_pGame->GetMapManager()->GetRootElement();

for (auto iter = m_pVehicleManager->IterBegin(); iter != m_pVehicleManager->IterEnd(); ++iter)
for (CVehicle* vehicle : m_pVehicleManager->GetVehicles())
{
CVehicle* const pVehicle = *iter;
const char* szAttachToID = pVehicle->GetAttachToID();
const char* szAttachToID = vehicle->GetAttachToID();

if (szAttachToID[0])
{
CElement* const pElement = pRootElement->FindChild(szAttachToID, 0, true);

if (pElement)
pVehicle->AttachTo(pElement);
vehicle->AttachTo(pElement);
}
}

@@ -135,13 +135,11 @@ void CUnoccupiedVehicleSync::UpdateVehicle(CVehicle* pVehicle)
// Called when a player changes dimension
void CUnoccupiedVehicleSync::ResyncForPlayer(CPlayer* pPlayer)
{
list<CVehicle*>::const_iterator iter = m_pVehicleManager->IterBegin();
for (; iter != m_pVehicleManager->IterEnd(); ++iter)
for (CVehicle* vehicle : m_pVehicleManager->GetVehicles())
{
CVehicle* pVehicle = *iter;
if (pVehicle->GetDimension() == pPlayer->GetDimension() && !pVehicle->GetFirstOccupant() && pVehicle->IsUnoccupiedSyncable())
if (vehicle->GetDimension() == pPlayer->GetDimension() && !vehicle->GetFirstOccupant() && vehicle->IsUnoccupiedSyncable())
{
pPlayer->Send(CVehicleResyncPacket(pVehicle));
pPlayer->Send(CVehicleResyncPacket(vehicle));
}
}
}
@@ -63,9 +63,6 @@ class CVehicleManager
Container& GetVehicles() noexcept { return m_List; }
Container const& GetVehicles() const noexcept { return m_List; }

Container::const_iterator IterBegin() { return m_List.begin(); };
Container::const_iterator IterEnd() { return m_List.end(); };

Container& GetRespawnEnabledVehicles() { return m_RespawnEnabledVehicles; };

private:

0 comments on commit d378336

Please sign in to comment.
You can’t perform that action at this time.