summaryrefslogtreecommitdiffstats
path: root/src/control
diff options
context:
space:
mode:
Diffstat (limited to 'src/control')
-rw-r--r--src/control/AutoPilot.h89
-rw-r--r--src/control/Bridge.cpp151
-rw-r--r--src/control/Bridge.h25
-rw-r--r--src/control/PathFind.cpp2
-rw-r--r--src/control/PathFind.h2
-rw-r--r--src/control/Population.cpp1
-rw-r--r--src/control/Population.h4
-rw-r--r--src/control/Replay.cpp129
8 files changed, 335 insertions, 68 deletions
diff --git a/src/control/AutoPilot.h b/src/control/AutoPilot.h
new file mode 100644
index 00000000..97b02f5c
--- /dev/null
+++ b/src/control/AutoPilot.h
@@ -0,0 +1,89 @@
+#pragma once
+
+class CVehicle;
+
+enum eCarMission : uint8
+{
+ MISSION_NONE,
+ MISSION_CRUISE,
+ MISSION_RAMPLAYER_FARAWAY,
+ MISSION_RAMPLAYER_CLOSE,
+ MISSION_BLOCKPLAYER_FARAWAY,
+ MISSION_BLOCKPLAYER_CLOSE,
+ MISSION_BLOCKPLAYER_HANDBRAKESTOP,
+ MISSION_WAITFORDELETION,
+ MISSION_GOTOCOORDS,
+ MISSION_GOTOCOORDS_STRAIGHT,
+ MISSION_EMERGENCYVEHICLE_STOP,
+ MISSION_STOP_FOREVER,
+ MISSION_GOTOCOORDS_ACCURATE,
+ MISSION_GOTO_COORDS_STRAIGHT_ACCURATE,
+ MISSION_GOTOCOORDS_ASTHECROWSWIMS,
+ MISSION_RAMCAR_FARAWAY,
+ MISSION_RAMCAR_CLOSE,
+ MISSION_BLOCKCAR_FARAWAY,
+ MISSION_BLOCKCAR_CLOSE,
+ MISSION_BLOCKCAR_HANDBRAKESTOP,
+ MISSION_HELI_FLYTOCOORS,
+ MISSION_ATTACKPLAYER,
+ MISSION_PLANE_FLYTOCOORS,
+ MISSION_HELI_LAND,
+ MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_1,
+ MISSION_SLOWLY_DRIVE_TOWARDS_PLAYER_2,
+ MISSION_BLOCKPLAYER_FORWARDANDBACK
+};
+
+enum eCarTempAction : uint8
+{
+ TEMPACT_NONE,
+ TEMPACT_WAIT,
+ TEMPACT_REVERSE,
+ TEMPACT_HANDBRAKETURNLEFT,
+ TEMPACT_HANDBRAKETURNRIGHT,
+ TEMPACT_HANDBRAKESTRAIGHT,
+ TEMPACT_TURNLEFT,
+ TEMPACT_TURNRIGHT,
+ TEMPACT_GOFORWARD,
+ TEMPACT_SWERVELEFT,
+ TEMPACT_SWERVERIGHT
+};
+
+enum eCarDrivingStyle : uint8
+{
+ DRIVINGSTYLE_STOP_FOR_CARS,
+ DRIVINGSTYLE_SLOW_DOWN_FOR_CARS,
+ DRIVINGSTYLE_AVOID_CARS,
+ DRIVINGSTYLE_PLOUGH_THROUGH,
+ DRIVINGSTYLE_STOP_FOR_CARS_IGNORE_LIGHTS
+};
+
+class CAutoPilot {
+public:
+ void *m_currentAddress;
+ void *m_startingRouteNode;
+ void *m_PreviousRouteNode;
+ uint32 m_nTotalSpeedScaleFactor;
+ uint32 m_nSpeedScaleFactor;
+ uint32 m_nCurrentPathNodeInfo;
+ uint32 m_nNextPathNodeInfo;
+ uint32 m_nPreviousPathNodeInfo;
+ uint32 m_nTimeToStartMission;
+ uint32 m_nTimeSwitchedToRealPhysics;
+ int8 m_nPreviousDirection;
+ int8 m_nCurrentDirecton;
+ int8 m_nNextDirection;
+ int8 m_nPreviousPathDirection;
+ int8 m_nCurrentPathDirection;
+ eCarDrivingStyle m_nDrivingStyle;
+ eCarMission m_nCarMission;
+ eCarTempAction m_nAnimationId;
+ uint8 m_nAnimationTime;
+ float m_fMaxTrafficSpeed;
+ uint8 m_nCruiseSpeed;
+ uint8 m_nCarCtrlFlags;
+ CVector m_vecDestinationCoors;
+ void *m_aPathFindNodesInfo[8];
+ uint16 m_nPathFindNodesCount;
+ CVehicle *m_pTargetCar;
+};
+static_assert(sizeof(CAutoPilot) == 0x70, "CAutoPilot: error");
diff --git a/src/control/Bridge.cpp b/src/control/Bridge.cpp
index 91f3c788..3215ea2d 100644
--- a/src/control/Bridge.cpp
+++ b/src/control/Bridge.cpp
@@ -1,5 +1,154 @@
#include "common.h"
#include "patcher.h"
#include "Bridge.h"
+#include "Pools.h"
+#include "ModelIndices.h"
+#include "PathFind.h"
+#include "Stats.h"
-WRAPPER bool CBridge::ShouldLightsBeFlashing(void) { EAXJMP(0x413D10); }
+CEntity*& CBridge::pLiftRoad = *(CEntity**)0x8E2C8C;
+CEntity*& CBridge::pLiftPart = *(CEntity**)0x8E2C94;
+CEntity*& CBridge::pWeight = *(CEntity**)0x8E28BC;
+
+int& CBridge::State = *(int*)0x8F2A1C;
+int& CBridge::OldState = *(int*)0x8F2A20;
+
+float& CBridge::DefaultZLiftPart = *(float*)0x941430;
+float& CBridge::DefaultZLiftRoad = *(float*)0x941438;
+float& CBridge::DefaultZLiftWeight = *(float*)0x8F1A44;
+
+float& CBridge::OldLift = *(float*)0x8F6254;
+
+uint32& CBridge::TimeOfBridgeBecomingOperational = *(uint32*)0x8F2BC0;
+
+void CBridge::Init()
+{
+ FindBridgeEntities();
+ OldLift = -1.0;
+ if (pLiftPart && pWeight)
+ {
+ DefaultZLiftPart = pLiftPart->GetPosition().z;
+ DefaultZLiftWeight = pWeight->GetPosition().z;
+
+ if (pLiftRoad)
+ DefaultZLiftRoad = pLiftRoad->GetPosition().z;
+
+ ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, true);
+ }
+}
+
+void CBridge::Update()
+{
+ if (!pLiftPart || !pWeight)
+ return;
+
+ OldState = State;
+
+ float liftHeight;
+
+ if (CStats::CommercialPassed)
+ {
+ 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;
+
+ // Calculate lift part height and bridge state
+ if (timeElapsed < 10000)
+ {
+ State = STATE_LIFT_PART_MOVING_DOWN;
+ liftHeight = 25.0 - timeElapsed / 10000.0 * 25.0;
+ }
+ else if (timeElapsed < 40000)
+ {
+ liftHeight = 0.0;
+ State = STATE_LIFT_PART_IS_DOWN;
+ }
+ else if (timeElapsed < 50000)
+ {
+ liftHeight = 0.0;
+ State = STATE_LIFT_PART_ABOUT_TO_MOVE_UP;
+ }
+ else if (timeElapsed < 60000)
+ {
+ State = STATE_LIFT_PART_MOVING_UP;
+ liftHeight = (timeElapsed - 50000) / 10000.0 * 25.0;
+ }
+ else
+ {
+ liftHeight = 25.0;
+ State = STATE_LIFT_PART_IS_UP;
+ }
+
+ // Move bridge part
+ if (liftHeight != OldLift)
+ {
+ pLiftPart->GetPosition().z = DefaultZLiftPart + liftHeight;
+ pLiftPart->GetMatrix().UpdateRW();
+ pLiftPart->UpdateRwFrame();
+ if (pLiftRoad)
+ {
+ pLiftRoad->GetPosition().z = DefaultZLiftRoad + liftHeight;
+ pLiftRoad->GetMatrix().UpdateRW();
+ pLiftRoad->UpdateRwFrame();
+ }
+ pWeight->GetPosition().z = DefaultZLiftWeight - liftHeight;
+ pWeight->GetMatrix().UpdateRW();
+ pWeight->UpdateRwFrame();
+
+ OldLift = liftHeight;
+ }
+
+ 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)
+ ThePaths.SetLinksBridgeLights(-330.0, -230.0, -700.0, -588.0, false);
+ }
+ else
+ {
+ liftHeight = 25.0;
+ TimeOfBridgeBecomingOperational = 0;
+ State = STATE_BRIDGE_LOCKED;
+ }
+}
+
+bool CBridge::ShouldLightsBeFlashing() { return State != STATE_LIFT_PART_IS_DOWN; }
+
+void CBridge::FindBridgeEntities()
+{
+ pWeight = nil;
+ pLiftRoad = nil;
+ pLiftPart = nil;
+
+ for (int i = 1; i < CPools::GetBuildingPool()->GetSize(); ++i)
+ {
+ CBuilding* entry = CPools::GetBuildingPool()->GetSlot(i);
+ if (entry)
+ {
+ if (entry->GetModelIndex() == MI_BRIDGELIFT)
+ pLiftPart = entry;
+ else if (entry->GetModelIndex() == MI_BRIDGEROADSEGMENT)
+ pLiftRoad = entry;
+ else if (entry->GetModelIndex() == MI_BRIDGEWEIGHT)
+ pWeight = entry;
+ }
+ }
+}
+
+bool CBridge::ThisIsABridgeObjectMovingUp(int index)
+{
+ if (index != MI_BRIDGEROADSEGMENT && index != MI_BRIDGELIFT)
+ return false;
+
+ return State == STATE_LIFT_PART_ABOUT_TO_MOVE_UP || State == STATE_LIFT_PART_MOVING_UP;
+}
+
+STARTPATCHES
+ InjectHook(0x413A30, &CBridge::Init, PATCH_JUMP);
+ InjectHook(0x413AC0, &CBridge::Update, PATCH_JUMP);
+ InjectHook(0x413D10, &CBridge::ShouldLightsBeFlashing, PATCH_JUMP);
+ InjectHook(0x413D20, &CBridge::FindBridgeEntities, PATCH_JUMP);
+ InjectHook(0x413DE0, &CBridge::ThisIsABridgeObjectMovingUp, PATCH_JUMP);
+ENDPATCHES \ No newline at end of file
diff --git a/src/control/Bridge.h b/src/control/Bridge.h
index 64b85c1d..52c85322 100644
--- a/src/control/Bridge.h
+++ b/src/control/Bridge.h
@@ -1,7 +1,30 @@
#pragma once
+#include "Entity.h"
class CBridge
{
+private:
+ enum bridgeStates
+ {
+ STATE_BRIDGE_LOCKED,
+ STATE_LIFT_PART_IS_UP,
+ STATE_LIFT_PART_MOVING_DOWN,
+ STATE_LIFT_PART_IS_DOWN,
+ STATE_LIFT_PART_ABOUT_TO_MOVE_UP,
+ STATE_LIFT_PART_MOVING_UP
+ };
+
+
+ static CEntity *&pLiftRoad, *&pLiftPart, *&pWeight;
+ static int &State, &OldState;
+ static float &DefaultZLiftPart, &DefaultZLiftRoad, &DefaultZLiftWeight;
+ static float& OldLift;
+ static uint32& TimeOfBridgeBecomingOperational;
+
public:
- static bool ShouldLightsBeFlashing(void);
+ static void Init();
+ static void Update();
+ static bool ShouldLightsBeFlashing();
+ static void FindBridgeEntities();
+ static bool ThisIsABridgeObjectMovingUp(int);
};
diff --git a/src/control/PathFind.cpp b/src/control/PathFind.cpp
index f511b5dc..f9ce7f35 100644
--- a/src/control/PathFind.cpp
+++ b/src/control/PathFind.cpp
@@ -626,6 +626,8 @@ CPathFind::CalcNodeCoors(int16 x, int16 y, int16 z, int id, CVector *out)
*out = m_mapObjects[id]->GetMatrix() * pos;
}
+WRAPPER void CPathFind::SetLinksBridgeLights(float, float, float, float, bool) { EAXJMP(0x42E3B0); }
+
STARTPATCHES
InjectHook(0x429610, &CPathFind::PreparePathData, PATCH_JUMP);
InjectHook(0x429C20, &CPathFind::PreparePathDataForType, PATCH_JUMP);
diff --git a/src/control/PathFind.h b/src/control/PathFind.h
index cc0b0a2f..9b6be573 100644
--- a/src/control/PathFind.h
+++ b/src/control/PathFind.h
@@ -131,6 +131,8 @@ public:
int32 FindNodeClosestToCoors(CVector coors, uint8 type, float distLimit, bool disabled, bool betweenLevels);
bool IsPathObject(int id) { return id < PATHNODESIZE && (InfoForTileCars[id*12].type != 0 || InfoForTilePeds[id*12].type != 0); }
+
+ void SetLinksBridgeLights(float, float, float, float, bool);
};
static_assert(sizeof(CPathFind) == 0x4c8f4, "CPathFind: error");
diff --git a/src/control/Population.cpp b/src/control/Population.cpp
index 9af68670..1ae5962d 100644
--- a/src/control/Population.cpp
+++ b/src/control/Population.cpp
@@ -10,3 +10,4 @@ float &CPopulation::PedDensityMultiplier = *(float*)0x5FA56C;
WRAPPER void CPopulation::UpdatePedCount(uint32, bool) { EAXJMP(0x4F5A60); }
WRAPPER void CPopulation::DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool) { EAXJMP(0x4F6200); }
+WRAPPER CPed *CPopulation::AddPedInCar(CVehicle *vehicle) { EAXJMP(0x4F5800); }
diff --git a/src/control/Population.h b/src/control/Population.h
index 4169261a..6bd2e3ae 100644
--- a/src/control/Population.h
+++ b/src/control/Population.h
@@ -1,6 +1,7 @@
#pragma once
-#include "PedType.h"
+class CPed;
+class CVehicle;
struct PedGroup
{
@@ -17,4 +18,5 @@ public:
static void UpdatePedCount(uint32, bool);
static void DealWithZoneChange(eLevelName oldLevel, eLevelName newLevel, bool);
+ static CPed *AddPedInCar(CVehicle *vehicle);
};
diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp
index a2164f6b..e166e6b5 100644
--- a/src/control/Replay.cpp
+++ b/src/control/Replay.cpp
@@ -135,34 +135,33 @@ WRAPPER static void ApplyPanelDamageToCar(uint32, CAutomobile*, bool) { EAXJMP(0
#else
static void ApplyPanelDamageToCar(uint32 panels, CAutomobile* vehicle, bool flying)
{
- CDamageManager::PanelStatus rp = *(CDamageManager::PanelStatus*)&panels;
- if (vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelFrontLeftStatus != rp.m_nPanelFrontLeftStatus){
- vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelFrontLeftStatus = rp.m_nPanelFrontLeftStatus;
- vehicle->SetPanelDamage(13, CDamageManager::PANEL_FL, flying);
+ if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT)){
+ vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_LEFT));
+ vehicle->SetPanelDamage(CAR_WING_LF, VEHPANEL_FRONT_LEFT, flying);
}
- if (vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelFrontRightStatus != rp.m_nPanelFrontRightStatus) {
- vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelFrontRightStatus = rp.m_nPanelFrontRightStatus;
- vehicle->SetPanelDamage(9, CDamageManager::PANEL_FR, flying);
+ if(vehicle->Damage.GetPanelStatus(VEHPANEL_FRONT_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT)){
+ vehicle->Damage.SetPanelStatus(VEHPANEL_FRONT_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_FRONT_RIGHT));
+ vehicle->SetPanelDamage(CAR_WING_RF, VEHPANEL_FRONT_RIGHT, flying);
}
- if (vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelBackLeftStatus != rp.m_nPanelBackLeftStatus) {
- vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelBackLeftStatus = rp.m_nPanelBackLeftStatus;
- vehicle->SetPanelDamage(14, CDamageManager::PANEL_RL, flying);
+ if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_LEFT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT)){
+ vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_LEFT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_LEFT));
+ vehicle->SetPanelDamage(CAR_WING_LR, VEHPANEL_REAR_LEFT, flying);
}
- if (vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelBackRightStatus != rp.m_nPanelBackRightStatus) {
- vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelBackRightStatus = rp.m_nPanelBackRightStatus;
- vehicle->SetPanelDamage(10, CDamageManager::PANEL_RR, flying);
+ if(vehicle->Damage.GetPanelStatus(VEHPANEL_REAR_RIGHT) != CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT)){
+ vehicle->Damage.SetPanelStatus(VEHPANEL_REAR_RIGHT, CDamageManager::GetPanelStatus(panels, VEHPANEL_REAR_RIGHT));
+ vehicle->SetPanelDamage(CAR_WING_RR, VEHPANEL_REAR_RIGHT, flying);
}
- if (vehicle->m_DamageManager.m_sPanelsStatus.m_nWindshieldStatus != rp.m_nWindshieldStatus) {
- vehicle->m_DamageManager.m_sPanelsStatus.m_nWindshieldStatus = rp.m_nWindshieldStatus;
- vehicle->SetPanelDamage(19, CDamageManager::PANEL_WINDSHIELD, flying);
+ if(vehicle->Damage.GetPanelStatus(VEHPANEL_WINDSCREEN) != CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN)){
+ vehicle->Damage.SetPanelStatus(VEHPANEL_WINDSCREEN, CDamageManager::GetPanelStatus(panels, VEHPANEL_WINDSCREEN));
+ vehicle->SetPanelDamage(CAR_WINDSCREEN, VEHPANEL_WINDSCREEN, flying);
}
- if (vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelFrontStatus != rp.m_nPanelFrontStatus) {
- vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelFrontStatus = rp.m_nPanelFrontStatus;
- vehicle->SetPanelDamage(7, CDamageManager::PANEL_FRONT, flying);
+ if(vehicle->Damage.GetPanelStatus(VEHBUMPER_FRONT) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT)){
+ vehicle->Damage.SetPanelStatus(VEHBUMPER_FRONT, CDamageManager::GetPanelStatus(panels, VEHBUMPER_FRONT));
+ vehicle->SetPanelDamage(CAR_BUMP_FRONT, VEHBUMPER_FRONT, flying);
}
- if (vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelBackStatus != rp.m_nPanelBackStatus) {
- vehicle->m_DamageManager.m_sPanelsStatus.m_nPanelBackStatus = rp.m_nPanelBackStatus;
- vehicle->SetPanelDamage(8, CDamageManager::PANEL_BACK, flying);
+ if(vehicle->Damage.GetPanelStatus(VEHBUMPER_REAR) != CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR)){
+ vehicle->Damage.SetPanelStatus(VEHBUMPER_REAR, CDamageManager::GetPanelStatus(panels, VEHBUMPER_REAR));
+ vehicle->SetPanelDamage(CAR_BUMP_REAR, VEHBUMPER_REAR, flying);
}
}
#endif
@@ -625,7 +624,7 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
vp->matrix.CompressFromFullMatrix(vehicle->GetMatrix());
vp->health = vehicle->m_fHealth / 4.0f; /* Not anticipated that health can be > 1000. */
vp->acceleration = vehicle->m_fGasPedal * 100.0f;
- vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->m_DamageManager.m_abPanelsStatus : 0;
+ vp->panels = vehicle->IsCar() ? ((CAutomobile*)vehicle)->Damage.m_panelStatus : 0;
vp->velocityX = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().x)); /* 8000!? */
vp->velocityY = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().y));
vp->velocityZ = 8000.0f * max(-4.0f, min(4.0f, vehicle->GetSpeed().z));
@@ -639,14 +638,14 @@ void CReplay::StoreCarUpdate(CVehicle *vehicle, int id)
if (vehicle->IsCar()){
CAutomobile* car = (CAutomobile*)vehicle;
for (int i = 0; i < 4; i++){
- vp->wheel_susp_dist[i] = 50.0f * car->m_afWheelSuspDist[i];
- vp->wheel_rotation[i] = 128.0f / M_PI * car->m_afWheelRotation[i];
+ vp->wheel_susp_dist[i] = 50.0f * car->m_aWheelDist[i];
+ vp->wheel_rotation[i] = 128.0f / M_PI * car->m_aWheelRotation[i];
}
- vp->door_angles[0] = 127.0f / M_PI * car->m_aDoors[2].m_fAngle;
- vp->door_angles[1] = 127.0f / M_PI * car->m_aDoors[3].m_fAngle;
+ vp->door_angles[0] = 127.0f / M_PI * car->Doors[2].m_fAngle;
+ vp->door_angles[1] = 127.0f / M_PI * car->Doors[3].m_fAngle;
vp->door_status = 0;
for (int i = 0; i < 6; i++){
- if (car->m_DamageManager.m_bDoorStatus[i] == 3)
+ if (car->Damage.GetDoorStatus(i) == 3)
vp->door_status |= BIT(i);
}
}
@@ -684,42 +683,42 @@ void CReplay::ProcessCarUpdate(CVehicle *vehicle, float interpolation, CAddressI
if (vehicle->IsCar()) {
CAutomobile* car = (CAutomobile*)vehicle;
for (int i = 0; i < 4; i++) {
- car->m_afWheelSuspDist[i] = vp->wheel_susp_dist[i] / 50.0f;
- car->m_afWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f;
+ car->m_aWheelDist[i] = vp->wheel_susp_dist[i] / 50.0f;
+ car->m_aWheelRotation[i] = vp->wheel_rotation[i] * M_PI / 128.0f;
}
- car->m_aDoors[2].m_fAngle = car->m_aDoors[2].m_fPreviousAngle = vp->door_angles[0] * M_PI / 127.0f;
- car->m_aDoors[3].m_fAngle = car->m_aDoors[3].m_fPreviousAngle = vp->door_angles[1] * M_PI / 127.0f;
+ car->Doors[2].m_fAngle = car->Doors[2].m_fPreviousAngle = vp->door_angles[0] * M_PI / 127.0f;
+ car->Doors[3].m_fAngle = car->Doors[3].m_fPreviousAngle = vp->door_angles[1] * M_PI / 127.0f;
if (vp->door_angles[0])
- car->m_DamageManager.m_bDoorStatus[2] = 2;
+ car->Damage.SetDoorStatus(2, 2);
if (vp->door_angles[1])
- car->m_DamageManager.m_bDoorStatus[3] = 2;
- if (vp->door_status & 1 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_BONNET) != 3){
- car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_BONNET, 3);
- car->SetDoorDamage(17, CDamageManager::CAR_DOOR_BONNET, true);
+ car->Damage.SetDoorStatus(3, 2);
+ if (vp->door_status & 1 && car->Damage.GetDoorStatus(DOOR_BONNET) != 3){
+ car->Damage.SetDoorStatus(DOOR_BONNET, 3);
+ car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
}
- if (vp->door_status & 2 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_BUMPER) != 3) {
- car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_BUMPER, 3);
- car->SetDoorDamage(18, CDamageManager::CAR_DOOR_BUMPER, true);
+ if (vp->door_status & 2 && car->Damage.GetDoorStatus(DOOR_BOOT) != 3) {
+ car->Damage.SetDoorStatus(DOOR_BOOT, 3);
+ car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
}
- if (vp->door_status & 4 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_LF) != 3) {
- car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_LF, 3);
- car->SetDoorDamage(15, CDamageManager::CAR_DOOR_LF, true);
+ if (vp->door_status & 4 && car->Damage.GetDoorStatus(DOOR_FRONT_LEFT) != 3) {
+ car->Damage.SetDoorStatus(DOOR_FRONT_LEFT, 3);
+ car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
}
- if (vp->door_status & 8 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_RF) != 3) {
- car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_RF, 3);
- car->SetDoorDamage(11, CDamageManager::CAR_DOOR_RF, true);
+ if (vp->door_status & 8 && car->Damage.GetDoorStatus(DOOR_FRONT_RIGHT) != 3) {
+ car->Damage.SetDoorStatus(DOOR_FRONT_RIGHT, 3);
+ car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
}
- if (vp->door_status & 0x10 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_LR) != 3) {
- car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_LR, 3);
- car->SetDoorDamage(16, CDamageManager::CAR_DOOR_LR, true);
+ if (vp->door_status & 0x10 && car->Damage.GetDoorStatus(DOOR_REAR_LEFT) != 3) {
+ car->Damage.SetDoorStatus(DOOR_REAR_LEFT, 3);
+ car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
}
- if (vp->door_status & 0x20 && car->m_DamageManager.GetDoorStatus(CDamageManager::CAR_DOOR_RR) != 3) {
- car->m_DamageManager.SetDoorStatus(CDamageManager::CAR_DOOR_RR, 3);
- car->SetDoorDamage(12, CDamageManager::CAR_DOOR_RR, true);
+ if (vp->door_status & 0x20 && car->Damage.GetDoorStatus(DOOR_REAR_RIGHT) != 3) {
+ car->Damage.SetDoorStatus(DOOR_REAR_RIGHT, 3);
+ car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
}
- vehicle->m_veh_flagA10 = true;
+ vehicle->bEngineOn = true;
if (vehicle->IsCar())
- ((CAutomobile*)vehicle)->m_nDriveWheelsOnGround = 4;
+ ((CAutomobile*)vehicle)->m_nWheelsOnGround = 4;
CWorld::Remove(vehicle);
CWorld::Add(vehicle);
if (vehicle->IsBoat())
@@ -1186,24 +1185,24 @@ void CReplay::RestoreStuffFromMem(void)
vehicle->SetModelIndex(mi);
if (mi == MI_DODO){
CAutomobile* dodo = (CAutomobile*)vehicle;
- GetFirstObject(dodo->m_apModelNodes[4])->flags = 0; /* TODO: 4 to enum */
+ RpAtomicSetFlags(GetFirstObject(dodo->m_aCarNodes[CAR_WHEEL_LF]), 0);
CMatrix tmp1;
- tmp1.Attach(&dodo->m_apModelNodes[1]->modelling, false);
- CMatrix tmp2(&dodo->m_apModelNodes[4]->modelling, false);
+ tmp1.Attach(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_RF]), false);
+ CMatrix tmp2(RwFrameGetMatrix(dodo->m_aCarNodes[CAR_WHEEL_LF]), false);
*tmp1.GetPosition() += CVector(tmp2.GetPosition()->x + 0.1f, 0.0f, tmp2.GetPosition()->z);
tmp1.UpdateRW();
}
if (vehicle->IsCar()){
CAutomobile* car = (CAutomobile*)vehicle;
- int32 panels = car->m_DamageManager.m_abPanelsStatus;
- car->m_DamageManager.m_abPanelsStatus = 0;
+ int32 panels = car->Damage.m_panelStatus;
+ car->Damage.m_panelStatus = 0;
ApplyPanelDamageToCar(panels, car, true);
- car->SetDoorDamage(17, 0, true); /* BONNET */
- car->SetDoorDamage(18, 1, true); /* BUMPER */
- car->SetDoorDamage(15, 2, true); /* DOOR_FRONT_LEFT */
- car->SetDoorDamage(11, 3, true); /* DOOR_FRONT_RIGHT */
- car->SetDoorDamage(16, 4, true); /* DOOR_BACK_LEFT */
- car->SetDoorDamage(12, 5, true); /* DOOR_BACK_RIGHT */
+ car->SetDoorDamage(CAR_BONNET, DOOR_BONNET, true);
+ car->SetDoorDamage(CAR_BOOT, DOOR_BOOT, true);
+ car->SetDoorDamage(CAR_DOOR_LF, DOOR_FRONT_LEFT, true);
+ car->SetDoorDamage(CAR_DOOR_RF, DOOR_FRONT_RIGHT, true);
+ car->SetDoorDamage(CAR_DOOR_LR, DOOR_REAR_LEFT, true);
+ car->SetDoorDamage(CAR_DOOR_RR, DOOR_REAR_RIGHT, true);
}
vehicle->m_audioEntityId = DMAudio.CreateEntity(0, vehicle);
DMAudio.SetEntityStatus(vehicle->m_audioEntityId, true);