From e14252914e9bd4cf7702479b5e0b050b935ba4aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?eray=20or=C3=A7unus?= Date: Mon, 3 Aug 2020 04:00:12 +0300 Subject: [PATCH] Squeeze performance option, minor fixes Fixes are already in miami --- src/control/RoadBlocks.cpp | 4 +++ src/core/Accident.cpp | 4 +++ src/core/Accident.h | 1 - src/core/Collision.h | 2 +- src/core/EventList.cpp | 8 ++++++ src/core/Game.cpp | 3 +++ src/core/Pad.cpp | 2 ++ src/core/World.cpp | 5 ++++ src/core/Zones.cpp | 5 ++++ src/core/config.h | 11 +++++++- src/core/main.cpp | 2 ++ src/peds/CopPed.cpp | 4 +-- src/peds/Population.cpp | 11 ++++++++ src/render/Fluff.cpp | 5 ++-- src/render/Font.h | 2 +- src/render/Renderer.cpp | 6 ++++- src/render/Rubbish.h | 4 +++ src/render/Sprite2d.cpp | 9 +++++++ src/weapons/BulletInfo.cpp | 39 ++++++++++++++++++++++++++-- src/weapons/ProjectileInfo.cpp | 46 ++++++++++++++++++++++++++++++++++ src/weapons/ShotInfo.cpp | 20 ++++++++++++++- 21 files changed, 181 insertions(+), 12 deletions(-) diff --git a/src/control/RoadBlocks.cpp b/src/control/RoadBlocks.cpp index ee9ec17e..86b4caf1 100644 --- a/src/control/RoadBlocks.cpp +++ b/src/control/RoadBlocks.cpp @@ -105,6 +105,10 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType void CRoadBlocks::GenerateRoadBlocks(void) { +#ifdef SQUEEZE_PERFORMANCE + if (FindPlayerPed()->m_pWanted->m_RoadblockDensity == 0) + return; +#endif CMatrix offsetMatrix; uint32 frame = CTimer::GetFrameCounter() & 0xF; int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16; diff --git a/src/core/Accident.cpp b/src/core/Accident.cpp index 1fd6c123..c8611323 100644 --- a/src/core/Accident.cpp +++ b/src/core/Accident.cpp @@ -53,6 +53,10 @@ CAccidentManager::ReportAccident(CPed *ped) void CAccidentManager::Update() { +#ifdef SQUEEZE_PERFORMANCE + // Handled after injury registered. + return; +#endif int32 e; if (CEventList::GetEvent(EVENT_INJURED_PED, &e)) { CPed *ped = CPools::GetPed(gaEvent[e].entityRef); diff --git a/src/core/Accident.h b/src/core/Accident.h index 949d5fb9..568e1149 100644 --- a/src/core/Accident.h +++ b/src/core/Accident.h @@ -1,5 +1,4 @@ #pragma once -#include "common.h" #include "config.h" class CPed; diff --git a/src/core/Collision.h b/src/core/Collision.h index d988f0c2..367ffa29 100644 --- a/src/core/Collision.h +++ b/src/core/Collision.h @@ -4,7 +4,7 @@ #include "Game.h" // for eLevelName // If you spawn many tanks at once, you will see that collisions of two entity exceeds 32. -#ifdef FIX_BUGS +#if defined(FIX_BUGS) && !defined(SQUEEZE_PERFORMANCE) #define MAX_COLLISION_POINTS 64 #else #define MAX_COLLISION_POINTS 32 diff --git a/src/core/EventList.cpp b/src/core/EventList.cpp index 675040ea..8d69ba78 100644 --- a/src/core/EventList.cpp +++ b/src/core/EventList.cpp @@ -8,6 +8,7 @@ #include "Messages.h" #include "Text.h" #include "main.h" +#include "Accident.h" int32 CEventList::ms_nFirstFreeSlotIndex; CEvent gaEvent[NUMEVENTS]; @@ -63,6 +64,13 @@ CEventList::RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent int ref; bool copsDontCare; +#ifdef SQUEEZE_PERFORMANCE + if (type == EVENT_INJURED_PED) { + gAccidentManager.ReportAccident((CPed*)ent); + return; + } +#endif + copsDontCare = false; switch(entityType){ case EVENT_ENTITY_PED: diff --git a/src/core/Game.cpp b/src/core/Game.cpp index 82e6992d..08623c65 100644 --- a/src/core/Game.cpp +++ b/src/core/Game.cpp @@ -106,6 +106,7 @@ int gameTxdSlot; bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); void DoRWStuffEndOfFrame(void); +#ifdef PS2_MENU void MessageScreen(char *msg) { //TODO: stretch_screen @@ -139,6 +140,7 @@ void MessageScreen(char *msg) DoRWStuffEndOfFrame(); } +#endif bool CGame::InitialiseOnceBeforeRW(void) @@ -431,6 +433,7 @@ bool CGame::Initialise(const char* datFile) if ( !TheMemoryCard.m_bWantToLoad ) { #endif + LoadingScreen("Loading the Game", "Start script", nil); CTheScripts::StartTestScript(); CTheScripts::Process(); TheCamera.Process(); diff --git a/src/core/Pad.cpp b/src/core/Pad.cpp index 7df548aa..d4ffc5ea 100644 --- a/src/core/Pad.cpp +++ b/src/core/Pad.cpp @@ -1104,7 +1104,9 @@ void CPad::UpdatePads(void) if ( bUpdate ) { GetPad(0)->Update(0); +#ifndef SQUEEZE_PERFORMANCE GetPad(1)->Update(0); +#endif } #if defined(MASTER) && !defined(XINPUT) diff --git a/src/core/World.cpp b/src/core/World.cpp index 9f384048..7f8d8994 100644 --- a/src/core/World.cpp +++ b/src/core/World.cpp @@ -1941,6 +1941,11 @@ CWorld::Process(void) } else { for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { CEntity *movingEnt = (CEntity *)node->item; +#ifdef SQUEEZE_PERFORMANCE + if (movingEnt->bRemoveFromWorld) { + RemoveEntityInsteadOfProcessingIt(movingEnt); + } else +#endif if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP && RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), diff --git a/src/core/Zones.cpp b/src/core/Zones.cpp index 1556731b..2e3e0f6e 100644 --- a/src/core/Zones.cpp +++ b/src/core/Zones.cpp @@ -7,6 +7,7 @@ #include "Clock.h" #include "Text.h" #include "World.h" +#include "Timer.h" eLevelName CTheZones::m_CurrLevel; CZone *CTheZones::m_pPlayersZone; @@ -122,6 +123,10 @@ CTheZones::Init(void) void CTheZones::Update(void) { +#ifdef SQUEEZE_PERFORMANCE + if (CTimer::GetFrameCounter() % 5 != 0) + return; +#endif CVector pos; pos = FindPlayerCoors(); m_pPlayersZone = FindSmallestZonePosition(&pos); diff --git a/src/core/config.h b/src/core/config.h index 94a35782..e1e11fe9 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -282,4 +282,13 @@ enum Config { #ifndef AUDIO_OAL // is not working yet for openal #define AUDIO_CACHE // cache sound lengths to speed up the cold boot #endif -//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS \ No newline at end of file +//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS + + +//#define SQUEEZE_PERFORMANCE +#ifdef SQUEEZE_PERFORMANCE + #undef PS2_ALPHA_TEST + #undef NO_ISLAND_LOADING + #define PC_PARTICLE + #define VC_PED_PORTS // To not process collisions always. But should be tested if that's really beneficial +#endif \ No newline at end of file diff --git a/src/core/main.cpp b/src/core/main.cpp index a1c64a6d..b63688ec 100644 --- a/src/core/main.cpp +++ b/src/core/main.cpp @@ -816,7 +816,9 @@ RenderScene(void) DefinedState(); CWaterLevel::RenderWater(); CRenderer::RenderFadingInEntities(); +#ifndef SQUEEZE_PERFORMANCE CRenderer::RenderVehiclesButNotBoats(); +#endif CWeather::RenderRainStreaks(); } diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp index 6d106b0e..f289697e 100644 --- a/src/peds/CopPed.cpp +++ b/src/peds/CopPed.cpp @@ -45,7 +45,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP) SetCurrentWeapon(WEAPONTYPE_UZI); m_fArmour = 50.0f; m_wepSkills = 32; /* TODO: what is this? seems unused */ - m_wepAccuracy = 64; + m_wepAccuracy = 68; break; case COP_ARMY: SetModelIndex(MI_ARMY); @@ -479,7 +479,7 @@ CCopPed::CopAI(void) SetAttack(playerOrHisVeh); SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000)); } - SetAttackTimer(CGeneral::GetRandomNumberInRange(100, 300)); + SetAttackTimer(CGeneral::GetRandomNumberInRange(200, 300)); } SetMoveState(PEDMOVE_STILL); } diff --git a/src/peds/Population.cpp b/src/peds/Population.cpp index 1357907d..0756df38 100644 --- a/src/peds/Population.cpp +++ b/src/peds/Population.cpp @@ -1104,7 +1104,11 @@ CPopulation::ManagePopulation(void) } int pedPoolSize = CPools::GetPedPool()->GetSize(); +#ifndef SQUEEZE_PERFORMANCE for (int poolIndex = pedPoolSize-1; poolIndex >= 0; poolIndex--) { +#else + for (int poolIndex = (pedPoolSize * (frameMod32 + 1) / 32) - 1; poolIndex >= pedPoolSize * frameMod32 / 32; poolIndex--) { +#endif CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex); if (ped && !ped->IsPlayer() && ped->CanBeDeleted() && !ped->bInVehicle) { @@ -1117,6 +1121,13 @@ CPopulation::ManagePopulation(void) } float dist = (ped->GetPosition() - playerPos).Magnitude2D(); +#ifdef SQUEEZE_PERFORMANCE + if (dist > 50.f) + ped->bUsesCollision = false; + else + ped->bUsesCollision = true; +#endif + bool pedIsFarAway = false; if (PedCreationDistMultiplier() * (PED_REMOVE_DIST_SPECIAL * TheCamera.GenerationDistMultiplier) < dist || (!ped->bCullExtraFarAway && PedCreationDistMultiplier() * PED_REMOVE_DIST * TheCamera.GenerationDistMultiplier < dist) diff --git a/src/render/Fluff.cpp b/src/render/Fluff.cpp index f86801bf..690a1d3f 100644 --- a/src/render/Fluff.cpp +++ b/src/render/Fluff.cpp @@ -152,9 +152,9 @@ void CMovingThings::Shutdown() void CMovingThings::Update() { - const int TIME_SPAN = 64; // frames to process all aMovingThings - int16 i; +#ifndef SQUEEZE_PERFORMANCE + const int TIME_SPAN = 64; // frames to process all aMovingThings int block = CTimer::GetFrameCounter() % TIME_SPAN; @@ -167,6 +167,7 @@ void CMovingThings::Update() if (aMovingThings[i].m_nHidden == 0) aMovingThings[i].Update(); } +#endif for (i = 0; i < ARRAY_SIZE(aScrollBars); ++i) { diff --git a/src/render/Font.h b/src/render/Font.h index 9b4e7132..48f5703d 100644 --- a/src/render/Font.h +++ b/src/render/Font.h @@ -68,8 +68,8 @@ class CFont static int16 Size[MAX_FONTS][193]; #endif static int16 NewLine; - static CSprite2d Sprite[MAX_FONTS]; public: + static CSprite2d Sprite[MAX_FONTS]; static CFontDetails Details; static void Initialise(void); diff --git a/src/render/Renderer.cpp b/src/render/Renderer.cpp index 88d412c9..717021a7 100644 --- a/src/render/Renderer.cpp +++ b/src/render/Renderer.cpp @@ -73,8 +73,12 @@ CRenderer::PreRender(void) for(i = 0; i < ms_nNoOfVisibleEntities; i++) ms_aVisibleEntityPtrs[i]->PreRender(); - for(i = 0; i < ms_nNoOfInVisibleEntities; i++) + for (i = 0; i < ms_nNoOfInVisibleEntities; i++) { +#ifdef SQUEEZE_PERFORMANCE + if (ms_aInVisibleEntityPtrs[i]->IsVehicle() && ((CVehicle*)ms_aInVisibleEntityPtrs[i])->IsHeli()) +#endif ms_aInVisibleEntityPtrs[i]->PreRender(); + } for(node = CVisibilityPlugins::m_alphaEntityList.head.next; node != &CVisibilityPlugins::m_alphaEntityList.tail; diff --git a/src/render/Rubbish.h b/src/render/Rubbish.h index 2be592fe..37f895f3 100644 --- a/src/render/Rubbish.h +++ b/src/render/Rubbish.h @@ -4,7 +4,11 @@ class CVehicle; enum { // NB: not all values are allowed, check the code +#ifdef SQUEEZE_PERFORMANCE + NUM_RUBBISH_SHEETS = 32 +#else NUM_RUBBISH_SHEETS = 64 +#endif }; class COneSheet diff --git a/src/render/Sprite2d.cpp b/src/render/Sprite2d.cpp index 52b85018..453ed004 100644 --- a/src/render/Sprite2d.cpp +++ b/src/render/Sprite2d.cpp @@ -4,6 +4,7 @@ #include "Draw.h" #include "Camera.h" #include "Sprite2d.h" +#include "Font.h" RwIm2DVertex CSprite2d::maVertices[8]; float CSprite2d::RecipNearClip; @@ -27,14 +28,18 @@ CSprite2d::InitPerFrame(void) mCurrentBank = 0; for(i = 0; i < 10; i++) mCurrentSprite[i] = 0; +#ifndef SQUEEZE_PERFORMANCE for(i = 0; i < 10; i++) mpBankTextures[i] = nil; +#endif } int32 CSprite2d::GetBank(int32 n, RwTexture *tex) { +#ifndef SQUEEZE_PERFORMANCE mpBankTextures[mCurrentBank] = tex; +#endif mCurrentSprite[mCurrentBank] = 0; mBankStart[mCurrentBank+1] = mBankStart[mCurrentBank] + n; return mCurrentBank++; @@ -59,8 +64,12 @@ CSprite2d::DrawBank(int32 bank) { if(mCurrentSprite[bank] == 0) return; +#ifndef SQUEEZE_PERFORMANCE RwRenderStateSet(rwRENDERSTATETEXTURERASTER, mpBankTextures[bank] ? RwTextureGetRaster(mpBankTextures[bank]) : nil); +#else + CFont::Sprite[bank].SetRenderState(); +#endif RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); RwIm2DRenderPrimitive(rwPRIMTYPETRILIST, &maBankVertices[6*mBankStart[bank]], 6*mCurrentSprite[bank]); diff --git a/src/weapons/BulletInfo.cpp b/src/weapons/BulletInfo.cpp index 26fc459d..15dde011 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 bool bAddSound = true; bPlayerSniperBullet = false; for (int i = 0; i < NUM_BULLETS; i++) { @@ -84,8 +99,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; } else { @@ -134,6 +156,9 @@ void CBulletInfo::Update(void) } } pBullet->m_bInUse = false; +#ifdef SQUEEZE_PERFORMANCE + bulletInfoInUse--; +#endif vecNewPos = point.point; } } @@ -148,6 +173,9 @@ void CBulletInfo::Update(void) } #ifdef FIX_BUGS pBullet->m_bInUse = false; +#ifdef SQUEEZE_PERFORMANCE + bulletInfoInUse--; +#endif vecNewPos = point.point; #endif } @@ -167,6 +195,9 @@ void CBulletInfo::Update(void) } #ifdef FIX_BUGS pBullet->m_bInUse = false; +#ifdef SQUEEZE_PERFORMANCE + bulletInfoInUse--; +#endif vecNewPos = point.point; #endif } @@ -217,8 +248,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 47bc65ac..b56e3a29 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 @@ -154,6 +162,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]); @@ -165,6 +177,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); @@ -192,6 +207,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; @@ -200,6 +220,10 @@ CProjectileInfo::Update() gaProjectileInfo[i].m_pSource = nil; if (ms_apProjectile[i] == nil) { +#ifdef SQUEEZE_PERFORMANCE + projectileInUse--; +#endif + gaProjectileInfo[i].m_bInUse = false; continue; } @@ -252,6 +276,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]; @@ -266,8 +294,17 @@ CProjectileInfo::IsProjectileInRange(float x1, float x2, float y1, float y2, flo 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]; @@ -278,12 +315,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 f09ae052..c0ab9ac1 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