summaryrefslogtreecommitdiffstats
path: root/src/weapons
diff options
context:
space:
mode:
Diffstat (limited to 'src/weapons')
-rw-r--r--src/weapons/BulletInfo.cpp39
-rw-r--r--src/weapons/ProjectileInfo.cpp46
-rw-r--r--src/weapons/ShotInfo.cpp20
3 files changed, 102 insertions, 3 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
+ }
}
}
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];
diff --git a/src/weapons/ShotInfo.cpp b/src/weapons/ShotInfo.cpp
index 6fc6341d..a70f3f7b 100644
--- a/src/weapons/ShotInfo.cpp
+++ b/src/weapons/ShotInfo.cpp
@@ -13,6 +13,9 @@
CShotInfo gaShotInfo[NUMSHOTINFOS];
float CShotInfo::ms_afRandTable[20];
+#ifdef SQUEEZE_PERFORMANCE
+uint32 shotInfoInUse;
+#endif
/*
Used for flamethrower. I don't know why it's name is CShotInfo.
@@ -41,6 +44,9 @@ CShotInfo::Initialise()
nextVal += 0.005f;
}
debug("CShotInfo ready\n");
+#ifdef SQUEEZE_PERFORMANCE
+ shotInfoInUse = 0;
+#endif
}
bool
@@ -54,6 +60,10 @@ CShotInfo::AddShot(CEntity *sourceEntity, eWeaponType weapon, CVector startPos,
if (slot == ARRAY_SIZE(gaShotInfo))
return false;
+#ifdef SQUEEZE_PERFORMANCE
+ shotInfoInUse++;
+#endif
+
gaShotInfo[slot].m_inUse = true;
gaShotInfo[slot].m_weapon = weapon;
gaShotInfo[slot].m_startPos = startPos;
@@ -87,6 +97,10 @@ CShotInfo::Shutdown()
void
CShotInfo::Update()
{
+#ifdef SQUEEZE_PERFORMANCE
+ if (shotInfoInUse == 0)
+ return;
+#endif
for (int slot = 0; slot < ARRAY_SIZE(gaShotInfo); slot++) {
CShotInfo &shot = gaShotInfo[slot];
if (shot.m_sourceEntity && shot.m_sourceEntity->IsPed() && !((CPed*)shot.m_sourceEntity)->IsPointerValid())
@@ -96,8 +110,12 @@ CShotInfo::Update()
continue;
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(shot.m_weapon);
- if (CTimer::GetTimeInMilliseconds() > shot.m_timeout)
+ if (CTimer::GetTimeInMilliseconds() > shot.m_timeout) {
+#ifdef SQUEEZE_PERFORMANCE
+ shotInfoInUse--;
+#endif
shot.m_inUse = false;
+ }
if (weaponInfo->m_bSlowsDown)
shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE