Remove island loading

This commit is contained in:
Sergeanur 2020-07-09 19:18:42 +03:00
parent 1cea84d2b1
commit cf69f22a0c
7 changed files with 66 additions and 5 deletions

View File

@ -10027,11 +10027,15 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
CTimer::Stop(); CTimer::Stop();
CGame::currLevel = (eLevelName)ScriptParams[0]; CGame::currLevel = (eLevelName)ScriptParams[0];
#ifndef NO_ISLAND_LOADING
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel);
#endif
CCollision::SortOutCollisionAfterLoad(); CCollision::SortOutCollisionAfterLoad();
#ifndef NO_ISLAND_LOADING
CStreaming::RequestIslands(CGame::currLevel); CStreaming::RequestIslands(CGame::currLevel);
CStreaming::LoadAllRequestedModels(true); CStreaming::LoadAllRequestedModels(true);
#endif
CTimer::Update(); CTimer::Update();
return 0; return 0;
} }
@ -10647,18 +10651,24 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
CTimer::Stop(); CTimer::Stop();
CGame::currLevel = (eLevelName)ScriptParams[0]; CGame::currLevel = (eLevelName)ScriptParams[0];
if (CGame::currLevel != CCollision::ms_collisionInMemory) { if (CGame::currLevel != CCollision::ms_collisionInMemory) {
#ifndef NO_ISLAND_LOADING
DMAudio.SetEffectsFadeVol(0); DMAudio.SetEffectsFadeVol(0);
CPad::StopPadsShaking(); CPad::StopPadsShaking();
CCollision::LoadCollisionScreen(CGame::currLevel); CCollision::LoadCollisionScreen(CGame::currLevel);
DMAudio.Service(); DMAudio.Service();
#endif
CPopulation::DealWithZoneChange(CCollision::ms_collisionInMemory, CGame::currLevel, false); CPopulation::DealWithZoneChange(CCollision::ms_collisionInMemory, CGame::currLevel, false);
#ifndef NO_ISLAND_LOADING
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel);
#endif
CCollision::SortOutCollisionAfterLoad(); CCollision::SortOutCollisionAfterLoad();
#ifndef NO_ISLAND_LOADING
CStreaming::RequestIslands(CGame::currLevel); CStreaming::RequestIslands(CGame::currLevel);
CStreaming::RequestBigBuildings(CGame::currLevel); CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(true); CStreaming::LoadAllRequestedModels(true);
DMAudio.SetEffectsFadeVol(127); DMAudio.SetEffectsFadeVol(127);
#endif
} }
CTimer::Update(); CTimer::Update();
return 0; return 0;

View File

@ -180,12 +180,16 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
if(level == CGame::currLevel || forceChange){ if(level == CGame::currLevel || forceChange){
CTimer::Stop(); CTimer::Stop();
#ifndef NO_ISLAND_LOADING
DMAudio.SetEffectsFadeVol(0); DMAudio.SetEffectsFadeVol(0);
CPad::StopPadsShaking(); CPad::StopPadsShaking();
LoadCollisionScreen(CGame::currLevel); LoadCollisionScreen(CGame::currLevel);
DMAudio.Service(); DMAudio.Service();
#endif
CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false); CPopulation::DealWithZoneChange(ms_collisionInMemory, CGame::currLevel, false);
#ifndef NO_ISLAND_LOADING
CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL); CStreaming::RemoveIslandsNotUsed(LEVEL_INDUSTRIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL); CStreaming::RemoveIslandsNotUsed(LEVEL_COMMERCIAL);
CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN); CStreaming::RemoveIslandsNotUsed(LEVEL_SUBURBAN);
@ -196,19 +200,27 @@ CCollision::LoadCollisionWhenINeedIt(bool forceChange)
CStreaming::RemoveUnusedModelsInLoadedList(); CStreaming::RemoveUnusedModelsInLoadedList();
CGame::TidyUpMemory(true, true); CGame::TidyUpMemory(true, true);
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel); CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
#endif
ms_collisionInMemory = CGame::currLevel; ms_collisionInMemory = CGame::currLevel;
CReplay::EmptyReplayBuffer(); CReplay::EmptyReplayBuffer();
#ifndef NO_ISLAND_LOADING
if(CGame::currLevel != LEVEL_NONE) if(CGame::currLevel != LEVEL_NONE)
LoadSplash(GetLevelSplashScreen(CGame::currLevel)); LoadSplash(GetLevelSplashScreen(CGame::currLevel));
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel);
CStreaming::RequestBigBuildings(CGame::currLevel); CStreaming::RequestBigBuildings(CGame::currLevel);
#endif
CStreaming::LoadAllRequestedModels(true); CStreaming::LoadAllRequestedModels(true);
#ifndef NO_ISLAND_LOADING
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
CGame::TidyUpMemory(true, true); CGame::TidyUpMemory(true, true);
#endif
CTimer::Update(); CTimer::Update();
#ifndef NO_ISLAND_LOADING
DMAudio.SetEffectsFadeVol(127); DMAudio.SetEffectsFadeVol(127);
#endif
} }
} }
@ -217,10 +229,23 @@ CCollision::SortOutCollisionAfterLoad(void)
{ {
if(ms_collisionInMemory == CGame::currLevel) if(ms_collisionInMemory == CGame::currLevel)
return; return;
#ifndef NO_ISLAND_LOADING
CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel); CModelInfo::RemoveColModelsFromOtherLevels(CGame::currLevel);
if(CGame::currLevel != LEVEL_NONE){ #endif
if (CGame::currLevel != LEVEL_NONE) {
#ifdef NO_ISLAND_LOADING
static bool bAlreadyLoaded = false;
if (bAlreadyLoaded) {
ms_collisionInMemory = CGame::currLevel;
return;
}
bAlreadyLoaded = true;
CFileLoader::LoadCollisionFromDatFile(LEVEL_INDUSTRIAL);
CFileLoader::LoadCollisionFromDatFile(LEVEL_COMMERCIAL);
CFileLoader::LoadCollisionFromDatFile(LEVEL_SUBURBAN);
#else
CFileLoader::LoadCollisionFromDatFile(CGame::currLevel); CFileLoader::LoadCollisionFromDatFile(CGame::currLevel);
#endif
if(!CGame::playingIntro) if(!CGame::playingIntro)
LoadSplash(GetLevelSplashScreen(CGame::currLevel)); LoadSplash(GetLevelSplashScreen(CGame::currLevel));
} }

View File

@ -725,7 +725,11 @@ CStreaming::RequestBigBuildings(eLevelName level)
n = CPools::GetBuildingPool()->GetSize()-1; n = CPools::GetBuildingPool()->GetSize()-1;
for(i = n; i >= 0; i--){ for(i = n; i >= 0; i--){
b = CPools::GetBuildingPool()->GetSlot(i); b = CPools::GetBuildingPool()->GetSlot(i);
if(b && b->bIsBIGBuilding && b->m_level == level) if(b && b->bIsBIGBuilding
#ifndef NO_ISLAND_LOADING
&& b->m_level == level
#endif
)
RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS); RequestModel(b->GetModelIndex(), BIGBUILDINGFLAGS);
} }
RequestIslands(level); RequestIslands(level);
@ -735,6 +739,7 @@ CStreaming::RequestBigBuildings(eLevelName level)
void void
CStreaming::RequestIslands(eLevelName level) CStreaming::RequestIslands(eLevelName level)
{ {
#ifndef NO_ISLAND_LOADING
switch(level){ switch(level){
case LEVEL_INDUSTRIAL: case LEVEL_INDUSTRIAL:
RequestModel(islandLODcomInd, BIGBUILDINGFLAGS); RequestModel(islandLODcomInd, BIGBUILDINGFLAGS);
@ -750,6 +755,7 @@ CStreaming::RequestIslands(eLevelName level)
break; break;
default: break; default: break;
} }
#endif
} }
void void
@ -935,12 +941,14 @@ CStreaming::RemoveBuildings(eLevelName level)
void void
CStreaming::RemoveUnusedBigBuildings(eLevelName level) CStreaming::RemoveUnusedBigBuildings(eLevelName level)
{ {
#ifndef NO_ISLAND_LOADING
if(level != LEVEL_INDUSTRIAL) if(level != LEVEL_INDUSTRIAL)
RemoveBigBuildings(LEVEL_INDUSTRIAL); RemoveBigBuildings(LEVEL_INDUSTRIAL);
if(level != LEVEL_COMMERCIAL) if(level != LEVEL_COMMERCIAL)
RemoveBigBuildings(LEVEL_COMMERCIAL); RemoveBigBuildings(LEVEL_COMMERCIAL);
if(level != LEVEL_SUBURBAN) if(level != LEVEL_SUBURBAN)
RemoveBigBuildings(LEVEL_SUBURBAN); RemoveBigBuildings(LEVEL_SUBURBAN);
#endif
RemoveIslandsNotUsed(level); RemoveIslandsNotUsed(level);
} }
@ -960,6 +968,7 @@ DeleteIsland(CEntity *island)
void void
CStreaming::RemoveIslandsNotUsed(eLevelName level) CStreaming::RemoveIslandsNotUsed(eLevelName level)
{ {
#ifndef NO_ISLAND_LOADING
switch(level){ switch(level){
case LEVEL_INDUSTRIAL: case LEVEL_INDUSTRIAL:
DeleteIsland(pIslandLODindustEntity); DeleteIsland(pIslandLODindustEntity);
@ -977,13 +986,16 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level)
DeleteIsland(pIslandLODcomIndEntity); DeleteIsland(pIslandLODcomIndEntity);
break; break;
default: default:
#endif // !NO_ISLAND_LOADING
DeleteIsland(pIslandLODindustEntity); DeleteIsland(pIslandLODindustEntity);
DeleteIsland(pIslandLODcomIndEntity); DeleteIsland(pIslandLODcomIndEntity);
DeleteIsland(pIslandLODcomSubEntity); DeleteIsland(pIslandLODcomSubEntity);
DeleteIsland(pIslandLODsubIndEntity); DeleteIsland(pIslandLODsubIndEntity);
DeleteIsland(pIslandLODsubComEntity); DeleteIsland(pIslandLODsubComEntity);
#ifndef NO_ISLAND_LOADING
break; break;
} }
#endif // !NO_ISLAND_LOADING
} }
void void

View File

@ -198,6 +198,7 @@ enum Config {
#define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch) #define DEFAULT_NATIVE_RESOLUTION // Set default video mode to your native resolution (fixes Windows 10 launch)
#define USE_TXD_CDIMAGE // generate and load textures from txd.img #define USE_TXD_CDIMAGE // generate and load textures from txd.img
#define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number #define IMPROVED_VIDEOMODE // save and load videomode parameters instead of a magic number
#define NO_ISLAND_LOADING // disable loadscreen between islands via loading all island data at once, consumes more memory and CPU
//#define USE_TEXTURE_POOL //#define USE_TEXTURE_POOL
// Particle // Particle

View File

@ -217,6 +217,7 @@ CModelInfo::IsBikeModel(int32 id)
void void
CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level) CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
{ {
#ifndef NO_ISLAND_LOADING
int i; int i;
CBaseModelInfo *mi; CBaseModelInfo *mi;
CColModel *colmodel; CColModel *colmodel;
@ -229,6 +230,7 @@ CModelInfo::RemoveColModelsFromOtherLevels(eLevelName level)
colmodel->RemoveCollisionVolumes(); colmodel->RemoveCollisionVolumes();
} }
} }
#endif
} }
void void

View File

@ -700,8 +700,16 @@ CRenderer::ScanWorld(void)
poly[2].y = CWorld::GetSectorY(vectors[CORNER_LOD_RIGHT].y); poly[2].y = CWorld::GetSectorY(vectors[CORNER_LOD_RIGHT].y);
} }
ScanSectorPoly(poly, 3, ScanSectorList); ScanSectorPoly(poly, 3, ScanSectorList);
#ifdef NO_ISLAND_LOADING
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_INDUSTRIAL));
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_COMMERCIAL));
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_SUBURBAN));
#else
#ifdef FIX_BUGS
if (CCollision::ms_collisionInMemory != LEVEL_NONE)
#endif
ScanBigBuildingList(CWorld::GetBigBuildingList(CCollision::ms_collisionInMemory)); ScanBigBuildingList(CWorld::GetBigBuildingList(CCollision::ms_collisionInMemory));
#endif
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_NONE)); ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_NONE));
} }
} }

View File

@ -562,14 +562,17 @@ RestoreForStartLoad()
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().x); ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().x);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().y); ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().y);
ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z); ReadDataFromBufferPointer(_buf, TheCamera.GetMatrix().GetPosition().z);
#ifndef NO_ISLAND_LOADING
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel); CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel); CStreaming::RemoveUnusedBuildings(CGame::currLevel);
#endif
CCollision::SortOutCollisionAfterLoad(); CCollision::SortOutCollisionAfterLoad();
#ifndef NO_ISLAND_LOADING
CStreaming::RequestBigBuildings(CGame::currLevel); CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(false); CStreaming::LoadAllRequestedModels(false);
CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel); CStreaming::HaveAllBigBuildingsLoaded(CGame::currLevel);
CGame::TidyUpMemory(true, false); CGame::TidyUpMemory(true, false);
#endif
if (CloseFile(file)) { if (CloseFile(file)) {
return true; return true;
} else { } else {