summaryrefslogtreecommitdiffstats
path: root/src/weapons/ProjectileInfo.cpp
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-08-07 11:34:41 +0200
committerSergeanur <s.anureev@yandex.ua>2020-08-07 11:34:41 +0200
commit7d8ffa9ebd32257d6aa59e27cd25a657a85613da (patch)
tree0eff46681a3524fd86a63bc8a0eb65b3c7409b5b /src/weapons/ProjectileInfo.cpp
parentMerge pull request #670 from Fire-Head/miami (diff)
parentMerge pull request #675 from erorcun/master (diff)
downloadre3-7d8ffa9ebd32257d6aa59e27cd25a657a85613da.tar
re3-7d8ffa9ebd32257d6aa59e27cd25a657a85613da.tar.gz
re3-7d8ffa9ebd32257d6aa59e27cd25a657a85613da.tar.bz2
re3-7d8ffa9ebd32257d6aa59e27cd25a657a85613da.tar.lz
re3-7d8ffa9ebd32257d6aa59e27cd25a657a85613da.tar.xz
re3-7d8ffa9ebd32257d6aa59e27cd25a657a85613da.tar.zst
re3-7d8ffa9ebd32257d6aa59e27cd25a657a85613da.zip
Diffstat (limited to 'src/weapons/ProjectileInfo.cpp')
-rw-r--r--src/weapons/ProjectileInfo.cpp46
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];