diff options
Diffstat (limited to 'src/control/CarCtrl.cpp')
-rw-r--r-- | src/control/CarCtrl.cpp | 39 |
1 files changed, 35 insertions, 4 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 93fde4eb..026a2057 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -17,6 +17,7 @@ #include "Garages.h" #include "General.h" #include "IniFile.h" +#include "Lines.h" #include "ModelIndices.h" #include "PathFind.h" #include "Ped.h" @@ -38,6 +39,8 @@ #include "Zones.h" #include "Pickups.h" +//--LCS: file done except TODO + #define DISTANCE_TO_SPAWN_ROADBLOCK_PEDS (51.0f) #define DISTANCE_TO_SCAN_FOR_DANGER (14.0f) #define DISTANCE_TO_SCAN_FOR_PED_DANGER (11.0f) @@ -96,7 +99,7 @@ int32 CCarCtrl::NumRandomCars; int32 CCarCtrl::NumParkedCars; int32 CCarCtrl::NumPermanentCars; int8 CCarCtrl::CountDownToCarsAtStart; -int32 CCarCtrl::MaxNumberOfCarsInUse = 30; +int32 CCarCtrl::MaxNumberOfCarsInUse = DEFAULT_MAX_NUMBER_OF_CARS; uint32 CCarCtrl::LastTimeLawEnforcerCreated; uint32 CCarCtrl::LastTimeFireTruckCreated; uint32 CCarCtrl::LastTimeAmbulanceCreated; @@ -424,7 +427,7 @@ CCarCtrl::GenerateOneRandomCar() pVehicle->m_bSirenOrAlarm = true; pVehicle->AutoPilot.m_nNextPathNodeInfo = connectionId; pVehicle->AutoPilot.m_nNextLane = pVehicle->AutoPilot.m_nCurrentLane = CGeneral::GetRandomNumber() % lanesOnCurrentRoad; - CBox* boundingBox = &CModelInfo::GetModelInfo(pVehicle->GetModelIndex())->GetColModel()->boundingBox; + CBox* boundingBox = &CModelInfo::GetColModel(pVehicle->GetModelIndex())->boundingBox; float carLength = 1.0f + (boundingBox->max.y - boundingBox->min.y) / 2; float distanceBetweenNodes = (pCurNode->GetPosition() - pNextNode->GetPosition()).Magnitude2D(); /* If car is so long that it doesn't fit between two car nodes, place it directly in the middle. */ @@ -3416,7 +3419,35 @@ float CCarCtrl::FindSpeedMultiplierWithSpeedFromNodes(int8 type) return 1.0f; } -void CCarCtrl::RenderDebugInfo(CVehicle*) +void CCarCtrl::RenderDebugInfo(CVehicle* pVehicle) { - //TODO(LCS) + if (!pVehicle->AutoPilot.m_nNextRouteNode || !pVehicle->AutoPilot.m_nCurrentRouteNode) + return; + + CPathNode* pCurNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nCurrentRouteNode]; + CPathNode* pNextNode = &ThePaths.m_pathNodes[pVehicle->AutoPilot.m_nNextRouteNode]; + CCarPathLink* pCurLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nCurrentPathNodeInfo]; + CCarPathLink* pNextLink = &ThePaths.m_carPathLinks[pVehicle->AutoPilot.m_nNextPathNodeInfo]; + + CVector vCurNodePos(pCurNode->GetPosition()); + vCurNodePos.z += 1.0f; + CVector vNextNodePos(pNextNode->GetPosition()); + vNextNodePos.z += 1.0f; + CVector vCurLinkDir(pCurLink->GetDirX() * pVehicle->AutoPilot.m_nCurrentDirection, pCurLink->GetDirY() * pVehicle->AutoPilot.m_nCurrentDirection, 0.0f); + CVector vNextLinkDir(pNextLink->GetDirX() * pVehicle->AutoPilot.m_nNextDirection, pNextLink->GetDirY() * pVehicle->AutoPilot.m_nNextDirection, 0.0f); + vCurLinkDir.Normalise(); + vNextLinkDir.Normalise(); + + if (vCurLinkDir.x * vNextLinkDir.x + vCurLinkDir.y * vNextLinkDir.y < 0.5f) { + CVector vCurPos(vCurNodePos); + CVector vCurDir(0.0f, 0.0f, 1.0f); + for (int i = 0; i < 10; i++) { + CVector vPrevPos = vCurPos; + CCurves::CalcCurvePoint(&vCurNodePos, &vNextNodePos, &vCurLinkDir, &vNextLinkDir, i * 0.1f, pVehicle->AutoPilot.m_nTimeToSpendOnCurrentCurve, &vCurPos, &vCurDir); + // Render3DLine(&vCurPos, &vNextPos, CVector(255.0f, 255.0f, 0.0f, 255.0f)); // <- originally this is called, let's reuse stuff we have + // TODO: not drawing :( + CLines::RenderLineWithClipping(vPrevPos.x, vPrevPos.y, vCurNodePos.z, vCurPos.x, vCurPos.y, vNextNodePos.z, 0xFFFF00FF, 0xFFFF00FF); // using NodePos for Z coord cause Curves set it to 0 + } + DefinedState(); + } } |