[Scummvm-cvs-logs] CVS: scummvm/scumm actor.cpp,1.198,1.199 actor.h,1.45,1.46 akos.cpp,1.92,1.93 base-costume.cpp,2.9,2.10 base-costume.h,1.15,1.16 costume.cpp,1.122,1.123 debugger.cpp,1.106,1.107 script_v2.cpp,2.224,2.225 script_v5.cpp,1.218,1.219 script_v6.cpp,1.243,1.244 script_v8.cpp,2.212,2.213 scumm.h,1.347,1.348 string.cpp,1.177,1.178

Max Horn fingolfin at users.sourceforge.net
Mon Jan 5 08:20:00 CET 2004


Update of /cvsroot/scummvm/scummvm/scumm
In directory sc8-pr-cvs1:/tmp/cvs-serv16673

Modified Files:
	actor.cpp actor.h akos.cpp base-costume.cpp base-costume.h 
	costume.cpp debugger.cpp script_v2.cpp script_v5.cpp 
	script_v6.cpp script_v8.cpp scumm.h string.cpp 
Log Message:
added Actor::getElevation and Actor::setElevation; cleaned up costume API a bit; some minor cleanup/tweaks

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.cpp,v
retrieving revision 1.198
retrieving revision 1.199
diff -u -d -r1.198 -r1.199
--- actor.cpp	5 Jan 2004 06:53:03 -0000	1.198
+++ actor.cpp	5 Jan 2004 16:19:13 -0000	1.199
@@ -305,7 +305,7 @@
 	if (ignoreTurns)
 		return facing;
 
-	dirType = (_vm->_features & GF_NEW_COSTUMES) ? _vm->akos_hasManyDirections(this) : false;
+	dirType = (_vm->_features & GF_NEW_COSTUMES) ? _vm->akos_hasManyDirections(costume) : false;
 
 	from = toSimpleDir(dirType, facing);
 	dir = remapDirection(targetFacing, is_walking);
@@ -876,7 +876,7 @@
 	for (int i = 1; i < _numActors; i++) {
 		if (_version == 8 && _actors[i].layer < 0)
 			continue;
-		if (_actors[i].isInCurrentRoom())
+		if (_actors[i].isInCurrentRoom() && _actors[i].costume)
 			actors[numactors++] = &_actors[i];
 	}
 	if (!numactors) {
@@ -893,12 +893,10 @@
 	// Finally draw the now sorted actors
 	for (Actor** ac = actors; ac != end; ++ac) {
 		Actor* a = *ac;
-		if (a->costume) {
-			CHECK_HEAP
-			a->drawActorCostume();
-			CHECK_HEAP
-			a->animateCostume();
-		}
+		CHECK_HEAP
+		a->drawActorCostume();
+		CHECK_HEAP
+		a->animateCostume();
 	}
 	
 	delete [] actors;
@@ -929,7 +927,7 @@
 
 	BaseCostumeRenderer* bcr = _vm->_costumeRenderer;
 
-	bcr->updateNbStrips();
+	bcr->_actorID = number;
 
 	bcr->_actorX = _pos.x - _vm->virtscr[0].xstart;
 	bcr->_actorY = _pos.y - elevation;
@@ -960,8 +958,6 @@
 	bcr->setPalette(palette);
 	bcr->setFacing(this);
 
-	bcr->_dirty_id = number;
-
 	if (!(_vm->_features & GF_NEW_COSTUMES)) {
 
 		if (forceClip)
@@ -989,13 +985,9 @@
 
 	bcr->_draw_bottom = bottom = 0;
 
-	bcr->_outptr = _vm->virtscr[0].screenPtr + _vm->virtscr[0].xstart;
-	bcr->_outwidth = _vm->virtscr[0].width;
-	bcr->_outheight = _vm->virtscr[0].height;
-
 	// If the actor is partially hidden, redraw it next frame.
 	// Only done for pre-AKOS, though.
-	if (bcr->drawCostume(cost) & 1) {
+	if (bcr->drawCostume(_vm->virtscr[0], cost) & 1) {
 		needRedraw = !(_vm->_features & GF_NEW_COSTUMES);
 	}
 

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/actor.h,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -d -r1.45 -r1.46
--- actor.h	3 Oct 2003 18:33:53 -0000	1.45
+++ actor.h	5 Jan 2004 16:19:13 -0000	1.46
@@ -85,7 +85,6 @@
 public:
 	Common::Point _pos;
 	int top, bottom;
-	int elevation;
 	uint width;
 	byte number;
 	uint16 costume;
@@ -112,6 +111,7 @@
 	CostumeData cost;
 	byte palette[256];
 protected:
+	int elevation;
 	uint16 facing;
 	uint16 targetFacing;
 	uint speedx, speedy;
@@ -193,6 +193,17 @@
 	void setAnimSpeed(byte newAnimSpeed) {
 		animSpeed = newAnimSpeed;
 		animProgress = 0;
+	}
+
+	int getElevation() const {
+		return elevation;
+	}
+	
+	void setElevation(int newElevation) {
+		if (elevation != newElevation) {
+			elevation = newElevation;
+			needRedraw = true;
+		}
 	}
 	
 	void classChanged(int cls, bool value);

Index: akos.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/akos.cpp,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -d -r1.92 -r1.93
--- akos.cpp	3 Jan 2004 22:45:23 -0000	1.92
+++ akos.cpp	5 Jan 2004 16:19:13 -0000	1.93
@@ -113,11 +113,11 @@
 	}
 }
 
-bool ScummEngine::akos_hasManyDirections(Actor *a) {
+bool ScummEngine::akos_hasManyDirections(int costume) {
 	byte *akos;
 	const AkosHeader *akhd;
 
-	akos = getResourceAddress(rtCostume, a->costume);
+	akos = getResourceAddress(rtCostume, costume);
 	assert(akos);
 
 	akhd = (const AkosHeader *)findResourceData(MKID('AKHD'), akos);
@@ -125,7 +125,7 @@
 }
 
 int ScummEngine::akos_frameToAnim(Actor *a, int frame) {
-	if (akos_hasManyDirections(a))
+	if (akos_hasManyDirections(a->costume))
 		return toSimpleDir(1, a->getFacing()) + frame * 8;
 	else
 		return newDirToOldDir(a->getFacing()) + frame * 4;
@@ -673,7 +673,7 @@
 		if (_actorHitX < x_left || _actorHitX >= x_right || _actorHitY < y_top || _actorHitY >= y_bottom)
 			return 0;
 	} else
-		_vm->markRectAsDirty(kMainVirtScreen, x_left, x_right, y_top, y_bottom, _dirty_id);
+		_vm->markRectAsDirty(kMainVirtScreen, x_left, x_right, y_top, y_bottom, _actorID);
 
 	if (y_top >= (int)_outheight || y_bottom <= 0)
 		return 0;
@@ -763,7 +763,7 @@
 	maxw = _outwidth - 1;
 	maxh = _outheight - 1;
 
-	_vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
+	_vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _actorID);
 
 	if (clip_top < 0) {
 		clip_top = 0;
@@ -980,7 +980,7 @@
 	cur_x = _width - 1;
 	cur_y = _height - 1;
 
-	_vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _dirty_id);
+	_vm->markRectAsDirty(kMainVirtScreen, clip_left, clip_right + 1, clip_top, clip_bottom + 1, _actorID);
 
 	if (clip_left < 0) {
 		skip_x = -clip_left;

Index: base-costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/base-costume.cpp,v
retrieving revision 2.9
retrieving revision 2.10
diff -u -d -r2.9 -r2.10
--- base-costume.cpp	3 Oct 2003 18:33:53 -0000	2.9
+++ base-costume.cpp	5 Jan 2004 16:19:13 -0000	2.10
@@ -25,10 +25,15 @@
 
 namespace Scumm {
 
-byte BaseCostumeRenderer::drawCostume(const CostumeData &cost) {
+byte BaseCostumeRenderer::drawCostume(const VirtScreen &vs, const CostumeData &cost) {
 	int i;
 	byte result = 0;
 
+	_outptr = vs.screenPtr + vs.xstart;
+	_outwidth = vs.width;
+	_outheight = vs.height;
+	_numStrips = vs.width / 8;
+
 	if (_vm->_version == 1) {
 		_xmove = 0;
 		_ymove = 0;
@@ -59,6 +64,20 @@
 				return;
 		} while (--v1.replen);
 	} while (1);
+}
+
+bool ScummEngine::isCostumeInUse(int cost) const {
+	int i;
+	Actor *a;
+
+	if (_roomResource != 0)
+		for (i = 1; i < _numActors; i++) {
+			a = derefActor(i);
+			if (a->isInCurrentRoom() && a->costume == cost)
+				return true;
+		}
+
+	return false;
 }
 
 } // End of namespace Scumm

Index: base-costume.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/base-costume.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- base-costume.h	3 Oct 2003 18:33:53 -0000	1.15
+++ base-costume.h	5 Jan 2004 16:19:13 -0000	1.16
@@ -44,13 +44,14 @@
 
 class Actor;
 class ScummEngine;
+struct VirtScreen;
 
 /**
  * Base class for both CostumeRenderer and AkosRenderer.
  */
 class BaseCostumeRenderer {
 public:
-	byte _dirty_id;
+	byte _actorID;
 
 	byte _shadow_mode;
 	byte *_shadow_table;
@@ -61,12 +62,12 @@
 
 	int _draw_top, _draw_bottom;
 
+protected:
+	ScummEngine *_vm;
+
 	// Destination
 	byte *_outptr;
 	uint _outwidth, _outheight;
-
-protected:
-	ScummEngine *_vm;
 	int32 _numStrips;
 
 	// Source pointer
@@ -98,7 +99,7 @@
 
 public:
 	BaseCostumeRenderer(ScummEngine *scumm) {
-		_dirty_id = 0;
+		_actorID = 0;
 		_shadow_mode = 0;
 		_shadow_table = 0;
 		_actorX = _actorY = 0;
@@ -120,10 +121,9 @@
 	virtual void setPalette(byte *palette) = 0;
 	virtual void setFacing(Actor *a) = 0;
 	virtual void setCostume(int costume) = 0;
-	void updateNbStrips (void)		{ _numStrips = _vm->gdi._numStrips; }
 
 
-	byte drawCostume(const CostumeData &cost);
+	byte drawCostume(const VirtScreen &vs, const CostumeData &cost);
 
 protected:
 

Index: costume.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/costume.cpp,v
retrieving revision 1.122
retrieving revision 1.123
diff -u -d -r1.122 -r1.123
--- costume.cpp	3 Jan 2004 22:45:23 -0000	1.122
+++ costume.cpp	5 Jan 2004 16:19:13 -0000	1.123
@@ -202,9 +202,9 @@
 
 	if (_vm->_version == 1)
 		//HACK: it fix gfx glitches leaved by actor costume in V1 games, when actor moving to left
-		_vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 8, y_top, y_bottom, _dirty_id);
+		_vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 8, y_top, y_bottom, _actorID);
 	else
-		_vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 1, y_top, y_bottom, _dirty_id);
+		_vm->markRectAsDirty(kMainVirtScreen, x_left, x_right + 1, y_top, y_bottom, _actorID);
 
 	if (y_top >= (int)_outheight || y_bottom <= 0)
 		return 0;
@@ -280,8 +280,8 @@
 
 	if (_loaded._format == 0x57) {
 		// The v1 costume renderer needs the actor number, which is
-		// the same thing as the costume renderer's _dirty_id.
-		procC64(_dirty_id);
+		// the same thing as the costume renderer's _actorID.
+		procC64(_actorID);
 	} else if (newAmiCost)
 		proc3_ami();
 	else
@@ -846,20 +846,6 @@
 		a->cost.curpos[slot] = i | highflag;
 		return (_animCmds[i] & 0x7F) != code;
 	} while (1);
-}
-
-bool ScummEngine::isCostumeInUse(int cost) const {
-	int i;
-	Actor *a;
-
-	if (_roomResource != 0)
-		for (i = 1; i < _numActors; i++) {
-			a = derefActor(i);
-			if (a->isInCurrentRoom() && a->costume == cost)
-				return true;
-		}
-
-	return false;
 }
 
 } // End of namespace Scumm

Index: debugger.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/debugger.cpp,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -d -r1.106 -r1.107
--- debugger.cpp	4 Jan 2004 14:00:57 -0000	1.106
+++ debugger.cpp	5 Jan 2004 16:19:13 -0000	1.107
@@ -377,8 +377,8 @@
 		DebugPrintf("Actor[%d].y = %d\n", actnum, a->_pos.y);
 		_vm->_fullRedraw = 1;
 	} else if (!strcmp(argv[2], "elevation")) {
-		a->elevation = value;
-		DebugPrintf("Actor[%d].elevation = %d\n", actnum, a->elevation);
+		a->setElevation(value);
+		DebugPrintf("Actor[%d].elevation = %d\n", actnum, a->getElevation());
 		_vm->_fullRedraw = 1;
 	} else if (!strcmp(argv[2], "costume")) {
 		if (value >= _vm->res.num[rtCostume])
@@ -408,7 +408,7 @@
 		a = &_vm->_actors[i];
 		if (a->visible)
 			DebugPrintf("|%2d|%4d|%4d|%4d|%4d|%3d|%5d|%3d|%3d|%3d|%5d|%5d|%3d|$%02x|\n",
-						 a->number, a->room, a->_pos.x, a->_pos.y, a->elevation, a->costume,
+						 a->number, a->room, a->_pos.x, a->_pos.y, a->getElevation(), a->costume,
 						 a->width, a->walkbox, a->moving, a->forceClip, a->frame,
 						 a->scalex, a->getFacing(), int(_vm->_classData[a->number]&0xFF));
 	}

Index: script_v2.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v2.cpp,v
retrieving revision 2.224
retrieving revision 2.225
diff -u -d -r2.224 -r2.225
--- script_v2.cpp	3 Jan 2004 21:22:07 -0000	2.224
+++ script_v2.cpp	5 Jan 2004 16:19:13 -0000	2.225
@@ -1153,7 +1153,7 @@
 	getResultPos();
 	int act = getVarOrDirectByte(PARAM_1);
 	Actor *a = derefActor(act, "o2_getActorElevation");
-	setResult(a->elevation / 2);
+	setResult(a->getElevation() / 2);
 }
 
 void ScummEngine_v2::o2_setActorElevation() {
@@ -1161,8 +1161,7 @@
 	int elevation = (int8)getVarOrDirectByte(PARAM_2);
 
 	Actor *a = derefActor(act, "o2_setActorElevation");
-	a->elevation = elevation * 2;
-	a->needRedraw = true;
+	a->setElevation(elevation * 2);
 }
 
 void ScummEngine_v2::o2_animateActor() {

Index: script_v5.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v5.cpp,v
retrieving revision 1.218
retrieving revision 1.219
diff -u -d -r1.218 -r1.219
--- script_v5.cpp	4 Jan 2004 14:49:14 -0000	1.218
+++ script_v5.cpp	5 Jan 2004 16:19:13 -0000	1.219
@@ -446,8 +446,7 @@
 			a->initActor(0);
 			break;
 		case 9:			// SO_ELEVATION
-			a->elevation = getVarOrDirectWord(PARAM_1);
-			a->needRedraw = true;
+			a->setElevation(getVarOrDirectWord(PARAM_1));
 			break;
 		case 10:		// SO_ANIMATION_DEFAULT
 			a->initFrame = 1;
@@ -1032,7 +1031,7 @@
 	getResultPos();
 	int act = getVarOrDirectByte(PARAM_1);
 	Actor *a = derefActor(act, "o5_getActorElevation");
-	setResult(a->elevation);
+	setResult(a->getElevation());
 }
 
 void ScummEngine_v5::o5_getActorFacing() {

Index: script_v6.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v6.cpp,v
retrieving revision 1.243
retrieving revision 1.244
diff -u -d -r1.243 -r1.244
--- script_v6.cpp	5 Jan 2004 14:39:44 -0000	1.243
+++ script_v6.cpp	5 Jan 2004 16:19:13 -0000	1.244
@@ -1254,7 +1254,7 @@
 
 void ScummEngine_v6::o6_getActorElevation() {
 	Actor *a = derefActor(pop(), "o6_getActorElevation");
-	push(a->elevation);
+	push(a->getElevation());
 }
 
 void ScummEngine_v6::o6_getActorWidth() {
@@ -1692,11 +1692,7 @@
 		a->initActor(0);
 		break;
 	case 84:		// SO_ELEVATION
-		i = pop();
-		if (i != a->elevation) {
-			a->elevation = i;
-			a->needRedraw = true;
-		}
+		a->setElevation(pop());
 		break;
 	case 85:		// SO_ANIMATION_DEFAULT
 		a->initFrame = 1;

Index: script_v8.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/script_v8.cpp,v
retrieving revision 2.212
retrieving revision 2.213
diff -u -d -r2.212 -r2.213
--- script_v8.cpp	27 Dec 2003 16:40:01 -0000	2.212
+++ script_v8.cpp	5 Jan 2004 16:19:13 -0000	2.213
@@ -967,11 +967,7 @@
 		a->initActor(0);
 		break;
 	case 0x6E:		// SO_ACTOR_ELEVATION
-		i = pop();
-		if (i != a->elevation) {
-			a->elevation = i;
-			a->needRedraw = true;
-		}
+		a->setElevation(pop());
 		break;
 	case 0x6F:		// SO_ACTOR_PALETTE Set actor palette
 		j = pop();

Index: scumm.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/scumm.h,v
retrieving revision 1.347
retrieving revision 1.348
diff -u -d -r1.347 -r1.348
--- scumm.h	4 Jan 2004 14:49:14 -0000	1.347
+++ scumm.h	5 Jan 2004 16:19:14 -0000	1.348
@@ -748,7 +748,7 @@
 	void akos_queCommand(byte cmd, Actor *a, int param_1, int param_2);
 	void akos_decodeData(Actor *a, int frame, uint usemask);
 	int akos_frameToAnim(Actor *a, int frame);
-	bool akos_hasManyDirections(Actor *a);
+	bool akos_hasManyDirections(int costume);
 
 protected:
 	/* Should be in Graphics class? */

Index: string.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/scumm/string.cpp,v
retrieving revision 1.177
retrieving revision 1.178
diff -u -d -r1.177 -r1.178
--- string.cpp	4 Jan 2004 14:32:26 -0000	1.177
+++ string.cpp	5 Jan 2004 16:19:14 -0000	1.178
@@ -118,14 +118,14 @@
 
 			if (VAR(VAR_V5_TALK_STRING_Y) < 0) {
 				s = (a->scaley * (int)VAR(VAR_V5_TALK_STRING_Y)) / 0xFF;
-				_string[0].ypos = (int)(((VAR(VAR_V5_TALK_STRING_Y) - s) / 2) + s - a->elevation + a->_pos.y);
+				_string[0].ypos = (int)(((VAR(VAR_V5_TALK_STRING_Y) - s) / 2) + s - a->getElevation() + a->_pos.y);
 			} else {
 				_string[0].ypos = (int)VAR(VAR_V5_TALK_STRING_Y);
 			}
 
 		} else {
 			s = a->scaley * a->talkPosY / 0xFF;
-			_string[0].ypos = ((a->talkPosY - s) / 2) + s - a->elevation + a->_pos.y;
+			_string[0].ypos = ((a->talkPosY - s) / 2) + s - a->getElevation() + a->_pos.y;
 
 			if (_string[0].ypos < _screenTop)
 				_string[0].ypos = _screenTop;





More information about the Scummvm-git-logs mailing list