diff options
-rw-r--r-- | src/DamageManager.h | 25 | ||||
-rw-r--r-- | src/control/Replay.cpp | 35 | ||||
-rw-r--r-- | src/entities/Automobile.cpp | 2 | ||||
-rw-r--r-- | src/entities/Automobile.h | 2 |
4 files changed, 63 insertions, 1 deletions
diff --git a/src/DamageManager.h b/src/DamageManager.h index 01269a42..4c1e3925 100644 --- a/src/DamageManager.h +++ b/src/DamageManager.h @@ -15,12 +15,35 @@ public: CAR_DOOR_RR }; + enum { + PANEL_FL = 0, + PANEL_FR, + PANEL_RL, + PANEL_RR, + PANEL_WINDSHIELD, + PANEL_FRONT, + PANEL_BACK + }; + + struct PanelStatus { + uint32 m_nPanelFrontLeftStatus : 4; + uint32 m_nPanelFrontRightStatus : 4; + uint32 m_nPanelBackLeftStatus : 4; + uint32 m_nPanelBackRightStatus : 4; + uint32 m_nWindshieldStatus : 4; + uint32 m_nPanelFrontStatus : 4; + uint32 m_nPanelBackStatus : 4; + }; + float field_0; char m_bEngineStatus; char m_bWheelStatus[4]; char m_bDoorStatus[7]; uint32 m_abLightStatus; - uint32 m_abPanelsStatus; + union{ + PanelStatus m_sPanelsStatus; + uint32 m_abPanelsStatus; + }; char field_24; char field_25; char field_26; diff --git a/src/control/Replay.cpp b/src/control/Replay.cpp index ce2a9bd4..e49e10bc 100644 --- a/src/control/Replay.cpp +++ b/src/control/Replay.cpp @@ -130,7 +130,42 @@ static void(*FindCBFunction(uint8 id))(CAnimBlendAssociation*, void*) return CBArray_RE3[id]; } +#if 0 WRAPPER static void ApplyPanelDamageToCar(uint32, CAutomobile*, bool) { EAXJMP(0x584EA0); } +#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->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->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->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->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->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->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); + } +} +#endif void PrintElementsInPtrList(void) { diff --git a/src/entities/Automobile.cpp b/src/entities/Automobile.cpp index e74013be..54eed17a 100644 --- a/src/entities/Automobile.cpp +++ b/src/entities/Automobile.cpp @@ -10,6 +10,8 @@ CAutomobile::CAutomobile(int mi, uint8 owner) WRAPPER CAutomobile* CAutomobile::ctor(int, uint8) { EAXJMP(0x52C6B0); } WRAPPER void CAutomobile::SetDoorDamage(int32, uint32, bool) { EAXJMP(0x530200); } +WRAPPER void CAutomobile::SetPanelDamage(int32, uint32, bool) { EAXJMP(0x5301A0); } +WRAPPER void CAutomobile::SetBumperDamage(int32, uint32, bool) { EAXJMP(0x530120); } STARTPATCHES InjectHook(0x52D170, &CAutomobile::dtor, PATCH_JUMP); diff --git a/src/entities/Automobile.h b/src/entities/Automobile.h index 246943a7..64e411ce 100644 --- a/src/entities/Automobile.h +++ b/src/entities/Automobile.h @@ -25,6 +25,8 @@ public: CAutomobile(int, uint8); CAutomobile* ctor(int, uint8); void SetDoorDamage(int32, uint32, bool); /* TODO: eDoors */ + void SetPanelDamage(int32, uint32, bool); /* TODO: ePanels */ + void SetBumperDamage(int32, uint32, bool); /* TODO: ePanels */ void dtor() { this->CAutomobile::~CAutomobile(); } }; static_assert(sizeof(CAutomobile) == 0x5A8, "CAutomobile: error"); |