[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.39,1.40 actor.h,1.19,1.20 actordata.cpp,1.8,1.9 actordata.h,1.9,1.10 render.cpp,1.40,1.41 scene.cpp,1.57,1.58 scene.h,1.22,1.23

Andrew Kurushin h00ligan at users.sourceforge.net
Sat Dec 18 12:34:00 CET 2004


Update of /cvsroot/scummvm/scummvm/saga
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18399

Modified Files:
	actor.cpp actor.h actordata.cpp actordata.h render.cpp 
	scene.cpp scene.h 
Log Message:
- updating actors state so they can be clipped on drawing (intro now runs without artefact)
- order list now uses only in draw section
- drawList rename to drawActors

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- actor.cpp	18 Dec 2004 16:08:58 -0000	1.39
+++ actor.cpp	18 Dec 2004 20:33:02 -0000	1.40
@@ -70,13 +70,16 @@
 
 	for (i = 0; i < ACTORCOUNT; i++) {
 		actor = &_actors[i];
-		actor->_actorId = ACTOR_INDEX_TO_ID(i);
-		actor->_index = i;
-		debug(0, "init actorId=0x%X index=0x%X", actor->_actorId, actor->_index);
+		actor->actorId = ACTOR_INDEX_TO_ID(i);
+		actor->index = i;
+		debug(0, "init actorId=0x%X index=0x%X", actor->actorId, actor->index);
+		actor->nameIndex = ActorTable[i].nameIndex;
 		actor->spriteListResourceId = ActorTable[i].spriteListResourceId;
 		actor->frameListResourceId = ActorTable[i].frameListResourceId;
-		actor->flags = ActorTable[i].flags;
 		actor->speechColor = ActorTable[i].speechColor;
+		actor->sceneNumber = ActorTable[i].sceneIndex;
+	
+		actor->flags = ActorTable[i].flags;
 		actor->orient = ACTOR_DEFAULT_ORIENT;
 		actor->def_action = 0;
 		actor->def_action_flags = 0;
@@ -84,13 +87,11 @@
 		actor->action_flags = 0;
 		actor->action_time = 0;
 		actor->action_frame = 0;
-		actor->_disabled = !loadActorResources(actor);
-		if (actor->_disabled) {
-			warning("Disabling actorId=0x%X index=0x%X", actor->_actorId, actor->_index);
-		} else {
-			_orderList.push_back(actor);
-		}
 
+		actor->disabled = !loadActorResources(actor);
+		if (actor->disabled) {
+			warning("Disabling actorId=0x%X index=0x%X", actor->actorId, actor->index);
+		} 
 	}
 }
 
@@ -110,7 +111,7 @@
 bool Actor::loadActorResources(ActorData * actor) {
 	byte *resourcePointer;
 	size_t resourceLength;
-	int frameCount;
+	int framesCount;
 	ActorFrame *framesPointer;
 	int lastFrame;
 	int i, orient;
@@ -123,10 +124,10 @@
 		return false;
 	}
 
-	frameCount = resourceLength / 16;
-	debug(0, "Frame resource contains %d frames", frameCount);
+	framesCount = resourceLength / 16;
+	debug(0, "Frame resource contains %d frames", framesCount);
 	
-	framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * frameCount);
+	framesPointer = (ActorFrame *)malloc(sizeof(ActorFrame) * framesCount);
 	if (framesPointer == NULL) {
 		error("Couldn't allocate memory for sprite frames");
 	}
@@ -135,7 +136,7 @@
 
 	lastFrame = 0;
 
-	for (i = 0; i < frameCount; i++) {
+	for (i = 0; i < framesCount; i++) {
 		for (orient = 0; orient < ACTOR_ORIENTATION_COUNT; orient++) {
 			// Load all four orientations
 			framesPointer[i].dir[orient].frameIndex = readS.readUint16();
@@ -149,7 +150,7 @@
 	RSC_FreeResource(resourcePointer);
 
 	actor->frames = framesPointer;
-	actor->frameCount = frameCount;
+	actor->framesCount = framesCount;
 
 
 	debug(0, "Loading sprite resource id 0x%X", actor->spriteListResourceId);
@@ -179,39 +180,26 @@
 
 	actor = &_actors[ACTOR_ID_TO_INDEX(actorId)];
 
-	if (actor->_disabled)
+	if (actor->disabled)
 		error("Actor::getActor disabled actorId 0x%X", actorId);
 
 	return actor;
 }
 
-ActorOrderList::iterator Actor::getActorOrderIterator(const ActorData *actor) {
-	ActorOrderList::iterator actorOrderIterator;
+void Actor::updateActorsScene() {
+	int i;
+	ActorData *actor;
 
-	for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator)
-		if (actor == actorOrderIterator.operator*()) {
-			return actorOrderIterator;
+	for (i = 0; i < ACTORCOUNT; i++) {
+		actor = &_actors[i];
+		if (actor->flags & (kProtagonist | kFollower)) {
+			actor->sceneNumber = _vm->_scene->currentSceneNumber();
 		}
-
-	error("Actor::getActorOrderIterator actor");
-}
-
-void Actor::reorderActorUp(ActorData *actor) {
-	ActorOrderList::iterator actorOrderIterator;
-
-    actorOrderIterator = getActorOrderIterator(actor);
-	actorOrderIterator = _orderList.reorderUp(actorOrderIterator, actorCompare);
-}
-
-void Actor::reorderActorDown(ActorData *actor) {
-	ActorOrderList::iterator actorOrderIterator;
-
-	actorOrderIterator = getActorOrderIterator(actor);
-	actorOrderIterator = _orderList.reorderDown(actorOrderIterator, actorCompare);
+	}
 }
 
 int Actor::direct(int msec) {
-	ActorOrderList::iterator actorOrderIterator;
+	int i;
 	ActorData *actor;
 
 	ActorIntentList::iterator actorIntentIterator;
@@ -221,8 +209,9 @@
 	int action_tdelta;
 
 	// Walk down the actor list and direct each actor
-	for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
-		actor =  actorOrderIterator.operator*();
+	for (i = 0; i < ACTORCOUNT; i++) {
+		actor = &_actors[i];
+		if (actor->disabled) continue;
 
 		// Process the actor intent list
 		actorIntentIterator = actor->a_intentlist.begin();
@@ -236,7 +225,6 @@
 				// Actor intends to go somewhere. Well good for him
 				{
 					handleWalkIntent(actor, &a_intent->walkIntent, &a_intent->a_idone, msec);
-					actorOrderIterator = getActorOrderIterator(actor);
 				}
 				break;
 			case INTENT_SPEAK:
@@ -289,8 +277,22 @@
 	return SUCCESS;
 }
 
-int Actor::drawList() {
-	ActorOrderList::iterator actorOrderIterator;
+void Actor::createDrawOrderList() {
+	int i;
+	ActorData *actor;
+
+	_drawOrderList.clear();
+	for (i = 0;i < ACTORCOUNT;i++) {
+		actor = &_actors[i];
+		if (actor->disabled) continue;
+
+		if (actor->sceneNumber == _vm->_scene->currentSceneNumber())
+			_drawOrderList.pushBack(actor, actorCompare);
+	}
+}
+
+int Actor::drawActors() {
+	ActorOrderList::iterator actorDrawOrderIterator;
 	ActorData *actor;
 
 	ActorIntentList::iterator actorIntentIterator;
@@ -308,14 +310,16 @@
 
 	back_buf = _vm->_gfx->getBackBuffer();
 
-	for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
-		actor =  actorOrderIterator.operator*();
-		if(actor->frameCount == 0) continue;
+	createDrawOrderList();
+
+	for (actorDrawOrderIterator = _drawOrderList.begin(); actorDrawOrderIterator != _drawOrderList.end(); ++actorDrawOrderIterator) {
+		actor =  actorDrawOrderIterator.operator*();
+		if (actor->framesCount == 0) continue;
 
 		o_idx = ActorOrientationLUT[actor->orient];
 		sprite_num = actor->frames[actor->action].dir[o_idx].frameIndex;
 		sprite_num += actor->action_frame;
-		if(actor->spriteList->sprite_count <= sprite_num) continue;
+		if (actor->spriteList->sprite_count <= sprite_num) continue;
 		_vm->_sprite->drawOccluded(back_buf, actor->spriteList, sprite_num, actor->s_pt.x, actor->s_pt.y);
 
 		// If actor's current intent is to speak, oblige him by 
@@ -345,7 +349,7 @@
 // dialogue entry if there is a current speak intent present.
 
 int Actor::skipDialogue() {
-	ActorOrderList::iterator actorOrderIterator;
+	int i;
 	ActorData *actor;
 
 	ActorIntentList::iterator actorIntentIterator;
@@ -354,8 +358,9 @@
 	ActorDialogList::iterator actorDialogIterator;
 	ACTORDIALOGUE *a_dialogue;
 
-	for (actorOrderIterator = _orderList.begin(); actorOrderIterator != _orderList.end(); ++actorOrderIterator) {
-		actor =  actorOrderIterator.operator*();
+	for (i = 0; i < ACTORCOUNT; i++) {
+		actor = &_actors[i];
+		if (actor->disabled) continue;
 		// Check the actor's current intent for a speak intent
 		actorIntentIterator = actor->a_intentlist.begin();
 		if (actorIntentIterator != actor->a_intentlist.end()) {
@@ -526,7 +531,7 @@
 
 	actor = getActor(actorId);
 
-	if ((action_n < 0) || (action_n >= actor->frameCount)) {
+	if ((action_n < 0) || (action_n >= actor->framesCount)) {
 		error("Actor::setAction wrong action_n 0x%X", action_n);
 	}
 
@@ -542,7 +547,7 @@
 
 	actor = getActor(actorId);
 
-	if ((action_n < 0) || (action_n >= actor->frameCount)) {
+	if ((action_n < 0) || (action_n >= actor->framesCount)) {
 		error("Actor::setDefaultAction wrong action_n 0x%X", action_n);
 	}
 
@@ -571,6 +576,8 @@
 	actor_intent.walkIntent.dst_pt = *walk_pt;
 
 	actor->a_intentlist.push_back(actor_intent);
+	int is = actor->a_intentlist.size();
+	debug(0, "actor->a_intentlist.size() %i", is);
 
 	if (sem != NULL) {
 		_vm->_script->SThreadHoldSem(sem);
@@ -620,7 +627,7 @@
 	// Initialize walk intent 
 	if (!a_walkint->wi_init) {
 		setPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
-		setDefaultAction(actor->_actorId, ACTION_IDLE, ACTION_NONE);
+		setDefaultAction(actor->actorId, ACTION_IDLE, ACTION_NONE);
 		a_walkint->wi_init = 1;
 	}
 
@@ -741,12 +748,6 @@
 	actor->s_pt.x = actor->a_pt.x >> 2;
 	actor->s_pt.y = actor->a_pt.y >> 2;
 
-	if (path_slope < 0) {
-		reorderActorUp(actor);
-	} else {
-		reorderActorDown(actor);
-	}
-
 	return SUCCESS;
 }
 
@@ -764,13 +765,6 @@
 	actor->a_pt = movePoint;
 
 	AtoS(actor->s_pt, actor->a_pt);
-
- 	if (moveUp) {
-		reorderActorUp(actor);
-	} else {
-		reorderActorDown(actor);
-	}
-
 }
 
 void Actor::moveRelative(uint16 actorId, const Point &movePoint) {
@@ -782,12 +776,6 @@
 	actor->a_pt.y += movePoint.y;
 
 	AtoS(actor->s_pt, actor->a_pt);
-
-	if (actor->a_pt.y < 0) {
-		reorderActorUp(actor);
-	} else {
-		reorderActorDown(actor);
-	}
 }
 
 void Actor::AtoS(Point &screenPoint, const Point &actorPoint) {

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- actor.h	18 Dec 2004 16:08:59 -0000	1.19
+++ actor.h	18 Dec 2004 20:33:02 -0000	1.20
@@ -177,24 +177,29 @@
 typedef Common::List<ACTORINTENT> ActorIntentList;
 
 struct ActorData {
-	bool _disabled;
-	int _index;		// Actor index
-	uint16 _actorId;	// Actor id
+	bool disabled;				// Actor disabled in init section
+	int index;					// Actor index
+	uint16 actorId;				// Actor id
+	int nameIndex;				// Actor's index in actor name string list
+	byte speechColor;			// Actor dialogue color
+	uint16 flags;				// Actor flags
+	int sceneNumber;			// scene of actor
 
-	int name_i;		// Actor's index in actor name string list
-	uint16 flags;
+	int currentAction;		
+	int facingDirection;
+	int actionDirection;
+	
+	SPRITELIST *spriteList;		// Actor's sprite list data
+	int spriteListResourceId;	// Actor's sprite list resource id
 
-	Point a_pt;		// Actor's logical coordinates
-	Point s_pt;		// Actor's screen coordinates
+	ActorFrame *frames;			// Actor's frames
+	int framesCount;			// Actor's frames count
+	int frameListResourceId;	// Actor's frame list resource id
 
-	SPRITELIST *spriteList;			// Actor's sprite list data
-	int spriteListResourceId;		// Actor's sprite list resource id
 
-	ActorFrame *frames;				// Actor's frames
-	int frameCount;					// Actor's frames count
-	int frameListResourceId;		// Actor's frame list resource id
+	Point a_pt;		// Actor's logical coordinates
+	Point s_pt;		// Actor's screen coordinates
 
-	byte speechColor;		// Actor dialogue color
 
 	int idle_time;
 	int orient;
@@ -220,20 +225,24 @@
 
 
 	ActorData() {
-		_disabled = false;
-		_index = 0;
-		_actorId = 0;
-		name_i = 0;
-		flags = 0;
+		disabled = false;
+		index = 0;
+		actorId = 0;
+		nameIndex = 0;
+		currentAction = 0;
+		facingDirection = 0;
+		actionDirection = 0;
+		speechColor = 0;
 		frames = NULL;
-		frameCount = 0;
+		framesCount = 0;
 		frameListResourceId = 0;
 		spriteList = NULL;
 		spriteListResourceId = 0;
+		flags = 0;
+
 		idle_time = 0;
 		orient = 0;
 		speaking = 0;
-		speechColor = 0;
 		def_action = 0;
 		def_action_flags = 0;
 		action = 0;
@@ -263,8 +272,9 @@
 	void CF_actor_setact(int argc, const char **argv);
 
 	int direct(int msec);
+	int drawActors();
+	void updateActorsScene();			// calls from scene loading to update Actors info
 
-	int drawList();
 	void AtoS(Point &screenPoint, const Point &actorPoint);
 	void StoA(Point &actorPoint, const Point &screenPoint);
 
@@ -282,7 +292,7 @@
 	void setAction(uint16 actorId, int action_n, uint16 action_flags);
 	void setDefaultAction(uint16 actorId, int action_n, uint16 action_flags);
 
-
+	
 private:
 	int handleWalkIntent(ActorData *actor, WALKINTENT *a_walk_int, int *complete_p, int msec);
 	int handleSpeakIntent(ActorData *actor, SPEAKINTENT *a_speakint, int *complete_p, int msec);
@@ -292,14 +302,11 @@
 
 	bool loadActorResources(ActorData * actor);
 	
-	ActorOrderList::iterator getActorOrderIterator(const ActorData *actor);
-	void reorderActorUp(ActorData *actor);
-	void reorderActorDown(ActorData *actor);
-
+	void createDrawOrderList();
 
 	SagaEngine *_vm;
 	RSCFILE_CONTEXT *_actorContext;
-	ActorOrderList _orderList;
+	ActorOrderList _drawOrderList;
 	ActorData _actors[ACTORCOUNT];
 };
 

Index: actordata.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actordata.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- actordata.cpp	17 Dec 2004 20:38:16 -0000	1.8
+++ actordata.cpp	18 Dec 2004 20:33:02 -0000	1.9
@@ -30,7 +30,7 @@
 // Lookup table to convert 8 cardinal directions to 4
 int ActorOrientationLUT[] = { 2, 0, 0, 0, 3, 1, 1, 1 };
 
-ACTORTABLE ActorTable[ACTORCOUNT] = {
+ActorTableData ActorTable[ACTORCOUNT] = {
 //       flags      name scene    x    y     z  spr  frm scp  col 
 //    -------------- --- ----  ---- ----- ---- ---- ---- --- ---- --- -- --
 	{ kProtagonist	,  0,   1,    0,    0,   0,  37, 135,  0,   1,  0, 0, 0},	// map party

Index: actordata.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actordata.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- actordata.h	17 Dec 2004 20:38:16 -0000	1.9
+++ actordata.h	18 Dec 2004 20:33:02 -0000	1.10
@@ -29,18 +29,18 @@
 namespace Saga {
 
 enum {
-	kProtagonist	= 0x01, // Actor is protagonist
-	kFollower	= 0x02, // Actor is follower
-	kCycle		= 0x04, // Actor stand has a cycle
-	kFaster		= 0x08, // Actor is fast
-	kFastest	= 0x10, // Actor is faster
-	kExtended	= 0x20  // Actor uses extended sprites
+	kProtagonist	= 0x01,	// Actor is protagonist
+	kFollower		= 0x02,	// Actor is follower
+	kCycle			= 0x04, // Actor stand has a cycle
+	kFaster			= 0x08, // Actor is fast
+	kFastest		= 0x10, // Actor is faster
+	kExtended		= 0x20  // Actor uses extended sprites
 };
 
 // TODO: This doesn't quite correspond to the original Actor struct, so I'm not
 // sure if I got it right.
 
-struct ACTORTABLE {
+struct ActorTableData {
 	byte flags;
 	byte nameIndex;
 	int32 sceneIndex;
@@ -59,7 +59,7 @@
 #define ACTORCOUNT 181
 
 extern int ActorOrientationLUT[];
-extern ACTORTABLE ActorTable[ACTORCOUNT];
+extern ActorTableData ActorTable[ACTORCOUNT];
 
 } // End of namespace Saga
 

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- render.cpp	3 Dec 2004 19:15:44 -0000	1.40
+++ render.cpp	18 Dec 2004 20:33:02 -0000	1.41
@@ -135,7 +135,7 @@
 	}
 
 	// Draw queued actors
-	_vm->_actor->drawList();
+	_vm->_actor->drawActors();
 
 	// Draw queued text strings
 	_vm->_scene->getInfo(&scene_info);

Index: scene.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.cpp,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- scene.cpp	18 Dec 2004 16:08:59 -0000	1.57
+++ scene.cpp	18 Dec 2004 20:33:02 -0000	1.58
@@ -43,6 +43,7 @@
 
 #include "saga/scene.h"
 #include "saga/stream.h"
+#include "saga/actor.h"
 
 namespace Saga {
 
@@ -552,6 +553,8 @@
 	getInfo(&scene_info);
 
 	_sceneProc(SCENE_BEGIN, &scene_info, this);
+	
+	_vm->_actor->updateActorsScene();
 
 	return SUCCESS;
 }

Index: scene.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/scene.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- scene.h	15 Dec 2004 00:24:11 -0000	1.22
+++ scene.h	18 Dec 2004 20:33:02 -0000	1.23
@@ -137,7 +137,6 @@
 struct SCENE_ANIMINFO {
 	int anim_res_number;
 	int anim_handle;
-	//SCENE_ANIMINFO *next;
 };
 
 typedef SortedList<SCENE_ANIMINFO> SceneAnimInfoList;





More information about the Scummvm-git-logs mailing list