- handled approx. half of all cases where the address of level is taken.

This commit is contained in:
Christoph Oelckers 2019-01-28 00:55:21 +01:00
commit 648e472744
38 changed files with 122 additions and 128 deletions

View file

@ -560,7 +560,7 @@ void FParser::SF_Include(void)
else
mysnprintf(tempstr, countof(tempstr), "%i", (int)t_argv[0].value.i);
Script->ParseInclude(tempstr);
Script->ParseInclude(Level, tempstr);
}
}

View file

@ -333,13 +333,13 @@ char *DFsScript::ProcessFindChar(char *datap, char find)
//
//==========================================================================
void DFsScript::DryRunScript()
void DFsScript::DryRunScript(FLevelLocals *Level)
{
char *end = data + len;
char *rover = data;
// allocate space for the tokens
FParser parse(&level, this);
FParser parse(Level, this);
try
{
while(rover < end && *rover)
@ -387,11 +387,11 @@ void DFsScript::DryRunScript()
//
//==========================================================================
void DFsScript::Preprocess()
void DFsScript::Preprocess(FLevelLocals *Level)
{
len = (int)strlen(data);
ProcessFindChar(data, 0); // fill in everything
DryRunScript();
DryRunScript(Level);
}
//==========================================================================
@ -406,7 +406,7 @@ void DFsScript::Preprocess()
//
//==========================================================================
void DFsScript::ParseInclude(char *lumpname)
void DFsScript::ParseInclude(FLevelLocals *Level, char *lumpname)
{
int lumpnum;
char *lump;
@ -429,7 +429,7 @@ void DFsScript::ParseInclude(char *lumpname)
ProcessFindChar(lump, 0);
// now parse the lump
FParser parse(&level, this);
FParser parse(Level, this);
parse.Run(lump, lump, lump+lumplen);
// free the lump

View file

@ -196,7 +196,7 @@ void DFsScript::Serialize(FSerializer &arc)
//
//==========================================================================
void DFsScript::ParseScript(char *position, AActor **pTrigger)
void DFsScript::ParseScript(char *position, DFraggleThinker *th)
{
if (position == nullptr)
{
@ -211,11 +211,11 @@ void DFsScript::ParseScript(char *position, AActor **pTrigger)
return;
}
*pTrigger = trigger; // set trigger variable.
th->trigger_obj = trigger; // set trigger variable.
try
{
FParser parse(&level, this);
FParser parse(th->Level, this);
parse.Run(position, data, data + len);
}
catch (CFraggleScriptError &err)
@ -528,7 +528,7 @@ void DFraggleThinker::Tick()
next = current->next; // save before freeing
// continue the script
current->script->ParseScript (current->script->data + current->save_point, &trigger_obj);
current->script->ParseScript (current->script->data + current->save_point, this);
// free
current->Destroy();
@ -618,8 +618,8 @@ void T_PreprocessScripts(FLevelLocals *Level)
// levelscript started by player 0 'superplayer'
th->LevelScript->trigger = players[0].mo;
th->LevelScript->Preprocess();
th->LevelScript->ParseScript(nullptr, &th->trigger_obj);
th->LevelScript->Preprocess(Level);
th->LevelScript->ParseScript(nullptr, th);
}
}
@ -667,6 +667,6 @@ CCMD(fpuke)
}
else
{
T_RunScript(&level, atoi(argv[1]), players[consoleplayer].mo);
T_RunScript(currentUILevel, atoi(argv[1]), players[consoleplayer].mo);
}
}

View file

@ -35,6 +35,8 @@
#pragma pointers_to_members( full_generality, single_inheritance )
#endif
class DFraggleThinker;
class CFraggleScriptError : public CDoomError
{
@ -360,10 +362,10 @@ public:
DFsSection *FindSectionStart(const char *brace);
DFsSection *FindSectionEnd(const char *brace);
char *ProcessFindChar(char *data, char find);
void DryRunScript();
void Preprocess();
void ParseInclude(char *lumpname);
void ParseScript(char *rover, AActor **pTrigger);
void DryRunScript(FLevelLocals *Level);
void Preprocess(FLevelLocals *Level);
void ParseInclude(FLevelLocals *Level, char *lumpname);
void ParseScript(char *rover, DFraggleThinker *th);
void ParseData(char *rover, char *data, char *end);
};

View file

@ -429,7 +429,7 @@ void FParser::spec_script()
newscript->parent = Script; // remember parent
// preprocess the newscript now
newscript->Preprocess();
newscript->Preprocess(Level);
// we dont want to run the newscript, only add it
// jump past the newscript in parsing