[Scummvm-cvs-logs] CVS: scummvm/scumm akos.cpp,1.52,1.53 gfx.cpp,2.115,2.116 object.cpp,1.104,1.105 script_v2.cpp,2.120,2.121 script_v5.cpp,1.100,1.101 script_v6.cpp,1.125,1.126 script_v8.cpp,2.165,2.166 sound.cpp,1.120,1.121
Max Horn
fingolfin at users.sourceforge.net
Fri May 23 06:25:11 CEST 2003
Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv18067
Modified Files:
akos.cpp gfx.cpp object.cpp script_v2.cpp script_v5.cpp
script_v6.cpp script_v8.cpp sound.cpp
Log Message:
replaced many unsafe uses of derefActorSafe by derefActor; replaced derefActorSafe/assert pairs by derefActor (gives better error message); replaced various derefActorSafe/if(a!=0) pairs by derefActor (in cases where the deref should never fail, ever, except due to a bug in ScummVM)
Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- akos.cpp 19 May 2003 09:02:16 -0000 1.52
+++ akos.cpp 23 May 2003 13:24:39 -0000 1.53
@@ -1464,7 +1464,7 @@
switch (code) {
case AKC_StartAnimInActor:
- akos_queCommand(4, derefActorSafe(a->getAnimVar(GB(2)), "akos_increaseAnim:29"), a->getAnimVar(GB(3)), 0);
+ akos_queCommand(4, derefActor(a->getAnimVar(GB(2)), "akos_increaseAnim:29"), a->getAnimVar(GB(3)), 0);
continue;
case AKC_Random:
@@ -1510,7 +1510,7 @@
akos_queCommand(4, a, a->getAnimVar(GB(2)), 0);
continue;
case AKC_SetVarInActor:
- derefActorSafe(a->getAnimVar(GB(2)), "akos_increaseAnim:9")->setAnimVar(GB(3), GW(4));
+ derefActor(a->getAnimVar(GB(2)), "akos_increaseAnim:9")->setAnimVar(GB(3), GW(4));
continue;
case AKC_HideActor:
akos_queCommand(1, a, 0, 0);
Index: gfx.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/gfx.cpp,v
retrieving revision 2.115
retrieving revision 2.116
diff -u -d -r2.115 -r2.116
--- gfx.cpp 21 May 2003 18:09:46 -0000 2.115
+++ gfx.cpp 23 May 2003 13:24:40 -0000 2.116
@@ -665,7 +665,7 @@
x = _virtualMouse.x;
y = _virtualMouse.y;
} else {
- Actor *a = a = derefActorSafe(VAR(VAR_EGO), "drawFlashlight");
+ Actor *a = derefActor(VAR(VAR_EGO), "drawFlashlight");
x = a->x;
y = a->y;
}
@@ -2062,7 +2062,6 @@
}
void Scumm::setCameraFollows(Actor *a) {
- assert(a != NULL);
if (_features & GF_AFTER_V7) {
byte oldfollow = camera._follows;
@@ -2103,9 +2102,8 @@
setCameraAt(a->x, 0);
for (i = 1; i < _numActors; i++) {
- a = derefActor(i);
- if (a->isInCurrentRoom())
- a->needRedraw = true;
+ if (_actors[i].isInCurrentRoom())
+ _actors[i].needRedraw = true;
}
runHook(0);
}
@@ -2131,7 +2129,7 @@
Actor *a = NULL;
if (camera._follows) {
- a = derefActorSafe(camera._follows, "moveCamera");
+ a = derefActor(camera._follows, "moveCamera");
if (abs(camera._cur.x - a->x) > VAR(VAR_CAMERA_THRESHOLD_X) ||
abs(camera._cur.y - a->y) > VAR(VAR_CAMERA_THRESHOLD_Y)) {
camera._movingToActor = true;
@@ -2234,7 +2232,7 @@
}
if (camera._mode == CM_FOLLOW_ACTOR) {
- a = derefActorSafe(camera._follows, "moveCamera");
+ a = derefActor(camera._follows, "moveCamera");
actorx = a->x;
t = (actorx >> 3) - _screenStartStrip;
@@ -2251,7 +2249,7 @@
}
if (camera._movingToActor) {
- a = derefActorSafe(camera._follows, "moveCamera(2)");
+ a = derefActor(camera._follows, "moveCamera(2)");
camera._dest.x = a->x;
}
@@ -2344,7 +2342,7 @@
}
old = camera._follows;
- setCameraFollows(derefActorSafe(act, "actorFollowCamera"));
+ setCameraFollows(derefActor(act, "actorFollowCamera"));
if (camera._follows != old)
runHook(0);
Index: object.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/object.cpp,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- object.cpp 22 May 2003 15:30:27 -0000 1.104
+++ object.cpp 23 May 2003 13:24:40 -0000 1.105
@@ -879,7 +879,7 @@
int i;
if (obj < _numActors)
- return derefActorSafe(obj, "getObjOrActorName")->getActorName();
+ return derefActor(obj, "getObjOrActorName")->getActorName();
if (_features & GF_SMALL_HEADER) {
byte offset = 0;
@@ -1179,7 +1179,7 @@
if (obj < _numActors) {
if (obj < 1)
return 0; /* fix for indy4's map */
- return derefActorSafe(obj, "getObjX")->x;
+ return derefActor(obj, "getObjX")->x;
} else {
if (whereIsObject(obj) == WIO_NOT_FOUND)
return -1;
@@ -1193,7 +1193,7 @@
if (obj < _numActors) {
if (obj < 1)
return 0; /* fix for indy4's map */
- return derefActorSafe(obj, "getObjY")->y;
+ return derefActor(obj, "getObjY")->y;
} else {
if (whereIsObject(obj) == WIO_NOT_FOUND)
return -1;
@@ -1210,7 +1210,7 @@
int Scumm::getObjNewDir(int obj) {
int dir;
if (obj < _numActors) {
- dir = derefActorSafe(obj, "getObjNewDir")->facing;
+ dir = derefActor(obj, "getObjNewDir")->facing;
} else {
int x, y;
getObjectXYPos(obj, x, y, dir);
@@ -1276,7 +1276,7 @@
if (getObjectOrActorXY(b, x, y) == -1)
return -1;
if (b < _numActors)
- i = derefActorSafe(b, "unkObjProc1")->scalex;
+ i = derefActor(b, "unkObjProc1")->scalex;
} else {
x = b;
y = c;
@@ -1286,7 +1286,7 @@
if (getObjectOrActorXY(e, x2, y2) == -1)
return -1;
if (e < _numActors)
- j = derefActorSafe(e, "unkObjProc1(2)")->scalex;
+ j = derefActor(e, "unkObjProc1(2)")->scalex;
} else {
x2 = e;
y2 = f;
Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.120
retrieving revision 2.121
diff -u -d -r2.120 -r2.121
--- script_v2.cpp 23 May 2003 12:07:36 -0000 2.120
+++ script_v2.cpp 23 May 2003 13:24:40 -0000 2.121
@@ -642,8 +642,7 @@
}
void Scumm_v2::o2_waitForActor() {
- Actor *a = derefActorSafe(getVarOrDirectByte(0x80), "o2_waitForActor");
- assert(a);
+ Actor *a = derefActor(getVarOrDirectByte(0x80), "o2_waitForActor");
if (a->moving) {
_scriptPointer -= 2;
o5_breakHere();
@@ -679,8 +678,7 @@
return;
}
- a = derefActorSafe(act, "actorSet");
- assert(a);
+ a = derefActor(act, "actorSet");
switch (_opcode) {
case 1: // Actor Sound
@@ -989,8 +987,7 @@
void Scumm_v2::o2_walkActorTo() {
int x, y;
Actor *a;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o2_walkActorTo");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o2_walkActorTo");
x = getVarOrDirectByte(0x40) * 8;
y = getVarOrDirectByte(0x20) * 2;
@@ -1003,8 +1000,7 @@
int x, y;
Actor *a;
- a = derefActorSafe(act, "o2_putActor");
- assert(a);
+ a = derefActor(act, "o2_putActor");
x = getVarOrDirectByte(0x40) * 8;
y = getVarOrDirectByte(0x20) * 2;
@@ -1025,8 +1021,7 @@
int obj;
Actor *a;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o2_walkActorToObject");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o2_walkActorToObject");
obj = getVarOrDirectWord(0x40);
if (whereIsObject(obj) != WIO_NOT_FOUND) {
int x, y, dir;
@@ -1039,8 +1034,7 @@
int obj, x, y;
Actor *a;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o2_putActorAtObject");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o2_putActorAtObject");
obj = getVarOrDirectByte(0x40);
if (whereIsObject(obj) != WIO_NOT_FOUND)
@@ -1057,8 +1051,7 @@
int act = getVarOrDirectByte(0x80);
int elevation = getVarOrDirectByte(0x40);
- Actor *a = derefActorSafe(act, "o2_setActorElevation");
- assert(a);
+ Actor *a = derefActor(act, "o2_setActorElevation");
a->elevation = elevation;
}
@@ -1066,8 +1059,7 @@
int act = getVarOrDirectByte(0x80);
int anim = getVarOrDirectByte(0x40);
- Actor *a = derefActorSafe(act, "o2_animateActor");
- assert(a);
+ Actor *a = derefActor(act, "o2_animateActor");
a->animateActor(anim);
}
@@ -1117,8 +1109,7 @@
obj = getVarOrDirectWord(0x80);
room = getVarOrDirectByte(0x40);
- a = derefActorSafe(VAR(VAR_EGO), "o2_loadRoomWithEgo");
- assert(a);
+ a = derefActor(VAR(VAR_EGO), "o2_loadRoomWithEgo");
a->putActor(0, 0, room);
_egoPositioned = false;
@@ -1368,8 +1359,7 @@
void Scumm_v2::o2_getActorWalkBox() {
Actor *a;
getResultPos();
- a = derefActorSafe(getVarOrDirectByte(0x80), "o2_getActorWalkbox");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o2_getActorWalkbox");
setResult(a->walkbox);
}
Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.100
retrieving revision 1.101
diff -u -d -r1.100 -r1.101
--- script_v5.cpp 23 May 2003 12:08:36 -0000 1.100
+++ script_v5.cpp 23 May 2003 13:24:40 -0000 1.101
@@ -412,8 +412,7 @@
ss->number, _scriptPointer - _scriptOrgPointer);
}
- a = derefActorSafe(act, "actorSet");
- assert(a);
+ a = derefActor(act, "o5_actorSet");
while ((_opcode = fetchScriptByte()) != 0xFF) {
if (_features & GF_SMALL_HEADER)
@@ -545,8 +544,7 @@
// Class '0' means: clean all class data
_classData[obj] = 0;
if ((_features & GF_SMALL_HEADER) && obj <= _numActors) {
- Actor *a = derefActorSafe(obj, "setClass");
- assert(a);
+ Actor *a = derefActor(obj, "o5_setClass");
a->ignoreBoxes = false;
a->forceClip = 0;
}
@@ -572,13 +570,7 @@
void Scumm_v5::o5_animateActor() {
int act = getVarOrDirectByte(0x80);
int anim = getVarOrDirectByte(0x40);
-
- Actor *a = derefActorSafe(act, "o5_animateActor");
- if (!a) {
- warning("Invalid actor %d in o5_animateActor", act);
- return;
- }
-
+ Actor *a = derefActor(act, "o5_animateActor");
a->animateActor(anim);
}
@@ -890,17 +882,9 @@
}
void Scumm_v5::o5_faceActor() {
- int act, obj;
- Actor *a;
- act = getVarOrDirectByte(0x80);
- obj = getVarOrDirectWord(0x40);
-
- a = derefActorSafe(act, "o5_faceActor");
- if (!a) {
- warning("Invalid actor %d in o5_faceActor", act);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ int obj = getVarOrDirectWord(0x40);
+ Actor *a = derefActor(act, "o5_faceActor");
a->faceToObject(obj);
}
@@ -928,82 +912,37 @@
}
void Scumm_v5::o5_getActorCostume() {
- int act;
- Actor *a;
getResultPos();
- act = getVarOrDirectByte(0x80);
-
- a = derefActorSafe(act, "o5_getActorCostume");
- if (!a) {
- warning("Invalid actor %d in o5_getActorCostume", act);
- setResult(0);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getActorCostume");
setResult(a->costume);
}
void Scumm_v5::o5_getActorElevation() {
- int act;
- Actor *a;
getResultPos();
- act = getVarOrDirectByte(0x80);
-
- a = derefActorSafe(act, "o5_getActorElevation");
- if (!a) {
- warning("Invalid actor %d in o5_getActorElevation", act);
- setResult(0);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getActorElevation");
setResult(a->elevation);
}
void Scumm_v5::o5_getActorFacing() {
- int act;
- Actor *a;
getResultPos();
- act = getVarOrDirectByte(0x80);
-
- a = derefActorSafe(act, "o5_getActorFacing");
- if (!a) {
- warning("Invalid actor %d in o5_getActorFacing", act);
- setResult(0);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getActorFacing");
setResult(newDirToOldDir(a->facing));
}
void Scumm_v5::o5_getActorMoving() {
- int act;
- Actor *a;
getResultPos();
- act = getVarOrDirectByte(0x80);
-
- a = derefActorSafe(act, "o5_getActorMoving");
- if (!a) {
- warning("Invalid actor %d in o5_getActorMoving", act);
- setResult(0);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getActorMoving");
setResult(a->moving);
}
void Scumm_v5::o5_getActorRoom() {
- int act;
- Actor *a;
getResultPos();
- act = getVarOrDirectByte(0x80);
-
- a = derefActorSafe(act, "o5_getActorRoom");
- if (!a) {
- warning("Invalid actor %d in o5_getActorRoom", act);
- setResult(0);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getActorRoom");
setResult(a->room);
}
@@ -1017,8 +956,7 @@
// INDY3 uses this opcode as a wait_for_actor();
if ((_gameId == GID_INDY3_256) || (_gameId == GID_INDY3)) {
const byte *oldaddr = _scriptPointer - 1;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_getActorScale (wait)");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o5_getActorScale (wait)");
if (a->moving) {
_scriptPointer = oldaddr;
o5_breakHere();
@@ -1027,32 +965,22 @@
}
getResultPos();
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_getActorScale");
- assert(a);
+ int act = getVarOrDirectByte(0x80);
+ a = derefActor(act, "o5_getActorScale");
setResult(a->scalex);
}
void Scumm_v5::o5_getActorWalkBox() {
- int act;
- Actor *a;
getResultPos();
- act = getVarOrDirectByte(0x80);
-
- a = derefActorSafe(act, "o5_getActorWalkbox");
- if (!a) { // FIXME - bug 572977 workaround
- warning("Invalid actor %d in o5_getActorWalkbox", act);
- setResult(0);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getActorWalkBox");
setResult(a->walkbox);
}
void Scumm_v5::o5_getActorWidth() {
- Actor *a;
getResultPos();
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_getActorWidth");
- assert(a);
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getActorWidth");
setResult(a->width);
}
@@ -1087,18 +1015,9 @@
}
void Scumm_v5::o5_getAnimCounter() {
- int act;
- Actor *a;
getResultPos();
- act = getVarOrDirectByte(0x80);
-
- a = derefActorSafe(act, "o5_getAnimCounter");
- if (!a) {
- warning("Invalid actor %d in o5_getAnimCounter", act);
- setResult(0);
- return;
- }
-
+ int act = getVarOrDirectByte(0x80);
+ Actor *a = derefActor(act, "o5_getAnimCounter");
setResult(a->cost.animCounter1);
}
@@ -1229,12 +1148,9 @@
}
void Scumm_v5::o5_isActorInBox() {
- int box;
- Actor *a;
-
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_isActorInBox");
- assert(a);
- box = getVarOrDirectByte(0x40);
+ int act = getVarOrDirectByte(0x80);
+ int box = getVarOrDirectByte(0x40);
+ Actor *a = derefActor(act, "o5_isActorInBox");
if (!checkXYInBoxBounds(box, a->x, a->y))
o5_jumpRelative();
@@ -1370,8 +1286,7 @@
obj = getVarOrDirectWord(0x80);
room = getVarOrDirectByte(0x40);
- a = derefActorSafe(VAR(VAR_EGO), "o5_loadRoomWithEgo");
- assert(a);
+ a = derefActor(VAR(VAR_EGO), "o5_loadRoomWithEgo");
a->putActor(0, 0, room);
_egoPositioned = false;
@@ -1502,11 +1417,9 @@
int x, y;
Actor *a;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_putActor");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o5_putActor");
x = getVarOrDirectWord(0x40);
y = getVarOrDirectWord(0x20);
-
a->putActor(x, y, a->room);
}
@@ -1514,8 +1427,7 @@
int obj, x, y;
Actor *a;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_putActorAtObject");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o5_putActorAtObject");
obj = getVarOrDirectWord(0x40);
if (whereIsObject(obj) != WIO_NOT_FOUND)
getObjectXYPos(obj, x, y);
@@ -1531,12 +1443,7 @@
int act = getVarOrDirectByte(0x80);
int room = getVarOrDirectByte(0x40);
- a = derefActorSafe(act, "o5_putActorInRoom");
-
- if (!a) { // FIXME - yet another null dref hack, see bug 639201
- warning("Invalid actor %d in o5_putActorInRoom", act);
- return;
- }
+ a = derefActor(act, "o5_putActorInRoom");
if (a->visible && _currentRoom != room && VAR(VAR_TALK_ACTOR) == a->number) {
clearMsgQueue();
@@ -2386,8 +2293,8 @@
void Scumm_v5::o5_walkActorTo() {
int x, y;
Actor *a;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_walkActorTo");
- assert(a);
+
+ a = derefActor(getVarOrDirectByte(0x80), "o5_walkActorTo");
x = getVarOrDirectWord(0x40);
y = getVarOrDirectWord(0x20);
a->startWalkActor(x, y, -1);
@@ -2405,13 +2312,11 @@
return;
}
- a = derefActorSafe(nr, "o5_walkActorToActor");
- assert(a);
+ a = derefActor(nr, "o5_walkActorToActor");
if (!a->isInCurrentRoom())
return;
- a2 = derefActorSafe(nr2, "o5_walkActorToActor(2)");
- assert(a2);
+ a2 = derefActor(nr2, "o5_walkActorToActor(2)");
if (!a2->isInCurrentRoom())
return;
@@ -2434,8 +2339,7 @@
int obj;
Actor *a;
- a = derefActorSafe(getVarOrDirectByte(0x80), "o5_walkActorToObject");
- assert(a);
+ a = derefActor(getVarOrDirectByte(0x80), "o5_walkActorToObject");
obj = getVarOrDirectWord(0x40);
if (whereIsObject(obj) != WIO_NOT_FOUND) {
int x, y, dir;
Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.125
retrieving revision 1.126
diff -u -d -r1.125 -r1.126
--- script_v6.cpp 23 May 2003 04:18:26 -0000 1.125
+++ script_v6.cpp 23 May 2003 13:24:40 -0000 1.126
@@ -951,7 +951,7 @@
void Scumm_v6::o6_actorFollowCamera() {
if (_features & GF_AFTER_V7)
- setCameraFollows(derefActorSafe(pop(), "actorFollowCamera"));
+ setCameraFollows(derefActor(pop(), "actorFollowCamera"));
else
actorFollowCamera(pop());
}
@@ -987,15 +987,14 @@
}
void Scumm_v6::o6_walkActorToObj() {
- int obj, dist;
+ int act, obj, dist;
Actor *a, *a2;
int x;
dist = pop();
obj = pop();
- a = derefActorSafe(pop(), "o6_walkActorToObj");
- if (!a)
- return;
+ act = pop();
+ a = derefActor(act, "o6_walkActorToObj");
if (obj >= _numActors) {
if (whereIsObject(obj) == WIO_NOT_FOUND)
@@ -1004,9 +1003,7 @@
getObjectXYPos(obj, x, y, dir);
a->startWalkActor(x, y, dir);
} else {
- a2 = derefActorSafe(obj, "o6_walkActorToObj(2)");
- if (!a2)
- return;
+ a2 = derefActor(obj, "o6_walkActorToObj(2)");
if (!a->isInCurrentRoom() || !a2->isInCurrentRoom())
return;
if (dist == 0) {
@@ -1026,21 +1023,19 @@
int x, y;
y = pop();
x = pop();
- Actor *a = derefActorSafe(pop(), "o6_walkActorTo");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_walkActorTo");
a->startWalkActor(x, y, -1);
}
void Scumm_v6::o6_putActorInRoom() {
- int room, x, y;
+ int room, x, y, act;
Actor *a;
room = pop();
y = pop();
x = pop();
- a = derefActorSafe(pop(), "o6_putActorInRoom");
- if (!a)
- return;
+ act = pop();
+ a = derefActor(act, "o6_putActorInRoom");
if (room == 0xFF || room == 0x7FFFFFFF) {
room = a->room;
@@ -1061,7 +1056,7 @@
obj = popRoomAndObj(&room);
- a = derefActorSafe(pop(), "o6_putActorAtObject");
+ a = derefActor(pop(), "o6_putActorAtObject");
if (whereIsObject(obj) != WIO_NOT_FOUND) {
getObjectXYPos(obj, x, y);
} else {
@@ -1075,18 +1070,13 @@
void Scumm_v6::o6_faceActor() {
int obj = pop();
- Actor *a = derefActorSafe(pop(), "o6_faceActor");
- assert(a);
-
+ Actor *a = derefActor(pop(), "o6_faceActor");
a->faceToObject(obj);
}
void Scumm_v6::o6_animateActor() {
int anim = pop();
- Actor *a = derefActorSafe(pop(), "o6_animateActor");
- if (!a)
- return;
-
+ Actor *a = derefActor(pop(), "o6_animateActor");
a->animateActor(anim);
}
@@ -1136,9 +1126,7 @@
obj = popRoomAndObj(&room);
- a = derefActorSafe(VAR(VAR_EGO), "o6_loadRoomWithEgo");
- assert(a);
-
+ a = derefActor(VAR(VAR_EGO), "o6_loadRoomWithEgo");
a->putActor(0, 0, room);
_egoPositioned = false;
@@ -1188,74 +1176,68 @@
}
void Scumm_v6::o6_getActorMoving() {
- Actor *a = derefActorSafe(pop(), "o6_getActorMoving");
- if (a)
- push(a->moving);
- else
- push(0);
+ Actor *a = derefActor(pop(), "o6_getActorMoving");
+ push(a->moving);
}
void Scumm_v6::o6_getActorRoom() {
- Actor *a = derefActorSafe(pop(), "o6_getActorRoom");
- if (a)
- push(a->room);
- else
+ int act = pop();
+ Actor *a = derefActorSafe(act, "o6_getActorRoom");
+ if (!a) {
+ // FIXME: We got called with act = 0. This happens *a lot* in COMI.
+ // But why? Is that just normal, or due to a bug in ScummVM?
+ //warning("Invalid actor %d in o6_getActorRoom", act);
push(0);
+ return;
+ }
+
+ push(a->room);
}
void Scumm_v6::o6_getActorWalkBox() {
- Actor *a = derefActorSafe(pop(), "o6_getActorWalkBox");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_getActorWalkBox");
push(a->ignoreBoxes ? 0 : a->walkbox);
}
void Scumm_v6::o6_getActorCostume() {
- Actor *a = derefActorSafe(pop(), "o6_getActorCostume");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_getActorCostume");
push(a->costume);
}
void Scumm_v6::o6_getActorElevation() {
- Actor *a = derefActorSafe(pop(), "o6_getActorElevation");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_getActorElevation");
push(a->elevation);
}
void Scumm_v6::o6_getActorWidth() {
- Actor *a = derefActorSafe(pop(), "o6_getActorWidth");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_getActorWidth");
push(a->width);
}
void Scumm_v6::o6_getActorScaleX() {
- Actor *a = derefActorSafe(pop(), "o6_getActorScale");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_getActorScale");
push(a->scalex);
}
void Scumm_v6::o6_getActorAnimCounter1() {
- Actor *a = derefActorSafe(pop(), "o6_getActorAnimCounter");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_getActorAnimCounter");
push(a->cost.animCounter1);
}
void Scumm_v6::o6_getAnimateVariable() {
int var = pop();
- Actor *a = derefActorSafe(pop(), "o6_getAnimateVariable");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_getAnimateVariable");
push(a->getAnimVar(var));
}
void Scumm_v6::o6_isActorInBox() {
int box = pop();
- Actor *a = derefActorSafe(pop(), "o6_isActorInBox");
- assert(a);
+ Actor *a = derefActor(pop(), "o6_isActorInBox");
push(checkXYInBoxBounds(box, a->x, a->y));
}
void Scumm_v6::o6_getActorLayer() {
- Actor *a = derefActorSafe(pop(), "getActorLayer");
- assert(a);
+ Actor *a = derefActor(pop(), "getActorLayer");
push(a->layer);
}
@@ -2454,10 +2436,10 @@
setCursorImg(args[1], (uint) - 1, args[2]);
break;
case 13:
- derefActorSafe(args[1], "o6_kernelSetFunctions:14")->remapActorPalette(args[2], args[3], args[4], -1);
+ derefActor(args[1], "o6_kernelSetFunctions:14")->remapActorPalette(args[2], args[3], args[4], -1);
break;
case 14:
- derefActorSafe(args[1], "o6_kernelSetFunctions:14")->remapActorPalette(args[2], args[3], args[4], args[5]);
+ derefActor(args[1], "o6_kernelSetFunctions:14")->remapActorPalette(args[2], args[3], args[4], args[5]);
break;
case 15:
_smushFrameRate = args[1];
@@ -2507,7 +2489,7 @@
warning("o6_kernelSetFunctions: stub18(%d,%d)", args[1], args[2]);
break;
case 107:
- a = derefActorSafe(args[1], "o6_kernelSetFunctions: 107");
+ a = derefActor(args[1], "o6_kernelSetFunctions: 107");
a->scalex = (unsigned char)args[2];
a->needBgReset = true;
a->needRedraw = true;
@@ -2572,7 +2554,7 @@
break;
case 107: /* set actor scale */
- a = derefActorSafe(args[1], "o6_kernelSetFunctions: 107");
+ a = derefActor(args[1], "o6_kernelSetFunctions: 107");
a->scalex = (unsigned char)args[2];
a->needBgReset = true;
a->needRedraw = true;
@@ -2589,7 +2571,7 @@
break;
case 111:
- a = derefActorSafe(args[1], "o6_kernelSetFunctions: 111");
+ a = derefActor(args[1], "o6_kernelSetFunctions: 111");
a->shadow_mode = args[2] + args[3];
break;
@@ -2740,7 +2722,7 @@
push(0);
break;
case 212:
- a = derefActorSafe(args[1], "o6_kernelGetFunctions:212");
+ a = derefActor(args[1], "o6_kernelGetFunctions:212");
// This is used by walk scripts
push(a->frame);
break;
@@ -2809,7 +2791,7 @@
state = 255;
}
warning("o6_stampObject: (%d at (%d,%d) scale %d)", object, x, y, state);
- Actor *a = derefActor(object);
+ Actor *a = derefActor(object, "o6_stampObject");
a->scalex = state;
a->scaley = state;
a->putActor(x, y, _currentRoom); // TODO
Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.165
retrieving revision 2.166
diff -u -d -r2.165 -r2.166
--- script_v8.cpp 22 May 2003 09:58:33 -0000 2.165
+++ script_v8.cpp 23 May 2003 13:24:40 -0000 2.166
@@ -639,8 +639,7 @@
case 0x1E: // SO_WAIT_FOR_ACTOR Wait for actor (to finish current action?)
offs = fetchScriptWordSigned();
actnum = pop();
- a = derefActorSafe(actnum, "o8_wait:SO_WAIT_FOR_ACTOR");
- assert(a);
+ a = derefActor(actnum, "o8_wait:SO_WAIT_FOR_ACTOR");
if (a->moving) {
_scriptPointer += offs;
o6_breakHere();
@@ -666,8 +665,7 @@
case 0x22: // SO_WAIT_FOR_ANIMATION
offs = fetchScriptWordSigned();
actnum = pop();
- a = derefActorSafe(actnum, "o8_wait:SO_WAIT_FOR_ANIMATION");
- assert(a);
+ a = derefActor(actnum, "o8_wait:SO_WAIT_FOR_ANIMATION");
if (a->isInCurrentRoom() && a->needRedraw) {
_scriptPointer += offs;
o6_breakHere();
@@ -676,8 +674,7 @@
case 0x23: // SO_WAIT_FOR_TURN
offs = fetchScriptWordSigned();
actnum = pop();
- a = derefActorSafe(actnum, "o8_wait:SO_WAIT_FOR_TURN");
- assert(a);
+ a = derefActor(actnum, "o8_wait:SO_WAIT_FOR_TURN");
if (a->isInCurrentRoom() && a->moving & MF_TURN) {
_scriptPointer += offs;
o6_breakHere();
@@ -1388,13 +1385,11 @@
break;
}
case 13: // remapCostume
- a = derefActorSafe(args[1], "o8_kernelSetFunctions:remapCostume");
- assert(a);
+ a = derefActor(args[1], "o8_kernelSetFunctions:remapCostume");
a->remapActorPalette(args[2], args[3], args[4], -1);
break;
case 14: // remapCostumeInsert
- a = derefActorSafe(args[1], "o8_kernelSetFunctions:remapCostumeInsert");
- assert(a);
+ a = derefActor(args[1], "o8_kernelSetFunctions:remapCostumeInsert");
a->remapActorPalette(args[2], args[3], args[4], args[5]);
break;
case 15: // setVideoFrameRate
@@ -1416,8 +1411,7 @@
// lipSyncWidth and lipSyncHeight, which we currently don't support. As a result,
// actors will currently not move their mouth at all!
// warning("o8_kernelSetFunctions: setActorChoreLimbFrame(%d, %d, %d, %d)", args[1], args[2], args[3], args[4]);
- a = derefActorSafe(args[1], "o8_kernelSetFunctions:setActorChoreLimbFrame");
- assert(a);
+ a = derefActor(args[1], "o8_kernelSetFunctions:setActorChoreLimbFrame");
a->startAnimActor(args[2]);
a->animateLimb(args[3], args[4]);
@@ -1553,8 +1547,7 @@
case 0xD9: { // actorHit - used, for example, to detect ship collision
// during ship-to-ship combat.
#if 0
- Actor *a = derefActorSafe(args[1], "actorHit");
- assert(a);
+ Actor *a = derefActor(args[1], "actorHit");
int x = args[2];
int y = args[3];
@@ -1609,8 +1602,7 @@
break;
case 0xDC: // actorTalkAnimation
{
- Actor *a = derefActorSafe(args[1], "actorTalkAnimation");
- assert(a);
+ Actor *a = derefActor(args[1], "actorTalkAnimation");
push(a->talkStartFrame);
}
break;
@@ -1655,8 +1647,7 @@
void Scumm_v8::o8_getActorChore() {
int actnum = pop();
- Actor *a = derefActorSafe(actnum, "o8_getActorChore");
- assert(a);
+ Actor *a = derefActor(actnum, "o8_getActorChore");
// FIXME: This is a hack for the cannon scene, as something isn't quite right
// here yet..
@@ -1670,8 +1661,7 @@
void Scumm_v8::o8_getActorZPlane() {
int actnum = pop();
- Actor *a = derefActorSafe(actnum, "o8_getActorChore");
- assert(a);
+ Actor *a = derefActor(actnum, "o8_getActorChore");
int z = a->forceClip;
if (z == 100) {
Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/sound.cpp,v
retrieving revision 1.120
retrieving revision 1.121
diff -u -d -r1.120 -r1.121
--- sound.cpp 22 May 2003 09:58:33 -0000 1.120
+++ sound.cpp 23 May 2003 13:24:41 -0000 1.121
@@ -489,7 +489,7 @@
if (act != 0 && (uint) act < 0x80 && !_scumm->_string[0].no_talk_anim) {
- a = _scumm->derefActorSafe(act, "processSfxQueues");
+ a = _scumm->derefActor(act, "processSfxQueues");
if (a->room == _scumm->_currentRoom && (finished || !_endOfMouthSync)) {
b = true;
if (!finished)
More information about the Scummvm-git-logs
mailing list