← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/bug-1228811-observer-minimap into lp:widelands

 

GunChleoc has proposed merging lp:~widelands-dev/widelands/bug-1228811-observer-minimap into lp:widelands.

Commit message:
Write minimap file for observers.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/bug-1228811-observer-minimap/+merge/292716
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/bug-1228811-observer-minimap into lp:widelands.
=== modified file 'src/game_io/game_preload_packet.cc'
--- src/game_io/game_preload_packet.cc	2016-03-20 15:51:39 +0000
+++ src/game_io/game_preload_packet.cc	2016-04-23 19:17:21 +0000
@@ -124,16 +124,17 @@
 	if (!game.is_loaded()) {
 		return;
 	}
-	if (ipl != nullptr) {
-		const MiniMapLayer flags = MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain;
-		const Point& vp = ipl->get_viewpoint();
-		std::unique_ptr< ::StreamWrite> sw(fs.open_stream_write(kMinimapFilename));
-		if (sw.get() != nullptr) {
-			write_minimap_image(game, &ipl->player(), vp, flags, sw.get());
-			sw->flush();
+
+	std::unique_ptr< ::StreamWrite> sw(fs.open_stream_write(kMinimapFilename));
+	if (sw.get() != nullptr) {
+		if (ipl != nullptr) {  // Player
+			const MiniMapLayer flags = MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain;
+			write_minimap_image(game, &ipl->player(), ipl->get_viewpoint(), flags, sw.get());
+		} else { // Observer
+			write_minimap_image(game, nullptr, Point(0, 0), MiniMapLayer::Terrain, sw.get());
 		}
+		sw->flush();
 	}
-
 }
 
 }


Follow ups