1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2025-02-04 10:34:01 +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()
{
destroy();
}
bool Path::hasScript()
@ -288,21 +289,20 @@ void Path::parseWarpNodeData(const std::string &dataString)
void Path::refreshScript()
{
amount = 0;
content.clear();
label.clear();
content.clear();
label.clear();
destroy();
// HACK: clean up
/*+ dsq->game->sceneName + "_"*/
script = 0;
warpMap = warpNode = "";
toFlip = -1;
stringToLower(name);
{
SimpleIStringStream is(name.c_str(), SimpleIStringStream::REUSE);
is >> label >> content >> amount;
}
{
SimpleIStringStream is(name.c_str(), SimpleIStringStream::REUSE);
is >> label >> content >> amount;
}
std::string scr;
if (dsq->mod.isActive())
@ -423,30 +423,14 @@ void Path::refreshScript()
std::string dummy, warpTypeStr;
SimpleIStringStream is(name);
is >> dummy >> warpMap >> warpTypeStr;
// warpType is just char, which does not automatically skip spaces like strings would
warpType = warpTypeStr.length() ? warpTypeStr[0] : 0;
// warpType is just char, which does not automatically skip spaces like strings would
warpType = warpTypeStr.length() ? warpTypeStr[0] : 0;
if (warpMap.find("vedha")!=std::string::npos)
{
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;
}
else if (label == "se")
{

View file

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