summaryrefslogtreecommitdiffstats
path: root/src/control/Remote.cpp
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2020-01-31 12:57:00 +0100
committerGitHub <noreply@github.com>2020-01-31 12:57:00 +0100
commite1e76f510e798d45db98354b739eaf5c1c95576d (patch)
treefee9bcb43054041fee538979c98f789dcb5242f1 /src/control/Remote.cpp
parentRC toyz crashfix (diff)
parentCRemote (diff)
downloadre3-e1e76f510e798d45db98354b739eaf5c1c95576d.tar
re3-e1e76f510e798d45db98354b739eaf5c1c95576d.tar.gz
re3-e1e76f510e798d45db98354b739eaf5c1c95576d.tar.bz2
re3-e1e76f510e798d45db98354b739eaf5c1c95576d.tar.lz
re3-e1e76f510e798d45db98354b739eaf5c1c95576d.tar.xz
re3-e1e76f510e798d45db98354b739eaf5c1c95576d.tar.zst
re3-e1e76f510e798d45db98354b739eaf5c1c95576d.zip
Diffstat (limited to 'src/control/Remote.cpp')
-rw-r--r--src/control/Remote.cpp54
1 files changed, 52 insertions, 2 deletions
diff --git a/src/control/Remote.cpp b/src/control/Remote.cpp
index 32ee4eda..e3891502 100644
--- a/src/control/Remote.cpp
+++ b/src/control/Remote.cpp
@@ -1,6 +1,56 @@
#include "common.h"
#include "patcher.h"
+#include "Automobile.h"
+#include "CarCtrl.h"
+#include "Camera.h"
#include "Remote.h"
+#include "Timer.h"
+#include "World.h"
+#include "PlayerInfo.h"
+#include "Vehicle.h"
-WRAPPER void CRemote::GivePlayerRemoteControlledCar(float, float, float, float, uint16) { EAXJMP(0x435C30); }
-WRAPPER void CRemote::TakeRemoteControlledCarFromPlayer(void) { EAXJMP(0x435DA0); }
+void
+CRemote::GivePlayerRemoteControlledCar(float x, float y, float z, float rot, uint16 model)
+{
+ CAutomobile *car = new CAutomobile(model, MISSION_VEHICLE);
+ bool found;
+
+ z = car->GetDistanceFromCentreOfMassToBaseOfModel() + CWorld::FindGroundZFor3DCoord(x, y, z + 2.0f, &found);
+
+ car->GetMatrix().SetRotateZOnly(rot);
+ car->GetPosition() = CVector(x, y, z);
+ car->m_status = STATUS_PLAYER_REMOTE;
+ car->bIsLocked = true;
+
+ CCarCtrl::JoinCarWithRoadSystem(car);
+ car->AutoPilot.m_nCarMission = MISSION_NONE;
+ car->AutoPilot.m_nTempAction = TEMPACT_NONE;
+ car->AutoPilot.m_nDrivingStyle = DRIVINGSTYLE_STOP_FOR_CARS;
+ car->AutoPilot.m_nCruiseSpeed = car->AutoPilot.m_fMaxTrafficSpeed = 9.0f;
+ car->AutoPilot.m_nNextLane = car->AutoPilot.m_nCurrentLane = 0;
+ car->bEngineOn = true;
+ CWorld::Add(car);
+ if (FindPlayerVehicle() != nil)
+ FindPlayerVehicle()->m_status = STATUS_PLAYER_DISABLED;
+
+ CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle = car;
+ CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->RegisterReference((CEntity**)&CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle);
+ TheCamera.TakeControl(car, CCam::MODE_BEHINDCAR, INTERPOLATION, CAM_CONTROLLER_1);
+}
+
+void
+CRemote::TakeRemoteControlledCarFromPlayer(void)
+{
+ CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->VehicleCreatedBy = RANDOM_VEHICLE;
+ CCarCtrl::NumMissionCars--;
+ CCarCtrl::NumRandomCars++;
+ CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->bIsLocked = false;
+ CWorld::Players[CWorld::PlayerInFocus].m_nTimeLostRemoteCar = CTimer::GetTimeInMilliseconds();
+ CWorld::Players[CWorld::PlayerInFocus].m_bInRemoteMode = true;
+ CWorld::Players[CWorld::PlayerInFocus].m_pRemoteVehicle->bRemoveFromWorld = true;
+}
+
+STARTPATCHES
+ InjectHook(0x435C30, &CRemote::GivePlayerRemoteControlledCar, PATCH_JUMP);
+ InjectHook(0x435DA0, &CRemote::TakeRemoteControlledCarFromPlayer, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file