diff options
-rw-r--r-- | src/FileLoader.cpp | 2 | ||||
-rw-r--r-- | src/control/HandlingMgr.cpp (renamed from src/control/HandlingDataMgr.cpp) | 2 | ||||
-rw-r--r-- | src/control/HandlingMgr.h (renamed from src/control/HandlingDataMgr.h) | 1 | ||||
-rw-r--r-- | src/control/Transmission.cpp | 2 | ||||
-rw-r--r-- | src/modelinfo/VehicleModelInfo.cpp | 48 | ||||
-rw-r--r-- | src/modelinfo/VehicleModelInfo.h | 2 | ||||
-rw-r--r-- | src/render/VisibilityPlugins.cpp | 2 |
7 files changed, 48 insertions, 11 deletions
diff --git a/src/FileLoader.cpp b/src/FileLoader.cpp index 53449d9b..1295177d 100644 --- a/src/FileLoader.cpp +++ b/src/FileLoader.cpp @@ -7,7 +7,7 @@ #include "TempColModels.h" #include "VisibilityPlugins.h" #include "FileMgr.h" -#include "HandlingDataMgr.h" +#include "HandlingMgr.h" #include "CarCtrl.h" #include "PedType.h" #include "PedStats.h" diff --git a/src/control/HandlingDataMgr.cpp b/src/control/HandlingMgr.cpp index 48000b48..47d0564c 100644 --- a/src/control/HandlingDataMgr.cpp +++ b/src/control/HandlingMgr.cpp @@ -2,7 +2,7 @@ #include "patcher.h" #include "main.h" #include "FileMgr.h" -#include "HandlingDatamgr.h" +#include "HandlingMgr.h" cHandlingDataMgr &mod_HandlingManager = *(cHandlingDataMgr*)0x728060; diff --git a/src/control/HandlingDataMgr.h b/src/control/HandlingMgr.h index 216aa7e8..958e2351 100644 --- a/src/control/HandlingDataMgr.h +++ b/src/control/HandlingMgr.h @@ -133,6 +133,7 @@ public: int FindExactWord(const char *word, const char *words, int wordLen, int numWords); void ConvertDataToGameUnits(tHandlingData *handling); int32 GetHandlingId(const char *name); + tHandlingData *GetHandlingData(eHandlingId id) { return &HandlingData[id]; } }; VALIDATE_SIZE(cHandlingDataMgr, 0x3030); extern cHandlingDataMgr &mod_HandlingManager; diff --git a/src/control/Transmission.cpp b/src/control/Transmission.cpp index aaa24ced..2be25cbb 100644 --- a/src/control/Transmission.cpp +++ b/src/control/Transmission.cpp @@ -24,7 +24,7 @@ cTransmission::InitGearRatios(void) pGearRatio1->fShiftUpVelocity = fMaxVelocity; }else{ Gears[i+1].fShiftDownVelocity = velocityDiff*0.42f + pGearRatio0->fMaxVelocity; - pGearRatio1->fShiftUpVelocity = velocityDiff/0.6667f + pGearRatio0->fMaxVelocity; + pGearRatio1->fShiftUpVelocity = velocityDiff*0.6667f + pGearRatio0->fMaxVelocity; } } diff --git a/src/modelinfo/VehicleModelInfo.cpp b/src/modelinfo/VehicleModelInfo.cpp index 5e3a77fe..36a6f301 100644 --- a/src/modelinfo/VehicleModelInfo.cpp +++ b/src/modelinfo/VehicleModelInfo.cpp @@ -6,6 +6,7 @@ #include "NodeName.h" #include "TxdStore.h" #include "Weather.h" +#include "HandlingMgr.h" #include "VisibilityPlugins.h" #include "FileMgr.h" #include "World.h" @@ -22,9 +23,6 @@ RwTexture **CVehicleModelInfo::ms_colourTextureTable = (RwTexture**)0x711C40; RwTexture *&gpWhiteTexture = *(RwTexture**)0x64C4F8; RwFrame *&pMatFxIdentityFrame = *(RwFrame**)0x64C510; -// TODO This depends on handling -WRAPPER void CVehicleModelInfo::SetVehicleComponentFlags(RwFrame *frame, uint32 flags) { EAXJMP(0x5203C0); } - enum { CAR_WHEEL_RF = 1, CAR_WHEEL_RM = 2, @@ -435,11 +433,13 @@ CVehicleModelInfo::SetAtomicRenderCallbacks(void) } } -RpAtomic* -CVehicleModelInfo::SetAtomicFlagCB(RpAtomic *atomic, void *data) +RwObject* +CVehicleModelInfo::SetAtomicFlagCB(RwObject *object, void *data) { + RpAtomic *atomic = (RpAtomic*)object; + assert(RwObjectGetType(object) == rpATOMIC); CVisibilityPlugins::SetAtomicFlag(atomic, (int)data); - return atomic; + return object; } RpAtomic* @@ -550,6 +550,41 @@ CVehicleModelInfo::PreprocessHierarchy(void) } } +void +CVehicleModelInfo::SetVehicleComponentFlags(RwFrame *frame, uint32 flags) +{ + tHandlingData *handling; + + handling = mod_HandlingManager.GetHandlingData((eHandlingId)m_handlingId); + +#define SETFLAGS(f) RwFrameForAllObjects(frame, SetAtomicFlagCB, (void*)(f)) + + if(flags & VEHICLE_FLAG_WINDSCREEN){ + if(this == CModelInfo::GetModelInfo(MI_RHINO)) + return; + SETFLAGS(ATOMIC_FLAG_WINDSCREEN); + } + + if(flags & VEHICLE_FLAG_ANGLECULL) + SETFLAGS(ATOMIC_FLAG_ANGLECULL); + + if(flags & VEHICLE_FLAG_FRONT) + SETFLAGS(ATOMIC_FLAG_FRONT); + else if(flags & VEHICLE_FLAG_REAR && (handling->Flags & HANDLING_IS_VAN || (flags & (VEHICLE_FLAG_LEFT|VEHICLE_FLAG_RIGHT)) == 0)) + SETFLAGS(ATOMIC_FLAG_REAR); + if(flags & VEHICLE_FLAG_LEFT) + SETFLAGS(ATOMIC_FLAG_LEFT); + if(flags & VEHICLE_FLAG_RIGHT) + SETFLAGS(ATOMIC_FLAG_RIGHT); + + if(flags & VEHICLE_FLAG_REARDOOR) + SETFLAGS(ATOMIC_FLAG_REARDOOR); + else if(flags & VEHICLE_FLAG_FRONTDOOR) + SETFLAGS(ATOMIC_FLAG_FRONTDOOR); + + if(flags & VEHICLE_FLAG_DRAWLAST) + SETFLAGS(ATOMIC_FLAG_DRAWLAST); +} #define COMPRULE_RULE(comprule) (((comprule) >> 12) & 0xF) #define COMPRULE_COMPS(comprule) ((comprule) & 0xFFF) @@ -1110,6 +1145,7 @@ STARTPATCHES InjectHook(0x520360, &CVehicleModelInfo::ClearAtomicFlagCB, PATCH_JUMP); InjectHook(0x5204D0, &CVehicleModelInfo::PreprocessHierarchy, PATCH_JUMP); + InjectHook(0x5203C0, &CVehicleModelInfo::SetVehicleComponentFlags, PATCH_JUMP); InjectHook(0x520840, &CVehicleModelInfo::GetWheelPosn, PATCH_JUMP); diff --git a/src/modelinfo/VehicleModelInfo.h b/src/modelinfo/VehicleModelInfo.h index 3f89414d..8068d359 100644 --- a/src/modelinfo/VehicleModelInfo.h +++ b/src/modelinfo/VehicleModelInfo.h @@ -99,7 +99,7 @@ public: static RpAtomic *SetAtomicRendererCB_Heli(RpAtomic *atomic, void *data); void SetAtomicRenderCallbacks(void); - static RpAtomic *SetAtomicFlagCB(RpAtomic *atomic, void *data); + static RwObject *SetAtomicFlagCB(RwObject *object, void *data); static RpAtomic *ClearAtomicFlagCB(RpAtomic *atomic, void *data); void SetVehicleComponentFlags(RwFrame *frame, uint32 flags); void PreprocessHierarchy(void); diff --git a/src/render/VisibilityPlugins.cpp b/src/render/VisibilityPlugins.cpp index 316a397c..ca3a0195 100644 --- a/src/render/VisibilityPlugins.cpp +++ b/src/render/VisibilityPlugins.cpp @@ -572,7 +572,7 @@ CVisibilityPlugins::GetDotProductWithCameraVector(RwMatrix *atomicMat, RwMatrix if(flags & (ATOMIC_FLAG_FRONT | ATOMIC_FLAG_REAR)) dot = RwV3dDotProduct(&dist, RwMatrixGetUp(clumpMat)); // left/right facing - else if(flags & (ATOMIC_FLAG_LEFT & ATOMIC_FLAG_RIGHT)) + else if(flags & (ATOMIC_FLAG_LEFT | ATOMIC_FLAG_RIGHT)) dot = RwV3dDotProduct(&dist, RwMatrixGetRight(clumpMat)); else dot = 0.0f; |