mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-02-09 21: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:
parent
0cd0971671
commit
568178bbb4
2 changed files with 20 additions and 29 deletions
|
@ -225,6 +225,7 @@ void Path::destroy()
|
||||||
|
|
||||||
Path::~Path()
|
Path::~Path()
|
||||||
{
|
{
|
||||||
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Path::hasScript()
|
bool Path::hasScript()
|
||||||
|
@ -288,21 +289,20 @@ void Path::parseWarpNodeData(const std::string &dataString)
|
||||||
void Path::refreshScript()
|
void Path::refreshScript()
|
||||||
{
|
{
|
||||||
amount = 0;
|
amount = 0;
|
||||||
content.clear();
|
content.clear();
|
||||||
label.clear();
|
label.clear();
|
||||||
|
|
||||||
|
destroy();
|
||||||
|
|
||||||
// HACK: clean up
|
|
||||||
/*+ dsq->game->sceneName + "_"*/
|
|
||||||
script = 0;
|
|
||||||
warpMap = warpNode = "";
|
warpMap = warpNode = "";
|
||||||
toFlip = -1;
|
toFlip = -1;
|
||||||
|
|
||||||
stringToLower(name);
|
stringToLower(name);
|
||||||
|
|
||||||
{
|
{
|
||||||
SimpleIStringStream is(name.c_str(), SimpleIStringStream::REUSE);
|
SimpleIStringStream is(name.c_str(), SimpleIStringStream::REUSE);
|
||||||
is >> label >> content >> amount;
|
is >> label >> content >> amount;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string scr;
|
std::string scr;
|
||||||
if (dsq->mod.isActive())
|
if (dsq->mod.isActive())
|
||||||
|
@ -423,30 +423,14 @@ void Path::refreshScript()
|
||||||
std::string dummy, warpTypeStr;
|
std::string dummy, warpTypeStr;
|
||||||
SimpleIStringStream is(name);
|
SimpleIStringStream is(name);
|
||||||
is >> dummy >> warpMap >> warpTypeStr;
|
is >> dummy >> warpMap >> warpTypeStr;
|
||||||
// warpType is just char, which does not automatically skip spaces like strings would
|
// warpType is just char, which does not automatically skip spaces like strings would
|
||||||
warpType = warpTypeStr.length() ? warpTypeStr[0] : 0;
|
warpType = warpTypeStr.length() ? warpTypeStr[0] : 0;
|
||||||
|
|
||||||
if (warpMap.find("vedha")!=std::string::npos)
|
if (warpMap.find("vedha")!=std::string::npos)
|
||||||
{
|
{
|
||||||
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")
|
||||||
{
|
{
|
||||||
|
|
|
@ -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);
|
||||||
p->refreshScript();
|
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);
|
dsq->game->addPath(newp);
|
||||||
selectedIdx = dsq->game->getNumPaths()-1;
|
selectedIdx = dsq->game->getNumPaths()-1;
|
||||||
|
newp->init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue