[Scummvm-cvs-logs] CVS: scummvm/saga actor.cpp,1.16,1.17 actor.h,1.5,1.6 input.cpp,1.6,1.7 interface.cpp,1.14,1.15 render.cpp,1.22,1.23 saga.cpp,1.34,1.35 saga.h,1.25,1.26 sdebug.cpp,1.9,1.10 sfuncs.cpp,1.9,1.10 sthread.cpp,1.15,1.16 actor_mod.h,1.4,NONE

Eugene Sandulenko sev at users.sourceforge.net
Mon Aug 2 08:48:03 CEST 2004


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

Modified Files:
	actor.cpp actor.h input.cpp interface.cpp render.cpp saga.cpp 
	saga.h sdebug.cpp sfuncs.cpp sthread.cpp 
Removed Files:
	actor_mod.h 
Log Message:
Objectize actor.cpp


Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- actor.cpp	1 Aug 2004 11:48:52 -0000	1.16
+++ actor.cpp	2 Aug 2004 15:47:42 -0000	1.17
@@ -36,7 +36,6 @@
 #include "text_mod.h"
 #include "sound.h"
 
-#include "actor_mod.h"
 #include "actor.h"
 #include "actordata.h"
 
@@ -44,83 +43,83 @@
 
 static R_ACTOR_MODULE ActorModule;
 
+static int zCompare(const void *elem1, const void *elem2);
+static void CF_actor_add(int argc, char *argv[], void *refCon);
+static void CF_actor_del(int argc, char *argv[], void *refCon);
+static void CF_actor_move(int argc, char *argv[], void *refCon);
+static void CF_actor_moverel(int argc, char *argv[], void *refCon);
+static void CF_actor_seto(int argc, char *argv[], void *refCon);
+static void CF_actor_setact(int argc, char *argv[], void *refCon);
+
 R_ACTIONTIMES ActionTDeltas[] = {
 	{ ACTION_IDLE, 80 },
 	{ ACTION_WALK, 80 },
 	{ ACTION_SPEAK, 200 }
 };
 
-int ACTOR_Register() {
-	CVAR_RegisterFunc(CF_actor_add, "actor_add", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, NULL);
-	CVAR_RegisterFunc(CF_actor_del, "actor_del", "<Actor id>", R_CVAR_NONE, 1, 1, NULL);
-	CVAR_RegisterFunc(CF_actor_move, "actor_move", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, NULL);
-	CVAR_RegisterFunc(CF_actor_moverel, "actor_moverel", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, NULL);
-	CVAR_RegisterFunc(CF_actor_seto, "actor_seto", "<Actor id> <Orientation>", R_CVAR_NONE, 2, 2, NULL);
-	CVAR_RegisterFunc(CF_actor_setact, "actor_setact", "<Actor id> <Action #>", R_CVAR_NONE, 2, 2, NULL);
+int Actor::reg() {
+	CVAR_RegisterFunc(CF_actor_add, "actor_add", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, this);
+	CVAR_RegisterFunc(CF_actor_del, "actor_del", "<Actor id>", R_CVAR_NONE, 1, 1, this);
+	CVAR_RegisterFunc(CF_actor_move, "actor_move", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, this);
+	CVAR_RegisterFunc(CF_actor_moverel, "actor_moverel", "<Actor id> <lx> <ly>", R_CVAR_NONE, 3, 3, this);
+	CVAR_RegisterFunc(CF_actor_seto, "actor_seto", "<Actor id> <Orientation>", R_CVAR_NONE, 2, 2, this);
+	CVAR_RegisterFunc(CF_actor_setact, "actor_setact", "<Actor id> <Action #>", R_CVAR_NONE, 2, 2, this);
 
 	return R_SUCCESS;
 }
 
-int ACTOR_Init() {
+Actor::Actor(SagaEngine *vm) : _vm(vm), _initialized(false) {
 	int result;
 	int i;
 
-	if (ActorModule.init) {
-		ActorModule.err_str = "Actor module already initialized.";
-		return R_FAILURE;
-	}
-
 	// Get actor resource file context
-	result = GAME_GetFileContext(&ActorModule.actor_ctxt, R_GAME_RESOURCEFILE, 0);
+	result = GAME_GetFileContext(&_actorContext, R_GAME_RESOURCEFILE, 0);
 	if (result != R_SUCCESS) {
-		ActorModule.err_str = "Couldn't load actor module resource context.";
-		return R_FAILURE;
+		error("Actor::Actor(): Couldn't load actor module resource context.");
 	}
 
 	// Create actor lookup table
-	ActorModule.tbl = (YS_DL_NODE **)malloc(R_ACTORCOUNT * sizeof *ActorModule.tbl);
-	if (ActorModule.tbl == NULL) {
-		ActorModule.err_str = "Memory allocation error.";
-		return R_MEM;
+	_tbl = (YS_DL_NODE **)malloc(R_ACTORCOUNT * sizeof(*_tbl));
+	if (_tbl == NULL) {
+		error("Actor::Actor(): Memory allocation error.");
+		return;
 	}
 
 	for (i = 0; i < R_ACTORCOUNT; i++) {
-		ActorModule.tbl[i] = NULL;
+		_tbl[i] = NULL;
 	}
 
 	// Create actor alias table
-	ActorModule.alias_tbl = (int *)malloc(R_ACTORCOUNT * sizeof *ActorModule.alias_tbl);
-	if (ActorModule.alias_tbl == NULL) {
-		free(ActorModule.tbl);
-		ActorModule.err_str = "Memory allocation error.";
-		return R_MEM;
+	_aliasTbl = (int *)malloc(R_ACTORCOUNT * sizeof *_aliasTbl);
+	if (_aliasTbl == NULL) {
+		free(_tbl);
+		error("Actor::Actor(): Memory allocation error.");
+		return;
 	}
 
 	// Initialize alias table so each index contains itself
 	for (i = 0; i < R_ACTORCOUNT; i++) {
-		ActorModule.alias_tbl[i] = i;
+		_aliasTbl[i] = i;
 	}
 
 	// Create actor list
-	ActorModule.list = ys_dll_create();
-	ActorModule.init = 1;
+	_list = ys_dll_create();
 
-	return R_SUCCESS;
+	_count = 0;
+	_initialized = true;
 }
 
-int ACTOR_Shutdown() {
-	if (!ActorModule.init) {
-		return R_FAILURE;
+Actor::~Actor() {
+	if (!_initialized) {
+		return;
 	}
 
-	if (ActorModule.tbl) {
-		free(ActorModule.tbl);
+	if (_tbl) {
+		free(_tbl);
 	}
-
-	return R_SUCCESS;
 }
 
-int ACTOR_Direct(int msec) {
+int Actor::direct(int msec) {
 	YS_DL_NODE *walk_p;
 	R_ACTOR *actor;
 
@@ -131,7 +130,7 @@
 	int action_tdelta;
 
 	// Walk down the actor list and direct each actor
-	for (walk_p = ys_dll_head(ActorModule.list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
+	for (walk_p = ys_dll_head(_list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
 		actor = (R_ACTOR *)ys_dll_get_data(walk_p);
 		// Process the actor intent list
 		a_inode = ys_dll_head(actor->a_intentlist);
@@ -146,7 +145,7 @@
 				{
 					R_WALKINTENT *a_walkint;
 					a_walkint = (R_WALKINTENT *)a_intent->a_data;
-					HandleWalkIntent(actor, a_walkint, &a_intent->a_idone, msec);
+					handleWalkIntent(actor, a_walkint, &a_intent->a_idone, msec);
 				}
 				break;
 			case INTENT_SPEAK:
@@ -154,7 +153,7 @@
 				{
 					R_SPEAKINTENT *a_speakint;
 					a_speakint = (R_SPEAKINTENT *)a_intent->a_data;
-					HandleSpeakIntent(actor, a_speakint, &a_intent->a_idone, msec);
+					handleSpeakIntent(actor, a_speakint, &a_intent->a_idone, msec);
 				}
 				break;
 
@@ -202,7 +201,7 @@
 	return R_SUCCESS;
 }
 
-int ACTOR_DrawList() {
+int Actor::drawList() {
 	YS_DL_NODE *walk_p;
 	R_ACTOR *actor;
 
@@ -222,7 +221,7 @@
 
 	back_buf = _vm->_gfx->getBackBuffer();
 
-	for (walk_p = ys_dll_head(ActorModule.list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
+	for (walk_p = ys_dll_head(_list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
 		actor = (R_ACTOR *)ys_dll_get_data(walk_p);
 		o_idx = ActorOrientationLUT[actor->orient];
 		sprite_num = actor->act_tbl[actor->action].dir[o_idx].frame_index;
@@ -256,7 +255,7 @@
 // original game). Will find all actors currently talking and remove one
 // dialogue entry if there is a current speak intent present.
 
-int ACTOR_SkipDialogue() {
+int Actor::skipDialogue() {
 	YS_DL_NODE *walk_p;
 	R_ACTOR *actor;
 
@@ -267,11 +266,11 @@
 	YS_DL_NODE *a_dnode;
 	R_ACTORDIALOGUE *a_dialogue;
 
-	if (!ActorModule.init) {
+	if (!_initialized) {
 		return R_FAILURE;
 	}
 
-	for (walk_p = ys_dll_head(ActorModule.list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
+	for (walk_p = ys_dll_head(_list); walk_p != NULL; walk_p = ys_dll_next(walk_p)) {
 		actor = (R_ACTOR *)ys_dll_get_data(walk_p);
 		// Check the actor's current intent for a speak intent
 		a_inode = ys_dll_head(actor->a_intentlist);
@@ -298,7 +297,7 @@
 	return R_SUCCESS;
 }
 
-int ACTOR_Create(int actor_id, int x, int y) {
+int Actor::create(int actor_id, int x, int y) {
 	R_ACTOR actor;
 
 	if (actor_id == 1) {
@@ -311,7 +310,7 @@
 	actor.a_pt.x = x;
 	actor.a_pt.y = y;
 
-	if (AddActor(&actor) != R_SUCCESS) {
+	if (addActor(&actor) != R_SUCCESS) {
 
 		return R_FAILURE;
 	}
@@ -319,12 +318,12 @@
 	return R_SUCCESS;
 }
 
-int AddActor(R_ACTOR * actor) {
+int Actor::addActor(R_ACTOR * actor) {
 	YS_DL_NODE *new_node;
 	int last_frame;
 	int i;
 
-	if (!ActorModule.init) {
+	if (!_initialized) {
 		return R_FAILURE;
 	}
 
@@ -332,18 +331,18 @@
 		return R_FAILURE;
 	}
 
-	if (ActorModule.tbl[actor->id] != NULL) {
+	if (_tbl[actor->id] != NULL) {
 		return R_FAILURE;
 	}
 
-	ACTOR_AtoS(&actor->s_pt, &actor->a_pt);
+	AtoS(&actor->s_pt, &actor->a_pt);
 
 	i = actor->id;
 
 	actor->sl_rn = ActorTable[i].spritelist_rn;
 	actor->si_rn = ActorTable[i].spriteindex_rn;
 
-	LoadActorSpriteIndex(actor, actor->si_rn, &last_frame);
+	loadActorSpriteIndex(actor, actor->si_rn, &last_frame);
 
 	if (SPRITE_LoadList(actor->sl_rn, &actor->sl_p) != R_SUCCESS) {
 		return R_FAILURE;
@@ -367,7 +366,7 @@
 	actor->action_time = 0;
 	actor->action_frame = 0;
 
-	new_node = ys_dll_insert(ActorModule.list, actor, sizeof *actor, Z_Compare);
+	new_node = ys_dll_insert(_list, actor, sizeof *actor, zCompare);
 
 	if (new_node == NULL) {
 		return R_FAILURE;
@@ -376,13 +375,13 @@
 	actor = (R_ACTOR *)ys_dll_get_data(new_node);
 	actor->node = new_node;
 
-	ActorModule.tbl[i] = new_node;
-	ActorModule.count++;
+	_tbl[i] = new_node;
+	_count++;
 
 	return R_SUCCESS;
 }
 
-int ACTOR_GetActorIndex(uint16 actor_id) {
+int Actor::getActorIndex(uint16 actor_id) {
 	uint16 actor_idx;
 
 	if (actor_id == 1) {
@@ -391,14 +390,14 @@
 		actor_idx = actor_id & ~0x2000;
 	}
 
-	if (ActorModule.tbl[actor_idx] == NULL) {
+	if (_tbl[actor_idx] == NULL) {
 		return -1;
 	}
 
 	return actor_idx;
 }
 
-int ACTOR_ActorExists(uint16 actor_id) {
+int Actor::actorExists(uint16 actor_id) {
 	uint16 actor_idx;
 
 	if (actor_id == 1) {
@@ -407,14 +406,14 @@
 		actor_idx = actor_id & ~0x2000;
 	}
 
-	if (ActorModule.tbl[actor_idx] == NULL) {
+	if (_tbl[actor_idx] == NULL) {
 		return 0;
 	}
 
 	return 1;
 }
 
-int ACTOR_Speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE *sem) {
+int Actor::speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE *sem) {
 	YS_DL_NODE *node;
 	R_ACTOR *actor;
 	YS_DL_NODE *a_inode;
@@ -426,11 +425,11 @@
 
 	a_dialogue.d_string = d_string;
 	a_dialogue.d_voice_rn = d_voice_rn;
-	a_dialogue.d_time = ACTOR_GetSpeechTime(d_string, d_voice_rn);
+	a_dialogue.d_time = getSpeechTime(d_string, d_voice_rn);
 	a_dialogue.d_sem_held = 1;
 	a_dialogue.d_sem = sem;
 
-	node = ActorModule.tbl[index];
+	node = _tbl[index];
 	if (node == NULL) {
 		return R_FAILURE;
 	}
@@ -480,7 +479,7 @@
 	return R_SUCCESS;
 }
 
-int HandleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec) {
+int Actor::handleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec) {
 	YS_DL_NODE *a_dnode;
 	YS_DL_NODE *a_dnext;
 	R_ACTORDIALOGUE *a_dialogue;
@@ -548,7 +547,7 @@
 	return R_SUCCESS;
 }
 
-int ACTOR_GetSpeechTime(const char *d_string, uint16 d_voice_rn) {
+int Actor::getSpeechTime(const char *d_string, uint16 d_voice_rn) {
 	int voice_len;
 
 	voice_len = _vm->_sndRes->getVoiceLength(d_voice_rn);
@@ -560,10 +559,10 @@
 	return voice_len;
 }
 
-int ACTOR_SetOrientation(int index, int orient) {
+int Actor::setOrientation(int index, int orient) {
 	R_ACTOR *actor;
 
-	if (!ActorModule.init) {
+	if (!_initialized) {
 		return R_FAILURE;
 	}
 
@@ -571,7 +570,7 @@
 		return R_FAILURE;
 	}
 
-	actor = LookupActor(index);
+	actor = lookupActor(index);
 	if (actor == NULL) {
 
 		return R_FAILURE;
@@ -582,14 +581,14 @@
 	return R_SUCCESS;
 }
 
-int ACTOR_SetAction(int index, int action_n, uint16 action_flags) {
+int Actor::setAction(int index, int action_n, uint16 action_flags) {
 	R_ACTOR *actor;
 
-	if (!ActorModule.init) {
+	if (!_initialized) {
 		return R_FAILURE;
 	}
 
-	actor = LookupActor(index);
+	actor = lookupActor(index);
 	if (actor == NULL) {
 		return R_FAILURE;
 	}
@@ -606,14 +605,14 @@
 	return R_SUCCESS;
 }
 
-int ACTOR_SetDefaultAction(int index, int action_n, uint16 action_flags) {
+int Actor::setDefaultAction(int index, int action_n, uint16 action_flags) {
 	R_ACTOR *actor;
 
-	if (!ActorModule.init) {
+	if (!_initialized) {
 		return R_FAILURE;
 	}
 
-	actor = LookupActor(index);
+	actor = lookupActor(index);
 	if (actor == NULL) {
 		return R_FAILURE;
 	}
@@ -628,11 +627,11 @@
 	return R_SUCCESS;
 }
 
-R_ACTOR *LookupActor(int index) {
+R_ACTOR *Actor::lookupActor(int index) {
 	YS_DL_NODE *node;
 	R_ACTOR *actor;
 
-	if (!ActorModule.init) {
+	if (!_initialized) {
 		return NULL;
 	}
 
@@ -640,17 +639,17 @@
 		return NULL;
 	}
 
-	if (ActorModule.tbl[index] == NULL) {
+	if (_tbl[index] == NULL) {
 		return NULL;
 	}
 
-	node = ActorModule.tbl[index];
+	node = _tbl[index];
 	actor = (R_ACTOR *)ys_dll_get_data(node);
 
 	return actor;
 }
 
-int LoadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) {
+int Actor::loadActorSpriteIndex(R_ACTOR * actor, int si_rn, int *last_frame_p) {
 	byte *res_p;
 	size_t res_len;
 	int s_action_ct;
@@ -659,7 +658,7 @@
 	int i, orient;
 	int result;
 
-	result = RSC_LoadResource(ActorModule.actor_ctxt, si_rn, &res_p, &res_len);
+	result = RSC_LoadResource(_actorContext, si_rn, &res_p, &res_len);
 	if (result != R_SUCCESS) {
 		warning("Couldn't load sprite action index resource");
 		return R_FAILURE;
@@ -702,11 +701,11 @@
 	return R_SUCCESS;
 }
 
-int DeleteActor(int index) {
+int Actor::deleteActor(int index) {
 	YS_DL_NODE *node;
 	R_ACTOR *actor;
 
-	if (!ActorModule.init) {
+	if (!_initialized) {
 		return R_FAILURE;
 	}
 
@@ -714,41 +713,41 @@
 		return R_FAILURE;
 	}
 
-	if (ActorModule.tbl[index] == NULL) {
+	if (_tbl[index] == NULL) {
 		return R_FAILURE;
 	}
 
-	node = ActorModule.tbl[index];
+	node = _tbl[index];
 	actor = (R_ACTOR *)ys_dll_get_data(node);
 
 	SPRITE_Free(actor->sl_p);
 
 	ys_dll_delete(node);
 
-	ActorModule.tbl[index] = NULL;
+	_tbl[index] = NULL;
 
 	return R_SUCCESS;
 }
 
-int ACTOR_WalkTo(int id, R_POINT *walk_pt, uint16 flags, R_SEMAPHORE *sem) {
+int Actor::walkTo(int id, R_POINT *walk_pt, uint16 flags, R_SEMAPHORE *sem) {
 	R_ACTORINTENT actor_intent;
 	R_WALKINTENT *walk_intent;
 	R_WALKINTENT zero_intent;
 	YS_DL_NODE *node;
 	R_ACTOR *actor;
 
-	assert(ActorModule.init);
+	assert(_initialized);
 	assert(walk_pt != NULL);
 
 	if ((id < 0) || (id >= R_ACTORCOUNT)) {
 		return R_FAILURE;
 	}
 
-	if (ActorModule.tbl[id] == NULL) {
+	if (_tbl[id] == NULL) {
 		return R_FAILURE;
 	}
 
-	node = ActorModule.tbl[id];
+	node = _tbl[id];
 	actor = (R_ACTOR *)ys_dll_get_data(node);
 
 	walk_intent = (R_WALKINTENT *)malloc(sizeof *walk_intent);
@@ -762,7 +761,7 @@
 	walk_intent->sem_held = 1;
 	walk_intent->sem = sem;
 
-	// HandleWalkIntent() will create path on initialization
+	// handleWalkIntent() will create path on initialization
 	walk_intent->wi_init = 0;
 	walk_intent->dst_pt = *walk_pt;
 
@@ -779,7 +778,7 @@
 	return R_SUCCESS;
 }
 
-int ACTOR_SetPathNode(R_WALKINTENT *walk_int, R_POINT *src_pt, R_POINT *dst_pt, R_SEMAPHORE *sem) {
+int Actor::setPathNode(R_WALKINTENT *walk_int, R_POINT *src_pt, R_POINT *dst_pt, R_SEMAPHORE *sem) {
 	R_WALKNODE new_node;
 
 	walk_int->wi_active = 1;
@@ -796,7 +795,7 @@
 	return R_SUCCESS;
 }
 
-int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, int delta_time) {
+int Actor::handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walkint, int *complete_p, int delta_time) {
 	YS_DL_NODE *walk_p;
 	YS_DL_NODE *next_p;
 
@@ -823,8 +822,8 @@
 	// Initialize walk intent 
 	if (!a_walkint->wi_init) {
 		a_walkint->nodelist = ys_dll_create();
-		ACTOR_SetPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
-		ACTOR_SetDefaultAction(actor->id, ACTION_IDLE, ACTION_NONE);
+		setPathNode(a_walkint, &actor->a_pt, &a_walkint->dst_pt, a_walkint->sem);
+		setDefaultAction(actor->id, ACTION_IDLE, ACTION_NONE);
 		a_walkint->wi_init = 1;
 	}
 
@@ -954,22 +953,22 @@
 	actor->s_pt.y = actor->a_pt.y >> 2;
 
 	if (path_slope < 0) {
-		ys_dll_reorder_up(ActorModule.list, actor->node, Z_Compare);
+		ys_dll_reorder_up(_list, actor->node, zCompare);
 
 	} else {
-		ys_dll_reorder_down(ActorModule.list, actor->node, Z_Compare);
+		ys_dll_reorder_down(_list, actor->node, zCompare);
 	}
 
 	return R_SUCCESS;
 }
 
-int ACTOR_Move(int index, R_POINT *move_pt) {
+int Actor::move(int index, R_POINT *move_pt) {
 	YS_DL_NODE *node;
 	R_ACTOR *actor;
 
 	int move_up = 0;
 
-	node = ActorModule.tbl[index];
+	node = _tbl[index];
 	if (node == NULL) {
 		return R_FAILURE;
 	}
@@ -983,23 +982,23 @@
 	actor->a_pt.x = move_pt->x;
 	actor->a_pt.y = move_pt->y;
 
-	ACTOR_AtoS(&actor->s_pt, &actor->a_pt);
+	AtoS(&actor->s_pt, &actor->a_pt);
 
 	if (move_up) {
-		ys_dll_reorder_up(ActorModule.list, actor->node, Z_Compare);
+		ys_dll_reorder_up(_list, actor->node, zCompare);
 	} else {
 
-		ys_dll_reorder_down(ActorModule.list, actor->node, Z_Compare);
+		ys_dll_reorder_down(_list, actor->node, zCompare);
 	}
 
 	return R_SUCCESS;
 }
 
-int ACTOR_MoveRelative(int index, R_POINT *move_pt) {
+int Actor::moveRelative(int index, R_POINT *move_pt) {
 	YS_DL_NODE *node;
 	R_ACTOR *actor;
 
-	node = ActorModule.tbl[index];
+	node = _tbl[index];
 	if (node == NULL) {
 		return R_FAILURE;
 	}
@@ -1009,21 +1008,21 @@
 	actor->a_pt.x += move_pt->x;
 	actor->a_pt.y += move_pt->y;
 
-	ACTOR_AtoS(&actor->s_pt, &actor->a_pt);
+	AtoS(&actor->s_pt, &actor->a_pt);
 
 	if (actor->a_pt.y < 0) {
 
-		ys_dll_reorder_up(ActorModule.list, actor->node, Z_Compare);
+		ys_dll_reorder_up(_list, actor->node, zCompare);
 	} else {
 
-		ys_dll_reorder_down(ActorModule.list, actor->node, Z_Compare);
+		ys_dll_reorder_down(_list, actor->node, zCompare);
 
 	}
 
 	return R_SUCCESS;
 }
 
-int Z_Compare(const void *elem1, const void *elem2) {
+static int zCompare(const void *elem1, const void *elem2) {
 	const R_ACTOR *actor1 = (const R_ACTOR *) elem1;
 	const R_ACTOR *actor2 = (const R_ACTOR *) elem2;
 
@@ -1036,14 +1035,14 @@
 	}
 }
 
-int ACTOR_AtoS(R_POINT *screen, const R_POINT *actor) {
+int Actor::AtoS(R_POINT *screen, const R_POINT *actor) {
 	screen->x = (actor->x / R_ACTOR_LMULT);
 	screen->y = (actor->y / R_ACTOR_LMULT);
 
 	return R_SUCCESS;
 }
 
-int ACTOR_StoA(R_POINT *actor, const R_POINT *screen) {
+int Actor::StoA(R_POINT *actor, const R_POINT *screen) {
 	actor->x = (screen->x * R_ACTOR_LMULT);
 	actor->y = (screen->y * R_ACTOR_LMULT);
 
@@ -1061,7 +1060,7 @@
 	actor.a_pt.x = atoi(argv[1]);
 	actor.a_pt.y = atoi(argv[2]);
 
-	AddActor(&actor);
+	((Actor *)refCon)->addActor(&actor);
 
 	return;
 }
@@ -1074,7 +1073,7 @@
 
 	id = atoi(argv[0]);
 
-	DeleteActor(id);
+	((Actor *)refCon)->deleteActor(id);
 
 	return;
 }
@@ -1091,7 +1090,7 @@
 	move_pt.x = atoi(argv[1]);
 	move_pt.y = atoi(argv[2]);
 
-	ACTOR_Move(id, &move_pt);
+	((Actor *)refCon)->move(id, &move_pt);
 
 	return;
 }
@@ -1108,7 +1107,7 @@
 	move_pt.x = atoi(argv[1]);
 	move_pt.y = atoi(argv[2]);
 
-	ACTOR_MoveRelative(id, &move_pt);
+	((Actor *)refCon)->moveRelative(id, &move_pt);
 
 	return;
 }
@@ -1123,7 +1122,7 @@
 	id = atoi(argv[0]);
 	orient = atoi(argv[1]);
 
-	ACTOR_SetOrientation(id, orient);
+	((Actor *)refCon)->setOrientation(id, orient);
 
 	return;
 }
@@ -1140,7 +1139,7 @@
 	index = atoi(argv[0]);
 	action_n = atoi(argv[1]);
 
-	actor = LookupActor(index);
+	actor = ((Actor *)refCon)->lookupActor(index);
 	if (actor == NULL) {
 		CON_Print("Invalid actor index.");
 
@@ -1159,7 +1158,7 @@
 			actor->act_tbl[action_n].dir[2].frame_count,
 			actor->act_tbl[action_n].dir[3].frame_count);
 
-	ACTOR_SetAction(index, action_n, ACTION_LOOP);
+	((Actor *)refCon)->setAction(index, action_n, ACTION_LOOP);
 
 	return;
 }

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- actor.h	31 Jul 2004 23:33:14 -0000	1.5
+++ actor.h	2 Aug 2004 15:47:42 -0000	1.6
@@ -26,6 +26,9 @@
 #ifndef SAGA_ACTOR_H__
 #define SAGA_ACTOR_H__
 
+#include "yslib.h"
+#include "sprite_mod.h"
+
 namespace Saga {
 
 #define ACTOR_BASE_SPEED 0.25
@@ -47,6 +50,34 @@
 	INTENT_SPEAK = 2
 };
 
+enum R_ACTOR_WALKFLAGS {
+	WALK_NONE = 0x00,
+	WALK_NOREORIENT = 0x01
+};
+
+enum R_ACTOR_ORIENTATIONS {
+	ORIENT_N = 0,
+	ORIENT_NE = 1,
+	ORIENT_E = 2,
+	ORIENT_SE = 3,
+	ORIENT_S = 4,
+	ORIENT_SW = 5,
+	ORIENT_W = 6,
+	ORIENT_NW = 7
+};
+
+enum R_ACTOR_ACTIONS {
+	ACTION_IDLE = 0,
+	ACTION_WALK = 1,
+	ACTION_SPEAK = 2,
+	ACTION_COUNT
+};
+
+enum R_ACTOR_ACTIONFLAGS {
+	ACTION_NONE = 0x00,
+	ACTION_LOOP = 0x01
+};
+
 struct R_ACTORACTIONITEM {
 	int frame_index;
 	int frame_count;
@@ -155,28 +186,58 @@
 
 struct R_ACTOR_MODULE {
 	int init;
-	R_RSCFILE_CONTEXT *actor_ctxt;
-	uint16 count;
-	int *alias_tbl;
-	YS_DL_NODE **tbl;
-	YS_DL_LIST *list;
-	int err_n;
 	const char *err_str;
 };
 
-R_ACTOR *LookupActor(int index);
-int AddActor(R_ACTOR * actor);
-int Z_Compare(const void *elem1, const void *elem2);
-int HandleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walk_int, int *complete_p, int msec);
-int HandleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec);
-int ACTOR_SetPathNode(R_WALKINTENT *walk_int, R_POINT *src_pt, R_POINT *dst_pt, R_SEMAPHORE *sem);
-int LoadActorSpriteIndex(R_ACTOR *actor, int si_rn, int *last_frame_p);
-static void CF_actor_add(int argc, char *argv[], void *refCon);
-static void CF_actor_del(int argc, char *argv[], void *refCon);
-static void CF_actor_move(int argc, char *argv[], void *refCon);
-static void CF_actor_moverel(int argc, char *argv[], void *refCon);
-static void CF_actor_seto(int argc, char *argv[], void *refCon);
-static void CF_actor_setact(int argc, char *argv[], void *refCon);
+class Actor {
+ public:
+	int reg();
+	Actor(SagaEngine *vm);
+	~Actor();
+
+	int direct(int msec);
+
+	int create(int actor_id, int x, int y);
+	int actorExists(uint16 actor_id);
+
+	int drawList();
+	int AtoS(R_POINT *logical, const R_POINT *actor);
+	int StoA(R_POINT *actor, const R_POINT *screen);
+
+	int move(int index, R_POINT *move_pt);
+	int moveRelative(int index, R_POINT *move_pt);
+
+	int walkTo(int index, R_POINT *walk_pt, uint16 flags, R_SEMAPHORE *sem);
+	
+	int getActorIndex(uint16 actor_id);
+	
+	int speak(int index, const char *d_string, uint16 d_voice_rn, R_SEMAPHORE *sem);
+	
+	int skipDialogue();
+	
+	int getSpeechTime(const char *d_string, uint16 d_voice_rn);
+	int setOrientation(int index, int orient);
+	int setAction(int index, int action_n, uint16 action_flags);
+	int setDefaultAction(int index, int action_n, uint16 action_flags);
+
+	int addActor(R_ACTOR * actor);
+	int deleteActor(int index);
+	R_ACTOR *lookupActor(int index);
+
+ private:
+	int handleWalkIntent(R_ACTOR *actor, R_WALKINTENT *a_walk_int, int *complete_p, int msec);
+	int handleSpeakIntent(R_ACTOR *actor, R_SPEAKINTENT *a_speakint, int *complete_p, int msec);
+	int setPathNode(R_WALKINTENT *walk_int, R_POINT *src_pt, R_POINT *dst_pt, R_SEMAPHORE *sem);
+	int loadActorSpriteIndex(R_ACTOR *actor, int si_rn, int *last_frame_p);
+
+	SagaEngine *_vm;
+	bool _initialized;
+	R_RSCFILE_CONTEXT *_actorContext;
+	uint16 _count;
+	int *_aliasTbl;
+	YS_DL_NODE **_tbl;
+	YS_DL_LIST *_list;
+};
 
 } // End of namespace Saga
 

Index: input.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/input.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- input.cpp	1 Aug 2004 11:48:53 -0000	1.6
+++ input.cpp	2 Aug 2004 15:47:42 -0000	1.7
@@ -23,7 +23,7 @@
 #include "saga/saga.h"
 
 #include "saga/gfx.h"
-#include "saga/actor_mod.h"
+#include "saga/actor.h"
 #include "saga/console_mod.h"
 #include "saga/interface_mod.h"
 #include "saga/render.h"
@@ -98,7 +98,7 @@
 
 			// Actual game keys
 			case 32: // space
-				ACTOR_SkipDialogue();
+				_vm->_actor->skipDialogue();
 				break;
 			case 19:  // pause
 			case 112: // p

Index: interface.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/interface.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- interface.cpp	2 Aug 2004 15:44:18 -0000	1.14
+++ interface.cpp	2 Aug 2004 15:47:42 -0000	1.15
@@ -27,7 +27,7 @@
 #include "gfx.h"
 #include "game_mod.h"
 #include "cvar_mod.h"
-#include "actor_mod.h"
+#include "actor.h"
 #include "console_mod.h"
 #include "font_mod.h"
 #include "objectmap.h"
@@ -484,8 +484,8 @@
 
 	if (hit_object != R_SUCCESS) {
 		// Player clicked on empty spot - walk here regardless of verb
-		ACTOR_StoA(&iactor_pt, imouse_pt);
-		ACTOR_WalkTo(0, &iactor_pt, 0, NULL);
+		_vm->_actor->StoA(&iactor_pt, imouse_pt);
+		_vm->_actor->walkTo(0, &iactor_pt, 0, NULL);
 		return R_SUCCESS;
 	}
 
@@ -506,8 +506,8 @@
 		}
 	} else {
 		// Not a normal scene object - walk to it as if it weren't there
-		ACTOR_StoA(&iactor_pt, imouse_pt);
-		ACTOR_WalkTo(0, &iactor_pt, 0, NULL);
+		_vm->_actor->StoA(&iactor_pt, imouse_pt);
+		_vm->_actor->walkTo(0, &iactor_pt, 0, NULL);
 	}
 
 	return R_SUCCESS;

Index: render.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/render.cpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- render.cpp	2 Aug 2004 15:44:18 -0000	1.22
+++ render.cpp	2 Aug 2004 15:47:42 -0000	1.23
@@ -25,7 +25,7 @@
 #include "saga.h"
 
 #include "gfx.h"
-#include "actor_mod.h"
+#include "actor.h"
 #include "console_mod.h"
 #include "cvar_mod.h"
 #include "font_mod.h"
@@ -142,7 +142,7 @@
 	}
 
 	// Draw queued actors
-	ACTOR_DrawList();
+	_vm->_actor->drawList();
 
 	// Draw queued text strings
 	SCENE_GetInfo(&scene_info);

Index: saga.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -d -r1.34 -r1.35
--- saga.cpp	2 Aug 2004 15:44:18 -0000	1.34
+++ saga.cpp	2 Aug 2004 15:47:42 -0000	1.35
@@ -35,7 +35,7 @@
 #include "gfx.h"
 #include "rscfile_mod.h"
 #include "render.h"
-#include "actor_mod.h"
+#include "actor.h"
 #include "animation.h"
 #include "console_mod.h"
 #include "cvar_mod.h"
@@ -117,7 +117,6 @@
 	CON_Register(); // Register console cvars first
 
 	GAME_Register();
-	ACTOR_Register();
 	SCENE_Register();
 
 	MainData.sound_enabled = 1;
@@ -156,7 +155,7 @@
 	_script = new Script();
 	_sdata = new SData();
 	INTERFACE_Init(); // requires script module
-	ACTOR_Init();
+	_actor = new Actor(this);
 
 	if (SCENE_Init() != R_SUCCESS) {
 		warning("Couldn't initialize scene module");
@@ -203,6 +202,7 @@
 		debug(0, "Sound disabled.");
 	}
 
+	_actor->reg();
 	_script->reg();
 	_render->reg();
 	_anim->reg();
@@ -232,7 +232,7 @@
 			if (msec > R_MAX_TIME_DELTA) {
 				msec = R_MAX_TIME_DELTA;
 			}
-			ACTOR_Direct(msec);
+			_actor->direct(msec);
 			EVENT_HandleEvents(msec);
 			STHREAD_ExecThreads(msec);
 		}
@@ -244,7 +244,7 @@
 
 void SagaEngine::shutdown() {
 	SCENE_Shutdown();
-	ACTOR_Shutdown();
+	delete _actor;
 	delete _script;
 	SPRITE_Shutdown();
 	FONT_Shutdown();

Index: saga.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/saga.h,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- saga.h	2 Aug 2004 15:44:18 -0000	1.25
+++ saga.h	2 Aug 2004 15:47:42 -0000	1.26
@@ -48,6 +48,7 @@
 class Gfx;
 class SData;
 class Script;
+class Actor;
 
 using Common::MemoryReadStream;
 
@@ -101,6 +102,7 @@
 	Gfx *_gfx;
 	SData *_sdata;
 	Script *_script;
+	Actor *_actor;
 	
 private:
 	int decodeBGImageRLE(const byte *inbuf, size_t inbuf_len, byte *outbuf, size_t outbuf_len);

Index: sdebug.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sdebug.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sdebug.cpp	1 Aug 2004 23:47:19 -0000	1.9
+++ sdebug.cpp	2 Aug 2004 15:47:42 -0000	1.10
@@ -25,7 +25,6 @@
 #include "saga.h"
 
 #include "gfx.h"
-#include "actor_mod.h"
 #include "console_mod.h"
 #include "text_mod.h"
 #include "scene_mod.h"

Index: sfuncs.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sfuncs.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- sfuncs.cpp	1 Aug 2004 19:53:29 -0000	1.9
+++ sfuncs.cpp	2 Aug 2004 15:47:42 -0000	1.10
@@ -26,7 +26,7 @@
 #include "saga.h"
 
 #include "gfx.h"
-#include "actor_mod.h"
+#include "actor.h"
 #include "animation.h"
 #include "console_mod.h"
 #include "interface_mod.h"
@@ -174,7 +174,7 @@
 	SSTACK_Pop(thread->stack, &y_parm);
 
 	actor_id = _vm->_sdata->readWordS(actor_parm);
-	actor_idx = ACTOR_GetActorIndex(actor_id);
+	actor_idx = _vm->_actor->getActorIndex(actor_id);
 	if (actor_idx < 0) {
 		CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.", actor_id);
 		return R_FAILURE;
@@ -183,7 +183,7 @@
 	pt.x = _vm->_sdata->readWordS(x_parm);
 	pt.y = _vm->_sdata->readWordS(y_parm);
 
-	ACTOR_WalkTo(actor_idx, &pt, 0, &thread->sem);
+	_vm->_actor->walkTo(actor_idx, &pt, 0, &thread->sem);
 
 	return R_SUCCESS;
 }
@@ -209,13 +209,13 @@
 
 	actor_id = _vm->_sdata->readWordS(actor_parm);
 	orientation = _vm->_sdata->readWordS(orient_parm);
-	actor_idx = ACTOR_GetActorIndex(actor_id);
+	actor_idx = _vm->_actor->getActorIndex(actor_id);
 	if (actor_idx < 0) {
 		CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.", actor_id);
 		return R_FAILURE;
 	}
 
-	ACTOR_SetOrientation(actor_idx, orientation);
+	_vm->_actor->setOrientation(actor_idx, orientation);
 	return R_SUCCESS;
 }
 
@@ -299,7 +299,7 @@
 	SSTACK_Pop(thread->stack, &y_parm);
 
 	actor_id = _vm->_sdata->readWordS(actor_parm);
-	actor_idx = ACTOR_GetActorIndex(actor_id);
+	actor_idx = _vm->_actor->getActorIndex(actor_id);
 	if (actor_idx < 0) {
 		CON_Print(S_WARN_PREFIX "SF.08: Actor id 0x%X not found.",
 		    actor_id);
@@ -308,7 +308,7 @@
 
 	pt.x = _vm->_sdata->readWordS(x_parm);
 	pt.y = _vm->_sdata->readWordS(y_parm);
-	ACTOR_WalkTo(actor_idx, &pt, 0, NULL);
+	_vm->_actor->walkTo(actor_idx, &pt, 0, NULL);
 
 	return R_SUCCESS;
 }
@@ -341,15 +341,15 @@
 	pt.x = _vm->_sdata->readWordS(x_parm);
 	pt.y = _vm->_sdata->readWordS(y_parm);
 
-	if (!ACTOR_ActorExists(actor_id)) {
-		result = ACTOR_Create(actor_id, pt.x, pt.y);
+	if (!_vm->_actor->actorExists(actor_id)) {
+		result = _vm->_actor->create(actor_id, pt.x, pt.y);
 		if (result != R_SUCCESS) {
 			CON_Print(S_WARN_PREFIX "SF.30: Couldn't create actor 0x%X.", actor_id);
 			return R_FAILURE;
 		}
 	} else {
-		actor_idx = ACTOR_GetActorIndex(actor_id);
-		ACTOR_Move(actor_idx, &pt);
+		actor_idx = _vm->_actor->getActorIndex(actor_id);
+		_vm->_actor->move(actor_idx, &pt);
 	}
 
 	return R_SUCCESS;
@@ -380,7 +380,7 @@
 	SSTACK_Pop(thread->stack, &y_parm);
 	SSTACK_Pop(thread->stack, &unk_parm);
 
-	actor_idx = ACTOR_GetActorIndex(_vm->_sdata->readWordS(actor_parm));
+	actor_idx = _vm->_actor->getActorIndex(_vm->_sdata->readWordS(actor_parm));
 	if (actor_idx < 0) {
 		CON_Print(S_WARN_PREFIX "SF.36: Actor id 0x%X not found.", (int)actor_parm);
 		return R_FAILURE;
@@ -390,9 +390,9 @@
 	pt.y = _vm->_sdata->readWordS(y_parm);
 
 #if 1
-	ACTOR_WalkTo(actor_idx, &pt, 0, NULL);
+	_vm->_actor->walkTo(actor_idx, &pt, 0, NULL);
 #else
-	ACTOR_WalkTo(actor_idx, &pt, 0, &thread->sem);
+	_vm->_actor->walkTo(actor_idx, &pt, 0, &thread->sem);
 #endif
 
 	return R_SUCCESS;
@@ -421,10 +421,10 @@
 	SSTACK_Pop(thread->stack, &unk2_parm);
 	actor_id = _vm->_sdata->readWordS(actor_parm);
 	action = _vm->_sdata->readWordS(action_parm);
-	actor_idx = ACTOR_GetActorIndex(actor_id);
+	actor_idx = _vm->_actor->getActorIndex(actor_id);
 
-	if (ACTOR_SetAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) {
-		CON_Print(S_WARN_PREFIX "SF.37: ACTOR_SetAction() failed.");
+	if (_vm->_actor->setAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) {
+		CON_Print(S_WARN_PREFIX "SF.37: Actor::setAction() failed.");
 		return R_FAILURE;
 	}
 
@@ -454,10 +454,10 @@
 
 	actor_id = _vm->_sdata->readWordS(actor_parm);
 	action = _vm->_sdata->readWordS(action_parm);
-	actor_idx = ACTOR_GetActorIndex(actor_id);
+	actor_idx = _vm->_actor->getActorIndex(actor_id);
 
-	if (ACTOR_SetAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) {
-		CON_Print(S_WARN_PREFIX "SF.38: ACTOR_SetAction() failed.");
+	if (_vm->_actor->setAction(actor_idx, action, ACTION_NONE) != R_SUCCESS) {
+		CON_Print(S_WARN_PREFIX "SF.38: Actor::setAction() failed.");
 		return R_FAILURE;
 	}
 
@@ -535,20 +535,20 @@
 	pt.y = _vm->_sdata->readWordS(y_parm);
 	action_state = _vm->_sdata->readWordU(action_parm);
 
-	if (!ACTOR_ActorExists(actor_id)) {
-		result = ACTOR_Create(actor_id, pt.x, pt.y);
+	if (!_vm->_actor->actorExists(actor_id)) {
+		result = _vm->_actor->create(actor_id, pt.x, pt.y);
 		if (result != R_SUCCESS) {
 			CON_Print(S_WARN_PREFIX "SF.43: Couldn't create actor 0x%X.", actor_id);
 			return R_FAILURE;
 		}
 	} else {
-		actor_idx = ACTOR_GetActorIndex(actor_id);
-		ACTOR_Move(actor_idx, &pt);
+		actor_idx = _vm->_actor->getActorIndex(actor_id);
+		_vm->_actor->move(actor_idx, &pt);
 	}
 
-	actor_idx = ACTOR_GetActorIndex(actor_id);
-	ACTOR_SetDefaultAction(actor_idx, action_state, ACTION_NONE);
-	ACTOR_SetAction(actor_idx, action_state, ACTION_NONE);
+	actor_idx = _vm->_actor->getActorIndex(actor_id);
+	_vm->_actor->setDefaultAction(actor_idx, action_state, ACTION_NONE);
+	_vm->_actor->setAction(actor_idx, action_state, ACTION_NONE);
 
 	return R_SUCCESS;
 }

Index: sthread.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/sthread.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- sthread.cpp	1 Aug 2004 23:47:19 -0000	1.15
+++ sthread.cpp	2 Aug 2004 15:47:42 -0000	1.16
@@ -27,7 +27,7 @@
 #include "yslib.h"
 
 #include "gfx.h"
-#include "actor_mod.h"
+#include "actor.h"
 #include "console_mod.h"
 #include "text_mod.h"
 
@@ -721,7 +721,7 @@
 				readS.readByte();
 				readS.readUint16LE();
 
-				a_index = ACTOR_GetActorIndex(param1);
+				a_index = _vm->_actor->getActorIndex(param1);
 				if (a_index < 0) {
 					CON_Print(S_WARN_PREFIX "%X: DLGP Actor id not found.", thread->i_offset);
 				}
@@ -735,7 +735,7 @@
 					} else {
 						voice_rn = _vm->_script->currentScript()->voice->voices[data];
 					}
-					ACTOR_Speak(a_index, _vm->_script->currentScript()->diag-> str[data], voice_rn, &thread->sem);
+					_vm->_actor->speak(a_index, _vm->_script->currentScript()->diag-> str[data], voice_rn, &thread->sem);
 				}
 			}
 			break;

--- actor_mod.h DELETED ---





More information about the Scummvm-git-logs mailing list