From 406f64694990ca84622205538a72e080499b4464 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 6 Dec 2020 21:28:40 +0300 Subject: [PATCH] pool stuff fix --- src/control/Phones.cpp | 2 +- src/control/Pickups.cpp | 4 ++-- src/control/Script5.cpp | 12 ++++++------ src/entities/Building.cpp | 4 ++-- src/entities/Dummy.cpp | 2 +- src/objects/Object.cpp | 2 +- src/peds/Ped.cpp | 2 +- src/render/Fluff.cpp | 2 +- src/vehicles/Cranes.cpp | 6 +++--- src/vehicles/Vehicle.cpp | 2 +- 10 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/control/Phones.cpp b/src/control/Phones.cpp index 7f8677ec..edbfe6c2 100644 --- a/src/control/Phones.cpp +++ b/src/control/Phones.cpp @@ -308,7 +308,7 @@ INITSAVEBUF // Convert entity pointer to building pool index while saving if (phone->m_pEntity) { - phone->m_pEntity = (CEntity*) (CPools::GetBuildingPool()->GetJustIndex((CBuilding*)phone->m_pEntity) + 1); + phone->m_pEntity = (CEntity*) (CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert((CBuilding*)phone->m_pEntity) + 1); } } VALIDATESAVEBUF(*size) diff --git a/src/control/Pickups.cpp b/src/control/Pickups.cpp index 1ff4f8f6..45659554 100644 --- a/src/control/Pickups.cpp +++ b/src/control/Pickups.cpp @@ -1458,9 +1458,9 @@ INITSAVEBUF CPickup *buf_pickup = WriteSaveBuf(buf, aPickUps[i]); if (buf_pickup->m_eType != PICKUP_NONE) { if (buf_pickup->m_pObject != nil) - buf_pickup->m_pObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex(buf_pickup->m_pObject) + 1); + buf_pickup->m_pObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(buf_pickup->m_pObject) + 1); if (buf_pickup->m_pExtraObject != nil) - buf_pickup->m_pExtraObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex(buf_pickup->m_pExtraObject) + 1); + buf_pickup->m_pExtraObject = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(buf_pickup->m_pExtraObject) + 1); } } diff --git a/src/control/Script5.cpp b/src/control/Script5.cpp index 7efebb73..1f47c9b9 100644 --- a/src/control/Script5.cpp +++ b/src/control/Script5.cpp @@ -1784,10 +1784,10 @@ INITSAVEBUF handle = 0; } else if (pBuilding->GetIsATreadable()) { type = 1; - handle = CPools::GetTreadablePool()->GetJustIndex((CTreadable*)pBuilding) + 1; + handle = CPools::GetTreadablePool()->GetJustIndex_NoFreeAssert((CTreadable*)pBuilding) + 1; } else { type = 2; - handle = CPools::GetBuildingPool()->GetJustIndex(pBuilding) + 1; + handle = CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(pBuilding) + 1; } WriteSaveBuf(buf, type); WriteSaveBuf(buf, handle); @@ -1805,19 +1805,19 @@ INITSAVEBUF case ENTITY_TYPE_BUILDING: if (((CBuilding*)pEntity)->GetIsATreadable()) { type = 1; - handle = CPools::GetTreadablePool()->GetJustIndex((CTreadable*)pEntity) + 1; + handle = CPools::GetTreadablePool()->GetJustIndex_NoFreeAssert((CTreadable*)pEntity) + 1; } else { type = 2; - handle = CPools::GetBuildingPool()->GetJustIndex((CBuilding*)pEntity) + 1; + handle = CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert((CBuilding*)pEntity) + 1; } break; case ENTITY_TYPE_OBJECT: type = 3; - handle = CPools::GetObjectPool()->GetJustIndex((CObject*)pEntity) + 1; + handle = CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)pEntity) + 1; break; case ENTITY_TYPE_DUMMY: type = 4; - handle = CPools::GetDummyPool()->GetJustIndex((CDummy*)pEntity) + 1; + handle = CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)pEntity) + 1; default: break; } } diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp index 921055ce..8035cf25 100644 --- a/src/entities/Building.cpp +++ b/src/entities/Building.cpp @@ -27,14 +27,14 @@ IsBuildingPointerValid(CBuilding* pBuilding) if (!pBuilding) return false; if (pBuilding->GetIsATreadable()) { - int index = CPools::GetTreadablePool()->GetJustIndex((CTreadable*)pBuilding); + int index = CPools::GetTreadablePool()->GetJustIndex_NoFreeAssert((CTreadable*)pBuilding); #ifdef FIX_BUGS return index >= 0 && index < CPools::GetTreadablePool()->GetSize(); #else return index >= 0 && index <= CPools::GetTreadablePool()->GetSize(); #endif } else { - int index = CPools::GetBuildingPool()->GetJustIndex(pBuilding); + int index = CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(pBuilding); #ifdef FIX_BUGS return index >= 0 && index < CPools::GetBuildingPool()->GetSize(); #else diff --git a/src/entities/Dummy.cpp b/src/entities/Dummy.cpp index 544e24a6..580245a8 100644 --- a/src/entities/Dummy.cpp +++ b/src/entities/Dummy.cpp @@ -58,7 +58,7 @@ IsDummyPointerValid(CDummy* pDummy) { if (!pDummy) return false; - int index = CPools::GetDummyPool()->GetJustIndex(pDummy); + int index = CPools::GetDummyPool()->GetJustIndex_NoFreeAssert(pDummy); #ifdef FIX_BUGS if (index < 0 || index >= CPools::GetDummyPool()->GetSize()) #else diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index 93b6d581..cfff1402 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -527,7 +527,7 @@ IsObjectPointerValid(CObject* pObject) { if (!pObject) return false; - int index = CPools::GetObjectPool()->GetJustIndex(pObject); + int index = CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(pObject); #ifdef FIX_BUGS if (index < 0 || index >= CPools::GetObjectPool()->GetSize()) #else diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp index b7623a33..c9a8ede7 100644 --- a/src/peds/Ped.cpp +++ b/src/peds/Ped.cpp @@ -7846,7 +7846,7 @@ IsPedPointerValid_NotInWorld(CPed* pPed) { if (!pPed) return false; - int index = CPools::GetPedPool()->GetJustIndex(pPed); + int index = CPools::GetPedPool()->GetJustIndex_NoFreeAssert(pPed); #ifdef FIX_BUGS if (index < 0 || index >= NUMPEDS) #else diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index 3c0d3708..e220ce5a 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -1291,7 +1291,7 @@ INITSAVEBUF for (int32 j = 0; j < 6; j++) { if (pPath->m_pObjects[j] != nil) - pPath->m_pObjects[j] = (CObject*)(CPools::GetObjectPool()->GetJustIndex(pPath->m_pObjects[j]) + 1); + pPath->m_pObjects[j] = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(pPath->m_pObjects[j]) + 1); } for (int32 j = 0; j < aArray[i].m_numNodes; j++) { diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp index 2a571a67..8433a0ba 100644 --- a/src/vehicles/Cranes.cpp +++ b/src/vehicles/Cranes.cpp @@ -629,11 +629,11 @@ void CCranes::Save(uint8* buf, uint32* size) for (int i = 0; i < NUM_CRANES; i++) { CCrane *pCrane = WriteSaveBuf(buf, aCranes[i]); if (pCrane->m_pCraneEntity != nil) - pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex(pCrane->m_pCraneEntity) + 1); + pCrane->m_pCraneEntity = (CBuilding*)(CPools::GetBuildingPool()->GetJustIndex_NoFreeAssert(pCrane->m_pCraneEntity) + 1); if (pCrane->m_pHook != nil) - pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex(pCrane->m_pHook) + 1); + pCrane->m_pHook = (CObject*)(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert(pCrane->m_pHook) + 1); if (pCrane->m_pVehiclePickedUp != nil) - pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex(pCrane->m_pVehiclePickedUp) + 1); + pCrane->m_pVehiclePickedUp = (CVehicle*)(CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(pCrane->m_pVehiclePickedUp) + 1); } VALIDATESAVEBUF(*size); diff --git a/src/vehicles/Vehicle.cpp b/src/vehicles/Vehicle.cpp index f083e0f6..56de3562 100644 --- a/src/vehicles/Vehicle.cpp +++ b/src/vehicles/Vehicle.cpp @@ -2492,7 +2492,7 @@ IsVehiclePointerValid(CVehicle* pVehicle) { if (!pVehicle) return false; - int index = CPools::GetVehiclePool()->GetJustIndex(pVehicle); + int index = CPools::GetVehiclePool()->GetJustIndex_NoFreeAssert(pVehicle); #ifdef FIX_BUGS if (index < 0 || index >= NUMVEHICLES) #else