mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-09 04:16:34 +00:00
DIRECTOR: XOBJ: Allow multiple SpaceMgr::m_parseText calls
SpaceMgr::m_parseText can be called multiple times, and assume the context from the previous call exists. For example, ml.dir in The Dark Eye will call it twice; the first time with a full hierarchy starting with a SPACECOLLECTION, the second time with a hierarchy starting with a SPACE and assuming _curSpaceCollection was set by the previous call. We should be able to reuse the object's global "_cur" values for this, as the game will override them soon after loading the model with a SpaceMgr::m_setCurData call. Fixes loading the scene graph data in The Dark Eye.
This commit is contained in:
parent
debb6425d4
commit
6db29a5f23
@ -225,10 +225,15 @@ void SpaceMgr::m_parseText(int nargs) {
|
|||||||
SpaceMgrXObject *me = static_cast<SpaceMgrXObject *>(g_lingo->_state->me.u.obj);
|
SpaceMgrXObject *me = static_cast<SpaceMgrXObject *>(g_lingo->_state->me.u.obj);
|
||||||
|
|
||||||
Common::String result = *text.u.s;
|
Common::String result = *text.u.s;
|
||||||
Common::String curSpaceCollection;
|
if (debugLevelSet(5)) {
|
||||||
Common::String curSpace;
|
Common::String format = result;
|
||||||
Common::String curNode;
|
for (int i = 0; i < (int)format.size(); i++) {
|
||||||
Common::String curView;
|
if (format[i] == '\r')
|
||||||
|
format.replace(i, 1, "\n");
|
||||||
|
}
|
||||||
|
debugC(5, kDebugXObj, "SpaceMgr::m_parseText:\n%s", format.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
Common::StringTokenizer instructions = Common::StringTokenizer(result, "\r");
|
Common::StringTokenizer instructions = Common::StringTokenizer(result, "\r");
|
||||||
|
|
||||||
while (!instructions.empty()) {
|
while (!instructions.empty()) {
|
||||||
@ -236,45 +241,45 @@ void SpaceMgr::m_parseText(int nargs) {
|
|||||||
Common::StringTokenizer instruction = Common::StringTokenizer(instructionBody, " ");
|
Common::StringTokenizer instruction = Common::StringTokenizer(instructionBody, " ");
|
||||||
Common::String type = instruction.nextToken();
|
Common::String type = instruction.nextToken();
|
||||||
if (type == "SPACECOLLECTION") {
|
if (type == "SPACECOLLECTION") {
|
||||||
curSpaceCollection = instruction.nextToken();
|
me->_curSpaceCollection = instruction.nextToken();
|
||||||
curSpace = "";
|
me->_curSpace = "";
|
||||||
curNode = "";
|
me->_curNode = "";
|
||||||
curView = "";
|
me->_curView = "";
|
||||||
if (!(me->_spaceCollections.contains(curSpaceCollection) && me->_checkForDups)) {
|
if (!(me->_spaceCollections.contains(me->_curSpaceCollection) && me->_checkForDups)) {
|
||||||
me->_spaceCollections[curSpaceCollection] = SpaceCollection();
|
me->_spaceCollections[me->_curSpaceCollection] = SpaceCollection();
|
||||||
}
|
}
|
||||||
} else if (type == "SPACE") {
|
} else if (type == "SPACE") {
|
||||||
curSpace = instruction.nextToken();
|
me->_curSpace = instruction.nextToken();
|
||||||
curNode = "";
|
me->_curNode = "";
|
||||||
curView = "";
|
me->_curView = "";
|
||||||
SpaceCollection &sc = me->_spaceCollections.getVal(curSpaceCollection);
|
SpaceCollection &sc = me->_spaceCollections.getVal(me->_curSpaceCollection);
|
||||||
if (!(sc.spaces.contains(curSpaceCollection) && me->_checkForDups)) {
|
if (!(sc.spaces.contains(me->_curSpaceCollection) && me->_checkForDups)) {
|
||||||
sc.spaces[curSpace] = Space();
|
sc.spaces[me->_curSpace] = Space();
|
||||||
}
|
}
|
||||||
} else if (type == "NODE") {
|
} else if (type == "NODE") {
|
||||||
curNode = instruction.nextToken();
|
me->_curNode = instruction.nextToken();
|
||||||
curView = "";
|
me->_curView = "";
|
||||||
SpaceCollection &sc = me->_spaceCollections.getVal(curSpaceCollection);
|
SpaceCollection &sc = me->_spaceCollections.getVal(me->_curSpaceCollection);
|
||||||
Space &s = sc.spaces.getVal(curSpace);
|
Space &s = sc.spaces.getVal(me->_curSpace);
|
||||||
if (!(s.nodes.contains(curNode) && me->_checkForDups)) {
|
if (!(s.nodes.contains(me->_curNode) && me->_checkForDups)) {
|
||||||
s.nodes[curNode] = Node();
|
s.nodes[me->_curNode] = Node();
|
||||||
}
|
}
|
||||||
} else if (type == "VIEW") {
|
} else if (type == "VIEW") {
|
||||||
curView = instruction.nextToken();
|
me->_curView = instruction.nextToken();
|
||||||
SpaceCollection &sc = me->_spaceCollections.getVal(curSpaceCollection);
|
SpaceCollection &sc = me->_spaceCollections.getVal(me->_curSpaceCollection);
|
||||||
Space &s = sc.spaces.getVal(curSpace);
|
Space &s = sc.spaces.getVal(me->_curSpace);
|
||||||
Node &n = s.nodes.getVal(curNode);
|
Node &n = s.nodes.getVal(me->_curNode);
|
||||||
if (!(n.views.contains(curView) && me->_checkForDups)) {
|
if (!(n.views.contains(me->_curView) && me->_checkForDups)) {
|
||||||
n.views[curView] = View();
|
n.views[me->_curView] = View();
|
||||||
n.views[curView].payload = instruction.nextToken();
|
n.views[me->_curView].payload = instruction.nextToken();
|
||||||
}
|
}
|
||||||
} else if (type == "LLINK") {
|
} else if (type == "LLINK") {
|
||||||
Common::String target = instruction.nextToken();
|
Common::String target = instruction.nextToken();
|
||||||
Common::String payload = instruction.nextToken();
|
Common::String payload = instruction.nextToken();
|
||||||
SpaceCollection &sc = me->_spaceCollections.getVal(curSpaceCollection);
|
SpaceCollection &sc = me->_spaceCollections.getVal(me->_curSpaceCollection);
|
||||||
Space &s = sc.spaces.getVal(curSpace);
|
Space &s = sc.spaces.getVal(me->_curSpace);
|
||||||
Node &n = s.nodes.getVal(curNode);
|
Node &n = s.nodes.getVal(me->_curNode);
|
||||||
View &v = n.views.getVal(curView);
|
View &v = n.views.getVal(me->_curView);
|
||||||
if (!(v.llinks.contains(target) && me->_checkForDups)) {
|
if (!(v.llinks.contains(target) && me->_checkForDups)) {
|
||||||
v.llinks[target] = LLink();
|
v.llinks[target] = LLink();
|
||||||
v.llinks[target].payload = payload;
|
v.llinks[target].payload = payload;
|
||||||
@ -284,15 +289,6 @@ void SpaceMgr::m_parseText(int nargs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debugLevelSet(5)) {
|
|
||||||
Common::String format = result;
|
|
||||||
for (int i = 0; i < (int)format.size(); i++) {
|
|
||||||
if (format[i] == '\r')
|
|
||||||
format.replace(i, 1, "\n");
|
|
||||||
}
|
|
||||||
debugC(5, kDebugXObj, "SpaceMgr::m_parseText: %s", format.c_str());
|
|
||||||
}
|
|
||||||
|
|
||||||
g_lingo->push(Datum(0));
|
g_lingo->push(Datum(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user