mirror of
https://gitlab.com/GaryOderNichts/re3-wiiu.git
synced 2024-12-25 17:21:49 +01:00
Pool fixes from master
This commit is contained in:
parent
579efc05fc
commit
f3e9c82432
@ -1466,7 +1466,7 @@ static bool DoINeedToRefreshPointer(CEntity * pDoor, bool bIsDummy, uint8 nIndex
|
||||
bool bNeedToFindDoorEntities = false;
|
||||
if (pDoor) {
|
||||
if (bIsDummy) {
|
||||
if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex((CDummy*)pDoor)))
|
||||
if (CPools::GetDummyPool()->IsFreeSlot(CPools::GetDummyPool()->GetJustIndex_NoFreeAssert((CDummy*)pDoor)))
|
||||
return true;
|
||||
if (nIndex != (CPools::GetDummyPool()->GetIndex((CDummy*)pDoor) & 0x7F))
|
||||
bNeedToFindDoorEntities = true;
|
||||
@ -1474,7 +1474,7 @@ static bool DoINeedToRefreshPointer(CEntity * pDoor, bool bIsDummy, uint8 nIndex
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex((CObject*)pDoor)))
|
||||
if (CPools::GetObjectPool()->IsFreeSlot(CPools::GetObjectPool()->GetJustIndex_NoFreeAssert((CObject*)pDoor)))
|
||||
return true;
|
||||
if (nIndex != (CPools::GetObjectPool()->GetIndex((CObject*)pDoor) & 0x7F))
|
||||
bNeedToFindDoorEntities = true;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@
|
||||
|
||||
CColPoint gaTempSphereColPoints[MAX_COLLISION_POINTS];
|
||||
|
||||
CPtrList CWorld::ms_bigBuildingsList[4];
|
||||
CPtrList CWorld::ms_bigBuildingsList[NUM_LEVELS];
|
||||
CPtrList CWorld::ms_listMovingEntityPtrs;
|
||||
CSector CWorld::ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
|
||||
uint16 CWorld::ms_nCurrentScanCode;
|
||||
@ -1781,21 +1781,29 @@ CWorld::ShutDown(void)
|
||||
CWorld::Remove(pEntity);
|
||||
delete pEntity;
|
||||
}
|
||||
#ifndef FIX_BUGS
|
||||
pSector->m_lists[ENTITYLIST_BUILDINGS].Flush();
|
||||
pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush();
|
||||
pSector->m_lists[ENTITYLIST_DUMMIES].Flush();
|
||||
pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush();
|
||||
#endif
|
||||
}
|
||||
for(int32 i = 0; i < 4; i++) {
|
||||
for(CPtrNode *pNode = GetBigBuildingList((eLevelName)i).first; pNode; pNode = pNode->next) {
|
||||
for(int32 i = 0; i < NUM_LEVELS; i++) {
|
||||
for(CPtrNode *pNode = ms_bigBuildingsList[i].first; pNode; pNode = pNode->next) {
|
||||
CEntity *pEntity = (CEntity *)pNode->item;
|
||||
// Maybe remove from world here?
|
||||
delete pEntity;
|
||||
}
|
||||
GetBigBuildingList((eLevelName)i).Flush();
|
||||
ms_bigBuildingsList[i].Flush();
|
||||
}
|
||||
for(int i = 0; i < NUMSECTORS_X * NUMSECTORS_Y; i++) {
|
||||
CSector *pSector = GetSector(i % NUMSECTORS_X, i / NUMSECTORS_Y);
|
||||
#ifdef FIX_BUGS
|
||||
pSector->m_lists[ENTITYLIST_BUILDINGS].Flush();
|
||||
pSector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].Flush();
|
||||
pSector->m_lists[ENTITYLIST_DUMMIES].Flush();
|
||||
pSector->m_lists[ENTITYLIST_DUMMIES_OVERLAP].Flush();
|
||||
#endif
|
||||
if(pSector->m_lists[ENTITYLIST_BUILDINGS].first) {
|
||||
sprintf(gString, "Building list %d,%d not empty\n", i % NUMSECTORS_X, i / NUMSECTORS_Y);
|
||||
pSector->m_lists[ENTITYLIST_BUILDINGS].Flush();
|
||||
|
@ -55,7 +55,7 @@ struct CStoredCollPoly;
|
||||
|
||||
class CWorld
|
||||
{
|
||||
static CPtrList ms_bigBuildingsList[4];
|
||||
static CPtrList ms_bigBuildingsList[NUM_LEVELS];
|
||||
static CPtrList ms_listMovingEntityPtrs;
|
||||
static CSector ms_aSectors[NUMSECTORS_Y][NUMSECTORS_X];
|
||||
static uint16 ms_nCurrentScanCode;
|
||||
|
@ -124,12 +124,18 @@ public:
|
||||
(T*)&m_entries[handle >> 8] : nil;
|
||||
}
|
||||
int GetIndex(T *entry){
|
||||
int i = GetJustIndex(entry);
|
||||
int i = GetJustIndex_NoFreeAssert(entry);
|
||||
return m_flags[i].u + (i<<8);
|
||||
}
|
||||
int GetJustIndex(T *entry){
|
||||
// TODO: the cast is unsafe
|
||||
return (int)((U*)entry - m_entries);
|
||||
int index = GetJustIndex_NoFreeAssert(entry);
|
||||
assert(!IsFreeSlot(index));
|
||||
return index;
|
||||
}
|
||||
int GetJustIndex_NoFreeAssert(T* entry){
|
||||
int index = ((U*)entry - m_entries);
|
||||
assert((U*)entry == (U*)&m_entries[index]); // cast is unsafe - check required
|
||||
return index;
|
||||
}
|
||||
int GetNoOfUsedSpaces(void) const {
|
||||
int i;
|
||||
|
@ -1213,7 +1213,8 @@ CBike::ProcessControl(void)
|
||||
|
||||
// Balance bike
|
||||
if(bBalancedByRider || bIsBeingPickedUp || bIsStanding){
|
||||
float onSideness = clamp(DotProduct(GetRight(), m_vecAvgSurfaceNormal), -1.0f, 1.0f);
|
||||
float onSideness = DotProduct(GetRight(), m_vecAvgSurfaceNormal);
|
||||
onSideness = clamp(onSideness, -1.0f, 1.0f);
|
||||
CVector worldCOM = Multiply3x3(GetMatrix(), m_vecCentreOfMass);
|
||||
// Keep bike upright
|
||||
if(bBalancedByRider){
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user