Merge remote-tracking branch 'upstream/miami' into miami

This commit is contained in:
Nikolay Korolev 2020-10-18 17:30:51 +03:00
commit d7789661cd
23 changed files with 198 additions and 158 deletions

View File

@ -1,4 +1,4 @@
#include "common.h" #include "common.h"
#include "AudioManager.h" #include "AudioManager.h"
#include "audio_enums.h" #include "audio_enums.h"
@ -993,7 +993,7 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
int32 emittingVol; int32 emittingVol;
uint32 freq; uint32 freq;
float modificator; float multiplier;
int sampleFreq; int sampleFreq;
float velocity; float velocity;
@ -1016,9 +1016,9 @@ cAudioManager::ProcessVehicleRoadNoise(cVehicleParams *params)
freq = 6050 * emittingVol / 30 + 16000; freq = 6050 * emittingVol / 30 + 16000;
} else { } else {
m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE; m_sQueueSample.m_nSampleIndex = SFX_ROAD_NOISE;
modificator = m_sQueueSample.m_fDistance / 190.f; multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f;
sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); sampleFreq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
freq = (sampleFreq * modificator) + ((3 * sampleFreq) / 4); freq = (sampleFreq * multiplier) + ((3 * sampleFreq) / 4);
} }
m_sQueueSample.m_nFrequency = freq; m_sQueueSample.m_nFrequency = freq;
m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nLoopCount = 0;
@ -1046,7 +1046,7 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
float relativeVelocity; float relativeVelocity;
int32 emittingVol; int32 emittingVol;
float modificator; float multiplier;
int freq; int freq;
float velChange; float velChange;
@ -1066,9 +1066,13 @@ cAudioManager::ProcessWetRoadNoise(cVehicleParams *params)
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
m_sQueueSample.m_bIs2D = false; m_sQueueSample.m_bIs2D = false;
m_sQueueSample.m_nReleasingVolumeModificator = 3; m_sQueueSample.m_nReleasingVolumeModificator = 3;
modificator = m_sQueueSample.m_fDistance / 6.f; #ifdef FIX_BUGS
multiplier = (m_sQueueSample.m_fDistance / SOUND_INTENSITY) * 0.5f;
#else
multiplier = (m_sQueueSample.m_fDistance / 3.0f) * 0.5f;
#endif
freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE); freq = SampleManager.GetSampleBaseFrequency(SFX_ROAD_NOISE);
m_sQueueSample.m_nFrequency = freq + freq * modificator; m_sQueueSample.m_nFrequency = freq + freq * multiplier;
m_sQueueSample.m_nLoopCount = 0; m_sQueueSample.m_nLoopCount = 0;
m_sQueueSample.m_nEmittingVolume = emittingVol; m_sQueueSample.m_nEmittingVolume = emittingVol;
m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex); m_sQueueSample.m_nLoopStart = SampleManager.GetSampleLoopStartOffset(m_sQueueSample.m_nSampleIndex);
@ -4923,17 +4927,25 @@ cAudioManager::ProcessFires(int32)
void void
cAudioManager::ProcessWaterCannon(int32) cAudioManager::ProcessWaterCannon(int32)
{ {
const float SOUND_INTENSITY = 900.0f; const float SOUND_INTENSITY = 30.0f;
for (int32 i = 0; i < NUM_WATERCANNONS; i++) { for (int32 i = 0; i < NUM_WATERCANNONS; i++) {
if (CWaterCannons::aCannons[i].m_nId) { if (CWaterCannons::aCannons[i].m_nId) {
m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur]; m_sQueueSample.m_vecPos = CWaterCannons::aCannons[0].m_avecPos[CWaterCannons::aCannons[i].m_nCur];
float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos); float distSquared = GetDistanceSquared(m_sQueueSample.m_vecPos);
if (distSquared < SOUND_INTENSITY) { if (distSquared < SQR(SOUND_INTENSITY)) {
m_sQueueSample.m_fDistance = Sqrt(distSquared); m_sQueueSample.m_fDistance = Sqrt(distSquared);
#ifdef FIX_BUGS
m_sQueueSample.m_nVolume = ComputeVolume(50, SOUND_INTENSITY, m_sQueueSample.m_fDistance);
#else
m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance); m_sQueueSample.m_nVolume = ComputeVolume(50, m_sQueueSample.m_fSoundIntensity, m_sQueueSample.m_fDistance);
#endif
if (m_sQueueSample.m_nVolume != 0) { if (m_sQueueSample.m_nVolume != 0) {
#ifdef FIX_BUGS
m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY; m_sQueueSample.m_fSoundIntensity = SOUND_INTENSITY;
#else
m_sQueueSample.m_fSoundIntensity = SQR(SOUND_INTENSITY);
#endif
m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI; m_sQueueSample.m_nSampleIndex = SFX_JUMBO_TAXI;
m_sQueueSample.m_nBankIndex = SFX_BANK_0; m_sQueueSample.m_nBankIndex = SFX_BANK_0;
m_sQueueSample.m_nFrequency = 15591; m_sQueueSample.m_nFrequency = 15591;

View File

@ -122,11 +122,11 @@ CPickup::GiveUsAPickUpObject(int32 handle)
{ {
CObject *object; CObject *object;
if (handle <= 0) object = new CObject(m_eModelIndex, false); if (handle >= 0) {
else {
CPools::MakeSureSlotInObjectPoolIsEmpty(handle); CPools::MakeSureSlotInObjectPoolIsEmpty(handle);
object = new(handle) CObject(m_eModelIndex, false); object = new (handle) CObject(m_eModelIndex, false);
} } else
object = new CObject(m_eModelIndex, false);
if (object == nil) return nil; if (object == nil) return nil;
object->ObjectCreatedBy = MISSION_OBJECT; object->ObjectCreatedBy = MISSION_OBJECT;
@ -729,7 +729,7 @@ CPickups::Update()
#ifdef CAMERA_PICKUP #ifdef CAMERA_PICKUP
if ( bPickUpcamActivated ) // taken from PS2 if ( bPickUpcamActivated ) // taken from PS2
{ {
float dist = (FindPlayerCoors() - StaticCamCoors).Magnitude2D(); float dist = Distance2D(StaticCamCoors, FindPlayerCoors());
float mult; float mult;
if ( dist < 10.0f ) if ( dist < 10.0f )
mult = 1.0f - (dist / 10.0f ); mult = 1.0f - (dist / 10.0f );
@ -745,8 +745,7 @@ CPickups::Update()
TheCamera.TakeControl(FindPlayerVehicle(), CCam::MODE_FIXED, JUMP_CUT, CAMCONTROL_SCRIPT); TheCamera.TakeControl(FindPlayerVehicle(), CCam::MODE_FIXED, JUMP_CUT, CAMCONTROL_SCRIPT);
} }
if ( FindPlayerVehicle() != pPlayerVehicle if ( FindPlayerVehicle() != pPlayerVehicle || Distance(StaticCamCoors, FindPlayerCoors()) > 40.0f
|| (FindPlayerCoors() - StaticCamCoors).Magnitude() > 40.0f
|| ((CTimer::GetTimeInMilliseconds() - StaticCamStartTime) > 60000) ) || ((CTimer::GetTimeInMilliseconds() - StaticCamStartTime) > 60000) )
{ {
TheCamera.RestoreWithJumpCut(); TheCamera.RestoreWithJumpCut();
@ -836,7 +835,7 @@ CPickups::DoPickUpEffects(CEntity *entity)
CObject *object = (CObject*)entity; CObject *object = (CObject*)entity;
if (object->bPickupObjWithMessage || object->bOutOfStock || object->m_nBonusValue) { if (object->bPickupObjWithMessage || object->bOutOfStock || object->m_nBonusValue) {
float dist = (TheCamera.GetPosition() - pos).Magnitude(); float dist = Distance2D(pos, TheCamera.GetPosition());
const float MAXDIST = 12.0f; const float MAXDIST = 12.0f;
if (dist < MAXDIST && NumMessages < NUMPICKUPMESSAGES) { if (dist < MAXDIST && NumMessages < NUMPICKUPMESSAGES) {
@ -879,7 +878,7 @@ void
CPickups::DoMineEffects(CEntity *entity) CPickups::DoMineEffects(CEntity *entity)
{ {
const CVector &pos = entity->GetPosition(); const CVector &pos = entity->GetPosition();
float dist = (TheCamera.GetPosition() - pos).Magnitude(); float dist = Distance(pos, TheCamera.GetPosition());
const float MAXDIST = 20.0f; const float MAXDIST = 20.0f;
if (dist < MAXDIST) { if (dist < MAXDIST) {
@ -898,7 +897,7 @@ void
CPickups::DoMoneyEffects(CEntity *entity) CPickups::DoMoneyEffects(CEntity *entity)
{ {
const CVector &pos = entity->GetPosition(); const CVector &pos = entity->GetPosition();
float dist = (TheCamera.GetPosition() - pos).Magnitude(); float dist = Distance(pos, TheCamera.GetPosition());
const float MAXDIST = 20.0f; const float MAXDIST = 20.0f;
if (dist < MAXDIST) { if (dist < MAXDIST) {
@ -917,7 +916,7 @@ void
CPickups::DoCollectableEffects(CEntity *entity) CPickups::DoCollectableEffects(CEntity *entity)
{ {
const CVector &pos = entity->GetPosition(); const CVector &pos = entity->GetPosition();
float dist = (TheCamera.GetPosition() - pos).Magnitude(); float dist = Distance(pos, TheCamera.GetPosition());
const float MAXDIST = 14.0f; const float MAXDIST = 14.0f;
if (dist < MAXDIST) { if (dist < MAXDIST) {

View File

@ -236,7 +236,7 @@ CRoadBlocks::CreateRoadBlockBetween2Points(CVector point1, CVector point2)
tmp.GetPosition().z += fModelRadius - 0.6f; tmp.GetPosition().z += fModelRadius - 0.6f;
pVehicle->m_matrix = tmp; pVehicle->m_matrix = tmp;
pVehicle->PlaceOnRoadProperly(); pVehicle->PlaceOnRoadProperly();
pVehicle->bIsStatic = false; pVehicle->SetIsStatic(false);
pVehicle->m_matrix.UpdateRW(); pVehicle->m_matrix.UpdateRW();
pVehicle->m_nDoorLock = CARLOCK_UNLOCKED; pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
CCarCtrl::JoinCarWithRoadSystem(pVehicle); CCarCtrl::JoinCarWithRoadSystem(pVehicle);

View File

@ -1704,7 +1704,7 @@ static void PossiblyWakeThisEntity(CPhysical* pEntity, bool ifColLoaded = false)
return; return;
if (!ifColLoaded || CColStore::HasCollisionLoaded(pEntity->GetPosition())) { if (!ifColLoaded || CColStore::HasCollisionLoaded(pEntity->GetPosition())) {
pEntity->bIsStaticWaitingForCollision = false; pEntity->bIsStaticWaitingForCollision = false;
if (!pEntity->IsStatic()) if (!pEntity->GetIsStatic())
pEntity->AddToMovingList(); pEntity->AddToMovingList();
} }
} }
@ -2381,9 +2381,11 @@ void CTheScripts::Process()
case 4: case 4:
AllowMissionReplay = 5; AllowMissionReplay = 5;
RetryMission(0, 0); RetryMission(0, 0);
break;
case 6: case 6:
AllowMissionReplay = 7; AllowMissionReplay = 7;
TimeToWaitTill = CTimer::GetTimeInMilliseconds() + 500; TimeToWaitTill = CTimer::GetTimeInMilliseconds() + 500;
break;
case 7: case 7:
if (TimeToWaitTill < CTimer::GetTimeInMilliseconds()) { if (TimeToWaitTill < CTimer::GetTimeInMilliseconds()) {
AllowMissionReplay = 0; AllowMissionReplay = 0;
@ -3971,7 +3973,7 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
if (pos.z <= MAP_Z_LOW_LIMIT) if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y); pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel(); pos.z += car->GetDistanceFromCentreOfMassToBaseOfModel();
car->bIsStatic = false; car->SetIsStatic(false);
/* Again weird usage of virtual functions. */ /* Again weird usage of virtual functions. */
if (car->IsBoat()) { if (car->IsBoat()) {
car->Teleport(pos); car->Teleport(pos);
@ -9647,13 +9649,13 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
script_assert(pObject); script_assert(pObject);
if (ScriptParams[1]) { if (ScriptParams[1]) {
if (pObject->bIsStatic) { if (pObject->bIsStatic) {
pObject->bIsStatic = false; pObject->SetIsStatic(false);
pObject->AddToMovingList(); pObject->AddToMovingList();
} }
} }
else { else {
if (!pObject->bIsStatic) { if (!pObject->bIsStatic) {
pObject->bIsStatic = true; pObject->SetIsStatic(true);
pObject->RemoveFromMovingList(); pObject->RemoveFromMovingList();
} }
} }
@ -13725,7 +13727,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
pVehicle->bDontLoadCollision = true; pVehicle->bDontLoadCollision = true;
if (pVehicle->bIsStaticWaitingForCollision) { if (pVehicle->bIsStaticWaitingForCollision) {
pVehicle->bIsStaticWaitingForCollision = false; pVehicle->bIsStaticWaitingForCollision = false;
if (!pVehicle->IsStatic()) if (!pVehicle->GetIsStatic())
pVehicle->AddToMovingList(); pVehicle->AddToMovingList();
} }
} }
@ -13748,7 +13750,7 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
pPed->bDontLoadCollision = true; pPed->bDontLoadCollision = true;
if (pPed->bIsStaticWaitingForCollision) { if (pPed->bIsStaticWaitingForCollision) {
pPed->bIsStaticWaitingForCollision = false; pPed->bIsStaticWaitingForCollision = false;
if (!pPed->IsStatic()) if (!pPed->GetIsStatic())
pPed->AddToMovingList(); pPed->AddToMovingList();
} }
} }

View File

@ -4247,7 +4247,7 @@ CCam::GetLookFromLampPostPos(CEntity *Target, CPed *Cop, CVector &TargetCoors, C
CWorld::FindObjectsInRange(TargetCoors, 30.0f, true, &NumObjects, 15, Objects, false, false, false, true, true); CWorld::FindObjectsInRange(TargetCoors, 30.0f, true, &NumObjects, 15, Objects, false, false, false, true, true);
float NearestDist = 10000.0f; float NearestDist = 10000.0f;
for(i = 0; i < NumObjects; i++){ for(i = 0; i < NumObjects; i++){
if(Objects[i]->IsStatic() && Objects[i]->GetUp().z > 0.9f && IsLampPost(Objects[i]->GetModelIndex())){ if(Objects[i]->GetIsStatic() && Objects[i]->GetUp().z > 0.9f && IsLampPost(Objects[i]->GetModelIndex())){
float Dist = (Objects[i]->GetPosition() - TargetCoors).Magnitude2D(); float Dist = (Objects[i]->GetPosition() - TargetCoors).Magnitude2D();
if(Abs(ARRESTCAM_LAMP_BEST_DIST - Dist) < NearestDist){ if(Abs(ARRESTCAM_LAMP_BEST_DIST - Dist) < NearestDist){
CVector TestStart = Objects[i]->GetColModel()->boundingBox.max; CVector TestStart = Objects[i]->GetColModel()->boundingBox.max;

View File

@ -272,7 +272,7 @@ uint8 CRadar::CalculateBlipAlpha(float dist)
return 255; return 255;
if (dist <= 10.0f) if (dist <= 10.0f)
return (128.0f * ((dist - 1.0f) / 4.0f)) + ((1.0f - (dist - 1.0f) / 4.0f) * 255.0f); return (128.0f * ((dist - 1.0f) / 9.0f)) + ((1.0f - (dist - 1.0f) / 9.0f) * 255.0f);
return 128; return 128;
} }

View File

@ -79,7 +79,7 @@ CWorld::Add(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return; if(ent->IsBuilding() || ent->IsDummy()) return;
if(!ent->IsStatic()) ((CPhysical *)ent)->AddToMovingList(); if(!ent->GetIsStatic()) ((CPhysical *)ent)->AddToMovingList();
} }
void void
@ -94,7 +94,7 @@ CWorld::Remove(CEntity *ent)
if(ent->IsBuilding() || ent->IsDummy()) return; if(ent->IsBuilding() || ent->IsDummy()) return;
if(!ent->IsStatic()) ((CPhysical *)ent)->RemoveFromMovingList(); if(!ent->GetIsStatic()) ((CPhysical *)ent)->RemoveFromMovingList();
} }
void void
@ -1962,7 +1962,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt); RemoveEntityInsteadOfProcessingIt(movingEnt);
} else { } else {
movingEnt->ProcessControl(); movingEnt->ProcessControl();
if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); } if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); }
} }
} }
bForceProcessControl = true; bForceProcessControl = true;
@ -1973,7 +1973,7 @@ CWorld::Process(void)
RemoveEntityInsteadOfProcessingIt(movingEnt); RemoveEntityInsteadOfProcessingIt(movingEnt);
} else { } else {
movingEnt->ProcessControl(); movingEnt->ProcessControl();
if(movingEnt->IsStatic()) { movingEnt->RemoveFromMovingList(); } if(movingEnt->GetIsStatic()) { movingEnt->RemoveFromMovingList(); }
} }
} }
} }
@ -2133,13 +2133,13 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
CObject *pObject = (CObject *)pEntity; CObject *pObject = (CObject *)pEntity;
CVehicle *pVehicle = (CVehicle *)pEntity; CVehicle *pVehicle = (CVehicle *)pEntity;
if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) { if(!pEntity->bExplosionProof && (!pEntity->IsPed() || !pPed->bInVehicle)) {
if(pEntity->IsStatic()) { if(pEntity->GetIsStatic()) {
if(pEntity->IsObject()) { if(pEntity->IsObject()) {
if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) { if (fPower > pObject->m_fUprootLimit || IsFence(pObject->GetModelIndex())) {
if (IsGlass(pObject->GetModelIndex())) { if (IsGlass(pObject->GetModelIndex())) {
CGlass::WindowRespondsToExplosion(pObject, position); CGlass::WindowRespondsToExplosion(pObject, position);
} else { } else {
pObject->bIsStatic = false; pObject->SetIsStatic(false);
pObject->AddToMovingList(); pObject->AddToMovingList();
int16 modelId = pEntity->GetModelIndex(); int16 modelId = pEntity->GetModelIndex();
if(modelId != MI_FIRE_HYDRANT || if(modelId != MI_FIRE_HYDRANT ||
@ -2157,18 +2157,18 @@ CWorld::TriggerExplosionSectorList(CPtrList &list, const CVector &position, floa
} }
} }
} }
if(pEntity->IsStatic()) { if(pEntity->GetIsStatic()) {
float fDamageMultiplier = float fDamageMultiplier =
(fRadius - fMagnitude) * 2.0f / fRadius; (fRadius - fMagnitude) * 2.0f / fRadius;
float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f); float fDamage = 300.0f * Min(fDamageMultiplier, 1.0f);
pObject->ObjectDamage(fDamage); pObject->ObjectDamage(fDamage);
} }
} else { } else {
pEntity->bIsStatic = false; pEntity->SetIsStatic(false);
pEntity->AddToMovingList(); pEntity->AddToMovingList();
} }
} }
if(!pEntity->IsStatic()) { if(!pEntity->GetIsStatic()) {
float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f); float fDamageMultiplier = Min((fRadius - fMagnitude) * 2.0f / fRadius, 1.0f);
CVector vecForceDir = CVector vecForceDir =
vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier / vecDistance * (fPower * pEntity->m_fMass * 0.00071429f * fDamageMultiplier /

View File

@ -104,7 +104,8 @@ public:
eEntityStatus GetStatus() const { return (eEntityStatus)m_status; } eEntityStatus GetStatus() const { return (eEntityStatus)m_status; }
void SetStatus(eEntityStatus status) { m_status = status; } void SetStatus(eEntityStatus status) { m_status = status; }
CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); } CColModel *GetColModel(void) { return CModelInfo::GetModelInfo(m_modelIndex)->GetColModel(); }
bool IsStatic(void) { return bIsStatic || bIsStaticWaitingForCollision; } bool GetIsStatic(void) const { return bIsStatic || bIsStaticWaitingForCollision; }
void SetIsStatic(bool state) { bIsStatic = state; }
#ifdef COMPATIBLE_SAVES #ifdef COMPATIBLE_SAVES
void SaveEntityFlags(uint8*& buf); void SaveEntityFlags(uint8*& buf);
void LoadEntityFlags(uint8*& buf); void LoadEntityFlags(uint8*& buf);

View File

@ -344,7 +344,7 @@ CPhysical::ProcessEntityCollision(CEntity *ent, CColPoint *colpoints)
AddCollisionRecord(ent); AddCollisionRecord(ent);
if(!ent->IsBuilding()) // Can't this catch dummies too? if(!ent->IsBuilding()) // Can't this catch dummies too?
((CPhysical*)ent)->AddCollisionRecord(this); ((CPhysical*)ent)->AddCollisionRecord(this);
if(ent->IsBuilding() || ent->IsStatic()) if(ent->IsBuilding() || ent->GetIsStatic())
this->bHasHitWall = true; this->bHasHitWall = true;
} }
return numSpheres; return numSpheres;
@ -380,7 +380,7 @@ CPhysical::ProcessControl(void)
m_nStaticFrames++; m_nStaticFrames++;
if(m_nStaticFrames > 10){ if(m_nStaticFrames > 10){
m_nStaticFrames = 10; m_nStaticFrames = 10;
bIsStatic = true; SetIsStatic(true);
m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecMoveSpeed = CVector(0.0f, 0.0f, 0.0f);
m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f); m_vecTurnSpeed = CVector(0.0f, 0.0f, 0.0f);
m_vecMoveFriction = m_vecMoveSpeed; m_vecMoveFriction = m_vecMoveSpeed;
@ -614,7 +614,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
} }
float speedA, speedB; float speedA, speedB;
if(B->IsStatic() && !foo){ if(B->GetIsStatic() && !foo){
if(A->bPedPhysics){ if(A->bPedPhysics){
speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal); speedA = DotProduct(A->m_vecMoveSpeed, colpoint.normal);
if(speedA < 0.0f){ if(speedA < 0.0f){
@ -625,7 +625,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(IsGlass(B->GetModelIndex())) if(IsGlass(B->GetModelIndex()))
CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false); CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false);
else if(!B->bInfiniteMass){ else if(!B->bInfiniteMass){
B->bIsStatic = false; B->SetIsStatic(false);
CWorld::Players[CWorld::PlayerInFocus].m_nHavocLevel += 2; CWorld::Players[CWorld::PlayerInFocus].m_nHavocLevel += 2;
CStats::PropertyDestroyed += CGeneral::GetRandomNumberInRange(30, 60); CStats::PropertyDestroyed += CGeneral::GetRandomNumberInRange(30, 60);
} }
@ -637,7 +637,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
return true; return true;
} }
}else if(!B->bInfiniteMass) }else if(!B->bInfiniteMass)
B->bIsStatic = false; B->SetIsStatic(false);
if(B->bInfiniteMass){ if(B->bInfiniteMass){
impulseA = -speedA * A->m_fMass; impulseA = -speedA * A->m_fMass;
@ -675,7 +675,7 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
if(IsGlass(B->GetModelIndex())) if(IsGlass(B->GetModelIndex()))
CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false); CGlass::WindowRespondsToCollision(B, impulseA, A->m_vecMoveSpeed, colpoint.point, false);
else else
B->bIsStatic = false; B->SetIsStatic(false);
int16 model = B->GetModelIndex(); int16 model = B->GetModelIndex();
if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){ if(model == MI_FIRE_HYDRANT && !Bobj->bHasBeenDamaged){
CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true); CParticleObject::AddObject(POBJECT_FIRE_HYDRANT, B->GetPosition() - CVector(0.0f, 0.0f, 0.5f), true);
@ -699,11 +699,11 @@ CPhysical::ApplyCollision(CPhysical *B, CColPoint &colpoint, float &impulseA, fl
return true; return true;
} }
}else if(!B->bInfiniteMass) }else if(!B->bInfiniteMass)
B->bIsStatic = false; B->SetIsStatic(false);
} }
} }
if(B->IsStatic()) if(B->GetIsStatic())
return false; return false;
if(!B->bInfiniteMass && !B->m_phy_flagA08) if(!B->bInfiniteMass && !B->m_phy_flagA08)
B->AddToMovingList(); B->AddToMovingList();
@ -1231,7 +1231,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
canshift = true; canshift = true;
else else
canshift = A->IsPed() && canshift = A->IsPed() &&
B->IsObject() && B->IsStatic() && !Bobj->bHasBeenDamaged; B->IsObject() && B->GetIsStatic() && !Bobj->bHasBeenDamaged;
if(B == A || if(B == A ||
B->m_scanCode == CWorld::GetCurrentScanCode() || B->m_scanCode == CWorld::GetCurrentScanCode() ||
!B->bUsesCollision || !B->bUsesCollision ||
@ -1255,7 +1255,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Aobj = (CObject*)A; CObject *Aobj = (CObject*)A;
if(Aobj->ObjectCreatedBy != TEMP_OBJECT && if(Aobj->ObjectCreatedBy != TEMP_OBJECT &&
!Aobj->bHasBeenDamaged && !Aobj->bHasBeenDamaged &&
Aobj->IsStatic()){ Aobj->GetIsStatic()){
if(Aobj->m_pCollidingEntity == B) if(Aobj->m_pCollidingEntity == B)
Aobj->m_pCollidingEntity = nil; Aobj->m_pCollidingEntity = nil;
}else if(Aobj->m_pCollidingEntity != B){ }else if(Aobj->m_pCollidingEntity != B){
@ -1272,7 +1272,7 @@ CPhysical::ProcessShiftSectorList(CPtrList *lists)
CObject *Bobj = (CObject*)B; CObject *Bobj = (CObject*)B;
if(Bobj->ObjectCreatedBy != TEMP_OBJECT && if(Bobj->ObjectCreatedBy != TEMP_OBJECT &&
!Bobj->bHasBeenDamaged && !Bobj->bHasBeenDamaged &&
Bobj->IsStatic()){ Bobj->GetIsStatic()){
if(Bobj->m_pCollidingEntity == A) if(Bobj->m_pCollidingEntity == A)
Bobj->m_pCollidingEntity = nil; Bobj->m_pCollidingEntity = nil;
}else if(Bobj->m_pCollidingEntity != A){ }else if(Bobj->m_pCollidingEntity != A){
@ -1595,7 +1595,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true; skipCollision = true;
else if(Aobj->ObjectCreatedBy == TEMP_OBJECT || else if(Aobj->ObjectCreatedBy == TEMP_OBJECT ||
Aobj->bHasBeenDamaged || Aobj->bHasBeenDamaged ||
!Aobj->IsStatic()){ !Aobj->GetIsStatic()){
if(Aobj->m_pCollidingEntity == B) if(Aobj->m_pCollidingEntity == B)
skipCollision = true; skipCollision = true;
else if(Aobj->m_nCollisionDamageEffect < DAMAGE_EFFECT_SMASH_COMPLETELY){ else if(Aobj->m_nCollisionDamageEffect < DAMAGE_EFFECT_SMASH_COMPLETELY){
@ -1614,7 +1614,7 @@ CPhysical::ProcessCollisionSectorList(CPtrList *lists)
skipCollision = true; skipCollision = true;
else if(Bobj->ObjectCreatedBy == TEMP_OBJECT || else if(Bobj->ObjectCreatedBy == TEMP_OBJECT ||
Bobj->bHasBeenDamaged || Bobj->bHasBeenDamaged ||
!Bobj->IsStatic()){ !Bobj->GetIsStatic()){
if(Bobj->m_pCollidingEntity == A) if(Bobj->m_pCollidingEntity == A)
skipCollision = true; skipCollision = true;
else if(Bobj->m_nCollisionDamageEffect < DAMAGE_EFFECT_SMASH_COMPLETELY){ else if(Bobj->m_nCollisionDamageEffect < DAMAGE_EFFECT_SMASH_COMPLETELY){

View File

@ -115,6 +115,14 @@ Distance(const CVector &v1, const CVector &v2)
return (v2 - v1).Magnitude(); return (v2 - v1).Magnitude();
} }
inline float
Distance2D(const CVector &v1, const CVector &v2)
{
float x = v2.x - v1.x;
float y = v2.y - v1.y;
return Sqrt(x*x + y*y);
}
class CMatrix; class CMatrix;
CVector Multiply3x3(const CMatrix &mat, const CVector &vec); CVector Multiply3x3(const CMatrix &mat, const CVector &vec);

View File

@ -98,7 +98,7 @@ CObject::ProcessControl(void)
CPhysical::ProcessControl(); CPhysical::ProcessControl();
if (mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)) { if (mod_Buoyancy.ProcessBuoyancy(this, m_fBuoyancy, &point, &impulse)) {
bIsInWater = true; bIsInWater = true;
bIsStatic = false; SetIsStatic(false);
ApplyMoveForce(impulse); ApplyMoveForce(impulse);
ApplyTurnForce(impulse, point); ApplyTurnForce(impulse, point);
float fTimeStep = Pow(0.97f, CTimer::GetTimeStep()); float fTimeStep = Pow(0.97f, CTimer::GetTimeStep());
@ -197,7 +197,7 @@ CObject::ObjectDamage(float amount)
case DAMAGE_EFFECT_SMASH_COMPLETELY: case DAMAGE_EFFECT_SMASH_COMPLETELY:
bIsVisible = false; bIsVisible = false;
bUsesCollision = false; bUsesCollision = false;
bIsStatic = true; SetIsStatic(true);
bExplosionProof = true; bExplosionProof = true;
SetMoveSpeed(0.0f, 0.0f, 0.0f); SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f);
@ -209,7 +209,7 @@ CObject::ObjectDamage(float amount)
else { else {
bIsVisible = false; bIsVisible = false;
bUsesCollision = false; bUsesCollision = false;
bIsStatic = true; SetIsStatic(true);
bExplosionProof = true; bExplosionProof = true;
SetMoveSpeed(0.0f, 0.0f, 0.0f); SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f);
@ -218,7 +218,7 @@ CObject::ObjectDamage(float amount)
case DAMAGE_EFFECT_SMASH_CARDBOARD_COMPLETELY: { case DAMAGE_EFFECT_SMASH_CARDBOARD_COMPLETELY: {
bIsVisible = false; bIsVisible = false;
bUsesCollision = false; bUsesCollision = false;
bIsStatic = true; SetIsStatic(true);
bExplosionProof = true; bExplosionProof = true;
SetMoveSpeed(0.0f, 0.0f, 0.0f); SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f);
@ -241,7 +241,7 @@ CObject::ObjectDamage(float amount)
case DAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: { case DAMAGE_EFFECT_SMASH_WOODENBOX_COMPLETELY: {
bIsVisible = false; bIsVisible = false;
bUsesCollision = false; bUsesCollision = false;
bIsStatic = true; SetIsStatic(true);
bExplosionProof = true; bExplosionProof = true;
SetMoveSpeed(0.0f, 0.0f, 0.0f); SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f);
@ -264,7 +264,7 @@ CObject::ObjectDamage(float amount)
case DAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: { case DAMAGE_EFFECT_SMASH_TRAFFICCONE_COMPLETELY: {
bIsVisible = false; bIsVisible = false;
bUsesCollision = false; bUsesCollision = false;
bIsStatic = true; SetIsStatic(true);
bExplosionProof = true; bExplosionProof = true;
SetMoveSpeed(0.0f, 0.0f, 0.0f); SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f);
@ -289,7 +289,7 @@ CObject::ObjectDamage(float amount)
case DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: { case DAMAGE_EFFECT_SMASH_BARPOST_COMPLETELY: {
bIsVisible = false; bIsVisible = false;
bUsesCollision = false; bUsesCollision = false;
bIsStatic = true; SetIsStatic(true);
bExplosionProof = true; bExplosionProof = true;
SetMoveSpeed(0.0f, 0.0f, 0.0f); SetMoveSpeed(0.0f, 0.0f, 0.0f);
SetTurnSpeed(0.0f, 0.0f, 0.0f); SetTurnSpeed(0.0f, 0.0f, 0.0f);
@ -329,7 +329,7 @@ CObject::Init(void)
CObjectData::SetObjectData(GetModelIndex(), *this); CObjectData::SetObjectData(GetModelIndex(), *this);
m_nEndOfLifeTime = 0; m_nEndOfLifeTime = 0;
ObjectCreatedBy = GAME_OBJECT; ObjectCreatedBy = GAME_OBJECT;
bIsStatic = true; SetIsStatic(true);
bIsPickup = false; bIsPickup = false;
bPickupObjWithMessage = false; bPickupObjWithMessage = false;
bOutOfStock = false; bOutOfStock = false;

View File

@ -425,7 +425,7 @@ void CCivilianPed::FindNearbyAttractorsSectorList(CPtrList& list, float& minDist
{ {
for (CPtrNode* pNode = list.first; pNode != nil; pNode = pNode->next) { for (CPtrNode* pNode = list.first; pNode != nil; pNode = pNode->next) {
CEntity* pEntity = (CEntity*)pNode->item; CEntity* pEntity = (CEntity*)pNode->item;
if (pEntity->IsObject() && (!pEntity->IsStatic() || ((CObject*)pEntity)->bHasBeenDamaged)) if (pEntity->IsObject() && (!pEntity->GetIsStatic() || ((CObject*)pEntity)->bHasBeenDamaged))
continue; continue;
CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(pEntity->GetModelIndex()); CBaseModelInfo* pModelInfo = CModelInfo::GetModelInfo(pEntity->GetModelIndex());
for (int i = 0; i < pModelInfo->GetNum2dEffects(); i++) { for (int i = 0; i < pModelInfo->GetNum2dEffects(); i++) {

View File

@ -15403,17 +15403,17 @@ CPed::ProcessObjective(void)
CVector distance = m_nextRoutePointPos - GetPosition(); CVector distance = m_nextRoutePointPos - GetPosition();
distance.z = 0.0f; distance.z = 0.0f;
if (m_objective == OBJECTIVE_GOTO_SHELTER_ON_FOOT) { if (m_objective == OBJECTIVE_GOTO_SHELTER_ON_FOOT) {
if (m_nMoveState == PEDMOVE_SPRINT && distance.Magnitude() < SQR(2.0f)) { if (m_nMoveState == PEDMOVE_RUN && distance.Magnitude() < SQR(2.0f)) {
SetMoveState(PEDMOVE_WALK); SetMoveState(PEDMOVE_WALK);
bIsRunning = false; bIsRunning = false;
} }
else if (CWeather::Rain < 0.2f && m_attractor) { if (CWeather::Rain < 0.2f && m_attractor) {
GetPedAttractorManager()->DeRegisterPed(this, m_attractor); GetPedAttractorManager()->DeRegisterPed(this, m_attractor);
return; return;
} }
} }
else if (m_objective == OBJECTIVE_GOTO_ICE_CREAM_VAN_ON_FOOT) { else if (m_objective == OBJECTIVE_GOTO_ICE_CREAM_VAN_ON_FOOT) {
if (m_nMoveState == PEDMOVE_SPRINT && distance.Magnitude() < SQR(4.0f)) { if (m_nMoveState == PEDMOVE_RUN && distance.Magnitude() < SQR(4.0f)) {
SetMoveState(PEDMOVE_WALK); SetMoveState(PEDMOVE_WALK);
bIsRunning = false; bIsRunning = false;
} }
@ -15439,8 +15439,10 @@ CPed::ProcessObjective(void)
} }
} }
if (sq(m_distanceToCountSeekDone) < distance.MagnitudeSqr()) { if (sq(m_distanceToCountSeekDone) < distance.MagnitudeSqr()) {
if (CTimer::GetTimeInMilliseconds() > m_nPedStateTimer || GetPedState() != PED_SEEK_POS) if (CTimer::GetTimeInMilliseconds() > m_nPedStateTimer || GetPedState() != PED_SEEK_POS) {
m_vecSeekPos = m_nextRoutePointPos;
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone); SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
}
} }
else { else {
if (!bReachedAttractorHeadingTarget) { if (!bReachedAttractorHeadingTarget) {
@ -15510,6 +15512,10 @@ CPed::ProcessObjective(void)
SetObjective(OBJECTIVE_WAIT_ON_FOOT_AT_ICE_CREAM_VAN); SetObjective(OBJECTIVE_WAIT_ON_FOOT_AT_ICE_CREAM_VAN);
break; break;
} }
} else {
m_prevObjective = OBJECTIVE_NONE;
SetObjective(OBJECTIVE_WAIT_ON_FOOT);
m_objectiveTimer = 0;
} }
} }
} }
@ -15693,11 +15699,11 @@ CPed::ProcessObjective(void)
} }
if (!pVan->m_bSirenOrAlarm) { if (!pVan->m_bSirenOrAlarm) {
GetPedAttractorManager()->DeRegisterPed(this, m_attractor); GetPedAttractorManager()->DeRegisterPed(this, m_attractor);
return; // ??? return; // Why?
} }
if (pVan->GetStatus() == STATUS_WRECKED) { if (pVan->GetStatus() == STATUS_WRECKED) {
GetPedAttractorManager()->DeRegisterPed(this, m_attractor); GetPedAttractorManager()->DeRegisterPed(this, m_attractor);
return; // ??? return; // Why?
} }
break; break;
} }
@ -16422,11 +16428,11 @@ CPed::ProcessEntityCollision(CEntity *collidingEnt, CColPoint *collidingPoints)
if (!collidingEnt->IsBuilding()) if (!collidingEnt->IsBuilding())
((CPhysical*)collidingEnt)->AddCollisionRecord(this); ((CPhysical*)collidingEnt)->AddCollisionRecord(this);
if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->IsStatic())) { if (ourCollidedSpheres > 0 && (collidingEnt->IsBuilding() || collidingEnt->GetIsStatic())) {
bHasHitWall = true; bHasHitWall = true;
} }
} }
if (collidingEnt->IsBuilding() || collidingEnt->IsStatic()) { if (collidingEnt->IsBuilding() || collidingEnt->GetIsStatic()) {
if (bWasStanding) { if (bWasStanding) {
CVector sphereNormal; CVector sphereNormal;
float normalLength; float normalLength;
@ -17003,72 +17009,69 @@ CPed::ProcessBuoyancy(void)
} }
} }
} }
float speedMult = 0.0f; }
if (buoyancyImpulse.z / m_fMass > GRAVITY * CTimer::GetTimeStep() float speedMult = 0.0f;
|| mod_Buoyancy.m_waterlevel > GetPosition().z) { if (buoyancyImpulse.z / m_fMass > GRAVITY * CTimer::GetTimeStep()
|| mod_Buoyancy.m_waterlevel > GetPosition().z + 0.6f) {
speedMult = pow(0.9f, CTimer::GetTimeStep());
m_vecMoveSpeed.x *= speedMult;
m_vecMoveSpeed.y *= speedMult;
m_vecMoveSpeed.z *= speedMult;
bIsStanding = false;
bIsDrowning = true;
InflictDamage(nil, WEAPONTYPE_DROWNING, 3.0f * CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
}
if (buoyancyImpulse.z / m_fMass > GRAVITY * 0.25f * CTimer::GetTimeStep()) {
if (speedMult == 0.0f) {
speedMult = pow(0.9f, CTimer::GetTimeStep()); speedMult = pow(0.9f, CTimer::GetTimeStep());
m_vecMoveSpeed.x *= speedMult;
m_vecMoveSpeed.y *= speedMult;
m_vecMoveSpeed.z *= speedMult;
bIsStanding = false;
bIsDrowning = true;
InflictDamage(nil, WEAPONTYPE_DROWNING, 3.0f * CTimer::GetTimeStep(), PEDPIECE_TORSO, 0);
} }
if (buoyancyImpulse.z / m_fMass > GRAVITY * 0.25f * CTimer::GetTimeStep()) { m_vecMoveSpeed.x *= speedMult;
if (speedMult == 0.0f) { m_vecMoveSpeed.y *= speedMult;
speedMult = pow(0.9f, CTimer::GetTimeStep()); if (m_vecMoveSpeed.z >= -0.1f) {
} if (m_vecMoveSpeed.z < -0.04f)
m_vecMoveSpeed.x *= speedMult; m_vecMoveSpeed.z = -0.02f;
m_vecMoveSpeed.y *= speedMult; } else {
if (m_vecMoveSpeed.z >= -0.1f) { m_vecMoveSpeed.z = -0.01f;
if (m_vecMoveSpeed.z < -0.04f) DMAudio.PlayOneShot(m_audioEntityId, SOUND_SPLASH, 0.0f);
m_vecMoveSpeed.z = -0.02f; CVector aBitForward = 2.2f * m_vecMoveSpeed + GetPosition();
} else { float level = 0.0f;
m_vecMoveSpeed.z = -0.01f; if (CWaterLevel::GetWaterLevel(aBitForward, &level, false))
DMAudio.PlayOneShot(m_audioEntityId, SOUND_SPLASH, 0.0f); aBitForward.z = level;
CVector aBitForward = 2.2f * m_vecMoveSpeed + GetPosition();
float level = 0.0f;
if (CWaterLevel::GetWaterLevel(aBitForward, &level, false))
aBitForward.z = level;
CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, aBitForward, CVector(0.0f, 0.0f, 0.1f), 0.0f, 200, color, true); CParticleObject::AddObject(POBJECT_PED_WATER_SPLASH, aBitForward, CVector(0.0f, 0.0f, 0.1f), 0.0f, 200, color, true);
nGenerateRaindrops = CTimer::GetTimeInMilliseconds() + 80; nGenerateRaindrops = CTimer::GetTimeInMilliseconds() + 80;
nGenerateWaterCircles = CTimer::GetTimeInMilliseconds() + 100; nGenerateWaterCircles = CTimer::GetTimeInMilliseconds() + 100;
}
}
if (nGenerateWaterCircles && CTimer::GetTimeInMilliseconds() >= nGenerateWaterCircles) {
CVector pos = GetPosition();
float level = 0.0f;
if (CWaterLevel::GetWaterLevel(pos, &level, false))
pos.z = level;
if (pos.z != 0.0f) {
nGenerateWaterCircles = 0;
for(int i = 0; i < 4; i++) {
pos.x += CGeneral::GetRandomNumberInRange(-0.75f, 0.75f);
pos.y += CGeneral::GetRandomNumberInRange(-0.75f, 0.75f);
CParticle::AddParticle(PARTICLE_RAIN_SPLASH_BIGGROW, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, color, 0, 0, 0, 0);
} }
} }
} else }
return; if (nGenerateRaindrops && CTimer::GetTimeInMilliseconds() >= nGenerateRaindrops) {
CVector pos = GetPosition();
float level = 0.0f;
if (CWaterLevel::GetWaterLevel(pos, &level, false))
pos.z = level;
if (pos.z >= 0.0f) {
pos.z += 0.25f;
nGenerateRaindrops = 0;
CParticleObject::AddObject(POBJECT_SPLASHES_AROUND, pos, CVector(0.0f, 0.0f, 0.0f), 4.5f, 1500, CRGBA(0,0,0,0), true);
}
}
} else } else
bTouchingWater = false; bTouchingWater = false;
if (nGenerateWaterCircles && CTimer::GetTimeInMilliseconds() >= nGenerateWaterCircles) {
CVector pos = GetPosition();
float level = 0.0f;
if (CWaterLevel::GetWaterLevel(pos, &level, false))
pos.z = level;
if (pos.z != 0.0f) {
nGenerateWaterCircles = 0;
for(int i = 0; i < 4; i++) {
pos.x += CGeneral::GetRandomNumberInRange(-0.75f, 0.75f);
pos.y += CGeneral::GetRandomNumberInRange(-0.75f, 0.75f);
CParticle::AddParticle(PARTICLE_RAIN_SPLASH_BIGGROW, pos, CVector(0.0f, 0.0f, 0.0f), nil, 0.0f, color, 0, 0, 0, 0);
}
}
}
if (nGenerateRaindrops && CTimer::GetTimeInMilliseconds() >= nGenerateRaindrops) {
CVector pos = GetPosition();
float level = 0.0f;
if (CWaterLevel::GetWaterLevel(pos, &level, false))
pos.z = level;
if (pos.z >= 0.0f) {
pos.z += 0.25f;
nGenerateRaindrops = 0;
CParticleObject::AddObject(POBJECT_SPLASHES_AROUND, pos, CVector(0.0f, 0.0f, 0.0f), 4.5f, 1500, CRGBA(0,0,0,0), true);
}
}
} }
// --MIAMI: Done // --MIAMI: Done
@ -18411,7 +18414,7 @@ CPed::SeekCar(void)
{ {
m_fRotationCur = m_fRotationDest; m_fRotationCur = m_fRotationDest;
if (!bVehEnterDoorIsBlocked) { if (!bVehEnterDoorIsBlocked) {
vehToSeek->bIsStatic = false; vehToSeek->SetIsStatic(false);
if (m_objective == OBJECTIVE_SOLICIT_VEHICLE) { if (m_objective == OBJECTIVE_SOLICIT_VEHICLE) {
SetSolicit(1000); SetSolicit(1000);
} else if (m_objective == OBJECTIVE_BUY_ICE_CREAM) { } else if (m_objective == OBJECTIVE_BUY_ICE_CREAM) {

View File

@ -945,7 +945,7 @@ CPopulation::ConvertToRealObject(CDummyObject *dummy)
if (IsGlass(obj->GetModelIndex()) && !mi->m_isArtistGlass) { if (IsGlass(obj->GetModelIndex()) && !mi->m_isArtistGlass) {
obj->bIsVisible = false; obj->bIsVisible = false;
} else if (obj->GetModelIndex() == MI_BUOY) { } else if (obj->GetModelIndex() == MI_BUOY) {
obj->bIsStatic = false; obj->SetIsStatic(false);
obj->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.001f); obj->m_vecMoveSpeed = CVector(0.0f, 0.0f, -0.001f);
obj->bTouchingWater = true; obj->bTouchingWater = true;
obj->AddToMovingList(); obj->AddToMovingList();

View File

@ -393,9 +393,9 @@ void
CGlass::AskForObjectToBeRenderedInGlass(CEntity *entity) CGlass::AskForObjectToBeRenderedInGlass(CEntity *entity)
{ {
#ifdef FIX_BUGS #ifdef FIX_BUGS
if ( NumGlassEntities < NUM_GLASSPANES ) if ( NumGlassEntities < NUM_GLASSENTITIES )
#else #else
if ( NumGlassEntities < NUM_GLASSPANES-1 ) if ( NumGlassEntities < NUM_GLASSENTITIES-1 )
#endif #endif
{ {
apEntitiesToBeRendered[NumGlassEntities++] = entity; apEntitiesToBeRendered[NumGlassEntities++] = entity;

View File

@ -209,7 +209,7 @@ CMotionBlurStreaks::Update(void)
{ {
int i; int i;
for(i = 0; i < NUMMBLURSTREAKS; i++) for(i = 0; i < NUMMBLURSTREAKS; i++)
if(aStreaks[i].m_id) if(aStreaks[i].m_id != 0)
aStreaks[i].Update(); aStreaks[i].Update();
} }
@ -230,7 +230,7 @@ CMotionBlurStreaks::RegisterStreak(uintptr id, uint8 r, uint8 g, uint8 b, CVecto
} }
} }
// Find free slot // Find free slot
for(i = 0; aStreaks[i].m_id; i++) for(i = 0; aStreaks[i].m_id != 0; i++)
if(i == NUMMBLURSTREAKS-1) if(i == NUMMBLURSTREAKS-1)
return; return;
// Create a new streak // Create a new streak
@ -251,7 +251,7 @@ CMotionBlurStreaks::Render(void)
bool setRenderStates = false; bool setRenderStates = false;
int i; int i;
for(i = 0; i < NUMMBLURSTREAKS; i++) for(i = 0; i < NUMMBLURSTREAKS; i++)
if(aStreaks[i].m_id){ if(aStreaks[i].m_id != 0){
if(!setRenderStates){ if(!setRenderStates){
RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE); RwRenderStateSet(rwRENDERSTATEZWRITEENABLE, (void*)FALSE);
RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE); RwRenderStateSet(rwRENDERSTATEVERTEXALPHAENABLE, (void*)TRUE);
@ -328,7 +328,7 @@ void CBulletTraces::Render(void)
RwIm3DVertexSetPos(&TraceVertices[4], sup.x + width.x, sup.y + width.y, sup.z + width.z); RwIm3DVertexSetPos(&TraceVertices[4], sup.x + width.x, sup.y + width.y, sup.z + width.z);
RwIm3DVertexSetPos(&TraceVertices[5], sup.x - width.x, sup.y - width.y, sup.z - width.z); RwIm3DVertexSetPos(&TraceVertices[5], sup.x - width.x, sup.y - width.y, sup.z - width.z);
LittleTest(); LittleTest();
if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, 1)) { if (RwIm3DTransform(TraceVertices, ARRAY_SIZE(TraceVertices), nil, rwIM3D_VERTEXUV)) {
RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList)); RwIm3DRenderIndexedPrimitive(rwPRIMTYPETRILIST, TraceIndexList, ARRAY_SIZE(TraceIndexList));
RwIm3DEnd(); RwIm3DEnd();
} }
@ -851,6 +851,22 @@ CBrightLights::Render(void)
TempBufferIndicesStored += 12*3; TempBufferIndicesStored += 12*3;
break; break;
case BRIGHTLIGHT_FRONT_BIG:
case BRIGHTLIGHT_REAR_BIG:
for (j = 0; j < 8; j++) {
pos = BigCarHeadLightsSide[j] * aBrightLights[i].m_side +
BigCarHeadLightsUp[j] * aBrightLights[i].m_up +
BigCarHeadLightsFront[j] * aBrightLights[i].m_front +
aBrightLights[i].m_pos;
RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored + j], r, g, b, a);
RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored + j], pos.x, pos.y, pos.z);
}
for (j = 0; j < 12 * 3; j++)
TempBufferRenderIndexList[TempBufferIndicesStored + j] = CubeIndices[j] + TempBufferVerticesStored;
TempBufferVerticesStored += 8;
TempBufferIndicesStored += 12 * 3;
break;
case BRIGHTLIGHT_FRONT_TALL: case BRIGHTLIGHT_FRONT_TALL:
case BRIGHTLIGHT_REAR_TALL: case BRIGHTLIGHT_REAR_TALL:
for(j = 0; j < 8; j++){ for(j = 0; j < 8; j++){
@ -869,8 +885,8 @@ CBrightLights::Render(void)
case BRIGHTLIGHT_SIREN: case BRIGHTLIGHT_SIREN:
for(j = 0; j < 6; j++){ for(j = 0; j < 6; j++){
pos = SirenLightsSide[j]*aBrightLights[i].m_side + pos = SirenLightsSide[j] * TheCamera.GetRight() +
SirenLightsUp[j]*aBrightLights[i].m_up + SirenLightsUp[j] * TheCamera.GetUp() +
aBrightLights[i].m_pos; aBrightLights[i].m_pos;
RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored+j], r, g, b, a); RwIm3DVertexSetRGBA(&TempBufferRenderVertices[TempBufferVerticesStored+j], r, g, b, a);
RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored+j], pos.x, pos.y, pos.z); RwIm3DVertexSetPos(&TempBufferRenderVertices[TempBufferVerticesStored+j], pos.x, pos.y, pos.z);
@ -1067,11 +1083,8 @@ CMoneyMessage::Render()
CFont::SetPropOn(); CFont::SetPropOn();
CFont::SetBackgroundOff(); CFont::SetBackgroundOff();
float fScaleY = fDistY / 100.0f; float fScaleY = Min(fDistY / 100.0f, MAX_SCALE);
if (fScaleY > MAX_SCALE) fScaleY = MAX_SCALE; float fScaleX = Min(fDistX / 100.0f, MAX_SCALE);
float fScaleX = fDistX / 100.0f;
if (fScaleX > MAX_SCALE) fScaleX = MAX_SCALE;
CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here? CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here?
CFont::SetCentreOn(); CFont::SetCentreOn();

View File

@ -43,6 +43,7 @@
#define MAX_SUBSYSTEMS (16) #define MAX_SUBSYSTEMS (16)
// --MIAMI: file done
rw::EngineOpenParams openParams; rw::EngineOpenParams openParams;

View File

@ -53,6 +53,7 @@
#define MAX_SUBSYSTEMS (16) #define MAX_SUBSYSTEMS (16)
// --MIAMI: file done
static RwBool ForegroundApp = TRUE; static RwBool ForegroundApp = TRUE;

View File

@ -1,4 +1,4 @@
#include "common.h" #include "common.h"
#include "main.h" #include "main.h"
#include "General.h" #include "General.h"
@ -4635,7 +4635,6 @@ CAutomobile::ProcessOpenDoor(uint32 component, uint32 anim, float time)
case ANIM_CAR_ROLLDOOR_LOW: case ANIM_CAR_ROLLDOOR_LOW:
ProcessDoorOpenCloseAnimation(this, component, door, time, 0.1f, 0.6f, 0.95f); ProcessDoorOpenCloseAnimation(this, component, door, time, 0.1f, 0.6f, 0.95f);
break; break;
break;
case ANIM_CAR_GETOUT_LHS: case ANIM_CAR_GETOUT_LHS:
case ANIM_CAR_GETOUT_LOW_LHS: case ANIM_CAR_GETOUT_LOW_LHS:
case ANIM_CAR_GETOUT_RHS: case ANIM_CAR_GETOUT_RHS:
@ -4649,6 +4648,7 @@ CAutomobile::ProcessOpenDoor(uint32 component, uint32 anim, float time)
case ANIM_CAR_PULLOUT_RHS: case ANIM_CAR_PULLOUT_RHS:
case ANIM_CAR_PULLOUT_LOW_RHS: case ANIM_CAR_PULLOUT_LOW_RHS:
OpenDoor(component, door, 1.0f); OpenDoor(component, door, 1.0f);
break;
case ANIM_COACH_OPEN_L: case ANIM_COACH_OPEN_L:
case ANIM_COACH_OPEN_R: case ANIM_COACH_OPEN_R:
ProcessDoorOpenAnimation(this, component, door, time, 0.66f, 0.8f); ProcessDoorOpenAnimation(this, component, door, time, 0.66f, 0.8f);
@ -5349,7 +5349,7 @@ CAutomobile::SpawnFlyingComponent(int32 component, uint32 type)
obj->m_fElasticity = 0.1f; obj->m_fElasticity = 0.1f;
obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f; obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f;
obj->ObjectCreatedBy = TEMP_OBJECT; obj->ObjectCreatedBy = TEMP_OBJECT;
obj->bIsStatic = false; obj->SetIsStatic(false);
obj->bIsPickup = false; obj->bIsPickup = false;
obj->bUseVehicleColours = true; obj->bUseVehicleColours = true;
obj->m_colour1 = m_currentColour1; obj->m_colour1 = m_currentColour1;

View File

@ -893,7 +893,7 @@ CBoat::BlowUpCar(CEntity *culprit)
obj->m_fElasticity = 0.1f; obj->m_fElasticity = 0.1f;
obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f; obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f;
obj->ObjectCreatedBy = TEMP_OBJECT; obj->ObjectCreatedBy = TEMP_OBJECT;
obj->bIsStatic = false; obj->SetIsStatic(false);
obj->bIsPickup = false; obj->bIsPickup = false;
// life time // life time

View File

@ -671,7 +671,7 @@ CHeli::SpawnFlyingComponent(int32 component)
obj->m_fElasticity = 0.1f; obj->m_fElasticity = 0.1f;
obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f; obj->m_fBuoyancy = obj->m_fMass*GRAVITY/0.75f;
obj->ObjectCreatedBy = TEMP_OBJECT; obj->ObjectCreatedBy = TEMP_OBJECT;
obj->bIsStatic = false; obj->SetIsStatic(false);
obj->bIsPickup = false; obj->bIsPickup = false;
// life time // life time

View File

@ -205,13 +205,13 @@ void CBulletInfo::Update(void)
if (pHitEntity->IsObject()) { if (pHitEntity->IsObject()) {
CObject *pHitObject = (CObject*)pHitEntity; CObject *pHitObject = (CObject*)pHitEntity;
if ( !pHitObject->bInfiniteMass && pHitObject->m_fCollisionDamageMultiplier < 99.9f) { if ( !pHitObject->bInfiniteMass && pHitObject->m_fCollisionDamageMultiplier < 99.9f) {
bool notStatic = !pHitObject->IsStatic(); bool notStatic = !pHitObject->GetIsStatic();
if (notStatic && pHitObject->m_fUprootLimit <= 0.0f) { if (notStatic && pHitObject->m_fUprootLimit <= 0.0f) {
pHitObject->bIsStatic = false; pHitObject->bIsStatic = false;
pHitObject->AddToMovingList(); pHitObject->AddToMovingList();
} }
notStatic = !pHitObject->IsStatic(); notStatic = !pHitObject->GetIsStatic();
if (!notStatic) { if (!notStatic) {
CVector moveForce = point.normal * -BULLET_HIT_FORCE; CVector moveForce = point.normal * -BULLET_HIT_FORCE;
pHitObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z); pHitObject->ApplyMoveForce(moveForce.x, moveForce.y, moveForce.z);

View File

@ -1526,14 +1526,14 @@ CWeapon::DoBulletImpact(CEntity *shooter, CEntity *victim,
if ( !victimObject->bInfiniteMass && victimObject->m_fCollisionDamageMultiplier < 99.9f) if ( !victimObject->bInfiniteMass && victimObject->m_fCollisionDamageMultiplier < 99.9f)
{ {
bool notStatic = !victimObject->IsStatic(); bool notStatic = !victimObject->GetIsStatic();
if (notStatic && victimObject->m_fUprootLimit <= 0.0f) if (notStatic && victimObject->m_fUprootLimit <= 0.0f)
{ {
victimObject->bIsStatic = false; victimObject->SetIsStatic(false);
victimObject->AddToMovingList(); victimObject->AddToMovingList();
} }
notStatic = !victimObject->IsStatic(); notStatic = !victimObject->GetIsStatic();
if (!notStatic) if (!notStatic)
{ {
CVector moveForce = point->normal * -4.0f; CVector moveForce = point->normal * -4.0f;
@ -1922,14 +1922,14 @@ CWeapon::FireShotgun(CEntity *shooter, CVector *fireSource)
if ( !victimObject->bInfiniteMass ) if ( !victimObject->bInfiniteMass )
{ {
bool notStatic = !victimObject->IsStatic(); bool notStatic = !victimObject->GetIsStatic();
if ( notStatic && victimObject->m_fUprootLimit <= 0.0f ) if ( notStatic && victimObject->m_fUprootLimit <= 0.0f )
{ {
victimObject->bIsStatic = false; victimObject->SetIsStatic(false);
victimObject->AddToMovingList(); victimObject->AddToMovingList();
} }
notStatic = !victimObject->IsStatic(); notStatic = !victimObject->GetIsStatic();
if ( !notStatic ) if ( !notStatic )
{ {
CVector moveForce = point.normal*-5.0f; CVector moveForce = point.normal*-5.0f;
@ -3149,9 +3149,9 @@ CWeapon::BlowUpExplosiveThings(CEntity *thing)
object->m_vecMoveSpeed.x += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f; object->m_vecMoveSpeed.x += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
object->m_vecMoveSpeed.y += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f; object->m_vecMoveSpeed.y += float((CGeneral::GetRandomNumber()&255) - 128) * 0.0002f;
if ( object->IsStatic()) if ( object->GetIsStatic())
{ {
object->bIsStatic = false; object->SetIsStatic(false);
object->AddToMovingList(); object->AddToMovingList();
} }
} }