mirror of
https://github.com/ZDoom/Raze.git
synced 2024-11-15 08:51:24 +00:00
- enabled the Blood RFS parser.
Seems to work but there's not that much material to use it on so the mileage may vary.
This commit is contained in:
parent
3ed7856f53
commit
bbc145cbee
6 changed files with 94 additions and 89 deletions
|
@ -152,7 +152,7 @@ private:
|
||||||
char _fileName[BMAX_PATH]; // [30]
|
char _fileName[BMAX_PATH]; // [30]
|
||||||
|
|
||||||
public:
|
public:
|
||||||
int Open(const char *fileName);
|
int Open(int lumpnum);
|
||||||
void Close();
|
void Close();
|
||||||
void Increment();
|
void Increment();
|
||||||
void SkipBeyondValue(char value);
|
void SkipBeyondValue(char value);
|
||||||
|
@ -162,13 +162,11 @@ public:
|
||||||
void UnsetMark();
|
void UnsetMark();
|
||||||
};
|
};
|
||||||
|
|
||||||
int RFS::Open(const char *fileName)
|
int RFS::Open(int lumpnum)
|
||||||
{
|
{
|
||||||
strcpy(_fileName, fileName);
|
auto hFile = fileSystem.OpenFileReader(lumpnum);
|
||||||
|
|
||||||
auto hFile = fileSystem.OpenFileReader(fileName, 0);
|
|
||||||
if (!hFile.isOpen()) {
|
if (!hFile.isOpen()) {
|
||||||
initprintf("BARF: Error opening file %s", _fileName);
|
initprintf("BARF: Error opening file %d", lumpnum);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,7 +174,7 @@ int RFS::Open(const char *fileName)
|
||||||
buffer.Resize(fileSize);
|
buffer.Resize(fileSize);
|
||||||
_ptr = buffer.Data();
|
_ptr = buffer.Data();
|
||||||
if (_ptr == NULL) {
|
if (_ptr == NULL) {
|
||||||
initprintf("BARF: Not enough memory to read %s", _fileName);
|
initprintf("BARF: Not enough memory to read %d", lumpnum);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,30 +233,32 @@ void RFS::UnsetMark()
|
||||||
void RFS::ScriptError(const char *message)
|
void RFS::ScriptError(const char *message)
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
|
TArray<char> msg;
|
||||||
|
|
||||||
char *p = _pStartLine;
|
char *p = _pStartLine;
|
||||||
while (*p != '\n')
|
while (*p != '\n')
|
||||||
{
|
{
|
||||||
if (isprint(*p))
|
if (isprint(*p))
|
||||||
putchar(*p);
|
msg.Push(*p);
|
||||||
else
|
else
|
||||||
putchar(' ');
|
msg.Push(' ');
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
putchar('\n');
|
msg.Push('\n');
|
||||||
|
|
||||||
p = _pStartLine;
|
p = _pStartLine;
|
||||||
|
|
||||||
while (p < _pMark)
|
while (p < _pMark)
|
||||||
{
|
{
|
||||||
putchar(' ');
|
msg.Push(' ');
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
||||||
puts("^");
|
msg.Push('^');
|
||||||
|
msg.Push(0);
|
||||||
|
|
||||||
initprintf("Error in %s line %d: %s\n\n", _fileName, _curLine, message);
|
initprintf("Error in %s line %d: %s\n\n%s", _fileName, _curLine, message, msg.Data());
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t RFS::GetNextTag()
|
uint8_t RFS::GetNextTag()
|
||||||
|
@ -447,21 +447,21 @@ uint8_t RFS::GetNextTag()
|
||||||
// qAssert(1==0); // TODO - what to return here
|
// qAssert(1==0); // TODO - what to return here
|
||||||
}
|
}
|
||||||
|
|
||||||
void ParseScript(const char *scriptFileName)
|
void ParseScript(int lumpnum)
|
||||||
{
|
{
|
||||||
char text[256];
|
char text[256];
|
||||||
char char256_1[256];
|
char char256_1[256];
|
||||||
char char256_2[256];
|
char char256_2[256];
|
||||||
char fileName[BMAX_PATH];
|
char fileName[BMAX_PATH];
|
||||||
char inp[BMAX_PATH];
|
char inp[BMAX_PATH];
|
||||||
char zScriptDirectory[BMAX_PATH], zTemp1[BMAX_PATH], zTemp2[BMAX_PATH];
|
//char zScriptDirectory[BMAX_PATH], zTemp1[BMAX_PATH], zTemp2[BMAX_PATH];
|
||||||
|
|
||||||
SplitPath(scriptFileName, zScriptDirectory, zTemp1, zTemp2);
|
//SplitPath(scriptFileName, zScriptDirectory, zTemp1, zTemp2);
|
||||||
|
|
||||||
RFS rfs;
|
RFS rfs;
|
||||||
|
|
||||||
// AddExtension(name, ".RFS");
|
// AddExtension(name, ".RFS");
|
||||||
if (rfs.Open(scriptFileName))
|
if (rfs.Open(lumpnum))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -706,7 +706,9 @@ void ParseScript(const char *scriptFileName)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ParseScript(scriptBuffer);
|
// too dangerous if we want to cumulatively collect all RFS files
|
||||||
|
//fileSystem.Rehash();
|
||||||
|
//ParseScript(scriptBuffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -895,4 +897,20 @@ void addMemoryResource(char *filePath, char flags, int ID)
|
||||||
fileSystem.AddFromBuffer(zFilename, zType, buffer, nBytes, ID, flags);
|
fileSystem.AddFromBuffer(zFilename, zType, buffer, nBytes, ID, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void ReadAllRFS()
|
||||||
|
{
|
||||||
|
bool found = false;
|
||||||
|
auto numf = fileSystem.GetNumEntries();
|
||||||
|
for (int i = 0; i < numf; i++)
|
||||||
|
{
|
||||||
|
auto rl = fileSystem.GetResourceType(i);
|
||||||
|
if (rl == NAME_RFS)
|
||||||
|
{
|
||||||
|
ParseScript(i);
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (found) fileSystem.Rehash();
|
||||||
|
}
|
||||||
END_BLD_NS
|
END_BLD_NS
|
||||||
|
|
|
@ -1125,17 +1125,17 @@ void ClockStrobe()
|
||||||
//gGameClock++;
|
//gGameClock++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ReadAllRFS();
|
||||||
|
|
||||||
int GameInterface::app_main()
|
int GameInterface::app_main()
|
||||||
{
|
{
|
||||||
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
|
memcpy(&gGameOptions, &gSingleGameOptions, sizeof(GAMEOPTIONS));
|
||||||
gGameOptions.nMonsterSettings = !userConfig.nomonsters;
|
gGameOptions.nMonsterSettings = !userConfig.nomonsters;
|
||||||
bQuickStart = userConfig.nologo;
|
bQuickStart = userConfig.nologo;
|
||||||
|
ReadAllRFS();
|
||||||
#ifdef USE_QHEAP
|
#ifdef USE_QHEAP
|
||||||
Resource::heap = new QHeap(nMaxAlloc);
|
Resource::heap = new QHeap(nMaxAlloc);
|
||||||
#endif
|
#endif
|
||||||
//gSysRes.Init(pUserRFF ? pUserRFF : "BLOOD.RFF");
|
|
||||||
//gGuiRes.Init("GUI.RFF");
|
|
||||||
|
|
||||||
HookReplaceFunctions();
|
HookReplaceFunctions();
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,12 @@ int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FStr
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
DeleteStuff(deletelumps, maingamefiles);
|
DeleteStuff(deletelumps, maingamefiles);
|
||||||
|
Rehash();
|
||||||
|
return NumEntries;
|
||||||
|
}
|
||||||
|
|
||||||
|
void FileSystem::Rehash()
|
||||||
|
{
|
||||||
// [RH] Set up hash table
|
// [RH] Set up hash table
|
||||||
Hashes.Resize(NumLookupModes * 2 * NumEntries);
|
Hashes.Resize(NumLookupModes * 2 * NumEntries);
|
||||||
for (int i = 0; i < NumLookupModes; i++)
|
for (int i = 0; i < NumLookupModes; i++)
|
||||||
|
@ -138,7 +143,6 @@ int FileSystem::InitMultipleFiles (TArray<FString> &filenames, const TArray<FStr
|
||||||
InitHashChains ();
|
InitHashChains ();
|
||||||
FileInfo.ShrinkToFit();
|
FileInfo.ShrinkToFit();
|
||||||
Files.ShrinkToFit();
|
Files.ShrinkToFit();
|
||||||
return NumEntries;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -480,22 +484,7 @@ void FileSystem::AddLump(FResourceLump *lump)
|
||||||
{
|
{
|
||||||
FileRecord rec = { -1, lump};
|
FileRecord rec = { -1, lump};
|
||||||
FileInfo.Push(rec);
|
FileInfo.Push(rec);
|
||||||
|
NumEntries++;
|
||||||
for (int l = 0; l < NumLookupModes; l++)
|
|
||||||
{
|
|
||||||
int hash = 0;
|
|
||||||
if (l != (int)ELookupMode::IdWithType && lump->LumpName[l] != NAME_None)
|
|
||||||
{
|
|
||||||
hash = int(lump->LumpName[l]) % NumEntries;
|
|
||||||
}
|
|
||||||
else if (lump->ResourceId >= 0)
|
|
||||||
{
|
|
||||||
hash = int(lump->ResourceId) % NumEntries;
|
|
||||||
}
|
|
||||||
auto nh = FileInfo.Size() - 1;
|
|
||||||
NextFileIndex[l][nh] = FirstFileIndex[l][hash];
|
|
||||||
FirstFileIndex[l][hash] = nh;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
@ -996,11 +985,6 @@ bool FileSystem::CreatePathlessCopy(const char *name, int id, int flags)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a lump with this name already exists.
|
|
||||||
// Blood does not allow re-replacing external resources.
|
|
||||||
auto prevlump = FindFile(filename);
|
|
||||||
if (prevlump >= 0 && FileInfo[prevlump].rfnum == -1) return true;
|
|
||||||
|
|
||||||
// Create a clone of the resource to give it new lookup properties.
|
// Create a clone of the resource to give it new lookup properties.
|
||||||
auto newlump = new FClonedLump(FileInfo[lump].lump);
|
auto newlump = new FClonedLump(FileInfo[lump].lump);
|
||||||
newlump->LumpNameSetup(filename.GetChars());
|
newlump->LumpNameSetup(filename.GetChars());
|
||||||
|
|
|
@ -83,6 +83,7 @@ public:
|
||||||
|
|
||||||
int InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &todelete, int maingamefiles);
|
int InitMultipleFiles (TArray<FString> &filenames, const TArray<FString> &todelete, int maingamefiles);
|
||||||
void DeleteStuff(const TArray<FString>& deletelumps, int numgamefiles);
|
void DeleteStuff(const TArray<FString>& deletelumps, int numgamefiles);
|
||||||
|
void Rehash();
|
||||||
|
|
||||||
void AddFile (const char *filename, FileReader *wadinfo = NULL, bool nosubdirflag = false);
|
void AddFile (const char *filename, FileReader *wadinfo = NULL, bool nosubdirflag = false);
|
||||||
void AddAdditionalFile(const char* filename, FileReader* wadinfo = NULL) {}
|
void AddAdditionalFile(const char* filename, FileReader* wadinfo = NULL) {}
|
||||||
|
|
|
@ -171,6 +171,7 @@ struct FMemoryLump : public FResourceLump
|
||||||
{
|
{
|
||||||
FMemoryLump(const void* data, int length)
|
FMemoryLump(const void* data, int length)
|
||||||
{
|
{
|
||||||
|
LumpSize = length;
|
||||||
Cache.Resize(length);
|
Cache.Resize(length);
|
||||||
memcpy(Cache.Data(), data, length);
|
memcpy(Cache.Data(), data, length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ xx(WAV)
|
||||||
xx(OGG)
|
xx(OGG)
|
||||||
xx(FLAC)
|
xx(FLAC)
|
||||||
xx(VOC)
|
xx(VOC)
|
||||||
|
xx(RFS)
|
||||||
xx(Controlmessage)
|
xx(Controlmessage)
|
||||||
|
|
||||||
xx(MainMenu)
|
xx(MainMenu)
|
||||||
|
|
Loading…
Reference in a new issue