1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 07:40:01 +00:00

Make CBaseModelInfo fields protected

This commit is contained in:
Sergeanur 2020-05-05 15:06:55 +03:00
parent e9b334d7bf
commit 4cc1bb92e7
14 changed files with 62 additions and 63 deletions

View file

@ -84,12 +84,11 @@ static int32 NextValidModelId(int32 mi, int32 step)
CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo; CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo;
if (!pInfo) if (!pInfo)
continue; continue;
if (pInfo->m_type == MITYPE_PED if (pInfo->GetModelType() == MITYPE_PED
#ifdef FIX_BUGS #ifdef FIX_BUGS
&& !(i >= MI_SPECIAL01 && i <= MI_SPECIAL04) && !(i >= MI_SPECIAL01 && i <= MI_SPECIAL04)
#endif #endif
|| || pInfo->GetModelType() == MITYPE_VEHICLE &&
pInfo->m_type == MITYPE_VEHICLE &&
#ifdef FIX_BUGS #ifdef FIX_BUGS
(pVehicleInfo->m_vehicleType == VEHICLE_TYPE_CAR || pVehicleInfo->m_vehicleType == VEHICLE_TYPE_BOAT)) (pVehicleInfo->m_vehicleType == VEHICLE_TYPE_CAR || pVehicleInfo->m_vehicleType == VEHICLE_TYPE_BOAT))
#else // && and || priority failure it seems, also crashes on special models #else // && and || priority failure it seems, also crashes on special models

View file

@ -8074,7 +8074,7 @@ int8 CRunningScript::ProcessCommands900To999(int32 command)
continue; continue;
// desperatly want to believe this was inlined :| // desperatly want to believe this was inlined :|
CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model); CBaseModelInfo* pInfo = CModelInfo::GetModelInfo(model);
assert(pInfo->m_type == MITYPE_VEHICLE); assert(pInfo->GetModelType() == MITYPE_VEHICLE);
CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo; CVehicleModelInfo* pVehicleInfo = (CVehicleModelInfo*)pInfo;
if (pVehicleInfo->m_vehicleType != VEHICLE_TYPE_CAR) { if (pVehicleInfo->m_vehicleType != VEHICLE_TYPE_CAR) {
switch (model) { switch (model) {

View file

@ -148,7 +148,7 @@ LastPedModelId(int modelId)
CBaseModelInfo *model; CBaseModelInfo *model;
for (int i = modelId; i >= 0; i--) { for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i); model = CModelInfo::GetModelInfo(i);
if (model->m_type == MITYPE_PED) if (model->GetModelType() == MITYPE_PED)
return i; return i;
} }
return modelId; return modelId;
@ -160,7 +160,7 @@ LastVehicleModelId(int modelId)
CBaseModelInfo* model; CBaseModelInfo* model;
for (int i = modelId; i >= 0; i--) { for (int i = modelId; i >= 0; i--) {
model = CModelInfo::GetModelInfo(i); model = CModelInfo::GetModelInfo(i);
if (model->m_type == MITYPE_VEHICLE) if (model->GetModelType() == MITYPE_VEHICLE)
return i; return i;
} }
return modelId; return modelId;
@ -222,7 +222,7 @@ CAnimViewer::Update(void)
CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId); CBaseModelInfo *modelInfo = CModelInfo::GetModelInfo(modelId);
CEntity *newEntity = nil; CEntity *newEntity = nil;
if (modelInfo->m_type == MITYPE_PED) { if (modelInfo->GetModelType() == MITYPE_PED) {
int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup; int animGroup = ((CPedModelInfo*)modelInfo)->m_animGroup;
if (animId > ANIM_IDLE_STANCE) if (animId > ANIM_IDLE_STANCE)
@ -257,7 +257,7 @@ CAnimViewer::Update(void)
if (!pTarget) { if (!pTarget) {
if (modelInfo->m_type == MITYPE_VEHICLE) { if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo; CVehicleModelInfo* veh = (CVehicleModelInfo*)modelInfo;
if (veh->m_vehicleType != VEHICLE_TYPE_CAR) { if (veh->m_vehicleType != VEHICLE_TYPE_CAR) {
@ -281,7 +281,7 @@ CAnimViewer::Update(void)
newEntity->SetStatus(STATUS_ABANDONED); newEntity->SetStatus(STATUS_ABANDONED);
} }
newEntity->bIsStuck = true; newEntity->bIsStuck = true;
} else if (modelInfo->m_type == MITYPE_PED) { } else if (modelInfo->GetModelType() == MITYPE_PED) {
pTarget = newEntity = new CPed(PEDTYPE_CIVMALE); pTarget = newEntity = new CPed(PEDTYPE_CIVMALE);
newEntity->SetModelIndex(modelId); newEntity->SetModelIndex(modelId);
} else { } else {
@ -301,9 +301,9 @@ CAnimViewer::Update(void)
} }
pTarget->GetMatrix().GetPosition().z = 0.0f; pTarget->GetMatrix().GetPosition().z = 0.0f;
if (modelInfo->m_type != MITYPE_PED) { if (modelInfo->GetModelType() != MITYPE_PED) {
if (modelInfo->m_type == MITYPE_VEHICLE) { if (modelInfo->GetModelType() == MITYPE_VEHICLE) {
if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) { if (pad->NewState.LeftShoulder1 && !pad->OldState.LeftShoulder1) {
nextModelId = LastPedModelId(modelId); nextModelId = LastPedModelId(modelId);

View file

@ -384,7 +384,7 @@ CFileLoader::LoadClumpFile(RwStream *stream, uint32 id)
return false; return false;
mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id); mi = (CClumpModelInfo*)CModelInfo::GetModelInfo(id);
mi->SetClump(clump); mi->SetClump(clump);
if(mi->m_type == MITYPE_PED && id != 0 && RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)){ if (mi->GetModelType() == MITYPE_PED && id != 0 && RwStreamFindChunk(stream, rwID_CLUMP, nil, nil)) {
// Read LOD ped // Read LOD ped
clump = RpClumpStreamRead(stream); clump = RpClumpStreamRead(stream);
if(clump){ if(clump){
@ -1325,7 +1325,7 @@ CFileLoader::ReloadObject(const char *line)
#ifdef FIX_BUGS #ifdef FIX_BUGS
mi && mi &&
#endif #endif
mi->m_type == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) { mi->GetModelType() == MITYPE_SIMPLE && !strcmp(mi->GetName(), model) && mi->m_numAtomics == numObjs) {
mi->SetLodDistances(dist); mi->SetLodDistances(dist);
SetModelInfoFlags(mi, flags); SetModelInfoFlags(mi, flags);
} else { } else {

View file

@ -435,7 +435,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(mi->IsSimple()){ if(mi->IsSimple()){
success = CFileLoader::LoadAtomicFile(stream, streamId); success = CFileLoader::LoadAtomicFile(stream, streamId);
}else if(mi->m_type == MITYPE_VEHICLE){ } else if (mi->GetModelType() == MITYPE_VEHICLE) {
// load vehicles in two parts // load vehicles in two parts
CModelInfo::GetModelInfo(streamId)->AddRef(); CModelInfo::GetModelInfo(streamId)->AddRef();
success = CFileLoader::StartLoadClumpFile(stream, streamId); success = CFileLoader::StartLoadClumpFile(stream, streamId);
@ -499,7 +499,7 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
if(streamId < STREAM_OFFSET_TXD){ if(streamId < STREAM_OFFSET_TXD){
// Model // Model
// Vehicles and Peds not in loaded list // Vehicles and Peds not in loaded list
if(mi->m_type != MITYPE_VEHICLE && mi->m_type != MITYPE_PED){ if (mi->GetModelType() != MITYPE_VEHICLE && mi->GetModelType() != MITYPE_PED) {
CSimpleModelInfo *smi = (CSimpleModelInfo*)mi; CSimpleModelInfo *smi = (CSimpleModelInfo*)mi;
// Set fading for some objects // Set fading for some objects
@ -858,7 +858,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex()); mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){ if(!e->bImBeingRendered){
e->DeleteRwObject(); e->DeleteRwObject();
if(mi->m_refCount == 0) if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
} }
} }
@ -871,7 +871,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex()); mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){ if(!e->bImBeingRendered){
e->DeleteRwObject(); e->DeleteRwObject();
if(mi->m_refCount == 0) if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
} }
} }
@ -884,7 +884,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex()); mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered && ((CObject*)e)->ObjectCreatedBy == GAME_OBJECT){ if(!e->bImBeingRendered && ((CObject*)e)->ObjectCreatedBy == GAME_OBJECT){
e->DeleteRwObject(); e->DeleteRwObject();
if(mi->m_refCount == 0) if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
} }
} }
@ -897,7 +897,7 @@ CStreaming::RemoveBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex()); mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){ if(!e->bImBeingRendered){
e->DeleteRwObject(); e->DeleteRwObject();
if(mi->m_refCount == 0) if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
} }
} }
@ -972,7 +972,7 @@ CStreaming::RemoveBigBuildings(eLevelName level)
mi = CModelInfo::GetModelInfo(e->GetModelIndex()); mi = CModelInfo::GetModelInfo(e->GetModelIndex());
if(!e->bImBeingRendered){ if(!e->bImBeingRendered){
e->DeleteRwObject(); e->DeleteRwObject();
if(mi->m_refCount == 0) if (mi->GetNumRefs() == 0)
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
} }
} }
@ -990,8 +990,7 @@ CStreaming::RemoveLoadedVehicle(void)
ms_lastVehicleDeleted = 0; ms_lastVehicleDeleted = 0;
id = ms_vehiclesLoaded[ms_lastVehicleDeleted]; id = ms_vehiclesLoaded[ms_lastVehicleDeleted];
if(id != -1 && if(id != -1 &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 && (ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 && CModelInfo::GetModelInfo(id)->GetNumRefs() == 0 &&
CModelInfo::GetModelInfo(id)->m_refCount == 0 &&
ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED) ms_aInfoForModel[id].m_loadState == STREAMSTATE_LOADED)
goto found; goto found;
} }
@ -1012,7 +1011,7 @@ CStreaming::RemoveLeastUsedModel(void)
for(si = ms_endLoadedList.m_prev; si != &ms_startLoadedList; si = si->m_prev){ for(si = ms_endLoadedList.m_prev; si != &ms_startLoadedList; si = si->m_prev){
streamId = si - ms_aInfoForModel; streamId = si - ms_aInfoForModel;
if(streamId < STREAM_OFFSET_TXD){ if(streamId < STREAM_OFFSET_TXD){
if(CModelInfo::GetModelInfo(streamId)->m_refCount == 0){ if (CModelInfo::GetModelInfo(streamId)->GetNumRefs() == 0) {
RemoveModel(streamId); RemoveModel(streamId);
return true; return true;
} }
@ -1038,7 +1037,7 @@ CStreaming::RemoveAllUnusedModels(void)
for(i = NUM_DEFAULT_MODELS; i < MODELINFOSIZE; i++){ for(i = NUM_DEFAULT_MODELS; i < MODELINFOSIZE; i++){
if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED && if(ms_aInfoForModel[i].m_loadState == STREAMSTATE_LOADED &&
ms_aInfoForModel[i].m_flags & STREAMFLAGS_DONT_REMOVE && ms_aInfoForModel[i].m_flags & STREAMFLAGS_DONT_REMOVE &&
CModelInfo::GetModelInfo(i)->m_refCount == 0){ CModelInfo::GetModelInfo(i)->GetNumRefs() == 0) {
RemoveModel(i); RemoveModel(i);
ms_aInfoForModel[i].m_loadState = STREAMSTATE_NOTLOADED; ms_aInfoForModel[i].m_loadState = STREAMSTATE_NOTLOADED;
} }
@ -1129,8 +1128,7 @@ CStreaming::AddToLoadedVehiclesList(int32 modelId)
for(i = 0; i < MAXVEHICLESLOADED; i++){ for(i = 0; i < MAXVEHICLESLOADED; i++){
id = ms_vehiclesLoaded[ms_lastVehicleDeleted]; id = ms_vehiclesLoaded[ms_lastVehicleDeleted];
if(id != -1 && if(id != -1 &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 && (ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 && CModelInfo::GetModelInfo(id)->GetNumRefs() == 0)
CModelInfo::GetModelInfo(id)->m_refCount == 0)
goto found; goto found;
ms_lastVehicleDeleted++; ms_lastVehicleDeleted++;
if(ms_lastVehicleDeleted == MAXVEHICLESLOADED) if(ms_lastVehicleDeleted == MAXVEHICLESLOADED)
@ -1202,7 +1200,7 @@ void
CStreaming::SetModelIsDeletable(int32 id) CStreaming::SetModelIsDeletable(int32 id)
{ {
ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_DONT_REMOVE; ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_DONT_REMOVE;
if((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->m_type != MITYPE_VEHICLE) && if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_SCRIPTOWNED) == 0){ (ms_aInfoForModel[id].m_flags & STREAMFLAGS_SCRIPTOWNED) == 0){
if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED) if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED)
RemoveModel(id); RemoveModel(id);
@ -1221,7 +1219,7 @@ void
CStreaming::SetMissionDoesntRequireModel(int32 id) CStreaming::SetMissionDoesntRequireModel(int32 id)
{ {
ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_SCRIPTOWNED; ms_aInfoForModel[id].m_flags &= ~STREAMFLAGS_SCRIPTOWNED;
if((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->m_type != MITYPE_VEHICLE) && if ((id >= STREAM_OFFSET_TXD || CModelInfo::GetModelInfo(id)->GetModelType() != MITYPE_VEHICLE) &&
(ms_aInfoForModel[id].m_flags & STREAMFLAGS_DONT_REMOVE) == 0){ (ms_aInfoForModel[id].m_flags & STREAMFLAGS_DONT_REMOVE) == 0){
if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED) if(ms_aInfoForModel[id].m_loadState != STREAMSTATE_LOADED)
RemoveModel(id); RemoveModel(id);
@ -1599,8 +1597,8 @@ CStreaming::RequestModelStream(int32 ch)
// Can't load certain combinations of files together // Can't load certain combinations of files together
if(streamId < STREAM_OFFSET_TXD){ if(streamId < STREAM_OFFSET_TXD){
if(havePed && CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_PED || if (havePed && CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_PED ||
haveBigFile && CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_VEHICLE || haveBigFile && CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_VEHICLE ||
!TxdAvailable(CModelInfo::GetModelInfo(streamId)->GetTxdSlot())) !TxdAvailable(CModelInfo::GetModelInfo(streamId)->GetTxdSlot()))
break; break;
}else{ }else{
@ -1619,9 +1617,9 @@ CStreaming::RequestModelStream(int32 ch)
break; break;
} }
if(streamId < STREAM_OFFSET_TXD){ if(streamId < STREAM_OFFSET_TXD){
if(CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_PED) if (CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_PED)
havePed = 1; havePed = 1;
if(CModelInfo::GetModelInfo(streamId)->m_type == MITYPE_VEHICLE) if (CModelInfo::GetModelInfo(streamId)->GetModelType() == MITYPE_VEHICLE)
haveBigFile = 1; haveBigFile = 1;
}else{ }else{
if(size > 200) if(size > 200)
@ -1679,8 +1677,7 @@ CStreaming::ProcessLoadingChannel(int32 ch)
continue; continue;
cdsize = ms_aInfoForModel[id].GetCdSize(); cdsize = ms_aInfoForModel[id].GetCdSize();
if(id < STREAM_OFFSET_TXD && if(id < STREAM_OFFSET_TXD && CModelInfo::GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
CModelInfo::GetModelInfo(id)->m_type == MITYPE_VEHICLE &&
ms_numVehiclesLoaded >= desiredNumVehiclesLoaded && ms_numVehiclesLoaded >= desiredNumVehiclesLoaded &&
!RemoveLoadedVehicle() && !RemoveLoadedVehicle() &&
((ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 || GetAvailableVehicleSlot() == -1)){ ((ms_aInfoForModel[id].m_flags & STREAMFLAGS_NOT_IN_LIST) == 0 || GetAvailableVehicleSlot() == -1)){
@ -1953,7 +1950,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float
if(!e->bStreamingDontDelete && !e->bIsSubway && if(!e->bStreamingDontDelete && !e->bIsSubway &&
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){ (!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()); CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())){ if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) {
lodDistSq = sq(mi->GetLargestLodDistance()); lodDistSq = sq(mi->GetLargestLodDistance());
lodDistSq = Min(lodDistSq, sq(STREAM_DIST)); lodDistSq = Min(lodDistSq, sq(STREAM_DIST));
pos = CVector2D(e->GetPosition()); pos = CVector2D(e->GetPosition());
@ -1983,7 +1980,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list)
if(!e->bStreamingDontDelete && !e->bIsSubway && if(!e->bStreamingDontDelete && !e->bIsSubway &&
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){ (!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()); CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
if(mi->m_type != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff()))
if(CRenderer::IsEntityCullZoneVisible(e)) if(CRenderer::IsEntityCullZoneVisible(e))
RequestModel(e->GetModelIndex(), 0); RequestModel(e->GetModelIndex(), 0);
} }
@ -2349,7 +2346,7 @@ CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, int32 mem)
if(!e->bStreamingDontDelete && !e->bImBeingRendered && if(!e->bStreamingDontDelete && !e->bImBeingRendered &&
e->m_rwObject && ms_aInfoForModel[e->GetModelIndex()].m_next){ e->m_rwObject && ms_aInfoForModel[e->GetModelIndex()].m_next){
e->DeleteRwObject(); e->DeleteRwObject();
if(CModelInfo::GetModelInfo(e->GetModelIndex())->m_refCount == 0){ if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
if(ms_memoryUsed < mem) if(ms_memoryUsed < mem)
return true; return true;
@ -2370,7 +2367,7 @@ CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, int32 mem)
if(!e->bStreamingDontDelete && !e->bImBeingRendered && if(!e->bStreamingDontDelete && !e->bImBeingRendered &&
e->m_rwObject && !e->IsVisible() && ms_aInfoForModel[e->GetModelIndex()].m_next){ e->m_rwObject && !e->IsVisible() && ms_aInfoForModel[e->GetModelIndex()].m_next){
e->DeleteRwObject(); e->DeleteRwObject();
if(CModelInfo::GetModelInfo(e->GetModelIndex())->m_refCount == 0){ if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
if(ms_memoryUsed < mem) if(ms_memoryUsed < mem)
return true; return true;

View file

@ -12,7 +12,7 @@ CBuilding::ReplaceWithNewModel(int32 id)
{ {
DeleteRwObject(); DeleteRwObject();
if(CModelInfo::GetModelInfo(m_modelIndex)->m_refCount == 0) if (CModelInfo::GetModelInfo(m_modelIndex)->GetNumRefs() == 0)
CStreaming::RemoveModel(m_modelIndex); CStreaming::RemoveModel(m_modelIndex);
m_modelIndex = id; m_modelIndex = id;

View file

@ -452,7 +452,7 @@ CEntity::PreRender(void)
break; break;
} }
if(CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects != 0) if (CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects() != 0)
ProcessLightsForEntity(); ProcessLightsForEntity();
} }
@ -611,7 +611,7 @@ CEntity::AddSteamsFromGround(CVector *unused)
C2dEffect *effect; C2dEffect *effect;
CVector pos; CVector pos;
n = CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects; n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects();
for(i = 0; i < n; i++){ for(i = 0; i < n; i++){
effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i); effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i);
if(effect->type != EFFECT_PARTICLE) if(effect->type != EFFECT_PARTICLE)
@ -654,7 +654,7 @@ CEntity::ProcessLightsForEntity(void)
flashTimer2 = 0; flashTimer2 = 0;
flashTimer3 = 0; flashTimer3 = 0;
n = CModelInfo::GetModelInfo(GetModelIndex())->m_num2dEffects; n = CModelInfo::GetModelInfo(GetModelIndex())->GetNum2dEffects();
for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){ for(i = 0; i < n; i++, flashTimer1 += 0x80, flashTimer2 += 0x100, flashTimer3 += 0x200){
effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i); effect = CModelInfo::GetModelInfo(GetModelIndex())->Get2dEffect(i);

View file

@ -22,18 +22,17 @@ class C2dEffect;
class CBaseModelInfo class CBaseModelInfo
{ {
protected: protected:
// TODO?: make more things protected
char m_name[MAX_MODEL_NAME]; char m_name[MAX_MODEL_NAME];
CColModel *m_colModel; CColModel *m_colModel;
C2dEffect *m_twodEffects; C2dEffect *m_twodEffects;
int16 m_objectId; int16 m_objectId;
public:
uint16 m_refCount; uint16 m_refCount;
int16 m_txdSlot; int16 m_txdSlot;
ModeInfoType m_type; ModeInfoType m_type;
uint8 m_num2dEffects; uint8 m_num2dEffects;
bool m_freeCol; bool m_freeCol;
public:
CBaseModelInfo(ModeInfoType type); CBaseModelInfo(ModeInfoType type);
virtual ~CBaseModelInfo() {} virtual ~CBaseModelInfo() {}
virtual void Shutdown(void); virtual void Shutdown(void);
@ -42,6 +41,8 @@ public:
virtual RwObject *CreateInstance(void) = 0; virtual RwObject *CreateInstance(void) = 0;
virtual RwObject *GetRwObject(void) = 0; virtual RwObject *GetRwObject(void) = 0;
// one day it becomes virtual
ModeInfoType GetModelType() const { return m_type; }
bool IsSimple(void) { return m_type == MITYPE_SIMPLE || m_type == MITYPE_TIME; } 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 || 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 m_type == MITYPE_MLO || m_type == MITYPE_XTRACOMPS; // unused but what the heck
@ -64,6 +65,8 @@ public:
void Init2dEffects(void); void Init2dEffects(void);
void Add2dEffect(C2dEffect *fx); void Add2dEffect(C2dEffect *fx);
C2dEffect *Get2dEffect(int n); C2dEffect *Get2dEffect(int n);
uint8 GetNum2dEffects() const { return m_num2dEffects; }
uint16 GetNumRefs() const { return m_refCount; }
}; };
static_assert(sizeof(CBaseModelInfo) == 0x30, "CBaseModelInfo: error"); static_assert(sizeof(CBaseModelInfo) == 0x30, "CBaseModelInfo: error");

View file

@ -203,14 +203,14 @@ CModelInfo::GetModelInfo(const char *name, int *id)
bool bool
CModelInfo::IsBoatModel(int32 id) CModelInfo::IsBoatModel(int32 id)
{ {
return GetModelInfo(id)->m_type == MITYPE_VEHICLE && return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT; ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BOAT;
} }
bool bool
CModelInfo::IsBikeModel(int32 id) CModelInfo::IsBikeModel(int32 id)
{ {
return GetModelInfo(id)->m_type == MITYPE_VEHICLE && return GetModelInfo(id)->GetModelType() == MITYPE_VEHICLE &&
((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE; ((CVehicleModelInfo*)GetModelInfo(id))->m_vehicleType == VEHICLE_TYPE_BIKE;
} }

View file

@ -22,7 +22,7 @@ CTimeModelInfo::FindOtherTimeModel(void)
for(i = 0; i < MODELINFOSIZE; i++){ for(i = 0; i < MODELINFOSIZE; i++){
CBaseModelInfo *mi = CModelInfo::GetModelInfo(i); CBaseModelInfo *mi = CModelInfo::GetModelInfo(i);
if(mi && mi->m_type == MITYPE_TIME && if (mi && mi->GetModelType() == MITYPE_TIME &&
strncmp(name, mi->GetName(), 24) == 0){ strncmp(name, mi->GetName(), 24) == 0){
m_otherTimeModelID = i; m_otherTimeModelID = i;
return (CTimeModelInfo*)mi; return (CTimeModelInfo*)mi;

View file

@ -125,7 +125,7 @@ CObject::Render(void)
if(m_nRefModelIndex != -1 && ObjectCreatedBy == TEMP_OBJECT && bUseVehicleColours){ if(m_nRefModelIndex != -1 && ObjectCreatedBy == TEMP_OBJECT && bUseVehicleColours){
CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_nRefModelIndex); CVehicleModelInfo *mi = (CVehicleModelInfo*)CModelInfo::GetModelInfo(m_nRefModelIndex);
assert(mi->m_type == MITYPE_VEHICLE); assert(mi->GetModelType() == MITYPE_VEHICLE);
mi->SetVehicleColour(m_colour1, m_colour2); mi->SetVehicleColour(m_colour1, m_colour2);
} }

View file

@ -8870,8 +8870,8 @@ CPed::LookForInterestingNodes(void)
for (ptrNode = sector->m_lists[ENTITYLIST_VEHICLES].first; ptrNode && !found; ptrNode = ptrNode->next) { for (ptrNode = sector->m_lists[ENTITYLIST_VEHICLES].first; ptrNode && !found; ptrNode = ptrNode->next) {
CVehicle *veh = (CVehicle*)ptrNode->item; CVehicle *veh = (CVehicle*)ptrNode->item;
model = veh->GetModelInfo(); model = veh->GetModelInfo();
if (model->m_num2dEffects != 0) { if (model->GetNum2dEffects() != 0) {
for (int e = 0; e < model->m_num2dEffects; e++) { for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e); effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &veh->GetMatrix(); objMat = &veh->GetMatrix();
@ -8888,8 +8888,8 @@ CPed::LookForInterestingNodes(void)
for (ptrNode = sector->m_lists[ENTITYLIST_OBJECTS].first; ptrNode && !found; ptrNode = ptrNode->next) { for (ptrNode = sector->m_lists[ENTITYLIST_OBJECTS].first; ptrNode && !found; ptrNode = ptrNode->next) {
CObject *obj = (CObject*)ptrNode->item; CObject *obj = (CObject*)ptrNode->item;
model = CModelInfo::GetModelInfo(obj->GetModelIndex()); model = CModelInfo::GetModelInfo(obj->GetModelIndex());
if (model->m_num2dEffects != 0) { if (model->GetNum2dEffects() != 0) {
for (int e = 0; e < model->m_num2dEffects; e++) { for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e); effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &obj->GetMatrix(); objMat = &obj->GetMatrix();
@ -8906,8 +8906,8 @@ CPed::LookForInterestingNodes(void)
for (ptrNode = sector->m_lists[ENTITYLIST_BUILDINGS].first; ptrNode && !found; ptrNode = ptrNode->next) { for (ptrNode = sector->m_lists[ENTITYLIST_BUILDINGS].first; ptrNode && !found; ptrNode = ptrNode->next) {
CBuilding *building = (CBuilding*)ptrNode->item; CBuilding *building = (CBuilding*)ptrNode->item;
model = CModelInfo::GetModelInfo(building->GetModelIndex()); model = CModelInfo::GetModelInfo(building->GetModelIndex());
if (model->m_num2dEffects != 0) { if (model->GetNum2dEffects() != 0) {
for (int e = 0; e < model->m_num2dEffects; e++) { for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e); effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &building->GetMatrix(); objMat = &building->GetMatrix();
@ -8924,8 +8924,8 @@ CPed::LookForInterestingNodes(void)
for (ptrNode = sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first; ptrNode && !found; ptrNode = ptrNode->next) { for (ptrNode = sector->m_lists[ENTITYLIST_BUILDINGS_OVERLAP].first; ptrNode && !found; ptrNode = ptrNode->next) {
CBuilding *building = (CBuilding*)ptrNode->item; CBuilding *building = (CBuilding*)ptrNode->item;
model = CModelInfo::GetModelInfo(building->GetModelIndex()); model = CModelInfo::GetModelInfo(building->GetModelIndex());
if (model->m_num2dEffects != 0) { if (model->GetNum2dEffects() != 0) {
for (int e = 0; e < model->m_num2dEffects; e++) { for (int e = 0; e < model->GetNum2dEffects(); e++) {
effect = model->Get2dEffect(e); effect = model->Get2dEffect(e);
if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) { if (effect->type == EFFECT_ATTRACTOR && effect->attractor.probability >= randVal) {
objMat = &building->GetMatrix(); objMat = &building->GetMatrix();

View file

@ -334,7 +334,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
float dist; float dist;
bool request = true; bool request = true;
if(mi->m_type == MITYPE_TIME){ if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi; ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel(); other = ti->GetOtherTimeModel();
if(CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())){ if(CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())){
@ -350,7 +350,7 @@ CRenderer::SetupEntityVisibility(CEntity *ent)
request = false; request = false;
} }
}else{ }else{
if(mi->m_type != MITYPE_SIMPLE){ if (mi->GetModelType() != MITYPE_SIMPLE) {
if(FindPlayerVehicle() == ent && if(FindPlayerVehicle() == ent &&
TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){ TheCamera.Cams[TheCamera.ActiveCam].Mode == CCam::MODE_1STPERSON){
// Player's vehicle in first person mode // Player's vehicle in first person mode
@ -482,7 +482,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
CTimeModelInfo *ti; CTimeModelInfo *ti;
int32 other; int32 other;
if(mi->m_type == MITYPE_TIME){ if (mi->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)mi; ti = (CTimeModelInfo*)mi;
other = ti->GetOtherTimeModel(); other = ti->GetOtherTimeModel();
// Hide objects not in time range if possible // Hide objects not in time range if possible
@ -490,7 +490,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
if(!CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff())) if(!CClock::GetIsTimeInRange(ti->GetTimeOn(), ti->GetTimeOff()))
return 0; return 0;
// Draw like normal // Draw like normal
}else if(mi->m_type == MITYPE_VEHICLE) } else if (mi->GetModelType() == MITYPE_VEHICLE)
return ent->IsVisible(); return ent->IsVisible();
float dist = (ms_vecCameraPosition-ent->GetPosition()).Magnitude(); float dist = (ms_vecCameraPosition-ent->GetPosition()).Magnitude();
@ -507,7 +507,7 @@ CRenderer::SetupBigBuildingVisibility(CEntity *ent)
// But if it is a time object, we'd rather draw the wrong // But if it is a time object, we'd rather draw the wrong
// non-LOD than the right LOD. // non-LOD than the right LOD.
if(nonLOD->m_type == MITYPE_TIME){ if (nonLOD->GetModelType() == MITYPE_TIME) {
ti = (CTimeModelInfo*)nonLOD; ti = (CTimeModelInfo*)nonLOD;
other = ti->GetOtherTimeModel(); other = ti->GetOtherTimeModel();
if(other != -1 && CModelInfo::GetModelInfo(other)->GetRwObject()) if(other != -1 && CModelInfo::GetModelInfo(other)->GetRwObject())

View file

@ -718,7 +718,7 @@ CVisibilityPlugins::SetAtomicModelInfo(RpAtomic *atomic,
{ {
AtomicExt *ext = ATOMICEXT(atomic); AtomicExt *ext = ATOMICEXT(atomic);
ext->modelInfo = modelInfo; ext->modelInfo = modelInfo;
switch(modelInfo->m_type) switch (modelInfo->GetModelType())
case MITYPE_SIMPLE: case MITYPE_SIMPLE:
case MITYPE_TIME: case MITYPE_TIME:
if(modelInfo->m_normalCull) if(modelInfo->m_normalCull)
@ -828,7 +828,7 @@ CVisibilityPlugins::SetClumpModelInfo(RpClump *clump, CClumpModelInfo *modelInfo
SetFrameHierarchyId(RpClumpGetFrame(clump), (int32)modelInfo); SetFrameHierarchyId(RpClumpGetFrame(clump), (int32)modelInfo);
// Unused // Unused
switch(modelInfo->m_type){ switch (modelInfo->GetModelType()) {
// ignore MLO // ignore MLO
case MITYPE_VEHICLE: case MITYPE_VEHICLE:
vmi = (CVehicleModelInfo*)modelInfo; vmi = (CVehicleModelInfo*)modelInfo;