Purge resource manager cache on level load

This commit is contained in:
nukeykt 2019-09-16 20:27:15 +09:00 committed by Christoph Oelckers
parent 3f42df45fd
commit 433fd62de5
2 changed files with 12 additions and 1 deletions

View file

@ -434,9 +434,12 @@ void PreloadCache(void)
char tempbuf[128];
if (gDemo.at1)
return;
gSysRes.PurgeCache();
gSoundRes.PurgeCache();
gSysRes.PrecacheSounds();
gSoundRes.PrecacheSounds();
if (MusicRestartsOnLoadToggle)
sndTryPlaySpecialMusic(MUS_LOADING);
gSoundRes.PrecacheSounds();
PreloadTiles();
ClockTicks clock = totalclock;
int cnt = 0;

View file

@ -776,6 +776,14 @@ void Resource::PurgeCache(void)
for (CACHENODE *node = purgeHead.next; node != &purgeHead; node = node->next)
{
DICTNODE *pDict = (DICTNODE*)node;
if (!(pDict->flags & DICT_LOAD))
{
dassert(pDict->lockCount == 0);
dassert(pDict->ptr != NULL);
Free(pDict->ptr);
pDict->ptr = NULL;
RemoveMRU(pDict);
}
}
#endif
}