Note/Edit: I just realized I was still trying to use Wads.FindLump() in my demo code. However when changing to CheckNumForFullName(), the game stops responding and seems to consume lots of memory, after force quitting via Task Manager. I haven't tested further yet but my first thought is it's the loop.
Edit2: Updated the code here in the post. Found a nice example from Graf here on trying to load lumps. So I've integrated it and changed my test file into more of a definition file and created a quick and dirty parser loop. Again the game behaves as stated in my first edit. This seems to be loop related. The looping function zWindow_Init() is called from OnRegister(), is that a problem?
Code: Select all
class zWin_Events : EventHandler
{
zWinDefs zDefs;
CVar cvZDebug;
bool bFileNamesLoaded, // true when "fileNames.zwin" has been read
bPicsLoaded; // true when file names have been loaded to NULL_ZWIN
// Primary Initialization
override void OnRegister()
{
zDefs = zWinDefs.Get();
cvZDebug = CVar.FindCVar(zDefs.zcv_Debug);
bFileNamesLoaded = bPicsLoaded = false;
consoleDebugMessage("Z-Windows Primary Handler Registered!");
zWindow_Init();
}
// Z-Window Definition Parser
void zWindow_Init()
{
consoleDebugMessage("ZWIN-PH : Z-Window Definition Parser executing.");
Array<string> fileNames;
int lump = zDefs.NO_FILE;
// Check for lump by full path
lump = Wads.CheckNumForFullName(zDefs.zfln_zWindowPath);
// Try normal lookup
if (lump == zDefs.NO_FILE)
{
consoleDebugMessage("ZWIN-PH : Full path search for window definitions failed\ntrying normal lookup.");
lump = Wads.CheckNumForName(zDefs.zfln_zWindow, Wads.ns_global);
}
//File Not Found
if (lump == zDefs.NO_FILE)
consoleDebugMessage("ZWIN-PH : NO ZWINDOW DEFINITIONS FOUND!", zDefs.FORCE);
// File was found, comence reading
else
{
consoleDebugMessage("ZWIN-PH : Storing Definition file names.");
string line = zDefs.NOTHING;
bool isMaster = false;
int reads = 0;
while (line != zDefs.FILE_END && (isMaster || reads == 0))
{
line = Wads.ReadLump(lump);
if (reads == 0 && line == zDefs.MASTER_HEADER)
{
consoleDebugMessage("ZWIN-PH : File is a valid Master.");
isMaster = true;
}
else if (isMaster && line != zDefs.FILE_END)
{
fileNames.Push(line);
if (cvZDebug.GetBool() == true)
console.printf("ZWIN-PH : File %s stored in slot %i.", fileNames[reads], reads);
reads++;
}
}
}
}
// Prints a message to the console if the debug cvar is on
// - full debug info is output if cvar is changed at titlescreen, not sure about titlemap
// - cvar is not saved to ini and is a user cvar
void consoleDebugMessage(string message, bool force = false)
{
if (cvZDebug.GetBool() || force)
Console.Printf(message);
}
override void WorldTick()
{
}
override void RenderOverlay(RenderEvent e)
{
}
}
Spoiler: Old Code