- CGObject_C base, CEffect, CObjectEffect/CObjectEffectManager effect states - Unit, Player, Item/Container/Bag, Corpse, DynamicObject, GameObject and all GameObject type classes (vtables matched slot by slot), Movement, MovementShared, Missile, Vehicle/Passenger/Camera, combat log, caches - Client object manager (0x4D3100-0x4D7880) incl. SMSG_UPDATE_OBJECT, SMSG_COMPRESSED_UPDATE_OBJECT, SMSG_DESTROY_OBJECT; type ctors/PostInit - CGGameUI::CanPerformAction and the ready part of CGInputControl - Layouts named from descriptor fields and code; CM2Model 0x134 matrix, CClientObjCreate tail, CGUnit_C/CGPlayer_C sizes 0x1008/0x1958 - WOWGUID struct replaces the IDB's WGUID low/high pair and guid uint64_t; SmartGUID derives from it; member functions returning a guid keep uint64_t (MSVC returns class types from members via hidden pointer); structs with 4-aligned guids in 12340 use pack(4) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
181 lines
5.6 KiB
C++
181 lines
5.6 KiB
C++
#include "UnitVehicle_C.h"
|
|
#include "WoW/Source/Object/ObjectClient/Unit_C.h"
|
|
#include "WoW/Source/Object/ObjectClient/Vehicle_C.h"
|
|
#include "WoW/Source/Object/ObjectClient/VehiclePassenger_C.h"
|
|
#include "WoW/Source/DB/Rec/VehicleSeatRec.h"
|
|
#include "WoW/Source/ObjectMgrClient/ObjectMgrClient.h"
|
|
#include "WoW/Source/Object/ObjectClient/VehicleCamera_C.h"
|
|
#include "WoW/Source/DB/Rec/VehicleRec.h"
|
|
#include "WoW/Source/UIUtil/InputControl.h"
|
|
#include "Engine/Source/FrameScript/FrameScript.h"
|
|
|
|
// VERIFY: bc21d620 manual
|
|
// OFFSET: 0x0074C650
|
|
CGUnit_C* CGUnit_C::FindRootVehicle(CGUnit_C* stop) {
|
|
CGUnit_C* unit = this;
|
|
|
|
if (this == stop && this->m_vehicle && this->m_vehicle->m_vehicleRec) {
|
|
return this;
|
|
}
|
|
|
|
WOWGUID guid = { this->GetTransportGUID() };
|
|
uint32_t high = static_cast<uint32_t>(guid.m_guid >> 32);
|
|
|
|
if ((high & 0xF0F00000) == 0xF0500000 || (!(high & 0xF0000000) && ((high & 0xF07FFFFF) | static_cast<uint32_t>(guid.m_guid)))) {
|
|
unit = static_cast<CGUnit_C*>(ClntObjMgrObjectPtr(guid, TYPEMASK_UNIT, __FILE__, __LINE__));
|
|
|
|
if (!unit) {
|
|
return nullptr;
|
|
}
|
|
|
|
while (unit != stop) {
|
|
guid.m_guid = unit->GetTransportGUID();
|
|
high = static_cast<uint32_t>(guid.m_guid >> 32);
|
|
|
|
if ((high & 0xF0F00000) != 0xF0500000 && ((high & 0xF0000000) || !((high & 0xF07FFFFF) | static_cast<uint32_t>(guid.m_guid)))) {
|
|
break;
|
|
}
|
|
|
|
unit = static_cast<CGUnit_C*>(ClntObjMgrObjectPtr(guid, TYPEMASK_UNIT, __FILE__, __LINE__));
|
|
|
|
if (!unit) {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
return unit;
|
|
}
|
|
|
|
if (unit->m_vehicle && unit->m_vehicle->m_vehicleRec) {
|
|
return unit;
|
|
}
|
|
|
|
return nullptr;
|
|
}
|
|
|
|
// VERIFY: 26588931 manual
|
|
// OFFSET: 0x0074CC40
|
|
CGUnit_C* CGUnit_C::FindRootVehicleOfPassengerChain(CGUnit_C* stop) {
|
|
CGUnit_C* unit = this;
|
|
WOWGUID guid = this->m_vehiclePassenger ? this->m_vehiclePassenger->m_transitionVehicleGuid : WOWGUID();
|
|
|
|
if (!guid) {
|
|
if (!this->m_vehicle || !this->m_vehicle->m_vehicleRec) {
|
|
return nullptr;
|
|
}
|
|
|
|
return unit;
|
|
}
|
|
|
|
unit = static_cast<CGUnit_C*>(ClntObjMgrObjectPtr(guid, TYPEMASK_UNIT, __FILE__, __LINE__));
|
|
|
|
if (!unit) {
|
|
return nullptr;
|
|
}
|
|
|
|
while (unit != stop) {
|
|
guid = unit->m_vehiclePassenger ? unit->m_vehiclePassenger->m_transitionVehicleGuid : WOWGUID();
|
|
|
|
if (!guid) {
|
|
break;
|
|
}
|
|
|
|
unit = static_cast<CGUnit_C*>(ClntObjMgrObjectPtr(guid, TYPEMASK_UNIT, __FILE__, __LINE__));
|
|
|
|
if (!unit) {
|
|
return nullptr;
|
|
}
|
|
}
|
|
|
|
return unit;
|
|
}
|
|
|
|
// VERIFY: 9db634f7 manual
|
|
// OFFSET: 0x0074B900
|
|
bool CGUnit_C::IsVehiclePreventingTurning() const {
|
|
uint32_t high = static_cast<uint32_t>(this->m_movementData.m_transportGuid.m_guid >> 32);
|
|
uint32_t low = static_cast<uint32_t>(this->m_movementData.m_transportGuid.m_guid);
|
|
|
|
if ((high & 0xF0F00000) != 0xF0500000 && ((high & 0xF0000000) || !((high & 0xF07FFFFF) | low))) {
|
|
return false;
|
|
}
|
|
|
|
CGUnit_C* transport = static_cast<CGUnit_C*>(ClntObjMgrObjectPtr(WOWGUID{ static_cast<uint64_t>(high) << 32 | low }, TYPEMASK_UNIT, __FILE__, __LINE__));
|
|
|
|
if (!transport || !transport->m_vehicle) {
|
|
return false;
|
|
}
|
|
|
|
VehicleSeatRec* seat = transport->m_vehicle->GetVehicleSeatRec(static_cast<uint8_t>(this->m_movementData.m_transportSeat));
|
|
return seat && !(seat->m_flags & 0x400);
|
|
}
|
|
|
|
// VERIFY: 08c11781 manual
|
|
// OFFSET: 0x0074BA40
|
|
bool CGUnit_C::IsAlteredFormTransitionPreventingMovement() const {
|
|
if (!this->IsLocalClientControlled()) {
|
|
return false;
|
|
}
|
|
|
|
CVehiclePassenger_C* passenger = this->m_vehiclePassenger;
|
|
|
|
if (passenger && passenger->m_state && passenger->m_state != 3) {
|
|
return true;
|
|
}
|
|
|
|
if (passenger && (passenger->m_flags & 0x200)) {
|
|
return true;
|
|
}
|
|
|
|
CGUnit_C* charmer = static_cast<CGUnit_C*>(ClntObjMgrObjectPtr(this->m_unit->m_unitFieldCharmedby, TYPEMASK_UNIT, __FILE__, __LINE__));
|
|
|
|
if (charmer) {
|
|
CVehiclePassenger_C* charmerPassenger = charmer->m_vehiclePassenger;
|
|
|
|
if (!charmerPassenger || ((!charmerPassenger->m_state || charmerPassenger->m_state == 3) && !(charmerPassenger->m_flags & 0x200))) {
|
|
return charmer->IsInVehicle() && (charmerPassenger->m_flags & 0x8);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
if (!(this->m_unit->m_unitFieldFlags & 0x1000000) && this->m_obj->m_guid != ClntObjMgrGetActivePlayer()) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
// VERIFY: 97008da9 manual
|
|
// OFFSET: 0x0074C550
|
|
void CGUnit_C::ConvertVehicleCameraRelativeFacingToTransportRelativeFacing(float& facing) {
|
|
if (this->m_vehicleCamera) {
|
|
CGObject_C* relativeTo = ClntObjMgrObjectPtr(WOWGUID{ this->m_vehicleCamera->GetRelativeTo() }, TYPEMASK_OBJECT, __FILE__, __LINE__);
|
|
CVehicleCamera_C::ConvertFromRawToWorld(facing, relativeTo);
|
|
facing = this->m_movement->GetRawFacing(facing);
|
|
}
|
|
}
|
|
|
|
// VERIFY: 137b6764 manual
|
|
// OFFSET: 0x0074C5A0
|
|
void CGUnit_C::UpdateVehicleUISliders(CGUnit_C* unit, const VehicleRec* vehicleRec) {
|
|
int32_t enable = unit && !unit->IsAlteredFormTransitionPreventingMovement();
|
|
|
|
if (enable && vehicleRec && (vehicleRec->m_flags & 0x400)) {
|
|
FrameScript_SignalEvent(584, "%d", 1);
|
|
} else {
|
|
FrameScript_SignalEvent(584, nullptr);
|
|
}
|
|
|
|
if (enable && vehicleRec && (vehicleRec->m_flags & 0x800)) {
|
|
FrameScript_SignalEvent(586, "%d", 1);
|
|
} else {
|
|
FrameScript_SignalEvent(586, nullptr);
|
|
}
|
|
|
|
if (unit) {
|
|
CGInputControl::GetActive();
|
|
CGInputControl::SendUIVehicleAngleUpdate(unit->GetPitch());
|
|
}
|
|
}
|