summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-06-24 23:11:56 +0200
committerGitHub <noreply@github.com>2019-06-24 23:11:56 +0200
commitf07f411629b686338df10fdce217b2d258f38c92 (patch)
treecd07798b2daf33ea3a152e54cd18809da2cc9b2f /src/control
parentreplaced some ctors; made PreRender call game function (diff)
parentCPed, CVehicle, mostly entering/exiting car (diff)
downloadre3-f07f411629b686338df10fdce217b2d258f38c92.tar
re3-f07f411629b686338df10fdce217b2d258f38c92.tar.gz
re3-f07f411629b686338df10fdce217b2d258f38c92.tar.bz2
re3-f07f411629b686338df10fdce217b2d258f38c92.tar.lz
re3-f07f411629b686338df10fdce217b2d258f38c92.tar.xz
re3-f07f411629b686338df10fdce217b2d258f38c92.tar.zst
re3-f07f411629b686338df10fdce217b2d258f38c92.zip
Diffstat (limited to 'src/control')
-rw-r--r--src/control/CarCtrl.cpp2
-rw-r--r--src/control/CarCtrl.h2
-rw-r--r--src/control/PedPlacement.cpp40
-rw-r--r--src/control/PedPlacement.h8
4 files changed, 52 insertions, 0 deletions
diff --git a/src/control/CarCtrl.cpp b/src/control/CarCtrl.cpp
index d59ae2d0..ff73e405 100644
--- a/src/control/CarCtrl.cpp
+++ b/src/control/CarCtrl.cpp
@@ -2,5 +2,7 @@
#include "patcher.h"
#include "CarCtrl.h"
+int &CCarCtrl::NumLawEnforcerCars = *(int*)0x8F1B38;
+
WRAPPER void CCarCtrl::SwitchVehicleToRealPhysics(CVehicle*) { EAXJMP(0x41F7F0); }
WRAPPER void CCarCtrl::AddToCarArray(int id, int vehclass) { EAXJMP(0x4182F0); }
diff --git a/src/control/CarCtrl.h b/src/control/CarCtrl.h
index 1f468475..06204ddd 100644
--- a/src/control/CarCtrl.h
+++ b/src/control/CarCtrl.h
@@ -7,4 +7,6 @@ class CCarCtrl
public:
static void SwitchVehicleToRealPhysics(CVehicle*);
static void AddToCarArray(int id, int vehclass);
+
+ static int32 &NumLawEnforcerCars;
};
diff --git a/src/control/PedPlacement.cpp b/src/control/PedPlacement.cpp
new file mode 100644
index 00000000..de4cdae1
--- /dev/null
+++ b/src/control/PedPlacement.cpp
@@ -0,0 +1,40 @@
+#include "common.h"
+#include "patcher.h"
+#include "PedPlacement.h"
+#include "World.h"
+
+void
+CPedPlacement::FindZCoorForPed(CVector* pos)
+{
+ float zForPed;
+ float startZ = pos->z - 100.0f;
+ float foundColZ = -100.0f;
+ float foundColZ2 = -100.0f;
+ CColPoint foundCol;
+ CEntity* foundEnt;
+
+ CVector vec(
+ pos->x,
+ pos->y,
+ pos->z + 1.0f
+ );
+
+ if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, false))
+ foundColZ = foundCol.point.z;
+
+ // Adjust coords and do a second test
+ vec.x += 0.1f;
+ vec.y += 0.1f;
+
+ if (CWorld::ProcessVerticalLine(vec, startZ, foundCol, foundEnt, true, false, false, false, true, false, false))
+ foundColZ2 = foundCol.point.z;
+
+ zForPed = max(foundColZ, foundColZ2);
+
+ if (zForPed > -99.0f)
+ pos->z = 1.04f + zForPed;
+}
+
+STARTPATCHES
+ InjectHook(0x4EE340, &CPedPlacement::FindZCoorForPed, PATCH_JUMP);
+ENDPATCHES
diff --git a/src/control/PedPlacement.h b/src/control/PedPlacement.h
new file mode 100644
index 00000000..4bd48b62
--- /dev/null
+++ b/src/control/PedPlacement.h
@@ -0,0 +1,8 @@
+#pragma once
+
+class CVector;
+
+class CPedPlacement {
+public:
+ static void FindZCoorForPed(CVector* pos);
+}; \ No newline at end of file