From e6b1a0691bf28d556a2dd4f063eb78e0b190da01 Mon Sep 17 00:00:00 2001 From: Nikolay Korolev Date: Sun, 8 Aug 2021 13:08:47 +0300 Subject: [PATCH] lcs bridge --- src/control/AutoPilot.cpp | 2 ++ src/control/Bridge.cpp | 43 ++++++++++++++++++++++----------------- src/control/CarAI.cpp | 2 ++ src/control/CarCtrl.cpp | 2 ++ src/control/Curves.cpp | 2 ++ src/control/Garages.cpp | 2 ++ 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/src/control/AutoPilot.cpp b/src/control/AutoPilot.cpp index d7c17a68..e52d788d 100644 --- a/src/control/AutoPilot.cpp +++ b/src/control/AutoPilot.cpp @@ -7,6 +7,8 @@ #include "PathFind.h" #include "SaveBuf.h" +//--LCS: file done + void CAutoPilot::ModifySpeed(float speed) { m_fMaxTrafficSpeed = Max(0.01f, speed); diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp index e7c76a9c..c1bf0369 100644 --- a/src/control/Bridge.cpp +++ b/src/control/Bridge.cpp @@ -6,6 +6,8 @@ #include "PathFind.h" #include "Stats.h" +//--LCS: file done except TODO + CEntity *CBridge::pLiftRoad; CEntity *CBridge::pLiftPart; CEntity *CBridge::pWeight; @@ -25,14 +27,14 @@ void CBridge::Init() { #ifdef GTA_BRIDGE FindBridgeEntities(); + State = STATE_BRIDGE_LOCKED; OldLift = -1.0f; if (pLiftPart && pWeight) { DefaultZLiftPart = pLiftPart->GetPosition().z; - DefaultZLiftWeight = pWeight->GetPosition().z; - if (pLiftRoad) DefaultZLiftRoad = pLiftRoad->GetPosition().z; + DefaultZLiftWeight = pWeight->GetPosition().z; ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true); } @@ -49,36 +51,42 @@ void CBridge::Update() float liftHeight; - // Set bridge height and state - if (CStats::CommercialPassed) - { + if (State == STATE_BRIDGE_LOCKED) { + liftHeight = 25.0f; + TimeOfBridgeBecomingOperational = 0; + } + else if (State == STATE_BRIDGE_ALWAYS_UNLOCKED) { + liftHeight = 0.0f; + TimeOfBridgeBecomingOperational = CTimer::GetTimeInMilliseconds() - 20001; + } + else { if (TimeOfBridgeBecomingOperational == 0) TimeOfBridgeBecomingOperational = CTimer::GetTimeInMilliseconds(); // Time remaining for bridge to become operational - // uint16, so after about a minute it overflows to 0 and the cycle repeats - uint16 timeElapsed = CTimer::GetTimeInMilliseconds() - TimeOfBridgeBecomingOperational; + // this time cycle duration is 0x20000, so ~2:11 + uint32 timeElapsed = (CTimer::GetTimeInMilliseconds() - TimeOfBridgeBecomingOperational) % 0x20000; // Calculate lift part height and bridge state - if (timeElapsed < 10000) + if (timeElapsed < 20000) { State = STATE_LIFT_PART_MOVING_DOWN; - liftHeight = 25.0f - timeElapsed / 10000.0f * 25.0f; + liftHeight = 25.0f - timeElapsed / 20000.0f * 25.0f; } - else if (timeElapsed < 40000) + else if (timeElapsed < 80000) { liftHeight = 0.0f; State = STATE_LIFT_PART_IS_DOWN; } - else if (timeElapsed < 50000) + else if (timeElapsed < 90000) { liftHeight = 0.0f; State = STATE_LIFT_PART_ABOUT_TO_MOVE_UP; } - else if (timeElapsed < 60000) + else if (timeElapsed < 110000) { State = STATE_LIFT_PART_MOVING_UP; - liftHeight = (timeElapsed - 50000) / 10000.0f * 25.0f; + liftHeight = (timeElapsed - 90000) / 20000.0f * 25.0f; } else { @@ -86,12 +94,7 @@ void CBridge::Update() State = STATE_LIFT_PART_IS_UP; } } - else - { - liftHeight = 25.0f; - TimeOfBridgeBecomingOperational = 0; - State = STATE_BRIDGE_LOCKED; - } + // Move bridge part if (liftHeight != OldLift) @@ -112,6 +115,8 @@ void CBridge::Update() OldLift = liftHeight; } + // TODO(LCS): cWorldStream + if (State == STATE_LIFT_PART_ABOUT_TO_MOVE_UP && OldState == STATE_LIFT_PART_IS_DOWN) ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true); else if (State == STATE_LIFT_PART_IS_DOWN && OldState == STATE_LIFT_PART_MOVING_DOWN) diff --git a/src/control/CarAI.cpp b/src/control/CarAI.cpp index 45652b23..11d756b4 100644 --- a/src/control/CarAI.cpp +++ b/src/control/CarAI.cpp @@ -21,6 +21,8 @@ #include "World.h" #include "ZoneCull.h" +//--LCS: file done + #define DISTANCE_TO_SWITCH_DISTANCE_GOTO 20.0f float CCarAI::FindSwitchDistanceClose(CVehicle* pVehicle) diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp index 93fde4eb..3f1cd0ca 100644 --- a/src/control/CarCtrl.cpp +++ b/src/control/CarCtrl.cpp @@ -38,6 +38,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) diff --git a/src/control/Curves.cpp b/src/control/Curves.cpp index 31a2767a..ad7b35b5 100644 --- a/src/control/Curves.cpp +++ b/src/control/Curves.cpp @@ -2,6 +2,8 @@ #include "Curves.h" +//--LCS: file done except TODO + float CCurves::CalcSpeedScaleFactor(CVector* pPoint1, CVector* pPoint2, float dir1X, float dir1Y, float dir2X, float dir2Y) { CVector2D dir1(dir1X, dir1Y); diff --git a/src/control/Garages.cpp b/src/control/Garages.cpp index 8978fac4..43bf6cea 100644 --- a/src/control/Garages.cpp +++ b/src/control/Garages.cpp @@ -29,6 +29,8 @@ #include "VarConsole.h" #include "SaveBuf.h" +//--LCS: file done except TODO + #define ROTATED_DOOR_OPEN_SPEED (0.015f) #define ROTATED_DOOR_CLOSE_SPEED (0.02f) #define DEFAULT_DOOR_OPEN_SPEED (0.035f)