[Scummvm-cvs-logs] CVS: scummvm/saga actor.h,1.20,1.21 actor.cpp,1.40,1.41

Andrew Kurushin h00ligan at users.sourceforge.net
Sat Dec 18 13:40:00 CET 2004


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

Modified Files:
	actor.h actor.cpp 
Log Message:
now actors will not stuck in the middle of dialog

Index: actor.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.h,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- actor.h	18 Dec 2004 20:33:02 -0000	1.20
+++ actor.h	18 Dec 2004 21:38:56 -0000	1.21
@@ -148,29 +148,27 @@
 
 typedef Common::List<ACTORDIALOGUE> ActorDialogList;
 
-struct SPEAKINTENT {
-	int si_init;
-	uint16 si_flags;
-	int si_last_action;
-	ActorDialogList si_diaglist;	/* Actor dialogue list */
-	SPEAKINTENT() {
-		si_init = 0;
-		si_flags = 0;
-		si_last_action = 0;
-	}
-};
 
 struct ACTORINTENT {
 	int a_itype;
 	uint16 a_iflags;
 	int a_idone;
-	SPEAKINTENT speakIntent;
+
+	int si_init;
+	uint16 si_flags;
+	int si_last_action;
+	ActorDialogList si_diaglist;	/* Actor dialogue list */
+
 	WALKINTENT walkIntent;
 
 	ACTORINTENT() {
 		a_itype = 0;
 		a_iflags = 0;
 		a_idone = 0;
+
+		si_init = 0;
+		si_flags = 0;
+		si_last_action = 0;
 	}
 };
 
@@ -295,7 +293,7 @@
 	
 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);
+	int handleSpeakIntent(ActorData *actor, ACTORINTENT *a_aintent, int *complete_p, int msec);
 	int setPathNode(WALKINTENT *walk_int, Point *src_pt, Point *dst_pt, SEMAPHORE *sem);
 
 	ActorData *getActor(uint16 actorId);

Index: actor.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/saga/actor.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- actor.cpp	18 Dec 2004 20:33:02 -0000	1.40
+++ actor.cpp	18 Dec 2004 21:38:56 -0000	1.41
@@ -230,7 +230,7 @@
 			case INTENT_SPEAK:
 				// Actor wants to blab
 				{
-					handleSpeakIntent(actor, &a_intent->speakIntent, &a_intent->a_idone, msec);
+					handleSpeakIntent(actor, a_intent, &a_intent->a_idone, msec);
 				}
 				break;
 
@@ -328,8 +328,8 @@
 		if (actorIntentIterator != actor->a_intentlist.end()) {
 			a_intent = actorIntentIterator.operator->();
 			if (a_intent->a_itype == INTENT_SPEAK) {
-				actorDialogIterator = a_intent->speakIntent.si_diaglist.begin();
-				if (actorDialogIterator != a_intent->speakIntent.si_diaglist.end()) {
+				actorDialogIterator = a_intent->si_diaglist.begin();
+				if (actorDialogIterator != a_intent->si_diaglist.end()) {
 					a_dialogue = actorDialogIterator.operator->();
 					diag_x = actor->s_pt.x;
 					diag_y = actor->s_pt.y;
@@ -368,13 +368,13 @@
 			if (a_intent->a_itype == INTENT_SPEAK) {
 				// Okay, found a speak intent. Remove one dialogue entry 
 				// from it, releasing any semaphore */
-				actorDialogIterator = a_intent->speakIntent.si_diaglist.begin();
-				if (actorDialogIterator != a_intent->speakIntent.si_diaglist.end()) {
+				actorDialogIterator = a_intent->si_diaglist.begin();
+				if (actorDialogIterator != a_intent->si_diaglist.end()) {
 					a_dialogue = actorDialogIterator.operator->();
 					if (a_dialogue->d_sem != NULL) {
 						_vm->_script->SThreadReleaseSem(a_dialogue->d_sem);
 					}
-					a_intent->speakIntent.si_diaglist.erase(actorDialogIterator);
+					a_intent->si_diaglist.erase(actorDialogIterator);
 					// And stop any currently playing voices
 					_vm->_sound->stopVoice();
 				}
@@ -386,7 +386,6 @@
 }
 
 void Actor::speak(uint16 actorId, const char *d_string, uint16 d_voice_rn, SEMAPHORE *sem) {
-	ActorOrderList::iterator actorOrderIterator;
 	ActorData *actor;
 	ActorIntentList::iterator actorIntentIterator;
 	ACTORINTENT *a_intent_p = NULL;
@@ -417,15 +416,15 @@
 
 	if (use_existing_ai) {
 		// Store the current dialogue off the existing actor intent
-		a_intent_p->speakIntent.si_diaglist.push_back(a_dialogue);
+		a_intent_p->si_diaglist.push_back(a_dialogue);
 	} else {
 		// Create a new actor intent
 		a_intent.a_itype = INTENT_SPEAK;
 		a_intent.a_idone = 0;
 		a_intent.a_iflags = 0;
 
-		a_intent.speakIntent.si_last_action = actor->action;
-		a_intent.speakIntent.si_diaglist.push_back(a_dialogue);
+		a_intent.si_last_action = actor->action;
+		a_intent.si_diaglist.push_back(a_dialogue);
 
 		actor->a_intentlist.push_back(a_intent);
 	}
@@ -435,7 +434,7 @@
 	}
 }
 
-int Actor::handleSpeakIntent(ActorData *actor, SPEAKINTENT *a_speakint, int *complete_p, int msec) {
+int Actor::handleSpeakIntent(ActorData *actor, ACTORINTENT *a_aintent, int *complete_p, int msec) {
 	ActorDialogList::iterator actorDialogIterator;
 	ActorDialogList::iterator nextActorDialogIterator;
 	ACTORDIALOGUE *a_dialogue;
@@ -443,18 +442,18 @@
 	long carry_time;
 	int intent_complete = 0;
 
-	if (!a_speakint->si_init) {
+	if (!a_aintent->si_init) {
 		// Initialize speak intent by setting up action
 		actor->action = ACTION_SPEAK;
 		actor->action_frame = 0;
 		actor->action_time = 0;
 		actor->action_flags = ACTION_LOOP;
-		a_speakint->si_init = 1;
+		a_aintent->si_init = 1;
 	}
 
 	// Process actor dialogue list
-	actorDialogIterator = a_speakint->si_diaglist.begin();
-	if (actorDialogIterator != a_speakint->si_diaglist.end()) {
+	actorDialogIterator = a_aintent->si_diaglist.begin();
+	if (actorDialogIterator != a_aintent->si_diaglist.end()) {
 		a_dialogue = actorDialogIterator.operator->();
 		if (!a_dialogue->d_playing) {
 			// Dialogue voice hasn't played yet - play it now
@@ -478,7 +477,7 @@
 
 			nextActorDialogIterator = actorDialogIterator;
 			++nextActorDialogIterator;
-			if (nextActorDialogIterator != a_speakint->si_diaglist.end()) {
+			if (nextActorDialogIterator != a_aintent->si_diaglist.end()) {
 				a_dialogue2 = nextActorDialogIterator.operator->();
 				a_dialogue2->d_time -= carry_time;
 			}
@@ -486,8 +485,8 @@
 			// Check if there are any dialogue nodes left. If not, 
 			// flag this speech intent as complete
 
-			actorDialogIterator = a_speakint->si_diaglist.erase(actorDialogIterator);
-			if (actorDialogIterator != a_speakint->si_diaglist.end()) {
+			actorDialogIterator = a_aintent->si_diaglist.erase(actorDialogIterator);
+			if (actorDialogIterator == a_aintent->si_diaglist.end()) {
 				intent_complete = 1;
 			}
 		}





More information about the Scummvm-git-logs mailing list