diff options
Diffstat (limited to 'src/objects')
-rw-r--r-- | src/objects/CutsceneHead.cpp | 3 | ||||
-rw-r--r-- | src/objects/Object.cpp | 40 | ||||
-rw-r--r-- | src/objects/Object.h | 8 | ||||
-rw-r--r-- | src/objects/ParticleObject.cpp | 2 |
4 files changed, 37 insertions, 16 deletions
diff --git a/src/objects/CutsceneHead.cpp b/src/objects/CutsceneHead.cpp index 15611c29..19b3a592 100644 --- a/src/objects/CutsceneHead.cpp +++ b/src/objects/CutsceneHead.cpp @@ -85,7 +85,6 @@ CCutsceneHead::ProcessControl(void) { m_matrix.SetRotateY(PI/2); m_matrix = CMatrix(RwFrameGetLTM(m_pHeadNode)) * m_matrix; - UpdateRwFrame(); // android/xbox don't call this } assert(RwObjectGetType(m_rwObject) == rpCLUMP); @@ -95,7 +94,7 @@ CCutsceneHead::ProcessControl(void) // PS2 only plays anims in cutscene, PC always plays anims if(!lastLoadedSKA || CCutsceneMgr::IsRunning()) #endif - RpHAnimHierarchyAddAnimTime(hier, CTimer::GetTimeStepNonClipped()/50.0f); + RpHAnimHierarchyAddAnimTime(hier, CTimer::GetTimeStepNonClippedInSeconds()); } void diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index 411e245a..2a7de2c7 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -16,10 +16,32 @@ int16 CObject::nNoTempObjects; int16 CObject::nBodyCastHealth = 1000; -void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); } -void *CObject::operator new(size_t sz, int handle) { return CPools::GetObjectPool()->New(handle);}; -void CObject::operator delete(void *p, size_t sz) { CPools::GetObjectPool()->Delete((CObject*)p); } -void CObject::operator delete(void *p, int handle) { CPools::GetObjectPool()->Delete((CObject*)p); } +// Object pools tends to be full sometimes, let's free a temp. object in this case. +#ifdef FIX_BUGS +void *CObject::operator new(size_t sz) throw() { + CObject *obj = CPools::GetObjectPool()->New(); + if (!obj) { + CObjectPool *objectPool = CPools::GetObjectPool(); + for (int32 i = 0; i < objectPool->GetSize(); i++) { + CObject *existing = objectPool->GetSlot(i); + if (existing && existing->ObjectCreatedBy == TEMP_OBJECT) { + int32 handle = objectPool->GetIndex(existing); + CWorld::Remove(existing); + delete existing; + obj = objectPool->New(handle); + break; + } + } + } + return obj; +} +#else +void *CObject::operator new(size_t sz) throw() { return CPools::GetObjectPool()->New(); } +#endif +void *CObject::operator new(size_t sz, int handle) throw() { return CPools::GetObjectPool()->New(handle); }; + +void CObject::operator delete(void *p, size_t sz) throw() { CPools::GetObjectPool()->Delete((CObject*)p); } +void CObject::operator delete(void *p, int handle) throw() { CPools::GetObjectPool()->Delete((CObject*)p); } CObject::CObject(void) { @@ -63,7 +85,7 @@ CObject::CObject(CDummyObject *dummy) if (dummy->m_rwObject) AttachToRwObject(dummy->m_rwObject); else - GetMatrix() = dummy->GetMatrix(); + SetMatrix(dummy->GetMatrix()); m_objectMatrix = dummy->GetMatrix(); dummy->DetachFromRwObject(); @@ -112,8 +134,8 @@ void CObject::Teleport(CVector vecPos) { CWorld::Remove(this); - m_matrix.GetPosition() = vecPos; - m_matrix.UpdateRW(); + GetMatrix().GetPosition() = vecPos; + GetMatrix().UpdateRW(); UpdateRwFrame(); CWorld::Add(this); } @@ -170,7 +192,7 @@ CObject::ObjectDamage(float amount) amount = 0.0f; } if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { - const CVector& vecPos = m_matrix.GetPosition(); + const CVector& vecPos = GetMatrix().GetPosition(); const float fDirectionZ = 0.0002f * amount; switch (m_nCollisionDamageEffect) { @@ -329,7 +351,7 @@ CObject::Init(void) m_pCollidingEntity = nil; CColPoint point; CEntity* outEntity = nil; - const CVector& vecPos = m_matrix.GetPosition(); + const CVector& vecPos = GetMatrix().GetPosition(); if (CWorld::ProcessVerticalLine(vecPos, vecPos.z - 10.0f, point, outEntity, true, false, false, false, false, false, nil)) m_pCurSurface = outEntity; else diff --git a/src/objects/Object.h b/src/objects/Object.h index c9a1bba8..114a1a9f 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -65,10 +65,10 @@ public: static int16 nNoTempObjects; static int16 nBodyCastHealth; - static void *operator new(size_t); - static void *operator new(size_t, int); - static void operator delete(void*, size_t); - static void operator delete(void*, int); + static void *operator new(size_t) throw(); + static void *operator new(size_t, int) throw(); + static void operator delete(void*, size_t) throw(); + static void operator delete(void*, int) throw(); CObject(void); CObject(int32, bool); diff --git a/src/objects/ParticleObject.cpp b/src/objects/ParticleObject.cpp index 71f223d7..211a568c 100644 --- a/src/objects/ParticleObject.cpp +++ b/src/objects/ParticleObject.cpp @@ -33,7 +33,7 @@ CAudioHydrant::Add(CParticleObject *particleobject) if ( AEHANDLE_IS_FAILED(List[i].AudioEntity) ) return false; - DMAudio.SetEntityStatus(List[i].AudioEntity, true); + DMAudio.SetEntityStatus(List[i].AudioEntity, TRUE); List[i].pParticleObject = particleobject; |