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

CStreaming done, hopefully

This commit is contained in:
aap 2020-08-20 23:43:13 +02:00
parent 857cef776d
commit a6fe606ce6
9 changed files with 387 additions and 188 deletions

View file

@ -374,10 +374,10 @@ private:
static int32 GetNewUniqueScriptSphereIndex(int32 index); static int32 GetNewUniqueScriptSphereIndex(int32 index);
static void RemoveScriptSphere(int32 index); static void RemoveScriptSphere(int32 index);
static void RemoveScriptTextureDictionary(); static void RemoveScriptTextureDictionary();
public:
static void RemoveThisPed(CPed* pPed); static void RemoveThisPed(CPed* pPed);
#ifdef MISSION_SWITCHER #ifdef MISSION_SWITCHER
public:
static void SwitchToMission(int32 mission); static void SwitchToMission(int32 mission);
#endif #endif

View file

@ -616,10 +616,7 @@ void CGame::ShutDownForRestart(void)
CWorld::ClearForRestart(); CWorld::ClearForRestart();
CGameLogic::ClearShortCut(); CGameLogic::ClearShortCut();
CTimer::Shutdown(); CTimer::Shutdown();
CStreaming::FlushRequestList(); CStreaming::ReInit();
CStreaming::DeleteAllRwObjects();
CStreaming::RemoveAllUnusedModels();
CStreaming::ms_disableStreaming = false;
CRadar::RemoveRadarSections(); CRadar::RemoveRadarSections();
FrontEndMenuManager.UnloadTextures(); FrontEndMenuManager.UnloadTextures();
CParticleObject::RemoveAllExpireableParticleObjects(); CParticleObject::RemoveAllExpireableParticleObjects();

View file

@ -31,6 +31,9 @@
#include "main.h" #include "main.h"
#include "ColStore.h" #include "ColStore.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "Script.h"
//--MIAMI: file done (possibly bugs)
bool CStreaming::ms_disableStreaming; bool CStreaming::ms_disableStreaming;
bool CStreaming::ms_bLoadingBigModel; bool CStreaming::ms_bLoadingBigModel;
@ -48,6 +51,7 @@ size_t CStreaming::ms_memoryUsed;
CStreamingChannel CStreaming::ms_channel[2]; CStreamingChannel CStreaming::ms_channel[2];
int32 CStreaming::ms_channelError; int32 CStreaming::ms_channelError;
int32 CStreaming::ms_numVehiclesLoaded; int32 CStreaming::ms_numVehiclesLoaded;
int32 CStreaming::ms_numPedsLoaded;
int32 CStreaming::ms_vehiclesLoaded[MAXVEHICLESLOADED]; int32 CStreaming::ms_vehiclesLoaded[MAXVEHICLESLOADED];
int32 CStreaming::ms_lastVehicleDeleted; int32 CStreaming::ms_lastVehicleDeleted;
bool CStreaming::ms_bIsPedFromPedGroupLoaded[NUMMODELSPERPEDGROUP]; bool CStreaming::ms_bIsPedFromPedGroupLoaded[NUMMODELSPERPEDGROUP];
@ -70,7 +74,6 @@ CEntity *pIslandLODbeachEntity;
int32 islandLODmainland; int32 islandLODmainland;
int32 islandLODbeach; int32 islandLODbeach;
//--MIAMI: done
bool bool
CStreamingInfo::GetCdPosnAndSize(uint32 &posn, uint32 &size) CStreamingInfo::GetCdPosnAndSize(uint32 &posn, uint32 &size)
{ {
@ -81,7 +84,6 @@ CStreamingInfo::GetCdPosnAndSize(uint32 &posn, uint32 &size)
return true; return true;
} }
//--MIAMI: done
void void
CStreamingInfo::SetCdPosnAndSize(uint32 posn, uint32 size) CStreamingInfo::SetCdPosnAndSize(uint32 posn, uint32 size)
{ {
@ -89,7 +91,6 @@ CStreamingInfo::SetCdPosnAndSize(uint32 posn, uint32 size)
m_size = size; m_size = size;
} }
//--MIAMI: done
void void
CStreamingInfo::AddToList(CStreamingInfo *link) CStreamingInfo::AddToList(CStreamingInfo *link)
{ {
@ -100,7 +101,6 @@ CStreamingInfo::AddToList(CStreamingInfo *link)
m_next->m_prev = this; m_next->m_prev = this;
} }
//--MIAMI: done
void void
CStreamingInfo::RemoveFromList(void) CStreamingInfo::RemoveFromList(void)
{ {
@ -110,7 +110,6 @@ CStreamingInfo::RemoveFromList(void)
m_prev = nil; m_prev = nil;
} }
//--MIAMI: done
void void
CStreaming::Init2(void) CStreaming::Init2(void)
{ {
@ -179,6 +178,7 @@ CStreaming::Init2(void)
for(i = 0; i < MAXVEHICLESLOADED; i++) for(i = 0; i < MAXVEHICLESLOADED; i++)
ms_vehiclesLoaded[i] = -1; ms_vehiclesLoaded[i] = -1;
ms_numVehiclesLoaded = 0; ms_numVehiclesLoaded = 0;
ms_numPedsLoaded = 8;
for(i = 0; i < ARRAY_SIZE(ms_bIsPedFromPedGroupLoaded); i++) for(i = 0; i < ARRAY_SIZE(ms_bIsPedFromPedGroupLoaded); i++)
ms_bIsPedFromPedGroupLoaded[i] = false; ms_bIsPedFromPedGroupLoaded[i] = false;
@ -233,6 +233,7 @@ void
CStreaming::Init(void) CStreaming::Init(void)
{ {
#ifdef USE_TXD_CDIMAGE #ifdef USE_TXD_CDIMAGE
if(!CanVideoCardDoDXT()){
int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r"); int txdHandle = CFileMgr::OpenFile("MODELS\\TXD.IMG", "r");
if (txdHandle) if (txdHandle)
CFileMgr::CloseFile(txdHandle); CFileMgr::CloseFile(txdHandle);
@ -247,22 +248,39 @@ CStreaming::Init(void)
CStreaming::Init2(); CStreaming::Init2();
} }
} }
} else
CStreaming::Init2();
#else #else
CStreaming::Init2(); CStreaming::Init2();
#endif #endif
} }
//--MIAMI: done void
CStreaming::ReInit(void)
{
int i;
CStreaming::FlushRequestList();
CStreaming::DeleteAllRwObjects();
CStreaming::RemoveAllUnusedModels();
for(i = 0; i < MODELINFOSIZE; i++)
if(CModelInfo::GetModelInfo(i) && ms_aInfoForModel[i].m_flags & STREAMFLAGS_SCRIPTOWNED)
SetMissionDoesntRequireModel(i);
CStreaming::ms_disableStreaming = false;
}
void void
CStreaming::Shutdown(void) CStreaming::Shutdown(void)
{ {
RwFreeAlign(ms_pStreamingBuffer[0]); RwFreeAlign(ms_pStreamingBuffer[0]);
ms_streamingBufferSize = 0; ms_streamingBufferSize = 0;
if(ms_pExtraObjectsDir) if(ms_pExtraObjectsDir) {
delete ms_pExtraObjectsDir; delete ms_pExtraObjectsDir;
#ifdef FIX_BUGS
ms_pExtraObjectsDir = nil;
#endif
}
} }
//--MIAMI: done
void void
CStreaming::Update(void) CStreaming::Update(void)
{ {
@ -281,7 +299,7 @@ CStreaming::Update(void)
LoadBigBuildingsWhenNeeded(); LoadBigBuildingsWhenNeeded();
if(!ms_disableStreaming && TheCamera.GetPosition().z < 55.0f) if(!ms_disableStreaming && TheCamera.GetPosition().z < 55.0f)
AddModelsToRequestList(TheCamera.GetPosition()); AddModelsToRequestList(TheCamera.GetPosition(), 0);
DeleteFarAwayRwObjects(TheCamera.GetPosition()); DeleteFarAwayRwObjects(TheCamera.GetPosition());
@ -313,7 +331,6 @@ CStreaming::Update(void)
} }
} }
//--MIAMI: done
void void
CStreaming::LoadCdDirectory(void) CStreaming::LoadCdDirectory(void)
{ {
@ -342,7 +359,6 @@ CStreaming::LoadCdDirectory(void)
ms_imageSize /= CDSTREAM_SECTOR_SIZE; ms_imageSize /= CDSTREAM_SECTOR_SIZE;
} }
//--MIAMI: done
void void
CStreaming::LoadCdDirectory(const char *dirname, int n) CStreaming::LoadCdDirectory(const char *dirname, int n)
{ {
@ -440,7 +456,6 @@ GetObjectName(int streamId)
} }
//--MIAMI: done
bool bool
CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId) CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
{ {
@ -591,7 +606,6 @@ CStreaming::ConvertBufferToObject(int8 *buf, int32 streamId)
return true; return true;
} }
//--MIAMI: done
bool bool
CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId) CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
{ {
@ -654,7 +668,6 @@ CStreaming::FinishLoadingLargeFile(int8 *buf, int32 streamId)
return true; return true;
} }
//--MIAMI: done
void void
CStreaming::RequestModel(int32 id, int32 flags) CStreaming::RequestModel(int32 id, int32 flags)
{ {
@ -710,7 +723,6 @@ CStreaming::RequestModel(int32 id, int32 flags)
#define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE #define BIGBUILDINGFLAGS STREAMFLAGS_DONT_REMOVE
//--MIAMI: done
void void
CStreaming::RequestBigBuildings(eLevelName level) CStreaming::RequestBigBuildings(eLevelName level)
{ {
@ -727,7 +739,6 @@ CStreaming::RequestBigBuildings(eLevelName level)
RequestIslands(level); RequestIslands(level);
} }
//--MIAMI: done
void void
CStreaming::RequestBigBuildings(eLevelName level, const CVector &pos) CStreaming::RequestBigBuildings(eLevelName level, const CVector &pos)
{ {
@ -751,7 +762,6 @@ CStreaming::RequestBigBuildings(eLevelName level, const CVector &pos)
RequestIslands(level); RequestIslands(level);
} }
//--MIAMI: done
void void
CStreaming::InstanceBigBuildings(eLevelName level, const CVector &pos) CStreaming::InstanceBigBuildings(eLevelName level, const CVector &pos)
{ {
@ -768,7 +778,6 @@ CStreaming::InstanceBigBuildings(eLevelName level, const CVector &pos)
} }
} }
//--MIAMI: done
void void
CStreaming::InstanceLoadedModelsInSectorList(CPtrList &list) CStreaming::InstanceLoadedModelsInSectorList(CPtrList &list)
{ {
@ -781,7 +790,6 @@ CStreaming::InstanceLoadedModelsInSectorList(CPtrList &list)
} }
} }
//--MIAMI: done
void void
CStreaming::InstanceLoadedModels(const CVector &pos) CStreaming::InstanceLoadedModels(const CVector &pos)
{ {
@ -809,7 +817,6 @@ CStreaming::InstanceLoadedModels(const CVector &pos)
} }
} }
//--MIAMI: done
void void
CStreaming::RequestIslands(eLevelName level) CStreaming::RequestIslands(eLevelName level)
{ {
@ -828,7 +835,56 @@ CStreaming::RequestIslands(eLevelName level)
#endif #endif
} }
//--MIAMI: TODO static char *IGnames[] = {
"player",
"player2",
"player3",
"player4",
"player5",
"player6",
"player7",
"player8",
"player9",
"play10",
"play11",
"igken",
"igcandy",
"igsonny",
"igbuddy",
"igjezz",
"ighlary",
"igphil",
"igmerc",
"igdick",
"igdiaz",
""
};
static char *CSnames[] = {
"csplay",
"csplay2",
"csplay3",
"csplay4",
"csplay5",
"csplay6",
"csplay7",
"csplay8",
"csplay9",
"csplay10",
"csplay11",
"csken",
"cscandy",
"cssonny",
"csbuddy",
"csjezz",
"cshlary",
"csphil",
"csmerc",
"csdick",
"csdiaz",
""
};
void void
CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flags) CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flags)
{ {
@ -836,14 +892,43 @@ CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flag
int txdId; int txdId;
char oldName[48]; char oldName[48];
uint32 pos, size; uint32 pos, size;
int i, n;
mi = CModelInfo::GetModelInfo(modelId); mi = CModelInfo::GetModelInfo(modelId);
if(!CGeneral::faststrcmp("CSPlay", modelName)){
char *curname = CModelInfo::GetModelInfo(MI_PLAYER)->GetName();
for(int i = 0; CSnames[i][0]; i++){
if(strcasecmp(curname, IGnames[i]) == 0){
modelName = CSnames[i];
break;
}
}
}
if(!CGeneral::faststrcmp(mi->GetName(), modelName)){ if(!CGeneral::faststrcmp(mi->GetName(), modelName)){
// Already have the correct name, just request it // Already have the correct name, just request it
RequestModel(modelId, flags); RequestModel(modelId, flags);
return; return;
} }
if(mi->GetNumRefs() > 0){
n = CPools::GetPedPool()->GetSize()-1;
for(i = n; i >= 0 && mi->GetNumRefs() > 0; i--){
CPed *ped = CPools::GetPedPool()->GetSlot(i);
if(ped && ped->GetModelIndex() == modelId &&
!ped->IsPlayer() && ped->CanBeDeletedEvenInVehicle())
CTheScripts::RemoveThisPed(ped);
}
n = CPools::GetObjectPool()->GetSize()-1;
for(i = n; i >= 0 && mi->GetNumRefs() > 0; i--){
CObject *obj = CPools::GetObjectPool()->GetSlot(i);
if(obj && obj->GetModelIndex() == modelId && obj->CanBeDeleted()){
CWorld::Remove(obj);
CWorld::RemoveReferencesToDeletedObject(obj);
delete obj;
}
}
}
strcpy(oldName, mi->GetName()); strcpy(oldName, mi->GetName());
mi->SetName(modelName); mi->SetName(modelName);
@ -870,28 +955,24 @@ CStreaming::RequestSpecialModel(int32 modelId, const char *modelName, int32 flag
RequestModel(modelId, flags); RequestModel(modelId, flags);
} }
//--MIAMI: done
void void
CStreaming::RequestSpecialChar(int32 charId, const char *modelName, int32 flags) CStreaming::RequestSpecialChar(int32 charId, const char *modelName, int32 flags)
{ {
RequestSpecialModel(charId + MI_SPECIAL01, modelName, flags); RequestSpecialModel(charId + MI_SPECIAL01, modelName, flags);
} }
//--MIAMI: done
bool bool
CStreaming::HasSpecialCharLoaded(int32 id) CStreaming::HasSpecialCharLoaded(int32 id)
{ {
return HasModelLoaded(id + MI_SPECIAL01); return HasModelLoaded(id + MI_SPECIAL01);
} }
//--MIAMI: done
void void
CStreaming::SetMissionDoesntRequireSpecialChar(int32 id) CStreaming::SetMissionDoesntRequireSpecialChar(int32 id)
{ {
return SetMissionDoesntRequireModel(id + MI_SPECIAL01); return SetMissionDoesntRequireModel(id + MI_SPECIAL01);
} }
//--MIAMI: done
void void
CStreaming::DecrementRef(int32 id) CStreaming::DecrementRef(int32 id)
{ {
@ -902,7 +983,6 @@ CStreaming::DecrementRef(int32 id)
} }
} }
//--MIAMI: done
void void
CStreaming::RemoveModel(int32 id) CStreaming::RemoveModel(int32 id)
{ {
@ -955,7 +1035,6 @@ CStreaming::RemoveModel(int32 id)
ms_aInfoForModel[id].m_loadState = STREAMSTATE_NOTLOADED; ms_aInfoForModel[id].m_loadState = STREAMSTATE_NOTLOADED;
} }
//--MIAMI: done
void void
CStreaming::RemoveUnusedBuildings(eLevelName level) CStreaming::RemoveUnusedBuildings(eLevelName level)
{ {
@ -965,7 +1044,6 @@ CStreaming::RemoveUnusedBuildings(eLevelName level)
RemoveBuildings(LEVEL_MAINLAND); RemoveBuildings(LEVEL_MAINLAND);
} }
//--MIAMI: done
void void
CStreaming::RemoveBuildings(eLevelName level) CStreaming::RemoveBuildings(eLevelName level)
{ {
@ -1026,7 +1104,61 @@ CStreaming::RemoveBuildings(eLevelName level)
} }
} }
//--MIAMI: done void
CStreaming::RemoveBuildingsNotInArea(int32 area)
{
int i, n;
CEntity *e;
n = CPools::GetBuildingPool()->GetSize()-1;
for(i = n; i >= 0; i--){
e = CPools::GetBuildingPool()->GetSlot(i);
if(e && e->m_rwObject && !IsAreaVisible(area) &&
(!e->bIsBIGBuilding || e->bStreamBIGBuilding)){
if(e->bIsBIGBuilding)
RequestModel(e->GetModelIndex(), 0);
if(!e->bImBeingRendered)
e->DeleteRwObject();
}
}
n = CPools::GetTreadablePool()->GetSize()-1;
for(i = n; i >= 0; i--){
e = CPools::GetTreadablePool()->GetSlot(i);
if(e && e->m_rwObject && !IsAreaVisible(area) &&
(!e->bIsBIGBuilding || e->bStreamBIGBuilding)){
if(e->bIsBIGBuilding)
RequestModel(e->GetModelIndex(), 0);
if(!e->bImBeingRendered)
e->DeleteRwObject();
}
}
n = CPools::GetObjectPool()->GetSize()-1;
for(i = n; i >= 0; i--){
e = CPools::GetObjectPool()->GetSlot(i);
if(e && e->m_rwObject && !IsAreaVisible(area) &&
(!e->bIsBIGBuilding || e->bStreamBIGBuilding)){
if(e->bIsBIGBuilding)
RequestModel(e->GetModelIndex(), 0);
if(!e->bImBeingRendered)
e->DeleteRwObject();
}
}
n = CPools::GetDummyPool()->GetSize()-1;
for(i = n; i >= 0; i--){
e = CPools::GetDummyPool()->GetSlot(i);
if(e && e->m_rwObject && !IsAreaVisible(area) &&
(!e->bIsBIGBuilding || e->bStreamBIGBuilding)){
if(e->bIsBIGBuilding)
RequestModel(e->GetModelIndex(), 0);
if(!e->bImBeingRendered)
e->DeleteRwObject();
}
}
}
void void
CStreaming::RemoveUnusedBigBuildings(eLevelName level) CStreaming::RemoveUnusedBigBuildings(eLevelName level)
{ {
@ -1039,7 +1171,6 @@ CStreaming::RemoveUnusedBigBuildings(eLevelName level)
RemoveIslandsNotUsed(level); RemoveIslandsNotUsed(level);
} }
//--MIAMI: done
void void
DeleteIsland(CEntity *island) DeleteIsland(CEntity *island)
{ {
@ -1053,7 +1184,6 @@ DeleteIsland(CEntity *island)
} }
} }
//--MIAMI: done
void void
CStreaming::RemoveIslandsNotUsed(eLevelName level) CStreaming::RemoveIslandsNotUsed(eLevelName level)
{ {
@ -1082,7 +1212,6 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level)
#endif // !NO_ISLAND_LOADING #endif // !NO_ISLAND_LOADING
} }
//--MIAMI: done
void void
CStreaming::RemoveBigBuildings(eLevelName level) CStreaming::RemoveBigBuildings(eLevelName level)
{ {
@ -1129,7 +1258,6 @@ found:
return true; return true;
} }
//--MIAMI: done
bool bool
CStreaming::RemoveLeastUsedModel(uint32 excludeMask) CStreaming::RemoveLeastUsedModel(uint32 excludeMask)
{ {
@ -1163,7 +1291,6 @@ CStreaming::RemoveLeastUsedModel(uint32 excludeMask)
return (ms_numVehiclesLoaded > 7 || CGame::currArea != AREA_MAIN_MAP && ms_numVehiclesLoaded > 4) && RemoveLoadedVehicle(); return (ms_numVehiclesLoaded > 7 || CGame::currArea != AREA_MAIN_MAP && ms_numVehiclesLoaded > 4) && RemoveLoadedVehicle();
} }
//--MIAMI: done
void void
CStreaming::RemoveAllUnusedModels(void) CStreaming::RemoveAllUnusedModels(void)
{ {
@ -1181,14 +1308,35 @@ CStreaming::RemoveAllUnusedModels(void)
} }
} }
//--MIAMI: done
void void
CStreaming::RemoveUnusedModelsInLoadedList(void) CStreaming::RemoveUnusedModelsInLoadedList(void)
{ {
// empty // empty
} }
//--MIAMI: done bool
CStreaming::RemoveLoadedZoneModel(void)
{
int i;
if(ms_currentPedGrp == -1)
return false;
for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
int mi = CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i];
if(mi != -1 && ms_bIsPedFromPedGroupLoaded[i] &&
HasModelLoaded(mi) && CanRemoveModel(mi) &&
CModelInfo::GetModelInfo(mi)->GetNumRefs() == 0){
RemoveModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
ms_numPedsLoaded--;
ms_bIsPedFromPedGroupLoaded[i] = false;
return true;
}
}
return false;
}
bool bool
CStreaming::IsTxdUsedByRequestedModels(int32 txdId) CStreaming::IsTxdUsedByRequestedModels(int32 txdId)
{ {
@ -1291,7 +1439,7 @@ found:
if(id == -1) if(id == -1)
return false; // still no luck return false; // still no luck
ms_lastVehicleDeleted = id; ms_lastVehicleDeleted = id;
// this is more that we wanted actually // this is more than we wanted actually
ms_numVehiclesLoaded++; ms_numVehiclesLoaded++;
} }
else{ else{
@ -1322,7 +1470,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)->GetModelType() != MITYPE_VEHICLE) && if ((id >= STREAM_OFFSET_TXD && id < STREAM_OFFSET_COL || 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);
@ -1337,7 +1485,6 @@ CStreaming::SetModelTxdIsDeletable(int32 id)
SetModelIsDeletable(CModelInfo::GetModelInfo(id)->GetTxdSlot() + STREAM_OFFSET_TXD); SetModelIsDeletable(CModelInfo::GetModelInfo(id)->GetTxdSlot() + STREAM_OFFSET_TXD);
} }
//--MIAMI: done
void void
CStreaming::SetMissionDoesntRequireModel(int32 id) CStreaming::SetMissionDoesntRequireModel(int32 id)
{ {
@ -1369,15 +1516,10 @@ CStreaming::LoadInitialWeapons(void)
void void
CStreaming::LoadInitialVehicles(void) CStreaming::LoadInitialVehicles(void)
{ {
int id;
ms_numVehiclesLoaded = 0; ms_numVehiclesLoaded = 0;
ms_lastVehicleDeleted = 0; ms_lastVehicleDeleted = 0;
if(CModelInfo::GetModelInfo("taxi", &id)) RequestModel(MI_POLICE, STREAMFLAGS_DONT_REMOVE);
RequestModel(id, STREAMFLAGS_DONT_REMOVE);
if(CModelInfo::GetModelInfo("police", &id))
RequestModel(id, STREAMFLAGS_DONT_REMOVE);
} }
void void
@ -1438,6 +1580,8 @@ CStreaming::StreamVehiclesAndPeds(void)
SetModelIsDeletable(MI_VICE6); SetModelIsDeletable(MI_VICE6);
SetModelIsDeletable(MI_VICE7); SetModelIsDeletable(MI_VICE7);
SetModelIsDeletable(MI_VICE8); SetModelIsDeletable(MI_VICE8);
RequestModel(MI_VICECHEE, STREAMFLAGS_DONT_REMOVE);
if(CPopulation::NumMiamiViceCops == 0)
switch (CCarCtrl::MiamiViceCycle) { switch (CCarCtrl::MiamiViceCycle) {
case 0: case 0:
RequestModel(MI_VICE1, STREAMFLAGS_DONT_REMOVE); RequestModel(MI_VICE1, STREAMFLAGS_DONT_REMOVE);
@ -1456,7 +1600,6 @@ CStreaming::StreamVehiclesAndPeds(void)
RequestModel(MI_VICE8, STREAMFLAGS_DONT_REMOVE); RequestModel(MI_VICE8, STREAMFLAGS_DONT_REMOVE);
break; break;
} }
RequestModel(MI_VICECHEE, STREAMFLAGS_DONT_REMOVE);
} }
else { else {
SetModelIsDeletable(MI_VICECHEE); SetModelIsDeletable(MI_VICECHEE);
@ -1495,13 +1638,13 @@ CStreaming::StreamVehiclesAndPeds(void)
} }
} }
//--MIAMI: TODO
void void
CStreaming::StreamZoneModels(const CVector &pos) CStreaming::StreamZoneModels(const CVector &pos)
{ {
int i; int i, j;
uint16 gangsToLoad, gangCarsToLoad, bit; uint16 gangsToLoad, gangCarsToLoad, bit;
CZoneInfo info; CZoneInfo info;
static int timeBeforeNextLoad = 0;
CTheZones::GetZoneInfoForTimeOfDay(&pos, &info); CTheZones::GetZoneInfoForTimeOfDay(&pos, &info);
@ -1510,22 +1653,64 @@ CStreaming::StreamZoneModels(const CVector &pos)
// unload pevious group // unload pevious group
if(ms_currentPedGrp != -1) if(ms_currentPedGrp != -1)
for(i = 0; i < NUMMODELSPERPEDGROUP; i++){ for(i = 0; i < NUMMODELSPERPEDGROUP; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) ms_bIsPedFromPedGroupLoaded[i] = false;
break; if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1){
SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
} }
}
ms_currentPedGrp = info.pedGroup; ms_currentPedGrp = info.pedGroup;
for(i = 0; i < NUMMODELSPERPEDGROUP; i++){ for(i = 0; i < MAXZONEPEDSLOADED; i++){
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) do
break; j = CGeneral::GetRandomNumberInRange(0, NUMMODELSPERPEDGROUP);
while(ms_bIsPedFromPedGroupLoaded[j]);
ms_bIsPedFromPedGroupLoaded[j] = true;
if(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[j] != -1)
RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DEPENDENCY); RequestModel(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i], STREAMFLAGS_DEPENDENCY);
} }
ms_numPedsLoaded = MAXZONEPEDSLOADED;
timeBeforeNextLoad = 300;
} }
if(timeBeforeNextLoad >= 0)
timeBeforeNextLoad--;
else{
// Switch a ped
int oldMI;
// Find a ped to unload
for(i = 0; i < NUMMODELSPERPEDGROUP; i++)
if(ms_bIsPedFromPedGroupLoaded[i]){
oldMI = CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i];
if(oldMI != -1 && CModelInfo::GetModelInfo(oldMI)->GetNumRefs() == 0)
break;
}
// And load a new one
if(i != NUMMODELSPERPEDGROUP || ms_numPedsLoaded < MAXZONEPEDSLOADED){
do
j = CGeneral::GetRandomNumberInRange(0, NUMMODELSPERPEDGROUP);
while(ms_bIsPedFromPedGroupLoaded[j]);
if(ms_numPedsLoaded == MAXZONEPEDSLOADED)
ms_bIsPedFromPedGroupLoaded[i] = 0;
ms_bIsPedFromPedGroupLoaded[j] = true;
int newMI = CPopulation::ms_pPedGroups[ms_currentPedGrp].models[j];
if(newMI != oldMI){
RequestModel(newMI, STREAMFLAGS_DEPENDENCY);
debug("Request Ped %s\n", CModelInfo::GetModelInfo(newMI)->GetName());
if(ms_numPedsLoaded == MAXZONEPEDSLOADED){
SetModelIsDeletable(oldMI);
SetModelTxdIsDeletable(oldMI);
debug("Remove Ped %s\n", CModelInfo::GetModelInfo(oldMI)->GetName());
}else
ms_numPedsLoaded++;
timeBeforeNextLoad = 300;
}
}
}
RequestModel(MI_MALE01, STREAMFLAGS_DONT_REMOVE); RequestModel(MI_MALE01, STREAMFLAGS_DONT_REMOVE);
//RequestModel(MI_HMOCA, STREAMFLAGS_DONT_REMOVE); RequestModel(MI_TAXI_D, STREAMFLAGS_DONT_REMOVE);
gangsToLoad = 0; gangsToLoad = 0;
gangCarsToLoad = 0; gangCarsToLoad = 0;
@ -1543,16 +1728,17 @@ CStreaming::StreamZoneModels(const CVector &pos)
if(gangsToLoad == ms_loadedGangs && gangCarsToLoad == ms_loadedGangCars) if(gangsToLoad == ms_loadedGangs && gangCarsToLoad == ms_loadedGangCars)
return; return;
gangsToLoad |= gangCarsToLoad; int gangModelsToload = gangsToLoad | gangCarsToLoad;
if(gangsToLoad != ms_loadedGangs || gangCarsToLoad != ms_loadedGangCars){
for(i = 0; i < NUM_GANGS; i++){ for(i = 0; i < NUM_GANGS; i++){
bit = 1<<i; bit = 1<<i;
if(gangsToLoad & bit && (ms_loadedGangs & bit) == 0){ if(gangModelsToload & bit && (ms_loadedGangs & bit) == 0){
RequestModel(CGangs::GetGangPedModel1(i), STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangPedModel1(i), STREAMFLAGS_DEPENDENCY);
RequestModel(CGangs::GetGangPedModel2(i), STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangPedModel2(i), STREAMFLAGS_DEPENDENCY);
ms_loadedGangs |= bit; ms_loadedGangs |= bit;
}else if((gangsToLoad & bit) == 0 && ms_loadedGangs & bit){ }else if((gangModelsToload & bit) == 0 && ms_loadedGangs & bit){
SetModelIsDeletable(CGangs::GetGangPedModel1(i)); SetModelIsDeletable(CGangs::GetGangPedModel1(i));
SetModelIsDeletable(CGangs::GetGangPedModel2(i)); SetModelIsDeletable(CGangs::GetGangPedModel2(i));
SetModelTxdIsDeletable(CGangs::GetGangPedModel1(i)); SetModelTxdIsDeletable(CGangs::GetGangPedModel1(i));
@ -1560,10 +1746,7 @@ CStreaming::StreamZoneModels(const CVector &pos)
ms_loadedGangs &= ~bit; ms_loadedGangs &= ~bit;
} }
// TODO(MIAMI): check this if(CGangs::GetGangVehicleModel(i) != -1){
if(CGangs::GetGangVehicleModel(i) < 0)
continue;
if((gangCarsToLoad & bit) && (ms_loadedGangCars & bit) == 0){ if((gangCarsToLoad & bit) && (ms_loadedGangCars & bit) == 0){
RequestModel(CGangs::GetGangVehicleModel(i), STREAMFLAGS_DEPENDENCY); RequestModel(CGangs::GetGangVehicleModel(i), STREAMFLAGS_DEPENDENCY);
}else if((gangCarsToLoad & bit) == 0 && ms_loadedGangCars & bit){ }else if((gangCarsToLoad & bit) == 0 && ms_loadedGangCars & bit){
@ -1571,7 +1754,9 @@ CStreaming::StreamZoneModels(const CVector &pos)
SetModelTxdIsDeletable(CGangs::GetGangVehicleModel(i)); SetModelTxdIsDeletable(CGangs::GetGangVehicleModel(i));
} }
} }
}
ms_loadedGangCars = gangCarsToLoad; ms_loadedGangCars = gangCarsToLoad;
}
} }
void void
@ -1581,9 +1766,8 @@ CStreaming::RemoveCurrentZonesModels(void)
if (ms_currentPedGrp != -1) if (ms_currentPedGrp != -1)
for (i = 0; i < NUMMODELSPERPEDGROUP; i++) { for (i = 0; i < NUMMODELSPERPEDGROUP; i++) {
if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] == -1) if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != -1 &&
break; CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != MI_MALE01) {
if (CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i] != MI_MALE01) {
SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]); SetModelTxdIsDeletable(CPopulation::ms_pPedGroups[ms_currentPedGrp].models[i]);
} }
@ -1630,7 +1814,6 @@ CStreaming::LoadBigBuildingsWhenNeeded(void)
CCollision::LoadCollisionScreen(CGame::currLevel); CCollision::LoadCollisionScreen(CGame::currLevel);
DMAudio.Service(); DMAudio.Service();
// CPopulation::DealWithZoneChange is unused in VC
RemoveUnusedBigBuildings(CGame::currLevel); RemoveUnusedBigBuildings(CGame::currLevel);
RemoveUnusedBuildings(CGame::currLevel); RemoveUnusedBuildings(CGame::currLevel);
RemoveUnusedModelsInLoadedList(); RemoveUnusedModelsInLoadedList();
@ -1771,11 +1954,8 @@ CStreaming::GetNextFileOnCd(int32 lastPosn, bool priority)
* Files larger than the buffer size can only be loaded by channel 0, * Files larger than the buffer size can only be loaded by channel 0,
* which then uses both buffers, while channel 1 is idle. * which then uses both buffers, while channel 1 is idle.
* ms_bLoadingBigModel is set to true to indicate this state. * ms_bLoadingBigModel is set to true to indicate this state.
*
* TODO: two-part files
*/ */
//--MIAMI: done
// Make channel read from disc // Make channel read from disc
void void
CStreaming::RequestModelStream(int32 ch) CStreaming::RequestModelStream(int32 ch)
@ -1886,7 +2066,6 @@ CStreaming::RequestModelStream(int32 ch)
ms_channel[ch].numTries = 0; ms_channel[ch].numTries = 0;
} }
//--MIAMI: done
// Load data previously read from disc // Load data previously read from disc
bool bool
CStreaming::ProcessLoadingChannel(int32 ch) CStreaming::ProcessLoadingChannel(int32 ch)
@ -1956,7 +2135,6 @@ CStreaming::ProcessLoadingChannel(int32 ch)
return true; return true;
} }
//--MIAMI: done
void void
CStreaming::RetryLoadFile(int32 ch) CStreaming::RetryLoadFile(int32 ch)
{ {
@ -1993,7 +2171,6 @@ CStreaming::RetryLoadFile(int32 ch)
} }
} }
//--MIAMI: done
void void
CStreaming::LoadRequestedModels(void) CStreaming::LoadRequestedModels(void)
{ {
@ -2018,7 +2195,6 @@ CStreaming::LoadRequestedModels(void)
} }
} }
//--MIAMI: done
void void
CStreaming::LoadAllRequestedModels(bool priority) CStreaming::LoadAllRequestedModels(bool priority)
{ {
@ -2027,18 +2203,26 @@ CStreaming::LoadAllRequestedModels(bool priority)
int i; int i;
uint32 posn, size; uint32 posn, size;
int numRequests = 4*ms_numModelsRequested;
if(bInsideLoadAll) if(bInsideLoadAll)
return; return;
bInsideLoadAll = true;
if(priority)
numRequests = ms_numPriorityRequests;
FlushChannels(); FlushChannels();
imgOffset = GetCdImageOffset(CdStreamGetLastPosn()); imgOffset = GetCdImageOffset(CdStreamGetLastPosn());
while(ms_endRequestedList.m_prev != &ms_startRequestedList){ while(ms_endRequestedList.m_prev != &ms_startRequestedList && numRequests > 0){
numRequests--;
streamId = GetNextFileOnCd(0, priority); streamId = GetNextFileOnCd(0, priority);
if(streamId == -1) if(streamId == -1)
break; break;
ms_aInfoForModel[streamId].RemoveFromList(); ms_aInfoForModel[streamId].RemoveFromList();
ms_channel[0].streamIds[0] = streamId;
DecrementRef(streamId); DecrementRef(streamId);
if(ms_aInfoForModel[streamId].GetCdPosnAndSize(posn, size)){ if(ms_aInfoForModel[streamId].GetCdPosnAndSize(posn, size)){
@ -2072,7 +2256,6 @@ CStreaming::LoadAllRequestedModels(bool priority)
bInsideLoadAll = false; bInsideLoadAll = false;
} }
//--MIAMI: done
void void
CStreaming::FlushChannels(void) CStreaming::FlushChannels(void)
{ {
@ -2094,7 +2277,6 @@ CStreaming::FlushChannels(void)
ProcessLoadingChannel(1); ProcessLoadingChannel(1);
} }
//--MIAMI: done
void void
CStreaming::FlushRequestList(void) CStreaming::FlushRequestList(void)
{ {
@ -2126,10 +2308,10 @@ CStreaming::UpdateMemoryUsed(void)
// empty // empty
} }
#define STREAM_DIST (2*SECTOR_SIZE_X) #define STREAM_DIST 80.0f
void void
CStreaming::AddModelsToRequestList(const CVector &pos) CStreaming::AddModelsToRequestList(const CVector &pos, int32 flags)
{ {
float xmin, xmax, ymin, ymax; float xmin, xmax, ymin, ymax;
int ixmin, ixmax, iymin, iymax; int ixmin, ixmax, iymin, iymax;
@ -2163,23 +2345,23 @@ CStreaming::AddModelsToRequestList(const CVector &pos)
dx = ix - CWorld::GetSectorIndexX(pos.x); dx = ix - CWorld::GetSectorIndexX(pos.x);
d = dx*dx + dy*dy; d = dx*dx + dy*dy;
sect = CWorld::GetSector(ix, iy); sect = CWorld::GetSector(ix, iy);
if(d <= 1){ if(d <= 0){
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS]); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS], flags);
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP]); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], flags);
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_OBJECTS]); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_OBJECTS], flags);
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_DUMMIES]); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_DUMMIES], flags);
}else if(d <= 4*4){ }else if(d <= 3*3){
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS], pos.x, pos.y, xmin, ymin, xmax, ymax); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS], pos.x, pos.y, xmin, ymin, xmax, ymax, flags);
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], pos.x, pos.y, xmin, ymin, xmax, ymax); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_BUILDINGS_OVERLAP], pos.x, pos.y, xmin, ymin, xmax, ymax, flags);
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_OBJECTS], pos.x, pos.y, xmin, ymin, xmax, ymax); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_OBJECTS], pos.x, pos.y, xmin, ymin, xmax, ymax, flags);
ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_DUMMIES], pos.x, pos.y, xmin, ymin, xmax, ymax); ProcessEntitiesInSectorList(sect->m_lists[ENTITYLIST_DUMMIES], pos.x, pos.y, xmin, ymin, xmax, ymax, flags);
} }
} }
} }
} }
void void
CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float xmin, float ymin, float xmax, float ymax) CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float xmin, float ymin, float xmax, float ymax, int32 flags)
{ {
CPtrNode *node; CPtrNode *node;
CEntity *e; CEntity *e;
@ -2193,8 +2375,7 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float
continue; continue;
e->m_scanCode = CWorld::GetCurrentScanCode(); e->m_scanCode = CWorld::GetCurrentScanCode();
if(!e->bStreamingDontDelete && !e->bIsSubway && if(!e->bStreamingDontDelete && IsAreaVisible(e->m_area) && !e->bDontStream && e->bIsVisible){
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()); CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
if (mi->GetModelType() != 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());
@ -2203,14 +2384,14 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float
if(xmin < pos.x && pos.x < xmax && if(xmin < pos.x && pos.x < xmax &&
ymin < pos.y && pos.y < ymax && ymin < pos.y && pos.y < ymax &&
(CVector2D(x, y) - pos).MagnitudeSqr() < lodDistSq) (CVector2D(x, y) - pos).MagnitudeSqr() < lodDistSq)
RequestModel(e->GetModelIndex(), 0); RequestModel(e->GetModelIndex(), flags);
} }
} }
} }
} }
void void
CStreaming::ProcessEntitiesInSectorList(CPtrList &list) CStreaming::ProcessEntitiesInSectorList(CPtrList &list, int32 flags)
{ {
CPtrNode *node; CPtrNode *node;
CEntity *e; CEntity *e;
@ -2222,11 +2403,10 @@ CStreaming::ProcessEntitiesInSectorList(CPtrList &list)
continue; continue;
e->m_scanCode = CWorld::GetCurrentScanCode(); e->m_scanCode = CWorld::GetCurrentScanCode();
if(!e->bStreamingDontDelete && !e->bIsSubway && if(!e->bStreamingDontDelete && IsAreaVisible(e->m_area) && !e->bDontStream && e->bIsVisible){
(!e->IsObject() || ((CObject*)e)->ObjectCreatedBy != TEMP_OBJECT)){
CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex()); CTimeModelInfo *mi = (CTimeModelInfo*)CModelInfo::GetModelInfo(e->GetModelIndex());
if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff())) if (mi->GetModelType() != MITYPE_TIME || CClock::GetIsTimeInRange(mi->GetTimeOn(), mi->GetTimeOff()))
RequestModel(e->GetModelIndex(), 0); RequestModel(e->GetModelIndex(), flags);
} }
} }
} }
@ -2421,7 +2601,7 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
assert(ymin <= ymax); assert(ymin <= ymax);
// Delete a block of sectors that we know is behind the camera // Delete a block of sectors that we know is behind the camera
if(TheCamera.GetForward().x > 0){ if(TheCamera.GetForward().x > 0.0f){
// looking east // looking east
xmax = Max(ix - 2, 0); xmax = Max(ix - 2, 0);
xmin = Max(ix - 10, 0); xmin = Max(ix - 10, 0);
@ -2442,8 +2622,13 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
} }
} }
while(RemoveLoadedZoneModel())
if(ms_memoryUsed < mem)
return;
// Now a block that intersects with the camera's frustum // Now a block that intersects with the camera's frustum
if(TheCamera.GetForward().x > 0){ if(TheCamera.GetForward().x > 0.0f){
// looking east // looking east
xmax = Max(ix + 10, 0); xmax = Max(ix + 10, 0);
xmin = Max(ix - 2, 0); xmin = Max(ix - 2, 0);
@ -2482,7 +2667,7 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
assert(xmin <= xmax); assert(xmin <= xmax);
// Delete a block of sectors that we know is behind the camera // Delete a block of sectors that we know is behind the camera
if(TheCamera.GetForward().y > 0){ if(TheCamera.GetForward().y > 0.0f){
// looking north // looking north
ymax = Max(iy - 2, 0); ymax = Max(iy - 2, 0);
ymin = Max(iy - 10, 0); ymin = Max(iy - 10, 0);
@ -2503,8 +2688,12 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
} }
} }
while(RemoveLoadedZoneModel())
if(ms_memoryUsed < mem)
return;
// Now a block that intersects with the camera's frustum // Now a block that intersects with the camera's frustum
if(TheCamera.GetForward().y > 0){ if(TheCamera.GetForward().y > 0.0f){
// looking north // looking north
ymax = Max(iy + 10, 0); ymax = Max(iy + 10, 0);
ymin = Max(iy - 2, 0); ymin = Max(iy - 2, 0);
@ -2525,6 +2714,10 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
} }
} }
// this is gone in mobile together with RemoveReferencedTxds
// if(RemoveReferencedTxds(mem))
// return;
// As last resort, delete objects from the last step more aggressively // As last resort, delete objects from the last step more aggressively
for(x = xmin; x <= xmax; x++){ for(x = xmin; x <= xmax; x++){
for(y = ymax; y != ymin; y -= inc){ for(y = ymax; y != ymin; y -= inc){
@ -2536,6 +2729,8 @@ CStreaming::DeleteRwObjectsBehindCamera(size_t mem)
} }
} }
} }
while(ms_memoryUsed >= mem && RemoveLeastUsedModel(0));
} }
void void
@ -2561,13 +2756,13 @@ CStreaming::DeleteRwObjectsInOverlapSectorList(CPtrList &list, int32 x, int32 y)
e = (CEntity*)node->item; e = (CEntity*)node->item;
if(e->m_rwObject && !e->bStreamingDontDelete && !e->bImBeingRendered){ if(e->m_rwObject && !e->bStreamingDontDelete && !e->bImBeingRendered){
// Now this is pretty weird... // Now this is pretty weird...
if(Abs(CWorld::GetSectorIndexX(e->GetPosition().x) - x) >= 2.0f) if(Abs(CWorld::GetSectorIndexX(e->GetPosition().x) - x) >= 1.6f)
// { // {
e->DeleteRwObject(); e->DeleteRwObject();
// return; // BUG? // return; // BUG?
// } // }
else // FIX? else // FIX?
if(Abs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 2.0f) if(Abs(CWorld::GetSectorIndexY(e->GetPosition().y) - y) >= 1.6f)
e->DeleteRwObject(); e->DeleteRwObject();
} }
} }
@ -2582,7 +2777,8 @@ CStreaming::DeleteRwObjectsBehindCameraInSectorList(CPtrList &list, size_t mem)
for(node = list.first; node; node = node->next){ for(node = list.first; node; node = node->next){
e = (CEntity*)node->item; e = (CEntity*)node->item;
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 &&
FindPlayerPed()->m_pCurSurface != e){
e->DeleteRwObject(); e->DeleteRwObject();
if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) { if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
@ -2603,7 +2799,7 @@ CStreaming::DeleteRwObjectsNotInFrustumInSectorList(CPtrList &list, size_t mem)
for(node = list.first; node; node = node->next){ for(node = list.first; node; node = node->next){
e = (CEntity*)node->item; e = (CEntity*)node->item;
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() || e->bOffscreen) && ms_aInfoForModel[e->GetModelIndex()].m_next){
e->DeleteRwObject(); e->DeleteRwObject();
if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) { if (CModelInfo::GetModelInfo(e->GetModelIndex())->GetNumRefs() == 0) {
RemoveModel(e->GetModelIndex()); RemoveModel(e->GetModelIndex());
@ -2629,7 +2825,6 @@ CStreaming::MakeSpaceFor(int32 size)
} }
} }
//--MIAMI: done
void void
CStreaming::LoadScene(const CVector &pos) CStreaming::LoadScene(const CVector &pos)
{ {
@ -2655,7 +2850,7 @@ CStreaming::LoadScene(const CVector &pos)
LoadAllRequestedModels(false); LoadAllRequestedModels(false);
InstanceBigBuildings(level, pos); InstanceBigBuildings(level, pos);
InstanceBigBuildings(LEVEL_GENERIC, pos); InstanceBigBuildings(LEVEL_GENERIC, pos);
AddModelsToRequestList(pos); AddModelsToRequestList(pos, STREAMFLAGS_20);
CRadar::StreamRadarSections(pos); CRadar::StreamRadarSections(pos);
if (!CGame::IsInInterior()) { if (!CGame::IsInInterior()) {
@ -2674,7 +2869,6 @@ CStreaming::LoadScene(const CVector &pos)
debug("End load scene\n"); debug("End load scene\n");
} }
//--MIAMI: done
void void
CStreaming::LoadSceneCollision(const CVector &pos) CStreaming::LoadSceneCollision(const CVector &pos)
{ {
@ -2711,7 +2905,7 @@ void
CStreaming::UpdateForAnimViewer(void) CStreaming::UpdateForAnimViewer(void)
{ {
if (CStreaming::ms_channelError == -1) { if (CStreaming::ms_channelError == -1) {
CStreaming::AddModelsToRequestList(CVector(0.0f, 0.0f, 0.0f)); CStreaming::AddModelsToRequestList(CVector(0.0f, 0.0f, 0.0f), 0);
CStreaming::LoadRequestedModels(); CStreaming::LoadRequestedModels();
// original modifier was %d // original modifier was %d
sprintf(gString, "Requested %d, memory size %zuK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed); sprintf(gString, "Requested %d, memory size %zuK\n", CStreaming::ms_numModelsRequested, 2 * CStreaming::ms_memoryUsed);

View file

@ -93,6 +93,7 @@ public:
static CStreamingChannel ms_channel[2]; static CStreamingChannel ms_channel[2];
static int32 ms_channelError; static int32 ms_channelError;
static int32 ms_numVehiclesLoaded; static int32 ms_numVehiclesLoaded;
static int32 ms_numPedsLoaded;
static int32 ms_vehiclesLoaded[MAXVEHICLESLOADED]; static int32 ms_vehiclesLoaded[MAXVEHICLESLOADED];
static int32 ms_lastVehicleDeleted; static int32 ms_lastVehicleDeleted;
static bool ms_bIsPedFromPedGroupLoaded[NUMMODELSPERPEDGROUP]; static bool ms_bIsPedFromPedGroupLoaded[NUMMODELSPERPEDGROUP];
@ -110,6 +111,7 @@ public:
static void Init(void); static void Init(void);
static void Init2(void); static void Init2(void);
static void ReInit(void);
static void Shutdown(void); static void Shutdown(void);
static void Update(void); static void Update(void);
static void LoadCdDirectory(void); static void LoadCdDirectory(void);
@ -149,6 +151,7 @@ public:
static void RemoveAnim(int32 id) { RemoveModel(id + STREAM_OFFSET_ANIM); } static void RemoveAnim(int32 id) { RemoveModel(id + STREAM_OFFSET_ANIM); }
static void RemoveUnusedBuildings(eLevelName level); static void RemoveUnusedBuildings(eLevelName level);
static void RemoveBuildings(eLevelName level); static void RemoveBuildings(eLevelName level);
static void RemoveBuildingsNotInArea(int32 area);
static void RemoveUnusedBigBuildings(eLevelName level); static void RemoveUnusedBigBuildings(eLevelName level);
static void RemoveIslandsNotUsed(eLevelName level); static void RemoveIslandsNotUsed(eLevelName level);
static void RemoveBigBuildings(eLevelName level); static void RemoveBigBuildings(eLevelName level);
@ -156,6 +159,7 @@ public:
static bool RemoveLeastUsedModel(uint32 excludeMask); static bool RemoveLeastUsedModel(uint32 excludeMask);
static void RemoveAllUnusedModels(void); static void RemoveAllUnusedModels(void);
static void RemoveUnusedModelsInLoadedList(void); static void RemoveUnusedModelsInLoadedList(void);
static bool RemoveLoadedZoneModel(void);
static int32 GetAvailableVehicleSlot(void); static int32 GetAvailableVehicleSlot(void);
static bool IsTxdUsedByRequestedModels(int32 txdId); static bool IsTxdUsedByRequestedModels(int32 txdId);
static bool AreAnimsUsedByRequestedModels(int32 animId); static bool AreAnimsUsedByRequestedModels(int32 animId);
@ -187,9 +191,9 @@ public:
static void IHaveUsedStreamingMemory(void); static void IHaveUsedStreamingMemory(void);
static void UpdateMemoryUsed(void); static void UpdateMemoryUsed(void);
static void AddModelsToRequestList(const CVector &pos); static void AddModelsToRequestList(const CVector &pos, int32 flags);
static void ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float xmin, float ymin, float xmax, float ymax); static void ProcessEntitiesInSectorList(CPtrList &list, float x, float y, float xmin, float ymin, float xmax, float ymax, int32 flags);
static void ProcessEntitiesInSectorList(CPtrList &list); static void ProcessEntitiesInSectorList(CPtrList &list, int32 flags);
static void DeleteFarAwayRwObjects(const CVector &pos); static void DeleteFarAwayRwObjects(const CVector &pos);
static void DeleteAllRwObjects(void); static void DeleteAllRwObjects(void);
static void DeleteRwObjectsAfterDeath(const CVector &pos); static void DeleteRwObjectsAfterDeath(const CVector &pos);

View file

@ -113,6 +113,7 @@ enum Config {
NUMPHONES = 50, NUMPHONES = 50,
NUMPEDGROUPS = 67, NUMPEDGROUPS = 67,
NUMMODELSPERPEDGROUP = 16, NUMMODELSPERPEDGROUP = 16,
MAXZONEPEDSLOADED = 8,
NUMSHOTINFOS = 100, NUMSHOTINFOS = 100,
NUMROADBLOCKS = 300, NUMROADBLOCKS = 300,

View file

@ -609,17 +609,13 @@ LoadingScreen(const char *str1, const char *str2, const char *splashscreen)
} }
} }
//--MIAMI: done
void void
LoadingIslandScreen(const char *levelName) LoadingIslandScreen(const char *levelName)
{ {
CSprite2d *splash; CSprite2d *splash;
wchar *name;
char str[100];
wchar wstr[80];
CRGBA col;
splash = LoadSplash(nil); splash = LoadSplash(nil);
name = TheText.Get(levelName);
if(!DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255)) if(!DoRWStuffStartOfFrame(0, 0, 0, 0, 0, 0, 255))
return; return;
@ -627,26 +623,10 @@ LoadingIslandScreen(const char *levelName)
CSprite2d::InitPerFrame(); CSprite2d::InitPerFrame();
CFont::InitPerFrame(); CFont::InitPerFrame();
DefinedState(); DefinedState();
col = CRGBA(255, 255, 255, 255); CRGBA col = CRGBA(255, 255, 255, 255);
CRGBA col2 = CRGBA(0, 0, 0, 255);
CSprite2d::DrawRect(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), col2);
splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), col, col, col, col); splash->Draw(CRect(0.0f, 0.0f, SCREEN_WIDTH, SCREEN_HEIGHT), col, col, col, col);
CFont::SetBackgroundOff();
CFont::SetScale(1.5f, 1.5f);
CFont::SetPropOn();
CFont::SetRightJustifyOn();
CFont::SetRightJustifyWrap(150.0f);
CFont::SetFontStyle(FONT_HEADING);
sprintf(str, "WELCOME TO");
AsciiToUnicode(str, wstr);
CFont::SetDropColor(CRGBA(0, 0, 0, 255));
CFont::SetDropShadowPosition(3);
CFont::SetColor(CRGBA(243, 237, 71, 255));
CFont::SetScale(SCREEN_STRETCH_X(1.2f), SCREEN_STRETCH_Y(1.2f));
CFont::PrintString(SCREEN_WIDTH - 20, SCREEN_STRETCH_FROM_BOTTOM(110.0f), TheText.Get("WELCOME"));
TextCopy(wstr, name);
TheText.UpperCase(wstr);
CFont::SetColor(CRGBA(243, 237, 71, 255));
CFont::SetScale(SCREEN_STRETCH_X(1.2f), SCREEN_STRETCH_Y(1.2f));
CFont::PrintString(SCREEN_WIDTH-20, SCREEN_STRETCH_FROM_BOTTOM(80.0f), wstr);
CFont::DrawFonts(); CFont::DrawFonts();
DoRWStuffEndOfFrame(); DoRWStuffEndOfFrame();
} }

View file

@ -3001,6 +3001,22 @@ CPed::CanBeDeleted(void)
} }
} }
//--MIAMI: done
bool
CPed::CanBeDeletedEvenInVehicle(void)
{
switch (CharCreatedBy) {
case RANDOM_CHAR:
return true;
case MISSION_CHAR:
return false;
case TODO_CHAR:
return false;
default:
return true;
}
}
// --MIAMI: Done // --MIAMI: Done
bool bool
CPed::CanPedDriveOff(void) CPed::CanPedDriveOff(void)

View file

@ -911,6 +911,7 @@ public:
bool IsPedInControl(void); bool IsPedInControl(void);
bool CanPedDriveOff(void); bool CanPedDriveOff(void);
bool CanBeDeleted(void); bool CanBeDeleted(void);
bool CanBeDeletedEvenInVehicle(void);
bool CanStrafeOrMouseControl(void); bool CanStrafeOrMouseControl(void);
bool CanPedReturnToState(void); bool CanPedReturnToState(void);
void SetMoveState(eMoveState); void SetMoveState(eMoveState);

View file

@ -1,7 +1,9 @@
#pragma warning( push ) #pragma warning( push )
#pragma warning( disable : 4005) #pragma warning( disable : 4005)
#pragma warning( pop ) #pragma warning( pop )
#ifndef LIBRW
#define WITHD3D #define WITHD3D
#endif
#include "common.h" #include "common.h"
#ifndef LIBRW #ifndef LIBRW
#include "rpanisot.h" #include "rpanisot.h"
@ -221,7 +223,11 @@ CanVideoCardDoDXT(void)
{ {
#ifdef LIBRW #ifdef LIBRW
// TODO // TODO
#ifdef RW_OPENGL
return false
#else
return true; return true;
#endif
#else #else
return _rwD3D8CheckValidTextureFormat(D3DFMT_DXT1) && _rwD3D8CheckValidTextureFormat(D3DFMT_DXT3); return _rwD3D8CheckValidTextureFormat(D3DFMT_DXT1) && _rwD3D8CheckValidTextureFormat(D3DFMT_DXT3);
#endif #endif