1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-10 14:14:05 +00:00

Some fixes for node script init/cleanup.

An Errorneous script could cause a node script instance leaking,
preventing the leaked inctances from unloading, and thus
locking the whole file, preventing it from re-loading when relaoding
the map, until the mod was exited.

Also init nodes properly when cloned or changed.
This commit is contained in:
fgenesis 2012-02-18 23:35:30 +01:00
parent 0cd0971671
commit 568178bbb4
2 changed files with 20 additions and 29 deletions

View file

@ -225,6 +225,7 @@ void Path::destroy()
Path::~Path() Path::~Path()
{ {
destroy();
} }
bool Path::hasScript() bool Path::hasScript()
@ -291,9 +292,8 @@ void Path::refreshScript()
content.clear(); content.clear();
label.clear(); label.clear();
// HACK: clean up destroy();
/*+ dsq->game->sceneName + "_"*/
script = 0;
warpMap = warpNode = ""; warpMap = warpNode = "";
toFlip = -1; toFlip = -1;
@ -430,23 +430,7 @@ void Path::refreshScript()
{ {
naijaHome = true; naijaHome = true;
} }
//debugLog(label + " " + warpMap + " " + warpType);
/*
std::string parse = name;
int pos = 0;
pos = parse.find('_');
parse = parse.substr(pos+1, parse.getLength2D());
pos = parse.find('_');
warpMap = parse.substr(0, pos-1);
parse = parse.substr(pos+1, parse.getLength2D());
pos = parse.find('_');
std::string
*/
pathType = PATH_WARP; pathType = PATH_WARP;
} }
else if (label == "se") else if (label == "se")
{ {

View file

@ -927,8 +927,14 @@ void SceneEditor::enterName()
Path *p = getSelectedPath(); Path *p = getSelectedPath();
if (p) if (p)
{ {
p->name = dsq->getUserInputString("PathName", p->name); std::string newname = dsq->getUserInputString("PathName", p->name);
bool changed = newname != p->name;
p->name = newname;
if (changed)
{
p->refreshScript(); p->refreshScript();
p->init();
}
} }
} }
} }
@ -3224,6 +3230,7 @@ void SceneEditor::cloneSelectedElement()
dsq->game->addPath(newp); dsq->game->addPath(newp);
selectedIdx = dsq->game->getNumPaths()-1; selectedIdx = dsq->game->getNumPaths()-1;
newp->init();
} }
} }