[Scummvm-cvs-logs] CVS: scummvm/scumm intern.h,2.108,2.109 script.cpp,1.130,1.131 script_v2.cpp,2.194,2.195 scumm.h,1.298,1.299
Max Horn
fingolfin at users.sourceforge.net
Wed Sep 10 17:35:22 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv12116
Modified Files:
intern.h script.cpp script_v2.cpp scumm.h
Log Message:
fix for bug #776807 (MM: Jail Door Closes). Our doSentence implementation should now be pretty close to what the original does. But regressions are possible...
Index: intern.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/intern.h,v
retrieving revision 2.108
retrieving revision 2.109
diff -u -d -r2.108 -r2.109
--- intern.h 10 Sep 2003 15:02:58 -0000 2.108
+++ intern.h 10 Sep 2003 17:15:44 -0000 2.109
@@ -220,8 +220,6 @@
void resetSentence();
void setUserState(byte state);
- void stopObjectScript(int script, bool background);
-
/* Version 2 script opcodes */
void o2_actorFromPos();
void o2_actorSet();
Index: script.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script.cpp,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- script.cpp 10 Sep 2003 14:43:42 -0000 1.130
+++ script.cpp 10 Sep 2003 17:15:44 -0000 1.131
@@ -76,15 +76,15 @@
runScriptNested(slot);
}
-void Scumm::runObjectScript(int object, int entry, bool freezeResistant, bool recursive, int *vars) {
+void Scumm::runObjectScript(int object, int entry, bool freezeResistant, bool recursive, int *vars, int slot) {
ScriptSlot *s;
uint32 obcd;
- int slot, where, offs;
+ int where, offs;
if (!object)
return;
- if (!recursive)
+ if (!recursive && (_version >= 3))
stopObjectScript(object);
where = whereIsObject(object);
@@ -95,7 +95,10 @@
}
obcd = getOBCDOffs(object);
- slot = getScriptSlot();
+
+ // Find a free object slot, unless one was specified
+ if (slot == -1)
+ slot = getScriptSlot();
offs = getVerbEntrypoint(object, entry);
if (offs == 0)
Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.194
retrieving revision 2.195
diff -u -d -r2.194 -r2.195
--- script_v2.cpp 10 Sep 2003 15:02:58 -0000 2.194
+++ script_v2.cpp 10 Sep 2003 17:15:44 -0000 2.195
@@ -918,17 +918,44 @@
if (st->verb == 254) {
Scumm::stopObjectScript(st->objectA);
- } else if (st->verb != 253 && st->verb != 250) {
- VAR(VAR_ACTIVE_VERB) = st->verb;
- VAR(VAR_ACTIVE_OBJECT1) = st->objectA;
- VAR(VAR_ACTIVE_OBJECT2) = st->objectB;
-
- stopObjectScript(st->objectA, false);
- runObjectScript(st->objectA, st->verb, false, false, NULL);
} else {
- bool isBackgroundScript = (st->verb == 250);
- stopObjectScript(st->objectA, isBackgroundScript);
- runObjectScript(st->objectA, 253, isBackgroundScript, false, NULL);
+ bool isBackgroundScript;
+ bool isSpecialVerb;
+ if (st->verb != 253 && st->verb != 250) {
+ VAR(VAR_ACTIVE_VERB) = st->verb;
+ VAR(VAR_ACTIVE_OBJECT1) = st->objectA;
+ VAR(VAR_ACTIVE_OBJECT2) = st->objectB;
+
+ isBackgroundScript = false;
+ isSpecialVerb = false;
+ } else {
+ isBackgroundScript = (st->verb == 250);
+ isSpecialVerb = true;
+ st->verb = 253;
+ }
+
+ // Check if an object script for this object is already running. If
+ // so, reuse its script slot. Note that we abuse two script flags:
+ // freezeResistant and recursive. We use them to track two
+ // script flags used in V1/V2 games. The main reason we do it this
+ // ugly evil way is to avoid having to introduce yet another save
+ // game revision.
+ int slot = -1;
+ ScriptSlot *ss;
+ int i;
+
+ ss = vm.slot;
+ for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
+ if (st->objectA == ss->number &&
+ ss->freezeResistant == isBackgroundScript &&
+ ss->recursive == isSpecialVerb &&
+ (ss->where == WIO_ROOM || ss->where == WIO_INVENTORY || ss->where == WIO_FLOBJECT)) {
+ slot = i;
+ break;
+ }
+ }
+
+ runObjectScript(st->objectA, st->verb, isBackgroundScript, isSpecialVerb, NULL, slot);
}
break;
case 2:
@@ -1549,49 +1576,4 @@
VAR(VAR_SENTENCE_OBJECT1) = 0;
VAR(VAR_SENTENCE_OBJECT2) = 0;
VAR(VAR_SENTENCE_PREPOSITION) = 0;
-}
-
-enum {
- ssDead = 0,
- ssPaused = 1,
- ssRunning = 2
-};
-
-/* Stop an object script 'script'*/
-void Scumm_v2::stopObjectScript(int script, bool background) {
- ScriptSlot *ss;
- NestedScript *nest;
- int i, num;
-
- if (script == 0)
- return;
-
- ss = vm.slot;
- for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
- if (script == ss->number && ss->status != ssDead &&
- ss->freezeResistant == background &&
- (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;
- }
- }
-
- nest = vm.nest;
- num = _numNestedScripts;
-
- while (num > 0) {
- if (nest->number == script &&
- vm.slot[nest->slot].freezeResistant == background &&
- (nest->where == WIO_ROOM || nest->where == WIO_INVENTORY || nest->where == WIO_FLOBJECT)) {
- nest->number = 0xFF;
- nest->slot = 0xFF;
- nest->where = 0xFF;
- }
- nest++;
- num--;
- }
}
Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.298
retrieving revision 1.299
diff -u -d -r1.298 -r1.299
--- scumm.h 9 Sep 2003 17:29:21 -0000 1.298
+++ scumm.h 10 Sep 2003 17:15:44 -0000 1.299
@@ -563,7 +563,7 @@
bool isScriptRunning(int script) const; // FIXME - should be protected, used by Sound::startTalkSound
protected:
- void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars);
+ void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars, int slot = -1);
void runScriptNested(int script);
void executeScript();
void updateScriptPtr();
More information about the Scummvm-git-logs
mailing list