summaryrefslogtreecommitdiffstats
path: root/src/vehicles
diff options
context:
space:
mode:
Diffstat (limited to 'src/vehicles')
-rw-r--r--src/vehicles/CarGen.cpp58
-rw-r--r--src/vehicles/Cranes.cpp27
2 files changed, 41 insertions, 44 deletions
diff --git a/src/vehicles/CarGen.cpp b/src/vehicles/CarGen.cpp
index 84a19b82..855d00b1 100644
--- a/src/vehicles/CarGen.cpp
+++ b/src/vehicles/CarGen.cpp
@@ -18,6 +18,8 @@
#include "Zones.h"
#include "Occlusion.h"
+// --MIAMI: file done
+
uint8 CTheCarGenerators::ProcessCounter;
uint32 CTheCarGenerators::NumOfCarGenerators;
CCarGenerator CTheCarGenerators::CarGeneratorArray[NUM_CARGENS];
@@ -42,7 +44,6 @@ uint32 CCarGenerator::CalcNextGen()
return CTimer::GetTimeInMilliseconds() + 4;
}
-//TODO(MIAMI): check for more changes - so far only -1 mi is accounted for
void CCarGenerator::DoInternalProcessing()
{
int mi;
@@ -53,6 +54,7 @@ void CCarGenerator::DoInternalProcessing()
m_nTimer += 4;
return;
}
+ CStreaming::RequestModel(m_nModelIndex, STREAMFLAGS_DEPENDENCY);
mi = m_nModelIndex;
}
else {
@@ -73,29 +75,25 @@ void CCarGenerator::DoInternalProcessing()
return;
}
}
- CStreaming::RequestModel(mi, STREAMFLAGS_DEPENDENCY);
if (!CStreaming::HasModelLoaded(mi))
return;
CVehicle* pVehicle;
+
+ CVector pos;
if (CModelInfo::IsBoatModel(mi)){
CBoat* pBoat = new CBoat(mi, PARKED_VEHICLE);
+ pos = m_vecPos;
pVehicle = pBoat;
- pBoat->bIsStatic = false;
- pBoat->bEngineOn = false;
- CVector pos = m_vecPos;
if (pos.z <= -100.0f)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y);
- pos.z += pBoat->GetDistanceFromCentreOfMassToBaseOfModel();
- pBoat->SetPosition(pos);
- pBoat->SetOrientation(0.0f, 0.0f, DEGTORAD(m_fAngle));
- pBoat->SetStatus(STATUS_ABANDONED);
- pBoat->m_nDoorLock = CARLOCK_UNLOCKED;
+ pBoat->bExtendedRange = false;
}else{
- bool groundFound = false;
- CVector pos = m_vecPos;
+ bool groundFound;
+ pos = m_vecPos;
if (pos.z > -100.0f){
pos.z = CWorld::FindGroundZFor3DCoord(pos.x, pos.y, pos.z, &groundFound);
}else{
+ groundFound = false;
CColPoint cp;
CEntity* pEntity;
groundFound = CWorld::ProcessVerticalLine(CVector(pos.x, pos.y, 1000.0f), -1000.0f,
@@ -107,7 +105,7 @@ void CCarGenerator::DoInternalProcessing()
debug("CCarGenerator::DoInternalProcessing - can't find ground z for new car x = %f y = %f \n", m_vecPos.x, m_vecPos.y);
return;
}
- if (CModelInfo::IsBikeModel(mi)) {
+ if (CModelInfo::GetModelInfo(mi)->GetModelType() == VEHICLE_TYPE_BIKE) {
CBike* pBike = new CBike(mi, PARKED_VEHICLE);
pBike->bIsStanding = true;
pVehicle = pBike;
@@ -116,16 +114,16 @@ void CCarGenerator::DoInternalProcessing()
CAutomobile* pCar = new CAutomobile(mi, PARKED_VEHICLE);
pVehicle = pCar;
}
- pVehicle->bIsStatic = false;
- pVehicle->bEngineOn = false;
- pos.z += pVehicle->GetDistanceFromCentreOfMassToBaseOfModel();
- pVehicle->SetPosition(pos);
- pVehicle->SetOrientation(0.0f, 0.0f, DEGTORAD(m_fAngle));
- pVehicle->SetStatus(STATUS_ABANDONED);
+ // pVehicle->GetDistanceFromCentreOfMassToBaseOfModel();
pVehicle->bLightsOn = false;
- pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
-
}
+ pVehicle->bIsStatic = false;
+ pVehicle->bEngineOn = false;
+ pos.z += pVehicle->GetDistanceFromCentreOfMassToBaseOfModel();
+ pVehicle->SetPosition(pos);
+ pVehicle->SetOrientation(0.0f, 0.0f, DEGTORAD(m_fAngle));
+ pVehicle->SetStatus(STATUS_ABANDONED);
+ pVehicle->m_nDoorLock = CARLOCK_UNLOCKED;
CWorld::Add(pVehicle);
if (CGeneral::GetRandomNumberInRange(0, 100) < m_nAlarm)
pVehicle->m_nAlarmState = -1;
@@ -173,6 +171,8 @@ void CCarGenerator::Process()
m_nVehicleHandle = -1;
m_bIsBlocking = true;
pVehicle->bExtendedRange = false;
+ if (m_nModelIndex < 0)
+ m_nModelIndex = -1;
}
void CCarGenerator::Setup(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay)
@@ -217,8 +217,8 @@ bool CCarGenerator::CheckIfWithinRangeOfAnyPlayers()
float farclip = 110.0f * TheCamera.GenerationDistMultiplier;
float nearclip = farclip - 20.0f;
bool canBeRemoved = (m_nModelIndex > 0 && CModelInfo::IsBoatModel(m_nModelIndex) && 165.0f * TheCamera.GenerationDistMultiplier > distance &&
- TheCamera.IsSphereVisible(m_vecPos, 0.0f) && COcclusion::IsPositionOccluded(m_vecPos, 0.0f));
- if (distance >= farclip || canBeRemoved){
+ TheCamera.IsSphereVisible(m_vecPos, 0.0f) && !COcclusion::IsPositionOccluded(m_vecPos, 0.0f));
+ if (distance >= farclip && !canBeRemoved){
if (m_bIsBlocking)
m_bIsBlocking = false;
return false;
@@ -227,7 +227,7 @@ bool CCarGenerator::CheckIfWithinRangeOfAnyPlayers()
return true;
if (m_bIsBlocking)
return false;
- if (distance < nearclip)
+ if (distance < nearclip && !m_bForceSpawn)
return false;
return DotProduct2D(direction, FindPlayerSpeed()) <= 0;
}
@@ -246,8 +246,9 @@ void CTheCarGenerators::Process()
int32 CTheCarGenerators::CreateCarGenerator(float x, float y, float z, float angle, int32 mi, int16 color1, int16 color2, uint8 force, uint8 alarm, uint8 lock, uint16 min_delay, uint16 max_delay)
{
- CarGeneratorArray[NumOfCarGenerators].Setup(x, y, z, angle, mi, color1, color2, force, alarm, lock, min_delay, max_delay);
- return NumOfCarGenerators++;
+ if (NumOfCarGenerators < NUM_CARGENS)
+ CarGeneratorArray[NumOfCarGenerators++].Setup(x, y, z, angle, mi, color1, color2, force, alarm, lock, min_delay, max_delay);
+ return NumOfCarGenerators - 1;
}
void CTheCarGenerators::Init()
@@ -279,6 +280,11 @@ VALIDATESAVEBUF(*size)
void CTheCarGenerators::LoadAllCarGenerators(uint8* buffer, uint32 size)
{
+ NumOfCarGenerators = 0;
+ GenerateEvenIfPlayerIsCloseCounter = 0;
+ CurrentActiveCount = 0;
+ ProcessCounter = 0;
+
const int32 nGeneralDataSize = sizeof(NumOfCarGenerators) + sizeof(CurrentActiveCount) + sizeof(ProcessCounter) + sizeof(GenerateEvenIfPlayerIsCloseCounter) + sizeof(int16);
Init();
INITSAVEBUF
diff --git a/src/vehicles/Cranes.cpp b/src/vehicles/Cranes.cpp
index 83c727f5..1ab31574 100644
--- a/src/vehicles/Cranes.cpp
+++ b/src/vehicles/Cranes.cpp
@@ -52,17 +52,22 @@ void CCranes::InitCranes(void)
CEntity* pEntity = (CEntity*)pNode->item;
if (MODELID_CRANE_1 == pEntity->GetModelIndex() ||
MODELID_CRANE_2 == pEntity->GetModelIndex() ||
- MODELID_CRANE_3 == pEntity->GetModelIndex())
+ MODELID_CRANE_3 == pEntity->GetModelIndex() ||
+ MODELID_CRANE_4 == pEntity->GetModelIndex() ||
+ MODELID_CRANE_5 == pEntity->GetModelIndex() ||
+ MODELID_CRANE_6 == pEntity->GetModelIndex())
AddThisOneCrane(pEntity);
}
}
}
- // TODO(MIAMI): LEVEL_MAINLAND just so it compiles
for (CPtrNode* pNode = CWorld::GetBigBuildingList(LEVEL_MAINLAND).first; pNode; pNode = pNode->next) {
CEntity* pEntity = (CEntity*)pNode->item;
if (MODELID_CRANE_1 == pEntity->GetModelIndex() ||
MODELID_CRANE_2 == pEntity->GetModelIndex() ||
- MODELID_CRANE_3 == pEntity->GetModelIndex())
+ MODELID_CRANE_3 == pEntity->GetModelIndex() ||
+ MODELID_CRANE_4 == pEntity->GetModelIndex() ||
+ MODELID_CRANE_5 == pEntity->GetModelIndex() ||
+ MODELID_CRANE_6 == pEntity->GetModelIndex())
AddThisOneCrane(pEntity);
}
}
@@ -85,21 +90,7 @@ void CCranes::AddThisOneCrane(CEntity* pEntity)
pCrane->m_nCraneState = CCrane::IDLE;
pCrane->m_bWasMilitaryCrane = false;
pCrane->m_bIsTop = (MODELID_CRANE_1 != pEntity->GetModelIndex());
-#if 0
- // Is this used to avoid military crane?
- if (pCrane->m_bIsTop || pEntity->GetPosition().y > 0.0f) {
- CObject* pHook = new CObject(MI_MAGNET, false);
- pHook->ObjectCreatedBy = MISSION_OBJECT;
- pHook->bUsesCollision = false;
- pHook->bExplosionProof = true;
- pHook->bAffectedByGravity = false;
- pCrane->m_pHook = pHook;
- pCrane->CalcHookCoordinates(&pCrane->m_vecHookCurPos.x, &pCrane->m_vecHookCurPos.y, &pCrane->m_vecHookCurPos.z);
- pCrane->SetHookMatrix();
- }
- else
-#endif
- pCrane->m_pHook = nil;
+ pCrane->m_pHook = nil;
NumCranes++;
}