diff options
Diffstat (limited to '')
-rw-r--r-- | src/weapons/ProjectileInfo.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/weapons/ProjectileInfo.cpp b/src/weapons/ProjectileInfo.cpp index 35e55b36..4150852a 100644 --- a/src/weapons/ProjectileInfo.cpp +++ b/src/weapons/ProjectileInfo.cpp @@ -13,6 +13,10 @@ #include "Weapon.h" #include "World.h" +#ifdef SQUEEZE_PERFORMANCE +uint32 projectileInUse; +#endif + CProjectileInfo gaProjectileInfo[NUM_PROJECTILES]; CProjectile *CProjectileInfo::ms_apProjectile[NUM_PROJECTILES]; @@ -30,6 +34,10 @@ CProjectileInfo::Initialise() } debug("CProjectileInfo ready\n"); + +#ifdef SQUEEZE_PERFORMANCE + projectileInUse = 0; +#endif } void @@ -163,6 +171,10 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos, ms_apProjectile[i]->m_fElasticity = elasticity; ms_apProjectile[i]->m_nSpecialCollisionResponseCases = SpecialCollisionResponseCase; +#ifdef SQUEEZE_PERFORMANCE + projectileInUse++; +#endif + gaProjectileInfo[i].m_bInUse = true; CWorld::Add(ms_apProjectile[i]); @@ -178,6 +190,9 @@ void CProjectileInfo::RemoveProjectile(CProjectileInfo *info, CProjectile *projectile) { RemoveNotAdd(info->m_pSource, info->m_eWeaponType, projectile->GetPosition()); +#ifdef SQUEEZE_PERFORMANCE + projectileInUse--; +#endif info->m_bInUse = false; CWorld::Remove(projectile); @@ -205,6 +220,11 @@ CProjectileInfo::RemoveNotAdd(CEntity *entity, eWeaponType weaponType, CVector p void CProjectileInfo::Update() { +#ifdef SQUEEZE_PERFORMANCE + if (projectileInUse == 0) + return; +#endif + for (int i = 0; i < ARRAY_SIZE(gaProjectileInfo); i++) { if (!gaProjectileInfo[i].m_bInUse) continue; @@ -213,6 +233,10 @@ CProjectileInfo::Update() gaProjectileInfo[i].m_pSource = nil; if (ms_apProjectile[i] == nil) { +#ifdef SQUEEZE_PERFORMANCE + projectileInUse--; +#endif + gaProjectileInfo[i].m_bInUse = false; continue; } @@ -276,6 +300,10 @@ CProjectileInfo::IsProjectileInRange(float x1, float x2, float y1, float y2, flo if (pos.x >= x1 && pos.x <= x2 && pos.y >= y1 && pos.y <= y2 && pos.z >= z1 && pos.z <= z2) { result = true; if (remove) { +#ifdef SQUEEZE_PERFORMANCE + projectileInUse--; +#endif + gaProjectileInfo[i].m_bInUse = false; CWorld::Remove(ms_apProjectile[i]); delete ms_apProjectile[i]; @@ -304,8 +332,17 @@ CProjectileInfo::RemoveDetonatorProjectiles() void CProjectileInfo::RemoveAllProjectiles() { +#ifdef SQUEEZE_PERFORMANCE + if (projectileInUse == 0) + return; +#endif + for (int i = 0; i < ARRAY_SIZE(ms_apProjectile); i++) { if (gaProjectileInfo[i].m_bInUse) { +#ifdef SQUEEZE_PERFORMANCE + projectileInUse--; +#endif + gaProjectileInfo[i].m_bInUse = false; CWorld::Remove(ms_apProjectile[i]); delete ms_apProjectile[i]; @@ -316,12 +353,21 @@ CProjectileInfo::RemoveAllProjectiles() bool CProjectileInfo::RemoveIfThisIsAProjectile(CObject *object) { +#ifdef SQUEEZE_PERFORMANCE + if (projectileInUse == 0) + return false; +#endif + int i = 0; while (ms_apProjectile[i++] != object) { if (i >= ARRAY_SIZE(ms_apProjectile)) return false; } +#ifdef SQUEEZE_PERFORMANCE + projectileInUse--; +#endif + gaProjectileInfo[i].m_bInUse = false; CWorld::Remove(ms_apProjectile[i]); delete ms_apProjectile[i]; |