diff options
Diffstat (limited to 'src/objects/ParticleObject.cpp')
-rw-r--r-- | src/objects/ParticleObject.cpp | 882 |
1 files changed, 431 insertions, 451 deletions
diff --git a/src/objects/ParticleObject.cpp b/src/objects/ParticleObject.cpp index 5d480ecc..28c5240f 100644 --- a/src/objects/ParticleObject.cpp +++ b/src/objects/ParticleObject.cpp @@ -11,7 +11,7 @@ #include "screendroplets.h" #ifdef COMPATIBLE_SAVES -#define PARTICLE_OBJECT_SIZEOF 0x88 +#define PARTICLE_OBJECT_SIZEOF 0x84 #else #define PARTICLE_OBJECT_SIZEOF sizeof(CParticleObject) #endif @@ -59,7 +59,7 @@ CAudioHydrant::Remove(CParticleObject *particleobject) { DMAudio.DestroyEntity(List[i].AudioEntity); List[i].AudioEntity = AEHANDLE_NONE; - List[i].pParticleObject = NULL; + List[i].pParticleObject = nil; } } } @@ -68,8 +68,8 @@ CParticleObject::CParticleObject() : CPlaceable(), m_nFrameCounter(0), m_nState(POBJECTSTATE_INITIALISED), - m_pNext(NULL), - m_pPrev(NULL), + m_pNext(nil), + m_pPrev(nil), m_nRemoveTimer(0) { @@ -84,20 +84,20 @@ CParticleObject::~CParticleObject() void CParticleObject::Initialise() { - pCloseListHead = NULL; - pFarListHead = NULL; + pCloseListHead = nil; + pFarListHead = nil; pUnusedListHead = &gPObjectArray[0]; for ( int32 i = 0; i < MAX_PARTICLEOBJECTS; i++ ) { if ( i == 0 ) - gPObjectArray[i].m_pPrev = NULL; + gPObjectArray[i].m_pPrev = nil; else gPObjectArray[i].m_pPrev = &gPObjectArray[i - 1]; if ( i == MAX_PARTICLEOBJECTS-1 ) - gPObjectArray[i].m_pNext = NULL; + gPObjectArray[i].m_pNext = nil; else gPObjectArray[i].m_pNext = &gPObjectArray[i + 1]; @@ -133,12 +133,10 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe { CParticleObject *pobj = pUnusedListHead; - ASSERT(pobj != NULL); - - if ( pobj == NULL ) + if ( pobj == nil ) { printf("Error: No particle objects available!\n"); - return NULL; + return nil; } MoveToList(&pUnusedListHead, &pCloseListHead, pobj); @@ -156,7 +154,7 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe pobj->m_bRemove = remove; - pobj->m_pParticle = NULL; + pobj->m_pParticle = nil; if ( lifeTime != 0 ) pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + lifeTime; @@ -171,229 +169,243 @@ CParticleObject::AddObject(uint16 type, CVector const &pos, CVector const &targe pobj->m_fSize = size; pobj->m_fRandVal = 0.0f; - if ( type <= POBJECT_CATALINAS_SHOTGUNFLASH ) + switch ( type ) { - switch ( type ) + case POBJECT_PAVEMENT_STEAM: { - case POBJECT_PAVEMENT_STEAM: - { - pobj->m_ParticleType = PARTICLE_STEAM_NY; - pobj->m_nNumEffectCycles = 1; -#ifdef PC_PARTICLE - pobj->m_nSkipFrames = 3; -#else - pobj->m_nSkipFrames = 1; -#endif - pobj->m_nCreationChance = 8; - break; - } - - case POBJECT_PAVEMENT_STEAM_SLOWMOTION: - { - pobj->m_ParticleType = PARTICLE_STEAM_NY_SLOWMOTION; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 8; - break; - } - - case POBJECT_WALL_STEAM: - { - pobj->m_ParticleType = PARTICLE_STEAM_NY; - pobj->m_nNumEffectCycles = 1; -#ifdef PC_PARTICLE - pobj->m_nSkipFrames = 3; -#else - pobj->m_nSkipFrames = 1; -#endif - pobj->m_nCreationChance = 8; - break; - } - - case POBJECT_WALL_STEAM_SLOWMOTION: - { - pobj->m_ParticleType = PARTICLE_STEAM_NY_SLOWMOTION; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 8; - break; - } - - case POBJECT_DARK_SMOKE: - { - pobj->m_ParticleType = PARTICLE_STEAM_NY; - pobj->m_nNumEffectCycles = 1; -#ifdef PC_PARTICLE - pobj->m_nSkipFrames = 3; -#else - pobj->m_nSkipFrames = 1; -#endif - pobj->m_nCreationChance = 8; - pobj->m_Color = CRGBA(16, 16, 16, 255); - break; - } - - case POBJECT_FIRE_HYDRANT: - { - pobj->m_ParticleType = PARTICLE_WATER_HYDRANT; - pobj->m_nNumEffectCycles = 4; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 0; - pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.3f); - pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + 5000; - CAudioHydrant::Add(pobj); - break; - } - - case POBJECT_CAR_WATER_SPLASH: - case POBJECT_PED_WATER_SPLASH: - { - pobj->m_ParticleType = PARTICLE_CAR_SPLASH; - pobj->m_nNumEffectCycles = 0; -#ifdef PC_PARTICLE - pobj->m_nSkipFrames = 1; -#else - pobj->m_nSkipFrames = 3; -#endif - pobj->m_nCreationChance = 0; + pobj->m_ParticleType = PARTICLE_STEAM_NY; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 3; + pobj->m_nCreationChance = 8; + break; + } + + case POBJECT_PAVEMENT_STEAM_SLOWMOTION: + { + pobj->m_ParticleType = PARTICLE_STEAM_NY_SLOWMOTION; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 8; + break; + } + + case POBJECT_WALL_STEAM: + { + pobj->m_ParticleType = PARTICLE_STEAM_NY; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 3; + pobj->m_nCreationChance = 8; + break; + } + + case POBJECT_WALL_STEAM_SLOWMOTION: + { + pobj->m_ParticleType = PARTICLE_STEAM_NY_SLOWMOTION; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 8; + break; + } + + case POBJECT_DARK_SMOKE: + { + pobj->m_ParticleType = PARTICLE_STEAM_NY; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 3; + pobj->m_nCreationChance = 8; + pobj->m_Color = CRGBA(16, 16, 16, 255); + break; + } + + case POBJECT_WATER_FOUNTAIN_VERT: + { + pobj->m_ParticleType = PARTICLE_WATER_HYDRANT; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; + pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.1f); + break; + } + + case POBJECT_WATER_FOUNTAIN_HORIZ: + { + pobj->m_ParticleType = PARTICLE_WATER_HYDRANT; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; + break; + } + + case POBJECT_FIRE_HYDRANT: + { + pobj->m_ParticleType = PARTICLE_WATER_HYDRANT; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; + pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.3f); + pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + 5000; + CAudioHydrant::Add(pobj); + break; + } + + case POBJECT_CAR_WATER_SPLASH: + case POBJECT_PED_WATER_SPLASH: + { + pobj->m_ParticleType = PARTICLE_CAR_SPLASH; + pobj->m_nNumEffectCycles = 0; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; #ifdef SCREEN_DROPLETS - ScreenDroplets::RegisterSplash(pobj); -#endif - break; - } - - case POBJECT_SPLASHES_AROUND: - { - pobj->m_ParticleType = PARTICLE_SPLASH; -#ifdef PC_PARTICLE - pobj->m_nNumEffectCycles = 15; -#else - pobj->m_nNumEffectCycles = 30; -#endif - pobj->m_nSkipFrames = 2; - pobj->m_nCreationChance = 0; - break; - } - - case POBJECT_SMALL_FIRE: - { - pobj->m_ParticleType = PARTICLE_FLAME; - pobj->m_nNumEffectCycles = 1; -#ifdef PC_PARTICLE - pobj->m_nSkipFrames = 2; -#else - pobj->m_nSkipFrames = 1; -#endif - pobj->m_nCreationChance = 2; - pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); - break; - } - - case POBJECT_BIG_FIRE: - { - pobj->m_ParticleType = PARTICLE_FLAME; - pobj->m_nNumEffectCycles = 1; -#ifdef PC_PARTICLE - pobj->m_nSkipFrames = 2; -#else - pobj->m_nSkipFrames = 1; + ScreenDroplets::RegisterSplash(pobj); #endif - pobj->m_nCreationChance = 4; - pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); - break; - } - - case POBJECT_DRY_ICE: - { - pobj->m_ParticleType = PARTICLE_SMOKE; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 0; - pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); - break; - } - - case POBJECT_DRY_ICE_SLOWMOTION: - { - pobj->m_ParticleType = PARTICLE_SMOKE_SLOWMOTION; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 0; - pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); - break; - } - - case POBJECT_FIRE_TRAIL: - { - pobj->m_ParticleType = PARTICLE_EXPLOSION_MEDIUM; - pobj->m_nNumEffectCycles = 1; -#ifdef PC_PARTICLE - pobj->m_nSkipFrames = 3; -#else - pobj->m_nSkipFrames = 1; -#endif - pobj->m_nCreationChance = 2; - pobj->m_fRandVal = 0.01f; - break; - } - - case POBJECT_SMOKE_TRAIL: - { - pobj->m_ParticleType = PARTICLE_FIREBALL_SMOKE; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 2; - pobj->m_fRandVal = 0.02f; - break; - } - - case POBJECT_FIREBALL_AND_SMOKE: - { - pobj->m_ParticleType = PARTICLE_FLAME; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 2; - pobj->m_fRandVal = 0.1f; - break; - } - - case POBJECT_ROCKET_TRAIL: - { - pobj->m_ParticleType = PARTICLE_FLAME; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 2; - pobj->m_nCreationChance = 8; - pobj->m_fRandVal = 0.1f; - break; - } - - case POBJECT_EXPLOSION_ONCE: - { - pobj->m_ParticleType = PARTICLE_EXPLOSION_LARGE; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 0; - pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds(); - break; - } - - case POBJECT_CATALINAS_GUNFLASH: - case POBJECT_CATALINAS_SHOTGUNFLASH: - { - pobj->m_ParticleType = PARTICLE_GUNFLASH_NOANIM; - pobj->m_nNumEffectCycles = 1; - pobj->m_nSkipFrames = 1; - pobj->m_nCreationChance = 0; - pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds(); - pobj->m_vecTarget.Normalise(); - break; - } + break; + } + + case POBJECT_SPLASHES_AROUND: + { + pobj->m_ParticleType = PARTICLE_SPLASH; + pobj->m_nNumEffectCycles = 15; + pobj->m_nSkipFrames = 2; + pobj->m_nCreationChance = 0; + break; + } + + case POBJECT_SMALL_FIRE: + { + pobj->m_ParticleType = PARTICLE_FLAME; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 2; + pobj->m_nCreationChance = 2; + pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); + break; + } + + case POBJECT_BIG_FIRE: + { + pobj->m_ParticleType = PARTICLE_FLAME; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 2; + pobj->m_nCreationChance = 4; + pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); + break; + } + + case POBJECT_DRY_ICE: + { + pobj->m_ParticleType = PARTICLE_SMOKE; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; + pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); + break; + } + + case POBJECT_DRY_ICE_SLOWMOTION: + { + pobj->m_ParticleType = PARTICLE_SMOKE_SLOWMOTION; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; + pobj->m_vecTarget = CVector(0.0f, 0.0f, 0.0f); + break; + } + + case POBJECT_FIRE_TRAIL: + { + pobj->m_ParticleType = PARTICLE_EXPLOSION_MEDIUM; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 3; + pobj->m_nCreationChance = 2; + pobj->m_fRandVal = 0.01f; + break; + } + + case POBJECT_SMOKE_TRAIL: + { + pobj->m_ParticleType = PARTICLE_FIREBALL_SMOKE; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 2; + pobj->m_fRandVal = 0.02f; + break; + } + + case POBJECT_FIREBALL_AND_SMOKE: + { + pobj->m_ParticleType = PARTICLE_FLAME; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; + pobj->m_fRandVal = 0.1f; + break; + } + + case POBJECT_ROCKET_TRAIL: + { + pobj->m_ParticleType = PARTICLE_FLAME; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 2; + pobj->m_nCreationChance = 8; + pobj->m_fRandVal = 0.1f; + break; + } + + case POBJECT_EXPLOSION_ONCE: + { + pobj->m_ParticleType = PARTICLE_EXPLOSION_LARGE; + pobj->m_nNumEffectCycles = 1; + pobj->m_nSkipFrames = 1; + pobj->m_nCreationChance = 0; + pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds(); + break; } } return pobj; } +CParticleObject * +CParticleObject::AddObject(tParticleType type, CVector const &pos, CVector const &target, float size, uint32 lifeTime, uint8 numEffectCycles, uint8 skipFrames, uint16 creationChance, uint8 remove) +{ + CParticleObject *pobj = pUnusedListHead; + + ASSERT(pobj != nil); + + if ( pobj == nil ) + { + printf("Error: No particle objects available!\n"); + return nil; + } + + MoveToList(&pUnusedListHead, &pCloseListHead, pobj); + + pobj->m_nState = POBJECTSTATE_UPDATE_CLOSE; + pobj->m_Type = (eParticleObjectType)-1; + pobj->m_ParticleType = type; + + pobj->SetPosition(pos); + pobj->m_vecTarget = target; + + pobj->m_nNumEffectCycles = numEffectCycles; + pobj->m_nSkipFrames = skipFrames; + pobj->m_nCreationChance = creationChance; + pobj->m_nFrameCounter = 0; + + pobj->m_bRemove = remove; + + if ( lifeTime != 0 ) + pobj->m_nRemoveTimer = CTimer::GetTimeInMilliseconds() + lifeTime; + else + pobj->m_nRemoveTimer = 0; + + pobj->m_Color.alpha = 0; + + pobj->m_fSize = size; + pobj->m_fRandVal = 0.0f; + + return pobj; +} + void CParticleObject::RemoveObject(void) { @@ -420,7 +432,7 @@ CParticleObject::UpdateAll(void) { CParticleObject *pobj = pCloseListHead; CParticleObject *nextpobj; - if ( pobj != NULL ) + if ( pobj != nil ) { do { @@ -428,7 +440,7 @@ CParticleObject::UpdateAll(void) pobj->UpdateClose(); pobj = nextpobj; } - while ( nextpobj != NULL ); + while ( nextpobj != nil ); } } @@ -438,7 +450,7 @@ CParticleObject::UpdateAll(void) CParticleObject *pobj = pFarListHead; CParticleObject *nextpobj; - if ( pobj != NULL ) + if ( pobj != nil ) { do { @@ -454,7 +466,7 @@ CParticleObject::UpdateAll(void) pobj = nextpobj; } - while ( nextpobj != NULL ); + while ( nextpobj != nil ); } } } @@ -509,7 +521,7 @@ void CParticleObject::UpdateClose(void) flamevel.y = vel.y; flamevel.z = CGeneral::GetRandomNumberInRange(0.0125f*size, 0.1f*size); - CParticle::AddParticle(PARTICLE_FLAME, pos, flamevel, NULL, size); + CParticle::AddParticle(PARTICLE_FLAME, pos, flamevel, nil, size); CVector possmoke = pos; @@ -540,7 +552,7 @@ void CParticleObject::UpdateClose(void) float flamesize = 0.8f*size; - CParticle::AddParticle(PARTICLE_FLAME, pos, flamevel, NULL, flamesize); + CParticle::AddParticle(PARTICLE_FLAME, pos, flamevel, nil, flamesize); for ( int32 i = 0; i < 4; i++ ) @@ -559,7 +571,7 @@ void CParticleObject::UpdateClose(void) case POBJECT_FIREBALL_AND_SMOKE: { - if ( this->m_pParticle == NULL ) + if ( this->m_pParticle == nil ) { CVector pos = this->GetPosition(); CVector vel = this->m_vecTarget; @@ -567,7 +579,7 @@ void CParticleObject::UpdateClose(void) CVector expvel = 1.2f*vel; float expsize = 1.2f*size; - this->m_pParticle = CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, expvel, NULL, expsize); + this->m_pParticle = CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, expvel, nil, expsize); } else { @@ -584,7 +596,7 @@ void CParticleObject::UpdateClose(void) fireballvel.y += CGeneral::GetRandomNumberInRange(-veloffset.y, veloffset.y); fireballvel.z += CGeneral::GetRandomNumberInRange(-veloffset.z, veloffset.z); - CParticle::AddParticle(PARTICLE_FIREBALL_SMOKE, pos, fireballvel, NULL, size); + CParticle::AddParticle(PARTICLE_FIREBALL_SMOKE, pos, fireballvel, nil, size); } } @@ -593,13 +605,13 @@ void CParticleObject::UpdateClose(void) case POBJECT_ROCKET_TRAIL: { - if ( this->m_pParticle == NULL ) + if ( this->m_pParticle == nil ) { CVector pos = this->GetPosition(); CVector vel = this->m_vecTarget; float size = this->m_fSize; - this->m_pParticle = CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, vel, NULL, size); + this->m_pParticle = CParticle::AddParticle(PARTICLE_EXPLOSION_MEDIUM, pos, vel, nil, size); } else { @@ -612,7 +624,7 @@ void CParticleObject::UpdateClose(void) for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ ) { - CParticle::AddParticle(PARTICLE_FIREBALL_SMOKE, pos, fireballvel, NULL, fireballsize); + CParticle::AddParticle(PARTICLE_FIREBALL_SMOKE, pos, fireballvel, nil, fireballsize); } } @@ -634,7 +646,7 @@ void CParticleObject::UpdateClose(void) if ( vel.z != 0.0f ) vel.z += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal); - CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), vel, NULL, this->m_fSize, + CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), vel, nil, this->m_fSize, CGeneral::GetRandomNumberInRange(-6.0f, 6.0f)); } @@ -643,7 +655,6 @@ void CParticleObject::UpdateClose(void) case POBJECT_PED_WATER_SPLASH: { -#ifdef PC_PARTICLE CRGBA colorsmoke(255, 255, 255, 196); CVector pos = this->GetPosition(); @@ -661,9 +672,9 @@ void CParticleObject::UpdateClose(void) splashpos = pos + CVector(0.75f*fCos, 0.75f*fSin, 0.0f); splashvel = vel + CVector(0.05f*fCos, 0.05f*fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f)); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color); @@ -671,9 +682,9 @@ void CParticleObject::UpdateClose(void) splashvel = vel + CVector(0.05f*fCos, 0.05f*-fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f)); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color); @@ -681,18 +692,18 @@ void CParticleObject::UpdateClose(void) splashvel = vel + CVector(0.05f*-fCos, 0.05f*fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f)); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color); splashpos = pos + CVector(0.75f*-fCos, 0.75f*-fSin, 0.0f); splashvel = vel + CVector(0.05f*-fCos, 0.05f*-fSin, CGeneral::GetRandomNumberInRange(0.04f, 0.08f)); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.8f), colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.1f, 0.5f), this->m_Color); } @@ -712,7 +723,7 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color); @@ -722,7 +733,7 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * -fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color); @@ -732,7 +743,7 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color); @@ -742,72 +753,15 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.25f, 0.25f) * -fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.05f, 0.25f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, CGeneral::GetRandomNumberInRange(0.4f, 1.0f), this->m_Color); } -#else - CVector pos; - CVector vel; - - for ( int32 i = -2; i < 2; i++ ) - { - pos = this->GetPosition(); - pos += CVector(-0.75f, 0.5f * float(i), 0.0f); - - vel = this->m_vecTarget; - vel.x += -1.5 * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color); - - pos = this->GetPosition(); - pos += CVector(0.75f, 0.5f * float(i), 0.0f); - - vel = this->m_vecTarget; - vel.x += 1.5f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color); - - pos = this->GetPosition(); - pos += CVector(0.5f * float(i), -0.75, 0.0f); - - vel = this->m_vecTarget; - vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += -1.5f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color); - - - pos = this->GetPosition(); - pos += CVector(0.5f * float(i), 0.75, 0.0f); - - vel = this->m_vecTarget; - vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += 1.5f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color); - } - - - for ( int32 i = 0; i < 4; i++ ) - { - pos = this->GetPosition(); - - pos.x += CGeneral::GetRandomNumberInRange(-1.5f, 1.5f); - pos.y += CGeneral::GetRandomNumberInRange(-1.5f, 1.5f); - pos.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - vel = this->m_vecTarget; - CParticle::AddParticle(PARTICLE_PED_SPLASH, pos, vel, NULL, 0.8f, this->m_Color); - } -#endif break; } case POBJECT_CAR_WATER_SPLASH: { -#ifdef PC_PARTICLE CRGBA colorsmoke(255, 255, 255, 196); CVector pos = this->GetPosition(); @@ -831,8 +785,8 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, size, colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); splashpos = pos + CVector(2.0f*fCos, 2.0f*-fSin, 0.0f); @@ -841,8 +795,8 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * -fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, size, colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); splashpos = pos + CVector(2.0f*-fCos, 2.0f*fSin, 0.0f); splashvel = vel; @@ -850,8 +804,8 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, size, colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); splashpos = pos + CVector(2.0f*-fCos, 2.0f*-fSin, 0.0f); splashvel = vel; @@ -859,8 +813,8 @@ void CParticleObject::UpdateClose(void) splashvel.y += CGeneral::GetRandomNumberInRange(-0.5f, 0.5f) * -fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.01f, 0.03f); - CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, NULL, size, colorsmoke); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_RUBBER_SMOKE, splashpos, splashvel, nil, size, colorsmoke); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); } for ( int32 i = 0; i < 1; i++ ) @@ -879,88 +833,30 @@ void CParticleObject::UpdateClose(void) splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fCos; splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); splashpos = pos + CVector(1.25f*fCos, 1.25f*-fSin, 0.0f); splashvel = vel; splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fCos; splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); splashpos = pos + CVector(1.25f*-fCos, 1.25f*fSin, 0.0f); splashvel = vel; splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fCos; splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); splashpos = pos + CVector(1.25f*-fCos, 1.25f*-fSin, 0.0f); splashvel = vel; splashvel.x += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fCos; splashvel.y += CGeneral::GetRandomNumberInRange(-0.1f, 0.1f) * -fSin; splashvel.z += CGeneral::GetRandomNumberInRange(0.26f, 0.53f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, NULL, 0.0f, this->m_Color); + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, 0.0f, this->m_Color); } -#else - CVector pos; - CVector vel; - - for ( int32 i = -3; i < 4; i++ ) - { - pos = this->GetPosition(); - pos += CVector(-1.5f, 0.5f * float(i), 0.0f); - - - vel = this->m_vecTarget; - vel.x += -3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color); - - - pos = this->GetPosition(); - pos += CVector(1.5f, 0.5f * float(i), 0.0f); - - vel = this->m_vecTarget; - vel.x += 3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color); - - - pos = this->GetPosition(); - pos += CVector(0.5f * float(i), -1.5f, 0.0f); - - vel = this->m_vecTarget; - vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += -3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color); - - - pos = this->GetPosition(); - pos += CVector(0.5f * float(i), 1.5f, 0.0f); - - - vel = this->m_vecTarget; - vel.x += float(i) * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.y += 3.0f * CGeneral::GetRandomNumberInRange(0.001f, 0.006f); - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color); - } - - for ( int32 i = 0; i < 8; i++ ) - { - pos = this->GetPosition(); - pos.x += CGeneral::GetRandomNumberInRange(-3.0f, 3.0f); - pos.y += CGeneral::GetRandomNumberInRange(-3.0f, 3.0f); - - vel = this->m_vecTarget; - vel.z += CGeneral::GetRandomNumberInRange(0.03f, 0.06f); - CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, NULL, 0.0f, this->m_Color); - } -#endif + break; } @@ -979,75 +875,119 @@ void CParticleObject::UpdateClose(void) if ( CGeneral::GetRandomNumber() & 1 ) { CParticle::AddParticle(PARTICLE_RAIN_SPLASH, splashpos, CVector(0.0f, 0.0f, 0.0f), - NULL, 0.1f, this->m_Color); + nil, 0.1f, this->m_Color); } else { CParticle::AddParticle(PARTICLE_RAIN_SPLASHUP, splashpos, CVector(0.0f, 0.0f, 0.0f), - NULL, 0.12f, this->m_Color); + nil, 0.12f, this->m_Color); } } break; } - case POBJECT_CATALINAS_GUNFLASH: + case POBJECT_FIRE_HYDRANT: { - CRGBA flashcolor(120, 120, 120, 255); - - CVector vel = this->m_vecTarget; CVector pos = this->GetPosition(); - - float size = 1.0f; - if ( this->m_fSize != 0.0f ) - size = this->m_fSize; - - CParticle::AddParticle(PARTICLE_GUNFLASH, pos, CVector(0.0f, 0.0f, 0.0f), NULL, 0.12f*size, flashcolor); - - pos += size * (0.06f * vel); - CParticle::AddParticle(PARTICLE_GUNFLASH, pos, CVector(0.0f, 0.0f, 0.0f), NULL, 0.08f*size, flashcolor); - - pos += size * (0.04f * vel); - CParticle::AddParticle(PARTICLE_GUNFLASH, pos, CVector(0.0f, 0.0f, 0.0f), NULL, 0.04f*size, flashcolor); + CVector vel = this->m_vecTarget; - CVector smokepos = this->GetPosition(); - CVector smokevel = 0.1f * vel; - CParticle::AddParticle(PARTICLE_GUNSMOKE2, smokepos, smokevel, NULL, 0.005f*size); + if ( (TheCamera.GetPosition() - pos).Magnitude() > 5.0f ) + { + for ( int32 i = 0; i < 1; i++ ) + { + int32 angle = 180 * i; + + float fCos = CParticle::Cos(angle); + float fSin = CParticle::Sin(angle); + + CVector splashpos, splashvel; + + splashpos = pos + CVector(0.01f*fCos, 0.01f*fSin, 0.0f); + splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300); + + splashpos = pos + CVector(0.01f*fCos, 0.01f*-fSin, 0.0f); + splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300); + + splashpos = pos + CVector(0.01f*-fCos, 0.01f*fSin, 0.0f); + splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300); + + splashpos = pos + CVector(0.01f*-fCos, 0.01f*-fSin, 0.0f); + splashvel = vel + CVector(0.0f, 0.0f, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_CAR_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.005f, 0.0075f), this->m_Color, 0, 0, 1, 300); + } + for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ ) + { + CParticle::AddParticle(this->m_ParticleType, pos, vel, nil, 0.0f, this->m_Color); + } + } break; } - case POBJECT_CATALINAS_SHOTGUNFLASH: + case POBJECT_WATER_FOUNTAIN_VERT: { - CRGBA flashcolor(120, 120, 120, 255); - + CVector pos = this->GetPosition(); CVector vel = this->m_vecTarget; - float size = 1.0f; - if ( this->m_fSize != 0.0f ) - size = this->m_fSize; + for ( int32 i = 0; i < 2; i++ ) + { + int32 angle = 180 * i; + + float fCos = CParticle::Cos(angle); + float fSin = CParticle::Sin(angle); + + CVector splashpos, splashvel; + + splashpos = pos + CVector(0.015f*fCos, 0.015f*fSin, 0.0f); + splashvel = vel + CVector(0.015f*fCos, 0.015f*fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000); + + splashpos = pos + CVector(0.015f*fCos, 0.015f*-fSin, 0.0f); + splashvel = vel + CVector(0.015f*fCos, 0.015f*-fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000); + + splashpos = pos + CVector(0.015f*-fCos, 0.015f*fSin, 0.0f); + splashvel = vel + CVector(0.015f*-fCos, 0.015f*fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000); + + splashpos = pos + CVector(0.015f*-fCos, 0.015f*-fSin, 0.0f); + splashvel = vel + CVector(0.015f*-fCos, 0.015f*-fSin, CGeneral::GetRandomNumberInRange(0.004f, 0.008f)); + + CParticle::AddParticle(PARTICLE_SPLASH, splashpos, splashvel, nil, + CGeneral::GetRandomNumberInRange(0.001f, 0.005f), this->m_Color, 0, 0, 1, 1000); + } + break; + } + + case POBJECT_WATER_FOUNTAIN_HORIZ: + { CVector pos = this->GetPosition(); - - CVector velstep = size * (0.1f * vel); - CVector flashpos = pos; - - flashpos += velstep; - CParticle::AddParticle(PARTICLE_GUNFLASH, flashpos, CVector(0.0f, 0.0f, 0.0f), NULL, 0.0f, flashcolor); - - flashpos += velstep; - CParticle::AddParticle(PARTICLE_GUNFLASH, flashpos, CVector(0.0f, 0.0f, 0.0f), NULL, 0.15f*size, flashcolor); - - flashpos += velstep; - CParticle::AddParticle(PARTICLE_GUNFLASH, flashpos, CVector(0.0f, 0.0f, 0.0f), NULL, 0.2f*size, flashcolor); - + CVector vel = this->m_vecTarget; - CParticle::AddParticle(PARTICLE_GUNFLASH, pos, CVector(0.0f, 0.0f, 0.0f), NULL, 0.0f, flashcolor); + for ( int32 i = 0; i < 3; i++ ) + { + CParticle::AddParticle(PARTICLE_CAR_SPLASH, pos, vel, nil, 0.001f, this->m_Color, 0, 0, 1, 1000); + } - CVector smokepos = this->GetPosition(); - CVector smokevel = 0.1f*vel; - CParticle::AddParticle(PARTICLE_GUNSMOKE2, smokepos, smokevel, NULL, 0.1f*size); - break; } @@ -1068,7 +1008,7 @@ void CParticleObject::UpdateClose(void) if ( vel.z != 0.0f ) vel.z += CGeneral::GetRandomNumberInRange(-this->m_fRandVal, this->m_fRandVal); - CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), vel, NULL, + CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), vel, nil, this->m_fSize, this->m_Color); } } @@ -1076,7 +1016,7 @@ void CParticleObject::UpdateClose(void) { for ( int32 i = 0; i < this->m_nNumEffectCycles; i++ ) { - CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), this->m_vecTarget, NULL, + CParticle::AddParticle(this->m_ParticleType, this->GetPosition(), this->m_vecTarget, nil, this->m_fSize, this->m_Color); } } @@ -1126,7 +1066,6 @@ SaveOneParticle(CParticleObject *p, uint8 *&buffer) #define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); SkipBuf(buf, sizeof(data)) // CPlaceable { - ZeroBuf(buffer, 4); CopyToBuf(buffer, p->GetMatrix().f); ZeroBuf(buffer, 4); CopyToBuf(buffer, p->GetMatrix().m_hasRwMatrix); @@ -1163,15 +1102,15 @@ SaveOneParticle(CParticleObject *p, uint8 *&buffer) bool CParticleObject::SaveParticle(uint8 *buffer, uint32 *length) { - ASSERT( buffer != NULL ); - ASSERT( length != NULL ); + ASSERT( buffer != nil ); + ASSERT( length != nil ); int32 numObjects = 0; - for ( CParticleObject *p = pCloseListHead; p != NULL; p = p->m_pNext ) + for ( CParticleObject *p = pCloseListHead; p != nil; p = p->m_pNext ) ++numObjects; - for ( CParticleObject *p = pFarListHead; p != NULL; p = p->m_pNext ) + for ( CParticleObject *p = pFarListHead; p != nil; p = p->m_pNext ) ++numObjects; *(int32 *)buffer = numObjects; @@ -1180,7 +1119,7 @@ CParticleObject::SaveParticle(uint8 *buffer, uint32 *length) int32 objectsLength = PARTICLE_OBJECT_SIZEOF * (numObjects + 1); int32 dataLength = objectsLength + sizeof(int32); - for ( CParticleObject *p = pCloseListHead; p != NULL; p = p->m_pNext ) + for ( CParticleObject *p = pCloseListHead; p != nil; p = p->m_pNext ) { #ifdef COMPATIBLE_SAVES SaveOneParticle(p, buffer); @@ -1194,7 +1133,7 @@ CParticleObject::SaveParticle(uint8 *buffer, uint32 *length) #endif } - for ( CParticleObject *p = pFarListHead; p != NULL; p = p->m_pNext ) + for ( CParticleObject *p = pFarListHead; p != nil; p = p->m_pNext ) { #ifdef COMPATIBLE_SAVES SaveOneParticle(p, buffer); @@ -1216,7 +1155,7 @@ CParticleObject::SaveParticle(uint8 *buffer, uint32 *length) bool CParticleObject::LoadParticle(uint8 *buffer, uint32 length) { - ASSERT( buffer != NULL ); + ASSERT( buffer != nil ); RemoveAllParticleObjects(); @@ -1239,11 +1178,11 @@ CParticleObject::LoadParticle(uint8 *buffer, uint32 length) buffer += sizeof(CParticleObject); #endif - if ( dst == NULL ) + if ( dst == nil ) return false; MoveToList(&pUnusedListHead, &pCloseListHead, dst); - + #ifndef COMPATIBLE_SAVES dst->m_nState = POBJECTSTATE_UPDATE_CLOSE; dst->m_Type = src->m_Type; @@ -1252,7 +1191,7 @@ CParticleObject::LoadParticle(uint8 *buffer, uint32 length) dst->m_vecTarget = src->m_vecTarget; dst->m_nFrameCounter = src->m_nFrameCounter; dst->m_bRemove = src->m_bRemove; - dst->m_pParticle = NULL; + dst->m_pParticle = nil; dst->m_nRemoveTimer = src->m_nRemoveTimer; dst->m_Color = src->m_Color; dst->m_fSize = src->m_fSize; @@ -1268,7 +1207,6 @@ CParticleObject::LoadParticle(uint8 *buffer, uint32 length) #define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); SkipBuf(buf, sizeof(data)) // CPlaceable { - SkipBuf(buffer, 4); CMatrix matrix; CopyFromBuf(buffer, matrix.f); SkipBuf(buffer, 4); @@ -1309,22 +1247,64 @@ CParticleObject::LoadParticle(uint8 *buffer, uint32 length) } void +CParticleObject::RemoveAllExpireableParticleObjects(void) +{ + { + CParticleObject *pobj = pCloseListHead; + CParticleObject *nextpobj; + if ( pobj != nil ) + { + do + { + nextpobj = pobj->m_pNext; + if ( pobj->m_nRemoveTimer != 0 ) + { + MoveToList(&pCloseListHead, &pUnusedListHead, pobj); + pobj->m_nState = POBJECTSTATE_FREE; + } + pobj = nextpobj; + } + while ( nextpobj != nil ); + } + } + + { + CParticleObject *pobj = pFarListHead; + CParticleObject *nextpobj; + if ( pobj != nil ) + { + do + { + nextpobj = pobj->m_pNext; + if ( pobj->m_nRemoveTimer != 0 ) + { + MoveToList(&pFarListHead, &pUnusedListHead, pobj); + pobj->m_nState = POBJECTSTATE_FREE; + } + pobj = nextpobj; + } + while ( nextpobj != nil ); + } + } +} + +void CParticleObject::RemoveAllParticleObjects(void) { pUnusedListHead = &gPObjectArray[0]; - pCloseListHead = NULL; - pFarListHead = NULL; + pCloseListHead = nil; + pFarListHead = nil; for ( int32 i = 0; i < MAX_PARTICLEOBJECTS; i++ ) { if ( i == 0 ) - gPObjectArray[i].m_pPrev = NULL; + gPObjectArray[i].m_pPrev = nil; else gPObjectArray[i].m_pPrev = &gPObjectArray[i - 1]; if ( i == MAX_PARTICLEOBJECTS-1 ) - gPObjectArray[i].m_pNext = NULL; + gPObjectArray[i].m_pNext = nil; else gPObjectArray[i].m_pNext = &gPObjectArray[i + 1]; @@ -1335,20 +1315,20 @@ CParticleObject::RemoveAllParticleObjects(void) void CParticleObject::MoveToList(CParticleObject **from, CParticleObject **to, CParticleObject *obj) { - ASSERT( from != NULL ); - ASSERT( to != NULL ); - ASSERT( obj != NULL ); + ASSERT( from != nil ); + ASSERT( to != nil ); + ASSERT( obj != nil ); - if ( obj->m_pPrev == NULL ) + if ( obj->m_pPrev == nil ) { *from = obj->m_pNext; if ( *from ) - (*from)->m_pPrev = NULL; + (*from)->m_pPrev = nil; } else { - if ( obj->m_pNext == NULL ) - obj->m_pPrev->m_pNext = NULL; + if ( obj->m_pNext == nil ) + obj->m_pPrev->m_pNext = nil; else { obj->m_pNext->m_pPrev = obj->m_pPrev; @@ -1357,7 +1337,7 @@ CParticleObject::MoveToList(CParticleObject **from, CParticleObject **to, CParti } obj->m_pNext = *to; - obj->m_pPrev = NULL; + obj->m_pPrev = nil; *to = obj; if ( obj->m_pNext ) |