diff options
Diffstat (limited to '')
-rw-r--r-- | src/objects/Object.cpp | 42 | ||||
-rw-r--r-- | src/objects/Object.h | 31 |
2 files changed, 49 insertions, 24 deletions
diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp index a5896975..daa48d98 100644 --- a/src/objects/Object.cpp +++ b/src/objects/Object.cpp @@ -11,9 +11,11 @@ #include "ObjectData.h" #include "World.h" #include "Floater.h" +#include "soundlist.h" int16 CObject::nNoTempObjects; -int16 CObject::nBodyCastHealth = 1000; +//int16 CObject::nBodyCastHealth = 1000; +float CObject::fDistToNearestTree; 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);}; @@ -160,6 +162,7 @@ CObject::ObjectDamage(float amount) return; static int8 nFrameGen = 0; bool bBodyCastDamageEffect = false; +#if 0 if (GetModelIndex() == MI_BODYCAST) { if (amount > 50.0f) nBodyCastHealth = (int16)(nBodyCastHealth - 0.5f * amount); @@ -169,6 +172,7 @@ CObject::ObjectDamage(float amount) bBodyCastDamageEffect = true; amount = 0.0f; } +#endif if ((amount * m_fCollisionDamageMultiplier > 150.0f || bBodyCastDamageEffect) && m_nCollisionDamageEffect) { const CVector& vecPos = m_matrix.GetPosition(); const float fDirectionZ = 0.0002f * amount; @@ -220,7 +224,7 @@ CObject::ObjectDamage(float amount) int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); } - PlayOneShotScriptObject(_SCRSOUND_CARDBOARD_BOX_SMASH, vecPos); + PlayOneShotScriptObject(SCRIPT_SOUND_BOX_DESTROYED_2, vecPos); break; } case DAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { @@ -243,7 +247,7 @@ CObject::ObjectDamage(float amount) int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, randomColor, nRotationSpeed, 0, currentFrame, 0); } - PlayOneShotScriptObject(_SCRSOUND_WOODEN_BOX_SMASH, vecPos); + PlayOneShotScriptObject(SCRIPT_SOUND_BOX_DESTROYED_1, vecPos); break; } case DAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { @@ -268,7 +272,7 @@ CObject::ObjectDamage(float amount) int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); } - PlayOneShotScriptObject(_SCRSOUND_TYRE_BUMP, vecPos); + PlayOneShotScriptObject(SCRIPT_SOUND_TIRE_COLLISION, vecPos); break; } case DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { @@ -293,7 +297,7 @@ CObject::ObjectDamage(float amount) int32 nRotationSpeed = CGeneral::GetRandomNumberInRange(-40, 80); CParticle::AddParticle(PARTICLE_CAR_DEBRIS, vecPos, vecDir, nil, fSize, color, nRotationSpeed, 0, currentFrame, 0); } - PlayOneShotScriptObject(_SCRSOUND_COL_CAR, vecPos); + PlayOneShotScriptObject(SCRIPT_SOUND_METAL_COLLISION, vecPos); break; } } @@ -326,6 +330,8 @@ CObject::Init(void) m_colour1 = 0; m_colour2 = 0; m_nBonusValue = 0; + bIsWeapon = false; +// TODO(MIAMI): some new field here m_pCollidingEntity = nil; CColPoint point; CEntity* outEntity = nil; @@ -334,10 +340,15 @@ CObject::Init(void) m_pCurSurface = outEntity; else m_pCurSurface = nil; - if (GetModelIndex() == MI_BODYCAST) - nBodyCastHealth = 1000; - else if (GetModelIndex() == MI_BUOY) + + if (GetModelIndex() == MI_BUOY) bTouchingWater = true; + + if(CModelInfo::GetModelInfo(GetModelIndex())->GetModelType() == MITYPE_WEAPON) + bIsWeapon = true; + bIsStreetLight = IsLightObject(GetModelIndex()); + + m_area = AREA_EVERYWHERE; } bool @@ -395,3 +406,18 @@ CObject::DeleteAllTempObjectsInArea(CVector point, float fRadius) } } } + +bool +IsObjectPointerValid(CObject* pObject) +{ + if (!pObject) + return false; + int index = CPools::GetObjectPool()->GetJustIndex(pObject); +#ifdef FIX_BUGS + if (index < 0 || index >= CPools::GetObjectPool()->GetSize()) +#else + if (index < 0 || index > CPools::GetObjectPool()->GetSize()) +#endif + return false; + return pObject->bIsBIGBuilding || pObject->m_entryInfoList.first; +} diff --git a/src/objects/Object.h b/src/objects/Object.h index 20c99b1b..5a9c0195 100644 --- a/src/objects/Object.h +++ b/src/objects/Object.h @@ -59,26 +59,23 @@ public: CMatrix m_objectMatrix; float m_fUprootLimit; int8 ObjectCreatedBy; - int8 bIsPickup : 1; - int8 bPickupObjWithMessage : 1; - int8 bOutOfStock : 1; - int8 bGlassCracked : 1; - int8 bGlassBroken : 1; - int8 bHasBeenDamaged : 1; - int8 bUseVehicleColours : 1; + uint8 bIsPickup : 1; + uint8 obj_flag_02 : 1; + uint8 bPickupObjWithMessage : 1; + uint8 bOutOfStock : 1; + uint8 bGlassCracked : 1; + uint8 bGlassBroken : 1; + uint8 bHasBeenDamaged : 1; + uint8 bUseVehicleColours : 1; + uint8 bIsWeapon : 1; + uint8 bIsStreetLight : 1; int8 m_nBonusValue; float m_fCollisionDamageMultiplier; uint8 m_nCollisionDamageEffect; uint8 m_nSpecialCollisionResponseCases; bool m_bCameraToAvoidThisObject; - - // this batch is unused - int8 field_17B; - int8 field_17C; - int8 field_17D; - int8 field_17E; - int8 field_17F; - + int8 m_nBeachballBounces; + uint32 m_obj_unused1; uint32 m_nEndOfLifeTime; int16 m_nRefModelIndex; CEntity *m_pCurSurface; @@ -86,7 +83,7 @@ public: int8 m_colour1, m_colour2; static int16 nNoTempObjects; - static int16 nBodyCastHealth; + static float fDistToNearestTree; static void *operator new(size_t); static void *operator new(size_t, int); @@ -113,3 +110,5 @@ public: static void DeleteAllTempObjects(); static void DeleteAllTempObjectsInArea(CVector point, float fRadius); }; + +bool IsObjectPointerValid(CObject* pObject); |