[Scummvm-cvs-logs] SF.net SVN: scummvm:[44059] scummvm/trunk/engines/teenagent/scene.cpp

megath at users.sourceforge.net megath at users.sourceforge.net
Sun Sep 13 15:59:56 CEST 2009


Revision: 44059
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44059&view=rev
Author:   megath
Date:     2009-09-13 13:59:55 +0000 (Sun, 13 Sep 2009)

Log Message:
-----------
fixed flickering by restarting render cycle

Modified Paths:
--------------
    scummvm/trunk/engines/teenagent/scene.cpp

Modified: scummvm/trunk/engines/teenagent/scene.cpp
===================================================================
--- scummvm/trunk/engines/teenagent/scene.cpp	2009-09-13 13:22:35 UTC (rev 44058)
+++ scummvm/trunk/engines/teenagent/scene.cpp	2009-09-13 13:59:55 UTC (rev 44059)
@@ -303,111 +303,119 @@
 		return true;
 	}
 	
-	bool busy = processEventQueue();
-	
-	system->copyRectToScreen((const byte *)background.pixels, background.pitch, 0, 0, background.w, background.h);
-	
-	Graphics::Surface * surface = system->lockScreen();
+	bool busy;
+	bool restart;
 
-	if (ons != NULL) {
-		for (uint32 i = 0; i < ons_count; ++i) {
-			Surface* s = ons + i;
-			if (s != NULL)
-				s->render(surface);
+	do {
+		restart = false;
+		busy = processEventQueue();
+		system->copyRectToScreen((const byte *)background.pixels, background.pitch, 0, 0, background.w, background.h);
+
+		Graphics::Surface * surface = system->lockScreen();
+
+		if (ons != NULL) {
+			for (uint32 i = 0; i < ons_count; ++i) {
+				Surface* s = ons + i;
+				if (s != NULL)
+					s->render(surface);
+			}
 		}
-	}
-	
-	//render on
-	if (on.pixels != NULL) {
-		on.render(surface);
-	}
 
-	bool got_any_animation = false;
+		//render on
+		if (on.pixels != NULL) {
+			on.render(surface);
+		}
 
-	for (int i = 0; i < 4; ++i) {
-		Animation *a = custom_animations + i;
-		Surface *s = a->currentFrame();
-		if (s != NULL) {
+		bool got_any_animation = false;
+
+		for (int i = 0; i < 4; ++i) {
+			Animation *a = custom_animations + i;
+			Surface *s = a->currentFrame();
+			if (s != NULL) {
+				s->render(surface);
+				busy = true;
+				got_any_animation = true;
+				continue;
+			}
+
+			a = animations + i;
+			s = a->currentFrame();
+			if (s == NULL)
+				continue;
+
 			s->render(surface);
-			busy = true;
-			got_any_animation = true;
-			continue;
+
+			if (a->id == 0)
+				continue;
+
+			Object * obj = getObject(a->id);
+			if (obj != NULL) {
+				obj->rect.left = s->x;
+				obj->rect.top = s->y;
+				obj->rect.right = s->w + s->x;
+				obj->rect.bottom = s->h + s->y;
+				//obj->dump();
+			}
 		}
 
-		a = animations + i;
-		s = a->currentFrame();
-		if (s == NULL)
-			continue;
+		if (!hide_actor) {
+			Surface * mark = actor_animation.currentFrame();
+			if (mark == NULL) {
+				actor_animation.free();
 
-		s->render(surface);
+				if (destination != position) {
+					Common::Point dp(destination.x - position0.x, destination.y - position0.y);
+					int o;
+					if (ABS(dp.x) > ABS(dp.y))
+						o = dp.x > 0? Object::ActorRight: Object::ActorLeft;
+					else
+						o = dp.y > 0? Object::ActorDown: Object::ActorUp;
 
-		if (a->id == 0)
-			continue;
-
-		Object * obj = getObject(a->id);
-		if (obj != NULL) {
-			obj->rect.left = s->x;
-			obj->rect.top = s->y;
-			obj->rect.right = s->w + s->x;
-			obj->rect.bottom = s->h + s->y;
-			//obj->dump();
+					position.x = position0.x + dp.x * progress / progress_total;
+					position.y = position0.y + dp.y * progress / progress_total;
+					teenagent.render(surface, position, o, 1);
+					++progress;
+					if (progress >= progress_total) {
+						position = destination;
+						if (orientation == 0)
+							orientation = o; //save last orientation
+						nextEvent();
+						restart = true;
+					} else
+						busy = true;
+				} else
+					teenagent.render(surface, position, orientation, 0);
+			} else {
+				mark->render(surface);
+				busy = true;
+				got_any_animation = true;
+			}
 		}
-	}
-	
-	if (!hide_actor) {
-		Surface * mark = actor_animation.currentFrame();
-		if (mark == NULL) {
-			actor_animation.free();
 
-			if (destination != position) {
-				Common::Point dp(destination.x - position0.x, destination.y - position0.y);
-				int o;
-				if (ABS(dp.x) > ABS(dp.y))
-					o = dp.x > 0? Object::ActorRight: Object::ActorLeft;
-				else
-					o = dp.y > 0? Object::ActorDown: Object::ActorUp;
-			
-				position.x = position0.x + dp.x * progress / progress_total;
-				position.y = position0.y + dp.y * progress / progress_total;
-				teenagent.render(surface, position, o, 1);
-				++progress;
-				if (progress >= progress_total) {
-					position = destination;
-					if (orientation == 0)
-						orientation = o; //save last orientation
-					nextEvent();
-				} else 
-					busy = true;
-			} else 
-				teenagent.render(surface, position, orientation, 0);
-		} else {
-			mark->render(surface);
+		if (!message.empty()) {
+			res->font7.render(surface, message_pos.x, message_pos.y, message);
 			busy = true;
-			got_any_animation = true;
 		}
-	}
 
-	if (current_event.type == SceneEvent::WaitForAnimation && !got_any_animation) {
-		nextEvent();
-	}
-		
-	//if (!current_event.empty())
-	//	current_event.dump();
-	/*
-	for (byte i = 0; i < walkboxes; ++i) {
-		Walkbox * w = walkbox[i];
-		w->rect.render(surface, 0xd0 + i);
-	}
-	*/
+		system->unlockScreen();
+
+		if (current_event.type == SceneEvent::WaitForAnimation && !got_any_animation) {
+			debug(0, "no animations, nextevent");
+			nextEvent();
+			restart = true;
+		}
+
+		//if (!current_event.empty())
+		//	current_event.dump();
+		/*
+		for (byte i = 0; i < walkboxes; ++i) {
+			Walkbox * w = walkbox[i];
+			w->rect.render(surface, 0xd0 + i);
+		}
+		*/
+
+	} while(restart);
 	
-	if (!message.empty()) {
-		res->font7.render(surface, message_pos.x, message_pos.y, message);
-		busy = true;
-	}
-	
-	system->unlockScreen();
-	
-	
 	for(Sounds::iterator i = sounds.begin(); i != sounds.end(); ) {
 		Sound &sound = *i;
 		if (sound.delay == 0) {


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