summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2019-09-13 21:04:55 +0200
committereray orçunus <erayorcunus@gmail.com>2019-09-14 01:24:53 +0200
commit88f0ef75e8596c752fe343c786294ffa6a8a7534 (patch)
treecacd806edb9ca44bda3a057a934b629cc7be1bc3 /src/control
parentfixed launch in space bug (diff)
downloadre3-88f0ef75e8596c752fe343c786294ffa6a8a7534.tar
re3-88f0ef75e8596c752fe343c786294ffa6a8a7534.tar.gz
re3-88f0ef75e8596c752fe343c786294ffa6a8a7534.tar.bz2
re3-88f0ef75e8596c752fe343c786294ffa6a8a7534.tar.lz
re3-88f0ef75e8596c752fe343c786294ffa6a8a7534.tar.xz
re3-88f0ef75e8596c752fe343c786294ffa6a8a7534.tar.zst
re3-88f0ef75e8596c752fe343c786294ffa6a8a7534.zip
Diffstat (limited to 'src/control')
-rw-r--r--src/control/CarCtrl.cpp29
-rw-r--r--src/control/CarCtrl.h1
2 files changed, 30 insertions, 0 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index ebcbb625..e927d673 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -67,6 +67,7 @@ int32 (&CCarCtrl::TotalNumOfCarsOfRating)[7] = *(int32(*)[7])*(uintptr*)0x8F1A60
int32 (&CCarCtrl::NextCarOfRating)[7] = *(int32(*)[7])*(uintptr*)0x9412AC;
int32 (&CCarCtrl::CarArrays)[7][MAX_CAR_MODELS_IN_ARRAY] = *(int32(*)[7][MAX_CAR_MODELS_IN_ARRAY])*(uintptr*)0x6EB860;
CVehicle* (&apCarsToKeep)[MAX_CARS_TO_KEEP] = *(CVehicle*(*)[MAX_CARS_TO_KEEP])*(uintptr*)0x70D830;
+uint32 (&aCarsToKeepTime)[MAX_CARS_TO_KEEP] = *(uint32(*)[MAX_CARS_TO_KEEP])*(uintptr*)0x87F9A8;
WRAPPER void CCarCtrl::SwitchVehicleToRealPhysics(CVehicle*) { EAXJMP(0x41F7F0); }
WRAPPER void CCarCtrl::UpdateCarCount(CVehicle*, bool) { EAXJMP(0x4202E0); }
@@ -746,6 +747,34 @@ CCarCtrl::IsThisVehicleInteresting(CVehicle* pVehicle)
}
void
+CCarCtrl::RegisterVehicleOfInterest(CVehicle* pVehicle)
+{
+ for(int i = 0; i < MAX_CARS_TO_KEEP; i++) {
+ if (apCarsToKeep[i] == pVehicle) {
+ aCarsToKeepTime[i] = CTimer::GetTimeInMilliseconds();
+ return;
+ }
+ }
+ for (int i = 0; i < MAX_CARS_TO_KEEP; i++) {
+ if (!apCarsToKeep[i]) {
+ apCarsToKeep[i] = pVehicle;
+ aCarsToKeepTime[i] = CTimer::GetTimeInMilliseconds();
+ return;
+ }
+ }
+ uint32 oldestCarWeKeepTime = UINT_MAX;
+ int oldestCarWeKeepIndex = 0;
+ for (int i = 0; i < MAX_CARS_TO_KEEP; i++) {
+ if (apCarsToKeep[i] && aCarsToKeepTime[i] < oldestCarWeKeepTime) {
+ oldestCarWeKeepTime = aCarsToKeepTime[i];
+ oldestCarWeKeepIndex = i;
+ }
+ }
+ apCarsToKeep[oldestCarWeKeepIndex] = pVehicle;
+ aCarsToKeepTime[oldestCarWeKeepIndex] = CTimer::GetTimeInMilliseconds();
+}
+
+void
CCarCtrl::UpdateCarOnRails(CVehicle* pVehicle)
{
if (pVehicle->AutoPilot.m_nTempAction == TEMPACT_WAIT){
diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h
index b06c1ca2..dc156c8f 100644
--- a/src/control/CarCtrl.h
+++ b/src/control/CarCtrl.h
@@ -58,6 +58,7 @@ public:
static void RemoveDistantCars(void);
static void PossiblyRemoveVehicle(CVehicle*);
static bool IsThisVehicleInteresting(CVehicle*);
+ static void RegisterVehicleOfInterest(CVehicle*);
static int32 CountCarsOfType(int32 mi);
static void SlowCarOnRailsDownForTrafficAndLights(CVehicle*);
static bool PickNextNodeAccordingStrategy(CVehicle*);