1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-11-18 06:37:46 +00:00
re3/src/modelinfo/ModelInfo.cpp

261 lines
7 KiB
C++
Raw Normal View History

2019-05-15 14:52:37 +00:00
#include "common.h"
2020-04-17 13:31:11 +00:00
#include "General.h"
2019-06-17 08:30:02 +00:00
#include "TempColModels.h"
#include "ModelIndices.h"
2019-05-15 14:52:37 +00:00
#include "ModelInfo.h"
// --MIAMI: file done
2020-04-17 05:54:14 +00:00
CBaseModelInfo *CModelInfo::ms_modelInfoPtrs[MODELINFOSIZE];
2019-05-15 14:52:37 +00:00
CStore<CSimpleModelInfo, SIMPLEMODELSIZE> CModelInfo::ms_simpleModelStore;
CStore<CTimeModelInfo, TIMEMODELSIZE> CModelInfo::ms_timeModelStore;
2020-05-10 08:04:20 +00:00
CStore<CWeaponModelInfo, WEAPONMODELSIZE> CModelInfo::ms_weaponModelStore;
2019-05-15 14:52:37 +00:00
CStore<CClumpModelInfo, CLUMPMODELSIZE> CModelInfo::ms_clumpModelStore;
CStore<CPedModelInfo, PEDMODELSIZE> CModelInfo::ms_pedModelStore;
CStore<CVehicleModelInfo, VEHICLEMODELSIZE> CModelInfo::ms_vehicleModelStore;
CStore<C2dEffect, TWODFXSIZE> CModelInfo::ms_2dEffectStore;
void
CModelInfo::Initialise(void)
{
int i;
2019-06-17 08:30:02 +00:00
CSimpleModelInfo *m;
debug("sizeof SimpleModelStore %d\n", sizeof(ms_simpleModelStore));
debug("sizeof TimeModelStore %d\n", sizeof(ms_timeModelStore));
debug("sizeof WeaponModelStore %d\n", sizeof(ms_weaponModelStore));
debug("sizeof ClumpModelStore %d\n", sizeof(ms_clumpModelStore));
debug("sizeof VehicleModelStore %d\n", sizeof(ms_vehicleModelStore));
debug("sizeof PedModelStore %d\n", sizeof(ms_pedModelStore));
debug("sizeof 2deffectsModelStore %d\n", sizeof(ms_2dEffectStore));
2019-05-15 14:52:37 +00:00
for(i = 0; i < MODELINFOSIZE; i++)
ms_modelInfoPtrs[i] = nil;
ms_2dEffectStore.clear();
ms_simpleModelStore.clear();
ms_timeModelStore.clear();
2020-05-10 08:04:20 +00:00
ms_weaponModelStore.clear();
2019-05-15 14:52:37 +00:00
ms_clumpModelStore.clear();
ms_pedModelStore.clear();
ms_vehicleModelStore.clear();
2019-06-17 08:30:02 +00:00
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;
2019-05-15 14:52:37 +00:00
}
void
2019-06-17 08:30:02 +00:00
CModelInfo::ShutDown(void)
2019-05-15 14:52:37 +00:00
{
int i;
for(i = 0; i < ms_simpleModelStore.allocPtr; i++)
ms_simpleModelStore.store[i].Shutdown();
for(i = 0; i < ms_timeModelStore.allocPtr; i++)
ms_timeModelStore.store[i].Shutdown();
2020-05-10 08:04:20 +00:00
for(i = 0; i < ms_weaponModelStore.allocPtr; i++)
ms_weaponModelStore.store[i].Shutdown();
2019-05-15 14:52:37 +00:00
for(i = 0; i < ms_clumpModelStore.allocPtr; i++)
ms_clumpModelStore.store[i].Shutdown();
for(i = 0; i < ms_vehicleModelStore.allocPtr; i++)
ms_vehicleModelStore.store[i].Shutdown();
for(i = 0; i < ms_pedModelStore.allocPtr; i++)
ms_pedModelStore.store[i].Shutdown();
2019-06-17 08:30:02 +00:00
for(i = 0; i < ms_2dEffectStore.allocPtr; i++)
ms_2dEffectStore.store[i].Shutdown();
ms_2dEffectStore.clear();
ms_simpleModelStore.clear();
ms_timeModelStore.clear();
2020-05-10 08:04:20 +00:00
ms_weaponModelStore.clear();
ms_pedModelStore.clear();
ms_clumpModelStore.clear();
ms_vehicleModelStore.clear();
2019-05-15 14:52:37 +00:00
}
CSimpleModelInfo*
CModelInfo::AddSimpleModel(int id)
{
CSimpleModelInfo *modelinfo;
modelinfo = CModelInfo::ms_simpleModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
}
CTimeModelInfo*
CModelInfo::AddTimeModel(int id)
{
CTimeModelInfo *modelinfo;
modelinfo = CModelInfo::ms_timeModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
}
2020-05-10 08:04:20 +00:00
CWeaponModelInfo*
CModelInfo::AddWeaponModel(int id)
{
CWeaponModelInfo *modelinfo;
modelinfo = CModelInfo::ms_weaponModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->Init();
return modelinfo;
}
2019-05-15 14:52:37 +00:00
CClumpModelInfo*
CModelInfo::AddClumpModel(int id)
{
CClumpModelInfo *modelinfo;
modelinfo = CModelInfo::ms_clumpModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
return modelinfo;
}
CPedModelInfo*
CModelInfo::AddPedModel(int id)
{
CPedModelInfo *modelinfo;
modelinfo = CModelInfo::ms_pedModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
return modelinfo;
}
CVehicleModelInfo*
CModelInfo::AddVehicleModel(int id)
{
CVehicleModelInfo *modelinfo;
modelinfo = CModelInfo::ms_vehicleModelStore.alloc();
CModelInfo::ms_modelInfoPtrs[id] = modelinfo;
modelinfo->m_clump = nil;
modelinfo->m_vehicleType = -1;
modelinfo->m_wheelId = -1;
modelinfo->m_materials1[0] = nil;
modelinfo->m_materials2[0] = nil;
modelinfo->m_bikeSteerAngle = 999.99f;
return modelinfo;
}
CBaseModelInfo*
CModelInfo::GetModelInfo(const char *name, int *id)
{
CBaseModelInfo *modelinfo;
for(int i = 0; i < MODELINFOSIZE; i++){
modelinfo = CModelInfo::ms_modelInfoPtrs[i];
if(modelinfo && !CGeneral::faststricmp(modelinfo->GetName(), name)){
2019-05-15 14:52:37 +00:00
if(id)
*id = i;
return modelinfo;
}
}
return nil;
}
CBaseModelInfo*
CModelInfo::GetModelInfo(const char *name, int minIndex, int maxIndex)
{
if (minIndex > maxIndex)
return 0;
CBaseModelInfo *modelinfo;
for(int i = minIndex; i <= maxIndex; i++){
modelinfo = CModelInfo::ms_modelInfoPtrs[i];
if(modelinfo && !CGeneral::faststricmp(modelinfo->GetName(), name))
return modelinfo;
}
return nil;
}
2019-06-27 08:58:51 +00:00
bool
CModelInfo::IsBoatModel(int32 id)
{
2020-05-05 12:06:55 +00:00
return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
2019-06-27 08:58:51 +00:00
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT;
}
2019-07-14 09:49:03 +00:00
bool
CModelInfo::IsBikeModel(int32 id)
{
2020-05-05 12:06:55 +00:00
return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
2019-07-14 09:49:03 +00:00
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE;
}
2020-05-08 20:29:43 +00:00
bool
CModelInfo::IsCarModel(int32 id)
{
return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_CAR;
}
bool
CModelInfo::IsHeliModel(int32 id)
{
return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_HELI;
}
bool
CModelInfo::IsPlaneModel(int32 id)
{
return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_PLANE;
}
void
CModelInfo::ReInit2dEffects()
{
ms_2dEffectStore.clear();
for (int i = 0; i < MODELINFOSIZE; i++) {
if (ms_modelInfoPtrs[i])
ms_modelInfoPtrs[i]->Init2dEffects();
}
}