first part of CFileLoader

This commit is contained in:
aap
2019-06-17 10:30:02 +02:00
parent fcc6a8bc55
commit b5fba778c4
41 changed files with 1182 additions and 45 deletions

View File

@ -41,6 +41,9 @@ public:
virtual RwObject *GetRwObject(void) = 0;
bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; }
bool IsClump(void) { return m_type == MITYPE_CLUMP || m_type == MITYPE_PED || m_type == MITYPE_VEHICLE ||
m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck
}
char *GetName(void) { return m_name; }
void SetName(const char *name) { strncpy(m_name, name, 24); }
void SetColModel(CColModel *col, bool free = false){

View File

@ -320,9 +320,12 @@ enum
MI_CAR_PANEL,
MI_CAR_BONNET,
MI_CAR_BOOT,
MI_CAR_WEEL,
MI_CAR_WHEEL,
MI_BODYPARTA,
MI_BODYPARTB,
MI_AIRTRAIN_VLO = 198,
MI_LOPOLYGUY,
};
void InitModelIndices(void);

View File

@ -1,5 +1,7 @@
#include "common.h"
#include "patcher.h"
#include "TempColModels.h"
#include "ModelIndices.h"
#include "ModelInfo.h"
CBaseModelInfo **CModelInfo::ms_modelInfoPtrs = (CBaseModelInfo**)0x83D408;
@ -18,6 +20,8 @@ void
CModelInfo::Initialise(void)
{
int i;
CSimpleModelInfo *m;
for(i = 0; i < MODELINFOSIZE; i++)
ms_modelInfoPtrs[i] = nil;
ms_2dEffectStore.clear();
@ -26,10 +30,58 @@ CModelInfo::Initialise(void)
ms_clumpModelStore.clear();
ms_pedModelStore.clear();
ms_vehicleModelStore.clear();
m = AddSimpleModel(MI_CAR_DOOR);
m->SetColModel(&CTempColModels::ms_colModelDoor1);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
m = AddSimpleModel(MI_CAR_BUMPER);
m->SetColModel(&CTempColModels::ms_colModelBumper1);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
m = AddSimpleModel(MI_CAR_PANEL);
m->SetColModel(&CTempColModels::ms_colModelPanel1);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
m = AddSimpleModel(MI_CAR_BONNET);
m->SetColModel(&CTempColModels::ms_colModelBonnet1);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
m = AddSimpleModel(MI_CAR_BOOT);
m->SetColModel(&CTempColModels::ms_colModelBoot1);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
m = AddSimpleModel(MI_CAR_WHEEL);
m->SetColModel(&CTempColModels::ms_colModelWheel1);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
m = AddSimpleModel(MI_BODYPARTA);
m->SetColModel(&CTempColModels::ms_colModelBodyPart1);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
m = AddSimpleModel(MI_BODYPARTB);
m->SetColModel(&CTempColModels::ms_colModelBodyPart2);
m->SetTexDictionary("generic");
m->SetNumAtomics(1);
m->m_lodDistances[0] = 80.0f;
}
void
CModelInfo::Shutdown(void)
CModelInfo::ShutDown(void)
{
int i;
for(i = 0; i < ms_simpleModelStore.allocPtr; i++)
@ -42,6 +94,8 @@ CModelInfo::Shutdown(void)
ms_pedModelStore.store[i].Shutdown();
for(i = 0; i < ms_vehicleModelStore.allocPtr; i++)
ms_vehicleModelStore.store[i].Shutdown();
for(i = 0; i < ms_2dEffectStore.allocPtr; i++)
ms_2dEffectStore.store[i].Shutdown();
}
CSimpleModelInfo*
@ -115,10 +169,12 @@ CModelInfo::GetModelInfo(const char *name, int *id)
}
STARTPATCHES
// InjectHook(0x50B920, CModelInfo::AddSimpleModel, PATCH_JUMP);
// InjectHook(0x50B9C0, CModelInfo::AddTimeModel, PATCH_JUMP);
// InjectHook(0x50BA10, CModelInfo::AddClumpModel, PATCH_JUMP);
// InjectHook(0x50BAD0, CModelInfo::AddPedModel, PATCH_JUMP);
// InjectHook(0x50BA60, CModelInfo::AddPedModel, PATCH_JUMP);
InjectHook(0x50B310, CModelInfo::Initialise, PATCH_JUMP);
InjectHook(0x50B5B0, CModelInfo::ShutDown, PATCH_JUMP);
InjectHook(0x50B920, CModelInfo::AddSimpleModel, PATCH_JUMP);
InjectHook(0x50B9C0, CModelInfo::AddTimeModel, PATCH_JUMP);
InjectHook(0x50BA10, CModelInfo::AddClumpModel, PATCH_JUMP);
InjectHook(0x50BAD0, CModelInfo::AddPedModel, PATCH_JUMP);
InjectHook(0x50BA60, CModelInfo::AddVehicleModel, PATCH_JUMP);
InjectHook(0x50B860, (CBaseModelInfo *(*)(const char*, int*))CModelInfo::GetModelInfo, PATCH_JUMP);
ENDPATCHES

View File

@ -20,7 +20,7 @@ class CModelInfo
public:
static void Initialise(void);
static void Shutdown(void);
static void ShutDown(void);
static CSimpleModelInfo *AddSimpleModel(int id);
static CTimeModelInfo *AddTimeModel(int id);
@ -28,6 +28,8 @@ public:
static CPedModelInfo *AddPedModel(int id);
static CVehicleModelInfo *AddVehicleModel(int id);
static CStore<C2dEffect, TWODFXSIZE> &Get2dEffectStore(void) { return ms_2dEffectStore; }
static CBaseModelInfo *GetModelInfo(const char *name, int *id);
static CBaseModelInfo *GetModelInfo(int id){
return ms_modelInfoPtrs[id];

View File

@ -21,7 +21,7 @@ enum PedNode {
class CPedModelInfo : public CClumpModelInfo
{
public:
void *m_animGroup; // TODO
int32 m_animGroup;
int32 m_pedType;
int32 m_pedStatType;
uint32 m_carsCanDrive;

View File

@ -53,7 +53,7 @@ CSimpleModelInfo::Init(void)
m_atomics[1] = nil;
m_atomics[2] = nil;
m_numAtomics = 0;
m_furthest = 0;
m_firstDamaged = 0;
m_normalCull = 0;
m_isDamaged = 0;
m_isBigBuilding = 0;
@ -103,11 +103,10 @@ float
CSimpleModelInfo::GetLargestLodDistance(void)
{
float d;
// TODO: what exactly is going on here?
if(m_furthest != 0 && !m_isDamaged)
d = m_lodDistances[m_furthest-1];
else
if(m_firstDamaged == 0 || m_isDamaged)
d = m_lodDistances[m_numAtomics-1];
else
d = m_lodDistances[m_firstDamaged-1];
return d * TheCamera.LODDistMultiplier;
}
@ -116,9 +115,8 @@ CSimpleModelInfo::GetAtomicFromDistance(float dist)
{
int i;
i = 0;
// TODO: what exactly is going on here?
if(m_isDamaged)
i = m_furthest;
i = m_firstDamaged;
for(; i < m_numAtomics; i++)
if(dist < m_lodDistances[i] *TheCamera.LODDistMultiplier)
return m_atomics[i];

View File

@ -11,9 +11,9 @@ public:
float m_lodDistances[3];
uint8 m_numAtomics;
uint8 m_alpha;
uint16 m_furthest : 2; // 0: numAtomics-1 is furthest visible
// 1: atomic 0 is furthest
// 2: atomic 1 is furthest
uint16 m_firstDamaged : 2; // 0: no damage model
// 1: 1 and 2 are damage models
// 2: 2 is damage model
uint16 m_normalCull : 1;
uint16 m_isDamaged : 1;
uint16 m_isBigBuilding : 1;

View File

@ -12,7 +12,9 @@ public:
int32 GetTimeOn(void) { return m_timeOn; }
int32 GetTimeOff(void) { return m_timeOff; }
void SetTimes(int32 on, int32 off) { m_timeOn = on; m_timeOff = off; }
int32 GetOtherTimeModel(void) { return m_otherTimeModelID; }
void SetOtherTimeModel(int32 other) { m_otherTimeModelID = other; }
CTimeModelInfo *FindOtherTimeModel(void);
};
static_assert(sizeof(CTimeModelInfo) == 0x58, "CTimeModelInfo: error");

View File

@ -35,6 +35,17 @@ enum {
NUM_VEHICLE_TYPES
};
enum {
VEHICLE_CLASS_POOR,
VEHICLE_CLASS_RICH,
VEHICLE_CLASS_EXECUTIVE,
VEHICLE_CLASS_WORKER,
VEHICLE_CLASS_SPECIAL,
VEHICLE_CLASS_BIG,
VEHICLE_CLASS_TAXI,
NUM_VEHICLE_CLASSES
};
class CVehicleModelInfo : public CClumpModelInfo
{
public: