Skip to content
Permalink
Browse files

Fix crash in CUnoccupiedVehicleSync::Update

  • Loading branch information...
botder committed Oct 23, 2019
1 parent fe2c374 commit ca698e7abc71c040877407e2560913c1c76088cb
@@ -60,10 +60,13 @@ void CUnoccupiedVehicleSync::OverrideSyncer(CVehicle* pVehicle, CPlayer* pPlayer

void CUnoccupiedVehicleSync::Update()
{
for (auto iter = m_pVehicleManager->IterBegin(); iter != m_pVehicleManager->IterEnd(); /* manual increment */)
std::vector<CVehicle*> vehicles;
vehicles.reserve(m_pVehicleManager->GetVehicleCount());
std::copy(std::begin(m_pVehicleManager->GetVehicles()), std::end(m_pVehicleManager->GetVehicles()), std::back_inserter(vehicles));

for (CVehicle* vehicle : vehicles)
{
std::list<CVehicle*>::const_iterator current = iter++;
UpdateVehicle(*current);
UpdateVehicle(vehicle);
}
}

@@ -26,6 +26,8 @@ class CVehicleManager
friend class CVehicle;

public:
using Container = std::list<CVehicle*>;

CVehicleManager();
~CVehicleManager();

@@ -57,17 +59,20 @@ class CVehicleManager

void GetVehiclesOfType(unsigned int uiModel, lua_State* luaVM);

list<CVehicle*>::const_iterator IterBegin() { return m_List.begin(); };
list<CVehicle*>::const_iterator IterEnd() { return m_List.end(); };
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(); };

list<CVehicle*>& GetRespawnEnabledVehicles() { return m_RespawnEnabledVehicles; };
Container& GetRespawnEnabledVehicles() { return m_RespawnEnabledVehicles; };

private:
void AddToList(CVehicle* pVehicle) { m_List.push_back(pVehicle); };
void RemoveFromList(CVehicle* pVehicle);

CVehicleColorManager m_ColorManager;

list<CVehicle*> m_List;
list<CVehicle*> m_RespawnEnabledVehicles;
Container m_List;
Container m_RespawnEnabledVehicles;
};

0 comments on commit ca698e7

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