[Scummvm-cvs-logs] SF.net SVN: scummvm: [24922] scummvm/trunk/engines/scumm

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Mon Dec 25 16:03:37 CET 2006


Revision: 24922
          http://scummvm.svn.sourceforge.net/scummvm/?rev=24922&view=rev
Author:   fingolfin
Date:     2006-12-25 07:03:36 -0800 (Mon, 25 Dec 2006)

Log Message:
-----------
Changed ScummEngine::_actors from an Actor array to a an array of Actor points (i.e. indirection)

Modified Paths:
--------------
    scummvm/trunk/engines/scumm/actor.cpp
    scummvm/trunk/engines/scumm/camera.cpp
    scummvm/trunk/engines/scumm/debugger.cpp
    scummvm/trunk/engines/scumm/object.cpp
    scummvm/trunk/engines/scumm/room.cpp
    scummvm/trunk/engines/scumm/saveload.cpp
    scummvm/trunk/engines/scumm/scumm.cpp
    scummvm/trunk/engines/scumm/scumm.h

Modified: scummvm/trunk/engines/scumm/actor.cpp
===================================================================
--- scummvm/trunk/engines/scumm/actor.cpp	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/actor.cpp	2006-12-25 15:03:36 UTC (rev 24922)
@@ -199,11 +199,11 @@
 	int i;
 
 	for (i = 1; i < _numActors; i++) {
-		if (_actors[i].isInCurrentRoom())
+		if (_actors[i]->isInCurrentRoom())
 			if (_game.version <= 3)
-				_actors[i].walkActorOld();
+				_actors[i]->walkActorOld();
 			else
-				_actors[i].walkActor();
+				_actors[i]->walkActor();
 	}
 }
 
@@ -871,7 +871,7 @@
 	int i;
 
 	for (i = 1; i < _numActors; i++) {
-		a = &_actors[i];
+		a = _actors[i];
 		if (a && a->isInCurrentRoom())
 			a->putActor();
 	}
@@ -1051,7 +1051,7 @@
 
 	for (i = 1; i < _numActors; i++) {
 		if (testGfxUsageBit(x / 8, i) && !getClass(i, kObjectClassUntouchable)
-			&& y >= _actors[i]._top && y <= _actors[i]._bottom) {
+			&& y >= _actors[i]->_top && y <= _actors[i]->_bottom) {
 			if (_game.version > 2 || i != VAR(VAR_EGO))
 				return i;
 		}
@@ -1070,8 +1070,8 @@
 	curActor = 0;
 	for (i = 1; i < _numActors; i++) {
 		if (testGfxUsageBit(x / 8, i) && !getClass(i, kObjectClassUntouchable)
-			&& y >= _actors[i]._top && y <= _actors[i]._bottom
-			&& (_actors[i].getPos().y > _actors[curActor].getPos().y || curActor == 0))
+			&& y >= _actors[i]->_top && y <= _actors[i]->_bottom
+			&& (_actors[i]->getPos().y > _actors[curActor]->getPos().y || curActor == 0))
 				curActor = i;
 	}
 
@@ -1129,8 +1129,8 @@
 	int i;
 
 	for (i = 1; i < _numActors; i++) {
-		if (_actors[i].isInCurrentRoom())
-			_actors[i].showActor();
+		if (_actors[i]->isInCurrentRoom())
+			_actors[i]->showActor();
 	}
 }
 
@@ -1139,11 +1139,11 @@
 	int i;
 
 	for (i = 1; i < _numActors; i++) {
-		if (_actors[i]._cost.soundCounter && _actors[i].isInCurrentRoom() && _actors[i]._sound) {
+		if (_actors[i]->_cost.soundCounter && _actors[i]->isInCurrentRoom() && _actors[i]->_sound) {
 			_currentScript = 0xFF;
-			_sound->addSoundToQueue(_actors[i]._sound[0]);
+			_sound->addSoundToQueue(_actors[i]->_sound[0]);
 			for (i = 1; i < _numActors; i++) {
-				_actors[i]._cost.soundCounter = 0;
+				_actors[i]->_cost.soundCounter = 0;
 			}
 			return;
 		}
@@ -1151,7 +1151,7 @@
 }
 
 bool ScummEngine::isValidActor(int id) const {
-	return id >= 0 && id < _numActors && _actors[id]._number == id;
+	return id >= 0 && id < _numActors && _actors[id]->_number == id;
 }
 
 Actor *ScummEngine::derefActor(int id, const char *errmsg) const {
@@ -1165,7 +1165,7 @@
 		else
 			error("Invalid actor %d", id);
 	}
-	return &_actors[id];
+	return _actors[id];
 }
 
 Actor *ScummEngine::derefActorSafe(int id, const char *errmsg) const {
@@ -1178,7 +1178,7 @@
 			 id, errmsg, vm.slot[_currentScript].number, _opcode);
 		return NULL;
 	}
-	return &_actors[id];
+	return _actors[id];
 }
 
 
@@ -1192,10 +1192,10 @@
 
 	// Make a list of all actors in this room
 	for (int i = 1; i < _numActors; i++) {
-		if (_game.version == 8 && _actors[i]._layer < 0)
+		if (_game.version == 8 && _actors[i]->_layer < 0)
 			continue;
-		if (_actors[i].isInCurrentRoom()) {
-			_sortedActors[numactors++] = &_actors[i];
+		if (_actors[i]->isInCurrentRoom()) {
+			_sortedActors[numactors++] = _actors[i];
 		}
 	}
 	if (!numactors) {
@@ -1304,9 +1304,9 @@
 	int i;
 
 	for (i = 1; i < _numActors; i++) {
-		if (_actors[i].isInCurrentRoom() && _actors[i]._costume && _actors[i]._layer < 0) {
-			_actors[i].drawActorCostume();
-			_actors[i].animateCostume();
+		if (_actors[i]->isInCurrentRoom() && _actors[i]->_costume && _actors[i]->_layer < 0) {
+			_actors[i]->drawActorCostume();
+			_actors[i]->animateCostume();
 		}
 	}
 }
@@ -1602,11 +1602,11 @@
 #endif
 
 void ScummEngine::redrawAllActors() {
-	int j;
+	int i;
 
-	for (j = 1; j < _numActors; j++) {
-		_actors[j]._needRedraw = true;
-		_actors[j]._needBgReset = true;
+	for (i = 1; i < _numActors; ++i) {
+		_actors[i]->_needRedraw = true;
+		_actors[i]->_needBgReset = true;
 	}
 }
 
@@ -1617,7 +1617,7 @@
 	// Also redraw all actors in COMI (see bug #1066329 for details).
 	if (_fullRedraw || _game.version == 8 || (VAR_REDRAW_ALL_ACTORS != 0xFF && VAR(VAR_REDRAW_ALL_ACTORS) != 0)) {
 		for (j = 1; j < _numActors; j++) {
-			_actors[j]._needRedraw = true;
+			_actors[j]->_needRedraw = true;
 		}
 	} else {
 		for (i = 0; i < _gdi->_numStrips; i++) {
@@ -1625,7 +1625,7 @@
 			if (testGfxAnyUsageBits(strip)) {
 				for (j = 1; j < _numActors; j++) {
 					if (testGfxUsageBit(strip, j) && testGfxOtherUsageBits(strip, j)) {
-						_actors[j]._needRedraw = true;
+						_actors[j]->_needRedraw = true;
 					}
 				}
 			}
@@ -1641,20 +1641,20 @@
 		clearGfxUsageBit(strip, USAGE_BIT_DIRTY);
 		clearGfxUsageBit(strip, USAGE_BIT_RESTORED);
 		for (j = 1; j < _numActors; j++) {
-			if (_actors[j]._heFlags & 1)
+			if (_actors[j]->_heFlags & 1)
 				continue;
 
 			if (testGfxUsageBit(strip, j) &&
-				((_actors[j]._top != 0x7fffffff && _actors[j]._needRedraw) || _actors[j]._needBgReset)) {
+				((_actors[j]->_top != 0x7fffffff && _actors[j]->_needRedraw) || _actors[j]->_needBgReset)) {
 				clearGfxUsageBit(strip, j);
-				if ((_actors[j]._bottom - _actors[j]._top) >= 0)
-					_gdi->resetBackground(_actors[j]._top, _actors[j]._bottom, i);
+				if ((_actors[j]->_bottom - _actors[j]->_top) >= 0)
+					_gdi->resetBackground(_actors[j]->_top, _actors[j]->_bottom, i);
 			}
 		}
 	}
 
 	for (i = 1; i < _numActors; i++) {
-		_actors[i]._needBgReset = false;
+		_actors[i]->_needBgReset = false;
 	}
 }
 
@@ -1697,14 +1697,14 @@
 		return VAR(VAR_TALK_ACTOR);
 }
 
-void ScummEngine::setTalkingActor(int value) {
+void ScummEngine::setTalkingActor(int i) {
 
-	if (value == 255) {
+	if (i == 255) {
 		_system->clearFocusRectangle();
 	} else {
 		// Work out the screen co-ordinates of the actor
-		int x = _actors[value].getPos().x - (camera._cur.x - (_screenWidth >> 1));
-		int y = _actors[value]._top - (camera._cur.y - (_screenHeight >> 1));
+		int x = _actors[i]->getPos().x - (camera._cur.x - (_screenWidth >> 1));
+		int y = _actors[i]->_top - (camera._cur.y - (_screenHeight >> 1));
 
 		// Set the focus area to the calculated position
 		// TODO: Make the size adjust depending on what it's focusing on.
@@ -1713,9 +1713,9 @@
 	}
 
 	if (_game.id == GID_MANIAC && _game.version <= 1 && !(_game.platform == Common::kPlatformNES))
-		_V1TalkingActor = value;
+		_V1TalkingActor = i;
 	else
-		VAR(VAR_TALK_ACTOR) = value;
+		VAR(VAR_TALK_ACTOR) = i;
 }
 
 static const int c64MMActorTalkColor[25] = {
@@ -1730,9 +1730,9 @@
 
 	for (i = 1; i < _numActors; i++) {
 		if (_game.platform == Common::kPlatformC64) {
-			_actors[i]._talkColor = c64MMActorTalkColor[i];
+			_actors[i]->_talkColor = c64MMActorTalkColor[i];
 		} else {
-			_actors[i]._talkColor = v1MMActorTalkColor[i];
+			_actors[i]->_talkColor = v1MMActorTalkColor[i];
 		}
 	}
 }

Modified: scummvm/trunk/engines/scumm/camera.cpp
===================================================================
--- scummvm/trunk/engines/scumm/camera.cpp	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/camera.cpp	2006-12-25 15:03:36 UTC (rev 24922)
@@ -79,8 +79,8 @@
 		setCameraAt(a->getPos().x, 0);
 
 	for (i = 1; i < _numActors; i++) {
-		if (_actors[i].isInCurrentRoom())
-			_actors[i]._needRedraw = true;
+		if (_actors[i]->isInCurrentRoom())
+			_actors[i]->_needRedraw = true;
 	}
 	runInventoryScript(0);
 }

Modified: scummvm/trunk/engines/scumm/debugger.cpp
===================================================================
--- scummvm/trunk/engines/scumm/debugger.cpp	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/debugger.cpp	2006-12-25 15:03:36 UTC (rev 24922)
@@ -189,7 +189,7 @@
 bool ScummDebugger::Cmd_Room(int argc, const char **argv) {
 	if (argc > 1) {
 		int room = atoi(argv[1]);
-		_vm->_actors[_vm->VAR(_vm->VAR_EGO)]._room = room;
+		_vm->_actors[_vm->VAR(_vm->VAR_EGO)]->_room = room;
 		_vm->_sound->stopAllSounds();
 		_vm->startScene(room, 0, 0);
 		_vm->_fullRedraw = true;
@@ -367,7 +367,7 @@
 		return true;
 	}
 
-	a = &_vm->_actors[actnum];
+	a = _vm->_actors[actnum];
 	if (argc > 3)
 		value = atoi(argv[3]);
 	if (argc > 4)
@@ -424,7 +424,7 @@
 	DebugPrintf("|# |  x |  y | w |elev|cos|box|mov| zp|frm|scl|dir|   cls   |\n");
 	DebugPrintf("+--+----+----+---+----+---+---+---+---+---+---+---+---------+\n");
 	for (i = 1; i < _vm->_numActors; i++) {
-		a = &_vm->_actors[i];
+		a = _vm->_actors[i];
 		if (a->_visible)
 			DebugPrintf("|%2d|%4d|%4d|%3d|%4d|%3d|%3d|%3d|%3d|%3d|%3d|%3d|$%08x|\n",
 						 a->_number, a->getPos().x, a->getPos().y, a->_width, a->getElevation(),

Modified: scummvm/trunk/engines/scumm/object.cpp
===================================================================
--- scummvm/trunk/engines/scumm/object.cpp	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/object.cpp	2006-12-25 15:03:36 UTC (rev 24922)
@@ -249,7 +249,7 @@
 		_classData[obj] &= ~(1 << (cls - 1));
 
 	if (_game.version <= 4 && obj >= 1 && obj < _numActors) {
-		_actors[obj].classChanged(cls, set);
+		_actors[obj]->classChanged(cls, set);
 	}
 }
 

Modified: scummvm/trunk/engines/scumm/room.cpp
===================================================================
--- scummvm/trunk/engines/scumm/room.cpp	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/room.cpp	2006-12-25 15:03:36 UTC (rev 24922)
@@ -96,7 +96,7 @@
 	nukeArrays(0xFF);
 
 	for (i = 1; i < _numActors; i++) {
-		_actors[i].hideActor();
+		_actors[i]->hideActor();
 	}
 
 	if (_game.version >= 7) {

Modified: scummvm/trunk/engines/scumm/saveload.cpp
===================================================================
--- scummvm/trunk/engines/scumm/saveload.cpp	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/saveload.cpp	2006-12-25 15:03:36 UTC (rev 24922)
@@ -934,7 +934,7 @@
 	// Save/load actors
 	//
 	for (i = 0; i < _numActors; i++)
-		_actors[i].saveLoadWithSerializer(s);
+		_actors[i]->saveLoadWithSerializer(s);
 
 
 	//

Modified: scummvm/trunk/engines/scumm/scumm.cpp
===================================================================
--- scummvm/trunk/engines/scumm/scumm.cpp	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/scumm.cpp	2006-12-25 15:03:36 UTC (rev 24922)
@@ -512,6 +512,8 @@
 
 	_mixer->stopAll();
 
+	for (int i = 0; i < _numActors; ++i)
+		delete _actors[i];
 	delete [] _actors;
 	delete [] _sortedActors;
 
@@ -1241,15 +1243,16 @@
 
 	// Allocate and Initialize actors
 	Actor::initActorClass(this);
-	_actors = new Actor[_numActors];
+	_actors = new Actor * [_numActors];
 	_sortedActors = new Actor * [_numActors];
-	for (i = 0; i < _numActors; i++) {
-		_actors[i]._number = i;
-		_actors[i].initActor(1);
+	for (i = 0; i < _numActors; ++i) {
+		_actors[i] = new Actor();
+		_actors[i]->_number = i;
+		_actors[i]->initActor(1);
 
 		// this is from IDB
 		if ((_game.version <= 1) || (_game.id == GID_MANIAC && (_game.features & GF_DEMO)))
-			_actors[i].setActorCostume(i);
+			_actors[i]->setActorCostume(i);
 	}
 
 	if (_game.id == GID_MANIAC && _game.version <= 1) {
@@ -1257,12 +1260,12 @@
 	} else if (_game.id == GID_MANIAC && _game.version == 2 && (_game.features & GF_DEMO)) {
 		// HACK Some palette changes needed for demo script
 		// in Maniac Mansion (Enhanced)
-		_actors[3].setPalette(3, 1);
-		_actors[9]._talkColor = 15;
-		_actors[10]._talkColor = 7;
-		_actors[11]._talkColor = 2;
-		_actors[13]._talkColor = 5;
-		_actors[23]._talkColor = 14;
+		_actors[3]->setPalette(3, 1);
+		_actors[9]->_talkColor = 15;
+		_actors[10]->_talkColor = 7;
+		_actors[11]->_talkColor = 2;
+		_actors[13]->_talkColor = 5;
+		_actors[23]->_talkColor = 14;
 	}
 
 	vm.numNestedScripts = 0;

Modified: scummvm/trunk/engines/scumm/scumm.h
===================================================================
--- scummvm/trunk/engines/scumm/scumm.h	2006-12-24 19:56:13 UTC (rev 24921)
+++ scummvm/trunk/engines/scumm/scumm.h	2006-12-25 15:03:36 UTC (rev 24922)
@@ -527,7 +527,7 @@
 	byte _fastMode;
 
 	byte _numActors;
-	Actor *_actors;	// Has _numActors elements
+	Actor **_actors;	// Has _numActors elements
 	Actor **_sortedActors;
 
 	byte *_arraySlot;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list