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);
CTimer::Stop();
CGame::currLevel = (eLevelName)ScriptParams[0];
#ifndef NO_ISLAND_LOADING
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
#endif
CCollision::SortOutCollisionAfterLoad();
#ifndef NO_ISLAND_LOADING
CStreaming::RequestIslands(CGame::currLevel);
CStreaming::LoadAllRequestedModels(true);
#endif
CTimer::Update();
return 0;
}
@ -10647,18 +10651,24 @@ int8 CRunningScript::ProcessCommands1100To1199(int32 command)
CTimer::Stop();
CGame::currLevel = (eLevelName)ScriptParams[0];
if (CGame::currLevel != CCollision::ms_collisionInMemory) {
#ifndef NO_ISLAND_LOADING
DMAudio.SetEffectsFadeVol(0);
CPad::StopPadsShaking();
CCollision::LoadCollisionScreen(CGame::currLevel);
DMAudio.Service();
#endif
CPopulation::DealWithZoneChange(CCollision::ms_collisionInMemory, CGame::currLevel, false);
#ifndef NO_ISLAND_LOADING
CStreaming::RemoveUnusedBigBuildings(CGame::currLevel);
CStreaming::RemoveUnusedBuildings(CGame::currLevel);
#endif
CCollision::SortOutCollisionAfterLoad();
#ifndef NO_ISLAND_LOADING
CStreaming::RequestIslands(CGame::currLevel);
CStreaming::RequestBigBuildings(CGame::currLevel);
CStreaming::LoadAllRequestedModels(true);
DMAudio.SetEffectsFadeVol(127);
#endif
}
CTimer::Update();
return 0;

View File

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

View File

@ -725,7 +725,11 @@ CStreaming::RequestBigBuildings(eLevelName level)
n = CPools::GetBuildingPool()->GetSize()-1;
for(i = n; i >= 0; 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);
}
RequestIslands(level);
@ -735,6 +739,7 @@ CStreaming::RequestBigBuildings(eLevelName level)
void
CStreaming::RequestIslands(eLevelName level)
{
#ifndef NO_ISLAND_LOADING
switch(level){
case LEVEL_INDUSTRIAL:
RequestModel(islandLODcomInd, BIGBUILDINGFLAGS);
@ -750,6 +755,7 @@ CStreaming::RequestIslands(eLevelName level)
break;
default: break;
}
#endif
}
void
@ -935,12 +941,14 @@ CStreaming::RemoveBuildings(eLevelName level)
void
CStreaming::RemoveUnusedBigBuildings(eLevelName level)
{
#ifndef NO_ISLAND_LOADING
if(level != LEVEL_INDUSTRIAL)
RemoveBigBuildings(LEVEL_INDUSTRIAL);
if(level != LEVEL_COMMERCIAL)
RemoveBigBuildings(LEVEL_COMMERCIAL);
if(level != LEVEL_SUBURBAN)
RemoveBigBuildings(LEVEL_SUBURBAN);
#endif
RemoveIslandsNotUsed(level);
}
@ -960,6 +968,7 @@ DeleteIsland(CEntity *island)
void
CStreaming::RemoveIslandsNotUsed(eLevelName level)
{
#ifndef NO_ISLAND_LOADING
switch(level){
case LEVEL_INDUSTRIAL:
DeleteIsland(pIslandLODindustEntity);
@ -977,13 +986,16 @@ CStreaming::RemoveIslandsNotUsed(eLevelName level)
DeleteIsland(pIslandLODcomIndEntity);
break;
default:
#endif // !NO_ISLAND_LOADING
DeleteIsland(pIslandLODindustEntity);
DeleteIsland(pIslandLODcomIndEntity);
DeleteIsland(pIslandLODcomSubEntity);
DeleteIsland(pIslandLODsubIndEntity);
DeleteIsland(pIslandLODsubComEntity);
#ifndef NO_ISLAND_LOADING
break;
}
#endif // !NO_ISLAND_LOADING
}
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 USE_TXD_CDIMAGE // generate and load textures from txd.img
#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
// Particle

View File

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

View File

@ -700,8 +700,16 @@ CRenderer::ScanWorld(void)
poly[2].y = CWorld::GetSectorY(vectors[CORNER_LOD_RIGHT].y);
}
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));
#endif
ScanBigBuildingList(CWorld::GetBigBuildingList(LEVEL_NONE));
}
}

View File

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