1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-22 23:10:00 +00:00

Merge pull request #675 from erorcun/master

Squeeze performance option, minor fixes
This commit is contained in:
aap 2020-08-07 10:18:46 +02:00 committed by GitHub
commit f14b1fba09
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 181 additions and 12 deletions

View file

@ -105,6 +105,10 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
void void
CRoadBlocks::GenerateRoadBlocks(void) CRoadBlocks::GenerateRoadBlocks(void)
{ {
#ifdef SQUEEZE_PERFORMANCE
if (FindPlayerPed()->m_pWanted->m_RoadblockDensity == 0)
return;
#endif
CMatrix offsetMatrix; CMatrix offsetMatrix;
uint32 frame = CTimer::GetFrameCounter() & 0xF; uint32 frame = CTimer::GetFrameCounter() & 0xF;
int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16; int16 nRoadblockNode = (int16)(NUMROADBLOCKS * frame) / 16;

View file

@ -53,6 +53,10 @@ CAccidentManager::ReportAccident(CPed *ped)
void void
CAccidentManager::Update() CAccidentManager::Update()
{ {
#ifdef SQUEEZE_PERFORMANCE
// Handled after injury registered.
return;
#endif
int32 e; int32 e;
if (CEventList::GetEvent(EVENT_INJURED_PED, &e)) { if (CEventList::GetEvent(EVENT_INJURED_PED, &e)) {
CPed *ped = CPools::GetPed(gaEvent[e].entityRef); CPed *ped = CPools::GetPed(gaEvent[e].entityRef);

View file

@ -1,5 +1,4 @@
#pragma once #pragma once
#include "common.h"
#include "config.h" #include "config.h"
class CPed; class CPed;

View file

@ -7,7 +7,7 @@
#endif #endif
// If you spawn many tanks at once, you will see that collisions of two entity exceeds 32. // 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 #define MAX_COLLISION_POINTS 64
#else #else
#define MAX_COLLISION_POINTS 32 #define MAX_COLLISION_POINTS 32

View file

@ -8,6 +8,7 @@
#include "Messages.h" #include "Messages.h"
#include "Text.h" #include "Text.h"
#include "main.h" #include "main.h"
#include "Accident.h"
int32 CEventList::ms_nFirstFreeSlotIndex; int32 CEventList::ms_nFirstFreeSlotIndex;
CEvent gaEvent[NUMEVENTS]; CEvent gaEvent[NUMEVENTS];
@ -63,6 +64,13 @@ CEventList::RegisterEvent(eEventType type, eEventEntity entityType, CEntity *ent
int ref; int ref;
bool copsDontCare; bool copsDontCare;
#ifdef SQUEEZE_PERFORMANCE
if (type == EVENT_INJURED_PED) {
gAccidentManager.ReportAccident((CPed*)ent);
return;
}
#endif
copsDontCare = false; copsDontCare = false;
switch(entityType){ switch(entityType){
case EVENT_ENTITY_PED: case EVENT_ENTITY_PED:

View file

@ -106,6 +106,7 @@ int gameTxdSlot;
bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha); bool DoRWStuffStartOfFrame(int16 TopRed, int16 TopGreen, int16 TopBlue, int16 BottomRed, int16 BottomGreen, int16 BottomBlue, int16 Alpha);
void DoRWStuffEndOfFrame(void); void DoRWStuffEndOfFrame(void);
#ifdef PS2_MENU
void MessageScreen(char *msg) void MessageScreen(char *msg)
{ {
//TODO: stretch_screen //TODO: stretch_screen
@ -139,6 +140,7 @@ void MessageScreen(char *msg)
DoRWStuffEndOfFrame(); DoRWStuffEndOfFrame();
} }
#endif
bool bool
CGame::InitialiseOnceBeforeRW(void) CGame::InitialiseOnceBeforeRW(void)
@ -431,6 +433,7 @@ bool CGame::Initialise(const char* datFile)
if ( !TheMemoryCard.m_bWantToLoad ) if ( !TheMemoryCard.m_bWantToLoad )
{ {
#endif #endif
LoadingScreen("Loading the Game", "Start script", nil);
CTheScripts::StartTestScript(); CTheScripts::StartTestScript();
CTheScripts::Process(); CTheScripts::Process();
TheCamera.Process(); TheCamera.Process();

View file

@ -1104,7 +1104,9 @@ void CPad::UpdatePads(void)
if ( bUpdate ) if ( bUpdate )
{ {
GetPad(0)->Update(0); GetPad(0)->Update(0);
#ifndef SQUEEZE_PERFORMANCE
GetPad(1)->Update(0); GetPad(1)->Update(0);
#endif
} }
#if defined(MASTER) && !defined(XINPUT) #if defined(MASTER) && !defined(XINPUT)

View file

@ -1941,6 +1941,11 @@ CWorld::Process(void)
} else { } else {
for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) { for(CPtrNode *node = ms_listMovingEntityPtrs.first; node; node = node->next) {
CEntity *movingEnt = (CEntity *)node->item; CEntity *movingEnt = (CEntity *)node->item;
#ifdef SQUEEZE_PERFORMANCE
if (movingEnt->bRemoveFromWorld) {
RemoveEntityInsteadOfProcessingIt(movingEnt);
} else
#endif
if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP && if(movingEnt->m_rwObject && RwObjectGetType(movingEnt->m_rwObject) == rpCLUMP &&
RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) { RpAnimBlendClumpGetFirstAssociation(movingEnt->GetClump())) {
RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(), RpAnimBlendClumpUpdateAnimations(movingEnt->GetClump(),

View file

@ -7,6 +7,7 @@
#include "Clock.h" #include "Clock.h"
#include "Text.h" #include "Text.h"
#include "World.h" #include "World.h"
#include "Timer.h"
eLevelName CTheZones::m_CurrLevel; eLevelName CTheZones::m_CurrLevel;
CZone *CTheZones::m_pPlayersZone; CZone *CTheZones::m_pPlayersZone;
@ -122,6 +123,10 @@ CTheZones::Init(void)
void void
CTheZones::Update(void) CTheZones::Update(void)
{ {
#ifdef SQUEEZE_PERFORMANCE
if (CTimer::GetFrameCounter() % 5 != 0)
return;
#endif
CVector pos; CVector pos;
pos = FindPlayerCoors(); pos = FindPlayerCoors();
m_pPlayersZone = FindSmallestZonePosition(&pos); m_pPlayersZone = FindSmallestZonePosition(&pos);

View file

@ -286,4 +286,13 @@ enum Config {
#ifndef AUDIO_OAL // is not working yet for openal #ifndef AUDIO_OAL // is not working yet for openal
#define AUDIO_CACHE // cache sound lengths to speed up the cold boot #define AUDIO_CACHE // cache sound lengths to speed up the cold boot
#endif #endif
//#define PS2_AUDIO // changes audio paths for cutscenes and radio to PS2 paths, needs vbdec to support VB with MSS //#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

View file

@ -816,7 +816,9 @@ RenderScene(void)
DefinedState(); DefinedState();
CWaterLevel::RenderWater(); CWaterLevel::RenderWater();
CRenderer::RenderFadingInEntities(); CRenderer::RenderFadingInEntities();
#ifndef SQUEEZE_PERFORMANCE
CRenderer::RenderVehiclesButNotBoats(); CRenderer::RenderVehiclesButNotBoats();
#endif
CWeather::RenderRainStreaks(); CWeather::RenderRainStreaks();
} }

View file

@ -45,7 +45,7 @@ CCopPed::CCopPed(eCopType copType) : CPed(PEDTYPE_COP)
SetCurrentWeapon(WEAPONTYPE_UZI); SetCurrentWeapon(WEAPONTYPE_UZI);
m_fArmour = 50.0f; m_fArmour = 50.0f;
m_wepSkills = 32; /* TODO: what is this? seems unused */ m_wepSkills = 32; /* TODO: what is this? seems unused */
m_wepAccuracy = 64; m_wepAccuracy = 68;
break; break;
case COP_ARMY: case COP_ARMY:
SetModelIndex(MI_ARMY); SetModelIndex(MI_ARMY);
@ -479,7 +479,7 @@ CCopPed::CopAI(void)
SetAttack(playerOrHisVeh); SetAttack(playerOrHisVeh);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000)); SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000));
} }
SetAttackTimer(CGeneral::GetRandomNumberInRange(100, 300)); SetAttackTimer(CGeneral::GetRandomNumberInRange(200, 300));
} }
SetMoveState(PEDMOVE_STILL); SetMoveState(PEDMOVE_STILL);
} }

View file

@ -1104,7 +1104,11 @@ CPopulation::ManagePopulation(void)
} }
int pedPoolSize = CPools::GetPedPool()->GetSize(); int pedPoolSize = CPools::GetPedPool()->GetSize();
#ifndef SQUEEZE_PERFORMANCE
for (int poolIndex = pedPoolSize-1; poolIndex >= 0; poolIndex--) { 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); CPed *ped = CPools::GetPedPool()->GetSlot(poolIndex);
if (ped && !ped->IsPlayer() && ped->CanBeDeleted() && !ped->bInVehicle) { if (ped && !ped->IsPlayer() && ped->CanBeDeleted() && !ped->bInVehicle) {
@ -1117,6 +1121,13 @@ CPopulation::ManagePopulation(void)
} }
float dist = (ped->GetPosition() - playerPos).Magnitude2D(); float dist = (ped->GetPosition() - playerPos).Magnitude2D();
#ifdef SQUEEZE_PERFORMANCE
if (dist > 50.f)
ped->bUsesCollision = false;
else
ped->bUsesCollision = true;
#endif
bool pedIsFarAway = false; bool pedIsFarAway = false;
if (PedCreationDistMultiplier() * (PED_REMOVE_DIST_SPECIAL * TheCamera.GenerationDistMultiplier) < dist if (PedCreationDistMultiplier() * (PED_REMOVE_DIST_SPECIAL * TheCamera.GenerationDistMultiplier) < dist
|| (!ped->bCullExtraFarAway && PedCreationDistMultiplier() * PED_REMOVE_DIST * TheCamera.GenerationDistMultiplier < dist) || (!ped->bCullExtraFarAway && PedCreationDistMultiplier() * PED_REMOVE_DIST * TheCamera.GenerationDistMultiplier < dist)

View file

@ -152,9 +152,9 @@ void CMovingThings::Shutdown()
void CMovingThings::Update() void CMovingThings::Update()
{ {
const int TIME_SPAN = 64; // frames to process all aMovingThings
int16 i; int16 i;
#ifndef SQUEEZE_PERFORMANCE
const int TIME_SPAN = 64; // frames to process all aMovingThings
int block = CTimer::GetFrameCounter() % TIME_SPAN; int block = CTimer::GetFrameCounter() % TIME_SPAN;
@ -167,6 +167,7 @@ void CMovingThings::Update()
if (aMovingThings[i].m_nHidden == 0) if (aMovingThings[i].m_nHidden == 0)
aMovingThings[i].Update(); aMovingThings[i].Update();
} }
#endif
for (i = 0; i < ARRAY_SIZE(aScrollBars); ++i) for (i = 0; i < ARRAY_SIZE(aScrollBars); ++i)
{ {

View file

@ -68,8 +68,8 @@ class CFont
static int16 Size[MAX_FONTS][193]; static int16 Size[MAX_FONTS][193];
#endif #endif
static int16 NewLine; static int16 NewLine;
static CSprite2d Sprite[MAX_FONTS];
public: public:
static CSprite2d Sprite[MAX_FONTS];
static CFontDetails Details; static CFontDetails Details;
static void Initialise(void); static void Initialise(void);

View file

@ -73,8 +73,12 @@ CRenderer::PreRender(void)
for(i = 0; i < ms_nNoOfVisibleEntities; i++) for(i = 0; i < ms_nNoOfVisibleEntities; i++)
ms_aVisibleEntityPtrs[i]->PreRender(); 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(); ms_aInVisibleEntityPtrs[i]->PreRender();
}
for(node = CVisibilityPlugins::m_alphaEntityList.head.next; for(node = CVisibilityPlugins::m_alphaEntityList.head.next;
node != &CVisibilityPlugins::m_alphaEntityList.tail; node != &CVisibilityPlugins::m_alphaEntityList.tail;

View file

@ -4,7 +4,11 @@ class CVehicle;
enum { enum {
// NB: not all values are allowed, check the code // NB: not all values are allowed, check the code
#ifdef SQUEEZE_PERFORMANCE
NUM_RUBBISH_SHEETS = 32
#else
NUM_RUBBISH_SHEETS = 64 NUM_RUBBISH_SHEETS = 64
#endif
}; };
class COneSheet class COneSheet

View file

@ -4,6 +4,7 @@
#include "Draw.h" #include "Draw.h"
#include "Camera.h" #include "Camera.h"
#include "Sprite2d.h" #include "Sprite2d.h"
#include "Font.h"
RwIm2DVertex CSprite2d::maVertices[8]; RwIm2DVertex CSprite2d::maVertices[8];
float CSprite2d::RecipNearClip; float CSprite2d::RecipNearClip;
@ -27,14 +28,18 @@ CSprite2d::InitPerFrame(void)
mCurrentBank = 0; mCurrentBank = 0;
for(i = 0; i < 10; i++) for(i = 0; i < 10; i++)
mCurrentSprite[i] = 0; mCurrentSprite[i] = 0;
#ifndef SQUEEZE_PERFORMANCE
for(i = 0; i < 10; i++) for(i = 0; i < 10; i++)
mpBankTextures[i] = nil; mpBankTextures[i] = nil;
#endif
} }
int32 int32
CSprite2d::GetBank(int32 n, RwTexture *tex) CSprite2d::GetBank(int32 n, RwTexture *tex)
{ {
#ifndef SQUEEZE_PERFORMANCE
mpBankTextures[mCurrentBank] = tex; mpBankTextures[mCurrentBank] = tex;
#endif
mCurrentSprite[mCurrentBank] = 0; mCurrentSprite[mCurrentBank] = 0;
mBankStart[mCurrentBank+1] = mBankStart[mCurrentBank] + n; mBankStart[mCurrentBank+1] = mBankStart[mCurrentBank] + n;
return mCurrentBank++; return mCurrentBank++;
@ -59,8 +64,12 @@ CSprite2d::DrawBank(int32 bank)
{ {
if(mCurrentSprite[bank] == 0) if(mCurrentSprite[bank] == 0)
return; return;
#ifndef SQUEEZE_PERFORMANCE
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, RwRenderStateSet(rwRENDERSTATETEXTURERASTER,
mpBankTextures[bank] ? RwTextureGetRaster(mpBankTextures[bank]) : nil); mpBankTextures[bank] ? RwTextureGetRaster(mpBankTextures[bank]) : nil);
#else
CFont::Sprite[bank].SetRenderState();
#endif
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR); RwRenderStateSet(rwRENDERSTATETEXTUREFILTER, (void*)rwFILTERLINEAR);
RwIm2DRenderPrimitive(rwPRIMTYPETRILIST, &maBankVertices[6*mBankStart[bank]], 6*mCurrentSprite[bank]); RwIm2DRenderPrimitive(rwPRIMTYPETRILIST, &maBankVertices[6*mBankStart[bank]], 6*mCurrentSprite[bank]);

View file

@ -24,6 +24,10 @@
#include "World.h" #include "World.h"
#include "SurfaceTable.h" #include "SurfaceTable.h"
#ifdef SQUEEZE_PERFORMANCE
uint32 bulletInfoInUse;
#endif
#define BULLET_LIFETIME (1000) #define BULLET_LIFETIME (1000)
#define NUM_PED_BLOOD_PARTICLES (8) #define NUM_PED_BLOOD_PARTICLES (8)
#define BLOOD_PARTICLE_OFFSET (CVector(0.0f, 0.0f, 0.0f)) #define BLOOD_PARTICLE_OFFSET (CVector(0.0f, 0.0f, 0.0f))
@ -47,6 +51,9 @@ void CBulletInfo::Initialise(void)
gaBulletInfo[i].m_pSource = nil; gaBulletInfo[i].m_pSource = nil;
} }
debug("CBulletInfo ready\n"); debug("CBulletInfo ready\n");
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse = 0;
#endif
} }
void CBulletInfo::Shutdown(void) 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_vecSpeed = vecSpeed;
gaBulletInfo[i].m_fTimer = CTimer::GetTimeInMilliseconds() + BULLET_LIFETIME; gaBulletInfo[i].m_fTimer = CTimer::GetTimeInMilliseconds() + BULLET_LIFETIME;
gaBulletInfo[i].m_bInUse = true; gaBulletInfo[i].m_bInUse = true;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse++;
#endif
return true; return true;
} }
void CBulletInfo::Update(void) void CBulletInfo::Update(void)
{ {
#ifdef SQUEEZE_PERFORMANCE
if (bulletInfoInUse == 0)
return;
#endif
bool bAddSound = true; bool bAddSound = true;
bPlayerSniperBullet = false; bPlayerSniperBullet = false;
for (int i = 0; i < NUM_BULLETS; i++) { for (int i = 0; i < NUM_BULLETS; i++) {
@ -84,8 +99,12 @@ void CBulletInfo::Update(void)
pBullet->m_pSource = nil; pBullet->m_pSource = nil;
if (!pBullet->m_bInUse) if (!pBullet->m_bInUse)
continue; continue;
if (CTimer::GetTimeInMilliseconds() > pBullet->m_fTimer) if (CTimer::GetTimeInMilliseconds() > pBullet->m_fTimer) {
pBullet->m_bInUse = false; pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
}
CVector vecOldPos = pBullet->m_vecPosition; CVector vecOldPos = pBullet->m_vecPosition;
CVector vecNewPos = pBullet->m_vecPosition + pBullet->m_vecSpeed * CTimer::GetTimeStep() * 0.5f; CVector vecNewPos = pBullet->m_vecPosition + pBullet->m_vecSpeed * CTimer::GetTimeStep() * 0.5f;
CWorld::bIncludeCarTyres = true; 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)); 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); 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; pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point; vecNewPos = point.point;
} }
else { else {
@ -134,6 +156,9 @@ void CBulletInfo::Update(void)
} }
} }
pBullet->m_bInUse = false; pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point; vecNewPos = point.point;
} }
} }
@ -148,6 +173,9 @@ void CBulletInfo::Update(void)
} }
#ifdef FIX_BUGS #ifdef FIX_BUGS
pBullet->m_bInUse = false; pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point; vecNewPos = point.point;
#endif #endif
} }
@ -167,6 +195,9 @@ void CBulletInfo::Update(void)
} }
#ifdef FIX_BUGS #ifdef FIX_BUGS
pBullet->m_bInUse = false; pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
vecNewPos = point.point; vecNewPos = point.point;
#endif #endif
} }
@ -217,8 +248,12 @@ void CBulletInfo::Update(void)
} }
pBullet->m_vecPosition = vecNewPos; pBullet->m_vecPosition = vecNewPos;
if (pBullet->m_vecPosition.x < -MAP_BORDER || pBullet->m_vecPosition.x > MAP_BORDER || 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; pBullet->m_bInUse = false;
#ifdef SQUEEZE_PERFORMANCE
bulletInfoInUse--;
#endif
}
} }
} }

View file

@ -13,6 +13,10 @@
#include "Weapon.h" #include "Weapon.h"
#include "World.h" #include "World.h"
#ifdef SQUEEZE_PERFORMANCE
uint32 projectileInUse;
#endif
CProjectileInfo gaProjectileInfo[NUM_PROJECTILES]; CProjectileInfo gaProjectileInfo[NUM_PROJECTILES];
CProjectile *CProjectileInfo::ms_apProjectile[NUM_PROJECTILES]; CProjectile *CProjectileInfo::ms_apProjectile[NUM_PROJECTILES];
@ -30,6 +34,10 @@ CProjectileInfo::Initialise()
} }
debug("CProjectileInfo ready\n"); debug("CProjectileInfo ready\n");
#ifdef SQUEEZE_PERFORMANCE
projectileInUse = 0;
#endif
} }
void void
@ -154,6 +162,10 @@ CProjectileInfo::AddProjectile(CEntity *entity, eWeaponType weapon, CVector pos,
ms_apProjectile[i]->m_fElasticity = elasticity; ms_apProjectile[i]->m_fElasticity = elasticity;
ms_apProjectile[i]->m_nSpecialCollisionResponseCases = SpecialCollisionResponseCase; ms_apProjectile[i]->m_nSpecialCollisionResponseCases = SpecialCollisionResponseCase;
#ifdef SQUEEZE_PERFORMANCE
projectileInUse++;
#endif
gaProjectileInfo[i].m_bInUse = true; gaProjectileInfo[i].m_bInUse = true;
CWorld::Add(ms_apProjectile[i]); CWorld::Add(ms_apProjectile[i]);
@ -165,6 +177,9 @@ void
CProjectileInfo::RemoveProjectile(CProjectileInfo *info, CProjectile *projectile) CProjectileInfo::RemoveProjectile(CProjectileInfo *info, CProjectile *projectile)
{ {
RemoveNotAdd(info->m_pSource, info->m_eWeaponType, projectile->GetPosition()); RemoveNotAdd(info->m_pSource, info->m_eWeaponType, projectile->GetPosition());
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
info->m_bInUse = false; info->m_bInUse = false;
CWorld::Remove(projectile); CWorld::Remove(projectile);
@ -192,6 +207,11 @@ CProjectileInfo::RemoveNotAdd(CEntity *entity, eWeaponType weaponType, CVector p
void void
CProjectileInfo::Update() CProjectileInfo::Update()
{ {
#ifdef SQUEEZE_PERFORMANCE
if (projectileInUse == 0)
return;
#endif
for (int i = 0; i < ARRAY_SIZE(gaProjectileInfo); i++) { for (int i = 0; i < ARRAY_SIZE(gaProjectileInfo); i++) {
if (!gaProjectileInfo[i].m_bInUse) continue; if (!gaProjectileInfo[i].m_bInUse) continue;
@ -200,6 +220,10 @@ CProjectileInfo::Update()
gaProjectileInfo[i].m_pSource = nil; gaProjectileInfo[i].m_pSource = nil;
if (ms_apProjectile[i] == nil) { if (ms_apProjectile[i] == nil) {
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false; gaProjectileInfo[i].m_bInUse = false;
continue; 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) { if (pos.x >= x1 && pos.x <= x2 && pos.y >= y1 && pos.y <= y2 && pos.z >= z1 && pos.z <= z2) {
result = true; result = true;
if (remove) { if (remove) {
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false; gaProjectileInfo[i].m_bInUse = false;
CWorld::Remove(ms_apProjectile[i]); CWorld::Remove(ms_apProjectile[i]);
delete ms_apProjectile[i]; delete ms_apProjectile[i];
@ -266,8 +294,17 @@ CProjectileInfo::IsProjectileInRange(float x1, float x2, float y1, float y2, flo
void void
CProjectileInfo::RemoveAllProjectiles() CProjectileInfo::RemoveAllProjectiles()
{ {
#ifdef SQUEEZE_PERFORMANCE
if (projectileInUse == 0)
return;
#endif
for (int i = 0; i < ARRAY_SIZE(ms_apProjectile); i++) { for (int i = 0; i < ARRAY_SIZE(ms_apProjectile); i++) {
if (gaProjectileInfo[i].m_bInUse) { if (gaProjectileInfo[i].m_bInUse) {
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false; gaProjectileInfo[i].m_bInUse = false;
CWorld::Remove(ms_apProjectile[i]); CWorld::Remove(ms_apProjectile[i]);
delete ms_apProjectile[i]; delete ms_apProjectile[i];
@ -278,12 +315,21 @@ CProjectileInfo::RemoveAllProjectiles()
bool bool
CProjectileInfo::RemoveIfThisIsAProjectile(CObject *object) CProjectileInfo::RemoveIfThisIsAProjectile(CObject *object)
{ {
#ifdef SQUEEZE_PERFORMANCE
if (projectileInUse == 0)
return false;
#endif
int i = 0; int i = 0;
while (ms_apProjectile[i++] != object) { while (ms_apProjectile[i++] != object) {
if (i >= ARRAY_SIZE(ms_apProjectile)) if (i >= ARRAY_SIZE(ms_apProjectile))
return false; return false;
} }
#ifdef SQUEEZE_PERFORMANCE
projectileInUse--;
#endif
gaProjectileInfo[i].m_bInUse = false; gaProjectileInfo[i].m_bInUse = false;
CWorld::Remove(ms_apProjectile[i]); CWorld::Remove(ms_apProjectile[i]);
delete ms_apProjectile[i]; delete ms_apProjectile[i];

View file

@ -13,6 +13,9 @@
CShotInfo gaShotInfo[NUMSHOTINFOS]; CShotInfo gaShotInfo[NUMSHOTINFOS];
float CShotInfo::ms_afRandTable[20]; float CShotInfo::ms_afRandTable[20];
#ifdef SQUEEZE_PERFORMANCE
uint32 shotInfoInUse;
#endif
/* /*
Used for flamethrower. I don't know why it's name is CShotInfo. Used for flamethrower. I don't know why it's name is CShotInfo.
@ -41,6 +44,9 @@ CShotInfo::Initialise()
nextVal += 0.005f; nextVal += 0.005f;
} }
debug("CShotInfo ready\n"); debug("CShotInfo ready\n");
#ifdef SQUEEZE_PERFORMANCE
shotInfoInUse = 0;
#endif
} }
bool bool
@ -54,6 +60,10 @@ CShotInfo::AddShot(CEntity *sourceEntity, eWeaponType weapon, CVector startPos,
if (slot == ARRAY_SIZE(gaShotInfo)) if (slot == ARRAY_SIZE(gaShotInfo))
return false; return false;
#ifdef SQUEEZE_PERFORMANCE
shotInfoInUse++;
#endif
gaShotInfo[slot].m_inUse = true; gaShotInfo[slot].m_inUse = true;
gaShotInfo[slot].m_weapon = weapon; gaShotInfo[slot].m_weapon = weapon;
gaShotInfo[slot].m_startPos = startPos; gaShotInfo[slot].m_startPos = startPos;
@ -87,6 +97,10 @@ CShotInfo::Shutdown()
void void
CShotInfo::Update() CShotInfo::Update()
{ {
#ifdef SQUEEZE_PERFORMANCE
if (shotInfoInUse == 0)
return;
#endif
for (int slot = 0; slot < ARRAY_SIZE(gaShotInfo); slot++) { for (int slot = 0; slot < ARRAY_SIZE(gaShotInfo); slot++) {
CShotInfo &shot = gaShotInfo[slot]; CShotInfo &shot = gaShotInfo[slot];
if (shot.m_sourceEntity && shot.m_sourceEntity->IsPed() && !((CPed*)shot.m_sourceEntity)->IsPointerValid()) if (shot.m_sourceEntity && shot.m_sourceEntity->IsPed() && !((CPed*)shot.m_sourceEntity)->IsPointerValid())
@ -96,8 +110,12 @@ CShotInfo::Update()
continue; continue;
CWeaponInfo *weaponInfo = CWeaponInfo::GetWeaponInfo(shot.m_weapon); 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; shot.m_inUse = false;
}
if (weaponInfo->m_bSlowsDown) if (weaponInfo->m_bSlowsDown)
shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE shot.m_areaAffected *= pow(0.96, CTimer::GetTimeStep()); // FRAMERATE