mirror of
https://github.com/ZDoom/raze-gles.git
synced 2025-01-11 18:50:46 +00:00
- added access wrappers to the two fields of DICTNODE that are accessed from the outside.
The idea here is to completely merge the resource management into the file system so that Blood's DICTNODE is merely an alias to the internal FResourceLump. A two-tiered resource system is not something I consider worthwile, it made sense to get around Builds crappy cache but in the long term this is not a good solution for a multi-game port to have a resource management system in the backend and another one put over it in the front end, both with their own caching logic that might interfere with each other. Better merge it into one that can handle everything.
This commit is contained in:
parent
c6753a3fec
commit
693095bffb
10 changed files with 34 additions and 30 deletions
|
@ -150,11 +150,11 @@ void ambInit(void)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (pRAWNode->size > 0) {
|
||||
pChannel->at14 = pRAWNode->size;
|
||||
if (pRAWNode->Size() > 0) {
|
||||
pChannel->at14 = pRAWNode->Size();
|
||||
pChannel->at8 = nSFX;
|
||||
pChannel->atc = pRAWNode;
|
||||
pChannel->at14 = pRAWNode->size;
|
||||
pChannel->at14 = pRAWNode->Size();
|
||||
pChannel->at10 = (char*)gSoundRes.Lock(pRAWNode);
|
||||
pChannel->at18 = pSFX->format;
|
||||
nAmbChannels++;
|
||||
|
|
|
@ -650,11 +650,7 @@ unsigned int dbReadMapCRC(const char *pPath)
|
|||
|
||||
Bstrncpy(name2, pPath, BMAX_PATH);
|
||||
Bstrupr(name2);
|
||||
DICTNODE* pNode = *gSysRes.Probe(name2, "MAP");
|
||||
if (pNode && pNode->flags & DICT_EXTERNAL)
|
||||
{
|
||||
gSysRes.RemoveNode(pNode);
|
||||
}
|
||||
DICTNODE* pNode;
|
||||
pNode = gSysRes.Lookup(pPath, "MAP");
|
||||
if (!pNode)
|
||||
{
|
||||
|
@ -673,7 +669,7 @@ unsigned int dbReadMapCRC(const char *pPath)
|
|||
char *pData = (char*)gSysRes.Lock(pNode);
|
||||
pathsearchmode = bakpathsearchmode;
|
||||
|
||||
int nSize = pNode->size;
|
||||
int nSize = pNode->Size();
|
||||
MAPSIGNATURE header;
|
||||
IOBuffer(nSize, pData).Read(&header, 6);
|
||||
#if B_BIG_ENDIAN == 1
|
||||
|
@ -721,11 +717,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
|
|||
|
||||
Bstrncpy(name2, pPath, BMAX_PATH);
|
||||
Bstrupr(name2);
|
||||
DICTNODE* pNode = *gSysRes.Probe(name2, "MAP");
|
||||
if (pNode && pNode->flags & DICT_EXTERNAL)
|
||||
{
|
||||
gSysRes.RemoveNode(pNode);
|
||||
}
|
||||
DICTNODE* pNode;
|
||||
|
||||
pNode = gSysRes.Lookup(pPath, "MAP");
|
||||
if (!pNode)
|
||||
|
@ -744,7 +736,7 @@ int dbLoadMap(const char *pPath, int *pX, int *pY, int *pZ, short *pAngle, short
|
|||
}
|
||||
char *pData = (char*)gSysRes.Lock(pNode);
|
||||
pathsearchmode = bakpathsearchmode;
|
||||
int nSize = pNode->size;
|
||||
int nSize = pNode->Size();
|
||||
MAPSIGNATURE header;
|
||||
IOBuffer IOBuffer1 = IOBuffer(nSize, pData);
|
||||
IOBuffer1.Read(&header, 6);
|
||||
|
|
|
@ -428,7 +428,7 @@ void LoadSavedInfo(void)
|
|||
int nCount = 0;
|
||||
for (auto pIterator = pList; pIterator != NULL && nCount < 10; pIterator = pIterator->next, nCount++)
|
||||
{
|
||||
auto hFile = kopenFileReader(pIterator->name, 0);
|
||||
auto hFile = fopenFileReader(pIterator->name, 0);
|
||||
if (!hFile.isOpen())
|
||||
ThrowError("Error loading save file header.");
|
||||
int vc;
|
||||
|
|
|
@ -82,6 +82,9 @@ struct DICTNODE : CACHENODE
|
|||
char *path;
|
||||
char *buffer;
|
||||
unsigned int id;
|
||||
|
||||
unsigned int Size() const { return size; }
|
||||
int LockCount() const { return lockCount; }
|
||||
};
|
||||
|
||||
class Resource
|
||||
|
|
|
@ -108,7 +108,7 @@ void scrLoadPLUs(void)
|
|||
DICTNODE *pPlu = gSysRes.Lookup(PLU[i].name, "PLU");
|
||||
if (!pPlu)
|
||||
ThrowError("%s.PLU not found", PLU[i].name);
|
||||
if (pPlu->size / 256 != 64)
|
||||
if (pPlu->Size() / 256 != 64)
|
||||
ThrowError("Incorrect PLU size");
|
||||
palookup[PLU[i].id] = (char*)gSysRes.Lock(pPlu);
|
||||
}
|
||||
|
@ -227,7 +227,7 @@ void scrInit(void)
|
|||
DICTNODE *pGamma = gSysRes.Lookup("gamma", "DAT");
|
||||
if (!pGamma)
|
||||
ThrowError("Gamma table not found");
|
||||
gGammaLevels = pGamma->size / 256;
|
||||
gGammaLevels = pGamma->Size() / 256;
|
||||
gammaTable = (char(*)[256])gSysRes.Lock(pGamma);
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, int nSector)
|
|||
pBonkle->at1c = pEffect->relVol;
|
||||
pBonkle->at18 = v18;
|
||||
pBonkle->at3c = pEffect->format;
|
||||
int size = hRes->size;
|
||||
int size = hRes->Size();
|
||||
char *pData = (char*)gSoundRes.Lock(hRes);
|
||||
Calc3DValues(pBonkle);
|
||||
int priority = 1;
|
||||
|
@ -183,7 +183,7 @@ void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3, int a4)
|
|||
hRes = gSoundRes.Lookup(pEffect->rawName, "RAW");
|
||||
if (!hRes)
|
||||
return;
|
||||
int size = hRes->size;
|
||||
int size = hRes->Size();
|
||||
if (size <= 0)
|
||||
return;
|
||||
int v14;
|
||||
|
@ -290,7 +290,7 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3, int a4, int pitc
|
|||
SFX* pEffect = (SFX*)gSoundRes.Load(hRes);
|
||||
hRes = gSoundRes.Lookup(pEffect->rawName, "RAW");
|
||||
if (!hRes) return;
|
||||
int size = hRes->size;
|
||||
int size = hRes->Size();
|
||||
if (size <= 0) return;
|
||||
|
||||
if (pitch <= 0) pitch = pEffect->pitch;
|
||||
|
|
|
@ -95,7 +95,7 @@ int sndPlaySong(const char *songName, bool bLoop)
|
|||
OSD_Printf(OSD_ERROR "sndPlaySong(): error: can't open \"%s\" for playback!\n", songName);
|
||||
return 2;
|
||||
}
|
||||
int nNewSongSize = hSong->size;
|
||||
int nNewSongSize = hSong->Size();
|
||||
char *pNewSongPtr = (char *)Xaligned_alloc(16, nNewSongSize);
|
||||
gSoundRes.Load(hSong, pNewSongPtr);
|
||||
MUSIC_SetVolume(mus_volume);
|
||||
|
@ -260,7 +260,7 @@ void sndStartSample(const char *pzSound, int nVolume, int nChannel)
|
|||
pChannel->at5 = gSoundRes.Lookup(pzSound, "RAW");
|
||||
if (!pChannel->at5)
|
||||
return;
|
||||
int nSize = pChannel->at5->size;
|
||||
int nSize = pChannel->at5->Size();
|
||||
char *pData = (char*)gSoundRes.Lock(pChannel->at5);
|
||||
pChannel->at0 = FX_PlayRaw(pData, nSize, sndGetRate(1), 0, nVolume, nVolume, nVolume, nVolume, 1.f, (intptr_t)&pChannel->at0);
|
||||
}
|
||||
|
@ -287,7 +287,7 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop)
|
|||
return;
|
||||
if (nVolume < 0)
|
||||
nVolume = pEffect->relVol;
|
||||
int nSize = pChannel->at5->size;
|
||||
int nSize = pChannel->at5->Size();
|
||||
int nLoopEnd = nSize - 1;
|
||||
if (nLoopEnd < 0)
|
||||
nLoopEnd = 0;
|
||||
|
@ -325,7 +325,7 @@ void sndStartWavID(unsigned int nSound, int nVolume, int nChannel)
|
|||
if (!pChannel->at5)
|
||||
return;
|
||||
char *pData = (char*)gSoundRes.Lock(pChannel->at5);
|
||||
pChannel->at0 = FX_Play(pData, pChannel->at5->size, 0, -1, 0, nVolume, nVolume, nVolume, nVolume, 1.f, (intptr_t)&pChannel->at0);
|
||||
pChannel->at0 = FX_Play(pData, pChannel->at5->Size(), 0, -1, 0, nVolume, nVolume, nVolume, nVolume, 1.f, (intptr_t)&pChannel->at0);
|
||||
}
|
||||
|
||||
void sndKillSound(SAMPLE2D *pChannel)
|
||||
|
|
|
@ -48,7 +48,7 @@ void qloadvoxel(int32_t nVoxel)
|
|||
return;
|
||||
}
|
||||
|
||||
if (!hVox->lockCount)
|
||||
if (!hVox->LockCount())
|
||||
voxoff[nLastVoxel][0] = 0;
|
||||
nLastVoxel = nVoxel;
|
||||
char *pVox = (char*)gSysRes.Lock(hVox);
|
||||
|
@ -135,7 +135,7 @@ void tileProcessGLVoxels(void)
|
|||
if (!hVox)
|
||||
continue;
|
||||
char *pVox = (char*)gSysRes.Load(hVox);
|
||||
voxmodels[i] = loadkvxfrombuf(pVox, hVox->size);
|
||||
voxmodels[i] = loadkvxfrombuf(pVox, hVox->Size());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -64,9 +64,9 @@ void trigInit(Resource &Res)
|
|||
DICTNODE *pTable = Res.Lookup("cosine","dat");
|
||||
if (!pTable)
|
||||
ThrowError("Cosine table not found");
|
||||
if (pTable->size != 2048)
|
||||
if (pTable->Size() != 2048)
|
||||
ThrowError("Cosine table incorrect size");
|
||||
memcpy(costable, Res.Load(pTable), pTable->size);
|
||||
memcpy(costable, Res.Load(pTable), pTable->Size());
|
||||
#if B_BIG_ENDIAN == 1
|
||||
for (int i = 0; i < 512; i++)
|
||||
{
|
||||
|
|
|
@ -46,11 +46,12 @@ struct FResourceLump
|
|||
{
|
||||
friend class FResourceFile;
|
||||
|
||||
int LumpSize = 0;
|
||||
unsigned LumpSize = 0;
|
||||
int RefCount = 0;
|
||||
int Flags = 0;
|
||||
int PathLen = 0;
|
||||
int ExtStart = -1;
|
||||
int ResourceId = -1;
|
||||
FString FullName; // Name with extension and path
|
||||
FResourceFile * Owner = nullptr;
|
||||
TArray<uint8_t> Cache;
|
||||
|
@ -67,12 +68,20 @@ struct FResourceLump
|
|||
|
||||
void *CacheLump();
|
||||
int ReleaseCache();
|
||||
|
||||
unsigned Size() const{ return LumpSize; }
|
||||
int LockCount() const { return RefCount; }
|
||||
FString BaseName(); // don't know if these will be needed
|
||||
FString Type();
|
||||
|
||||
protected:
|
||||
virtual int FillCache() { return -1; }
|
||||
|
||||
};
|
||||
|
||||
// Map NBlood's resource system to our own.
|
||||
using DICTNODE = FResourceLump;
|
||||
|
||||
class FResourceFile
|
||||
{
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue