summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraap <aap@papnet.eu>2019-06-20 01:07:57 +0200
committeraap <aap@papnet.eu>2019-06-20 01:07:57 +0200
commitf4146d39a266b83cef8e81bc62bcc77032c3b13c (patch)
tree50526c6443c448dbf0a2effa24b4dd040a3ac5e1
parenttypo in visibility plugins (diff)
parentimplemented cHandlingDataMgr (diff)
downloadre3-f4146d39a266b83cef8e81bc62bcc77032c3b13c.tar
re3-f4146d39a266b83cef8e81bc62bcc77032c3b13c.tar.gz
re3-f4146d39a266b83cef8e81bc62bcc77032c3b13c.tar.bz2
re3-f4146d39a266b83cef8e81bc62bcc77032c3b13c.tar.lz
re3-f4146d39a266b83cef8e81bc62bcc77032c3b13c.tar.xz
re3-f4146d39a266b83cef8e81bc62bcc77032c3b13c.tar.zst
re3-f4146d39a266b83cef8e81bc62bcc77032c3b13c.zip
-rw-r--r--src/FileLoader.cpp2
-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/modelinfo/VehicleModelInfo.cpp48
-rw-r--r--src/modelinfo/VehicleModelInfo.h2
5 files changed, 46 insertions, 9 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/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);