[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.101,2.102 script_v2.cpp,2.155,2.156
Jochen Hoenicke
hoenicke at users.sourceforge.net
Fri Jul 18 11:59:12 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv781
Modified Files:
intern.h script_v2.cpp
Log Message:
Fix recursive calls of object scripts. In V2 for each object two script
can be active at the same time: One 253 script and one normal script.
We misuse the recursive flag to mark 253 scripts. When starting a 253
script we stop a script that has recursive flag set and when starting
a normal script we stop the script that doesn't.
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.101
retrieving revision 2.102
diff -u -d -r2.101 -r2.102
--- intern.h 14 Jul 2003 22:21:11 -0000 2.101
+++ intern.h 18 Jul 2003 18:55:04 -0000 2.102
@@ -217,6 +217,9 @@
void resetSentence();
void setUserState(byte state);
+ void runObjectScript(int object, int entry, bool freezeResistant, bool recursive, int *vars);
+ void stopObjectScript(int script, bool recursive);
+
/* Version 2 script opcodes */
void o2_actorFromPos();
void o2_actorSet();
Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.155
retrieving revision 2.156
diff -u -d -r2.155 -r2.156
--- script_v2.cpp 15 Jul 2003 18:18:29 -0000 2.155
+++ script_v2.cpp 18 Jul 2003 18:55:04 -0000 2.156
@@ -906,7 +906,7 @@
_sentenceNum--;
if (st->verb == 254) {
- stopObjectScript(st->objectA);
+ stopObjectScript(st->objectA, true);
} else if (st->verb != 253 && st->verb != 250) {
VAR(VAR_ACTIVE_VERB) = st->verb;
VAR(VAR_ACTIVE_OBJECT1) = st->objectA;
@@ -1476,4 +1476,88 @@
VAR(VAR_SENTENCE_OBJECT1) = 0;
VAR(VAR_SENTENCE_OBJECT2) = 0;
VAR(VAR_SENTENCE_PREPOSITION) = 0;
+}
+
+enum {
+ ssDead = 0,
+ ssPaused = 1,
+ ssRunning = 2
+};
+
+void Scumm_v2::runObjectScript(int object, int entry, bool freezeResistant, bool recursive, int *vars) {
+ ScriptSlot *s;
+ uint32 obcd;
+ int slot, where, offs;
+
+ if (!object)
+ return;
+
+ stopObjectScript(object, recursive);
+
+ where = whereIsObject(object);
+
+ if (where == WIO_NOT_FOUND) {
+ warning("Code for object %d not in room %d", object, _roomResource);
+ return;
+ }
+
+ obcd = getOBCDOffs(object);
+ slot = getScriptSlot();
+
+ offs = getVerbEntrypoint(object, entry);
+ if (offs == 0)
+ return;
+
+ s = &vm.slot[slot];
+ s->number = object;
+ s->offs = obcd + offs;
+ s->status = ssRunning;
+ s->where = where;
+ s->freezeResistant = freezeResistant;
+ s->recursive = recursive;
+ s->freezeCount = 0;
+ s->delayFrameCount = 0;
+
+ initializeLocals(slot, vars);
+
+ runScriptNested(slot);
+}
+
+/* Stop an object script 'script'*/
+void Scumm_v2::stopObjectScript(int script, bool recursive) {
+ ScriptSlot *ss;
+ NestedScript *nest;
+ int i, num;
+
+ if (script == 0)
+ return;
+
+ nest = vm.nest;
+ num = _numNestedScripts;
+
+ while (num > 0) {
+ if (nest->number == script &&
+ vm.slot[nest->slot].recursive == recursive &&
+ (nest->where == WIO_ROOM || nest->where == WIO_INVENTORY || nest->where == WIO_FLOBJECT)) {
+ nest->number = 0xFF;
+ nest->slot = 0xFF;
+ nest->where = 0xFF;
+ }
+ nest++;
+ num--;
+ }
+
+ ss = vm.slot;
+ for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
+ if (script == ss->number && ss->status != ssDead &&
+ ss->recursive == recursive &&
+ (ss->where == WIO_ROOM || ss->where == WIO_INVENTORY || ss->where == WIO_FLOBJECT)) {
+ if (ss->cutsceneOverride)
+ error("Object %d stopped with active cutscene/override", script);
+ ss->number = 0;
+ ss->status = ssDead;
+ if (_currentScript == i)
+ _currentScript = 0xFF;
+ }
+ }
}
More information about the Scummvm-git-logs
mailing list