- fix handling of the global script in FraggleScript.
Depending on serialization order is not a good idea here, so now it's no longer stored as a parent in the main level script but explicitly checked for when looking for a variable.
This commit is contained in:
parent
4d98c10ea3
commit
11c453a71f
5 changed files with 25 additions and 22 deletions
|
|
@ -364,7 +364,7 @@ DFsVariable *DFsScript::VariableForName(const char *name)
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
DFsVariable *DFsScript::FindVariable(const char *name)
|
||||
DFsVariable *DFsScript::FindVariable(const char *name, DFsScript *GlobalScript)
|
||||
{
|
||||
DFsVariable *var;
|
||||
DFsScript *current = this;
|
||||
|
|
@ -374,7 +374,13 @@ DFsVariable *DFsScript::FindVariable(const char *name)
|
|||
// check this script
|
||||
if ((var = current->VariableForName(name)))
|
||||
return var;
|
||||
current = current->parent; // try the parent of this one
|
||||
|
||||
// Since the global script cannot be serialized, we cannot store a pointer to it, because this cannot be safely restored during deserialization.
|
||||
// To compensate we need to check the relationship explicitly here.
|
||||
if (current->parent == nullptr && current != GlobalScript)
|
||||
current = GlobalScript;
|
||||
else
|
||||
current = current->parent; // try the parent of this one
|
||||
}
|
||||
|
||||
return NULL; // no variable
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue