summaryrefslogtreecommitdiffstats
path: root/src/weapons/BulletInfo.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/BulletInfo.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/BulletInfo.cpp')
-rw-r--r--src/weapons/BulletInfo.cpp39
1 files changed, 37 insertions, 2 deletions
diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp
index 129e4b2b..41d9c730 100644
--- a/src/weapons/BulletInfo.cpp
+++ b/src/weapons/BulletInfo.cpp
@@ -24,6 +24,10 @@
#include "World.h"
#include "SurfaceTable.h"
+#ifdef SQUEEZE_PERFORMANCE
+uint32 bulletInfoInUse;
+#endif
+
#define BULLET_LIFETIME (1000)
#define NUM_PED_BLOOD_PARTICLES (8)
#define BLOOD_PARTICLE_OFFSET (CVector(0.0f, 0.0f, 0.0f))
@@ -47,6 +51,9 @@ void CBulletInfo::Initialise(void)
gaBulletInfo[i].m_pSource = nil;
}
debug("CBulletInfo ready\n");
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse = 0;
+#endif
}
void CBulletInfo::Shutdown(void)
@@ -71,11 +78,19 @@ bool CBulletInfo::AddBullet(CEntity* pSource, eWeaponType type, CVector vecPosit
gaBulletInfo[i].m_vecSpeed = vecSpeed;
gaBulletInfo[i].m_fTimer = CTimer::GetTimeInMilliseconds() + BULLET_LIFETIME;
gaBulletInfo[i].m_bInUse = true;
+
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse++;
+#endif
return true;
}
void CBulletInfo::Update(void)
{
+#ifdef SQUEEZE_PERFORMANCE
+ if (bulletInfoInUse == 0)
+ return;
+#endif
bPlayerSniperBullet = false;
for (int i = 0; i < NUM_BULLETS; i++) {
CBulletInfo* pBullet = &gaBulletInfo[i];
@@ -83,8 +98,12 @@ void CBulletInfo::Update(void)
pBullet->m_pSource = nil;
if (!pBullet->m_bInUse)
continue;
- if (CTimer::GetTimeInMilliseconds() > pBullet->m_fTimer)
+ if (CTimer::GetTimeInMilliseconds() > pBullet->m_fTimer) {
pBullet->m_bInUse = false;
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse--;
+#endif
+ }
CVector vecOldPos = pBullet->m_vecPosition;
CVector vecNewPos = pBullet->m_vecPosition + pBullet->m_vecSpeed * CTimer::GetTimeStep() * 0.5f;
CWorld::bIncludeCarTyres = true;
@@ -108,6 +127,9 @@ void CBulletInfo::Update(void)
pPed->InflictDamage(pBullet->m_pSource, pBullet->m_eWeaponType, pBullet->m_nDamage, (ePedPieceTypes)point.pieceB, pPed->GetLocalDirection(pPed->GetPosition() - point.point));
CEventList::RegisterEvent(pPed->m_nPedType == PEDTYPE_COP ? EVENT_SHOOT_COP : EVENT_SHOOT_PED, EVENT_ENTITY_PED, pPed, (CPed*)pBullet->m_pSource, 1000);
pBullet->m_bInUse = false;
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse--;
+#endif
vecNewPos = point.point;
}
if (CGame::nastyGame) {
@@ -130,6 +152,9 @@ void CBulletInfo::Update(void)
}
}
pBullet->m_bInUse = false;
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse--;
+#endif
vecNewPos = point.point;
}
}
@@ -144,6 +169,9 @@ void CBulletInfo::Update(void)
}
#ifdef FIX_BUGS
pBullet->m_bInUse = false;
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse--;
+#endif
vecNewPos = point.point;
#endif
}
@@ -163,6 +191,9 @@ void CBulletInfo::Update(void)
}
#ifdef FIX_BUGS
pBullet->m_bInUse = false;
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse--;
+#endif
vecNewPos = point.point;
#endif
}
@@ -213,8 +244,12 @@ void CBulletInfo::Update(void)
}
pBullet->m_vecPosition = vecNewPos;
if (pBullet->m_vecPosition.x < -MAP_BORDER || pBullet->m_vecPosition.x > MAP_BORDER ||
- pBullet->m_vecPosition.y < -MAP_BORDER || pBullet->m_vecPosition.y > MAP_BORDER)
+ pBullet->m_vecPosition.y < -MAP_BORDER || pBullet->m_vecPosition.y > MAP_BORDER) {
pBullet->m_bInUse = false;
+#ifdef SQUEEZE_PERFORMANCE
+ bulletInfoInUse--;
+#endif
+ }
}
}