← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/map_information into lp:widelands

 

SirVer has proposed merging lp:~widelands-dev/widelands/map_information into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/map_information/+merge/226572

Suggested submit message:

-----
- Add a stand alone tool logic/map_info that can render minimaps. 
The upload of maps on the homepage is broken right now. This was triggered through the one-world refactoring, but it is due to the homepage not using Widelands code, but reimplementing everything (including minimap generation) in python from scratch. This second implementation broke. This tool should help to consolidate code paths. I am investigating using boost python for binding to python, so that this can be turned in a python library directly.
- Fixes a bug in minimap rendering code: software rendering was sometimes using the wrong colors.
- Refactor to minimap rendering to not depend on wui.
- Minor refactorings.
-----


-- 
https://code.launchpad.net/~widelands-dev/widelands/map_information/+merge/226572
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/map_information into lp:widelands.
=== modified file 'src/game_io/game_preload_data_packet.cc'
--- src/game_io/game_preload_data_packet.cc	2014-04-18 12:43:49 +0000
+++ src/game_io/game_preload_data_packet.cc	2014-07-12 12:35:28 +0000
@@ -114,12 +114,11 @@
 		return;
 	}
 	if (ipl != nullptr) {
-		MiniMapRenderer mmr;
-		const uint32_t flags = MiniMap::Owner | MiniMap::Bldns | MiniMap::Terrn;
+		const MiniMapLayer flags = MiniMapLayer::Owner | MiniMapLayer::Building | MiniMapLayer::Terrain;
 		const Point& vp = ipl->get_viewpoint();
 		std::unique_ptr< ::StreamWrite> sw(fs.OpenStreamWrite(MINIMAP_FILENAME));
 		if (sw.get() != nullptr) {
-			mmr.write_minimap_image(game, &ipl->player(), vp, flags, sw.get());
+			write_minimap_image(game, &ipl->player(), vp, flags, sw.get());
 			sw->Flush();
 		}
 	}

=== modified file 'src/graphic/colormap.cc'
--- src/graphic/colormap.cc	2013-09-23 20:30:35 +0000
+++ src/graphic/colormap.cc	2014-07-12 12:35:28 +0000
@@ -19,6 +19,7 @@
 
 #include "graphic/colormap.h"
 
+#include <algorithm>
 #include <cassert>
 #include <cstdlib>
 #include <cstring>
@@ -38,13 +39,9 @@
 			int32_t shade = (j < 128) ? j : (j - 256);
 			shade = 256 + 2 * shade;
 
-			int32_t r = (palette[i].r * shade) >> 8;
-			int32_t g = (palette[i].g * shade) >> 8;
-			int32_t b = (palette[i].b * shade) >> 8;
-
-			if (r > 255) r = 255;
-			if (g > 255) g = 255;
-			if (b > 255) b = 255;
+			const uint32_t r = std::min<uint32_t>((palette[i].r * shade) >> 8, 255);
+			const uint32_t g = std::min<uint32_t>((palette[i].g * shade) >> 8, 255);
+			const uint32_t b = std::min<uint32_t>((palette[i].b * shade) >> 8, 255);
 
 			const Uint32 value =
 				SDL_MapRGB(&const_cast<SDL_PixelFormat &>(format), r, g, b);

=== modified file 'src/graphic/colormap.h'
--- src/graphic/colormap.h	2014-07-05 16:41:51 +0000
+++ src/graphic/colormap.h	2014-07-12 12:35:28 +0000
@@ -22,10 +22,23 @@
 
 #include <SDL_video.h>
 
+#include "graphic/color.h"
+
 /**
  * Colormap contains a palette and lookup table for use with ground textures.
 */
 class Colormap {
+public:
+	Colormap (const SDL_Color &, const SDL_PixelFormat & fmt);
+	~Colormap ();
+
+	// Returns the palette of this colormap (256 entries of RGB Colors);
+	SDL_Color * get_palette() {return palette;}
+
+	// Returns the internally calculated colormap used in the renderer.
+	void * get_colormap () const {return colormap;}
+
+private:
 	SDL_Color palette[256];
 
 	/// maps 8 bit color and brightness value to the shaded color.
@@ -33,14 +46,6 @@
 	/// less shades would greatly reduce the size of this table, and thus
 	/// improve memory cache impact inside the renderer.
 	void * colormap;
-
-public:
-	Colormap (const SDL_Color &, const SDL_PixelFormat & fmt);
-	~Colormap ();
-
-	SDL_Color * get_palette() {return palette;}
-
-	void * get_colormap () const {return colormap;}
 };
 
 #endif  // end of include guard: WL_GRAPHIC_COLORMAP_H

=== modified file 'src/graphic/graphic.cc'
--- src/graphic/graphic.cc	2014-07-05 14:39:48 +0000
+++ src/graphic/graphic.cc	2014-07-12 12:35:28 +0000
@@ -80,13 +80,12 @@
 {
 	ImageTransformations::initialize();
 
-	FileRead fr;
 #ifndef _WIN32
-	fr.Open(*g_fs, "pics/wl-ico-128.png");
+	const std::string icon_name = "pics/wl-ico-128.png";
 #else
-	fr.Open(*g_fs, "pics/wl-ico-32.png");
+	const std::string icon_name = "pics/wl-ico-32.png";
 #endif
-	SDL_Surface * s = IMG_Load_RW(SDL_RWFromMem(fr.Data(0), fr.GetSize()), 1);
+	SDL_Surface* s = load_image_as_sdl_surface(icon_name, g_fs);
 	SDL_WM_SetIcon(s, nullptr);
 	SDL_FreeSurface(s);
 }

=== modified file 'src/graphic/render/minimaprenderer.cc'
--- src/graphic/render/minimaprenderer.cc	2014-07-03 19:26:30 +0000
+++ src/graphic/render/minimaprenderer.cc	2014-07-12 12:35:28 +0000
@@ -36,7 +36,6 @@
 #include "logic/world/world.h"
 #include "wui/mapviewpixelconstants.h"
 #include "wui/mapviewpixelfunctions.h"
-#include "wui/minimap.h"
 
 using namespace Widelands;
 
@@ -56,24 +55,20 @@
 // Returns the color to be used in the minimap for the given field.
 inline uint32_t calc_minimap_color
 	(const SDL_PixelFormat& format, const Widelands::Editor_Game_Base& egbase,
-	 const Widelands::FCoords& f, uint32_t flags, Widelands::Player_Number owner,
+	 const Widelands::FCoords& f, MiniMapLayer layers, Widelands::Player_Number owner,
 	 bool see_details)
 {
 	uint32_t pixelcolor = 0;
 
-	if (flags & MiniMap::Terrn) {
-		// We or with format.Amask here because the terrain map texture data is
-		// only RGB and not RGBA in SDL render mode. Or'ing with Amask guarantees
-		// that alpha is set to 255 for this color and is fast.
-		pixelcolor =
-			g_gr->
-			get_maptexture_data
-				(egbase.world()
-				 .terrain_descr(f.field->terrain_d()).get_texture())
-			->get_minimap_color(f.field->get_brightness()) | format.Amask;
+	if (layers & MiniMapLayer::Terrain) {
+		const RGBColor color =
+		   g_gr->get_maptexture_data(egbase.world().terrain_descr(f.field->terrain_d()).get_texture())
+		      ->get_minimap_color(f.field->get_brightness());
+
+		pixelcolor = SDL_MapRGBA(&format, color.r, color.g, color.b, 255);
 	}
 
-	if (flags & MiniMap::Owner) {
+	if (layers & MiniMapLayer::Owner) {
 		if (0 < owner) { //  If owned, get the player's color...
 			const RGBColor & player_color = egbase.player(owner).get_playercolor();
 
@@ -92,14 +87,14 @@
 		// * winterland -> orange
 
 		if (upcast(PlayerImmovable const, immovable, f.field->get_immovable())) {
-			if ((flags & MiniMap::Roads) and dynamic_cast<Road const *>(immovable)) {
+			if ((layers & MiniMapLayer::Road) and dynamic_cast<Road const *>(immovable)) {
 				pixelcolor = blend_color(format, pixelcolor, 255, 255, 255);
 			}
 
 			if
-				(((flags & MiniMap::Flags) and dynamic_cast<Flag const *>(immovable))
+				(((layers & MiniMapLayer::Flag) and dynamic_cast<Flag const *>(immovable))
 				 or
-				 ((flags & MiniMap::Bldns)
+				 ((layers & MiniMapLayer::Building)
 				  and
 				  dynamic_cast<Widelands::Building const *>(immovable)))
 			{
@@ -160,7 +155,7 @@
 // Does the actual work of drawing the minimap.
 void draw_minimap_int
 	(Surface* surface, const Widelands::Editor_Game_Base& egbase,
-	 const Widelands::Player* player, const Point& viewpoint, uint32_t flags)
+	 const Widelands::Player* player, const Point& viewpoint, MiniMapLayer layers)
 {
 	const Widelands::Map & map = egbase.map();
 
@@ -197,24 +192,23 @@
 			Uint8 * pix = pixels + y * pitch;
 			Widelands::FCoords f
 				(Widelands::Coords
-					(viewpoint.x, viewpoint.y + (flags & MiniMap::Zoom2 ? y / 2 : y)));
+					(viewpoint.x, viewpoint.y + (layers & MiniMapLayer::Zoom2 ? y / 2 : y)));
 			map.normalize_coords(f);
 			f.field = &map[f];
 			Widelands::Map_Index i = Widelands::Map::get_index(f, mapwidth);
 			for (uint32_t x = 0; x < surface_w; ++x, pix += sizeof(Uint32)) {
-				if (x % 2 || !(flags & MiniMap::Zoom2))
+				if (x % 2 || !(layers & MiniMapLayer::Zoom2))
 					move_r(mapwidth, f, i);
 
-				if
-					(is_minimap_frameborder
-					 (f, ptopleft, pbottomright, mapwidth, mapheight, modx, mody))
-				{
+				if ((layers & MiniMapLayer::ViewWindow) &&
+				    is_minimap_frameborder(
+				       f, ptopleft, pbottomright, mapwidth, mapheight, modx, mody)) {
 					*reinterpret_cast<Uint32 *>(pix) = static_cast<Uint32>
 						(SDL_MapRGB(&const_cast<SDL_PixelFormat &>(format), 255, 0, 0));
 				} else {
 					*reinterpret_cast<Uint32 *>(pix) = static_cast<Uint32>
 						(calc_minimap_color
-							(format, egbase, f, flags, f.field->get_owned_by(), true));
+							(format, egbase, f, layers, f.field->get_owned_by(), true));
 				}
 			}
 		}
@@ -225,18 +219,17 @@
 			Widelands::FCoords f
 				(Widelands::Coords
 			 		(viewpoint.x, viewpoint.y +
-			 		 (flags & MiniMap::Zoom2 ? y / 2 : y)));
+			 		 (layers & MiniMapLayer::Zoom2 ? y / 2 : y)));
 			map.normalize_coords(f);
 			f.field = &map[f];
 			Widelands::Map_Index i = Widelands::Map::get_index(f, mapwidth);
 			for (uint32_t x = 0; x < surface_w; ++x, pix += sizeof(Uint32)) {
-				if (x % 2 || !(flags & MiniMap::Zoom2))
+				if (x % 2 || !(layers & MiniMapLayer::Zoom2))
 					move_r(mapwidth, f, i);
 
-				if
-					(is_minimap_frameborder
-					 (f, ptopleft, pbottomright, mapwidth, mapheight, modx, mody))
-				{
+				if ((layers & MiniMapLayer::ViewWindow) &&
+				    is_minimap_frameborder(
+				       f, ptopleft, pbottomright, mapwidth, mapheight, modx, mody)) {
 					*reinterpret_cast<Uint32 *>(pix) = static_cast<Uint32>
 						(SDL_MapRGB
 							(&const_cast<SDL_PixelFormat &>(format), 255, 0, 0));
@@ -251,7 +244,7 @@
 						 	(format,
 						 	 egbase,
 						 	 f,
-						 	 flags,
+						 	 layers,
 						 	 player_field.owner,
 						 	 1 < vision)
 						 :
@@ -262,19 +255,20 @@
 	}
 }
 
-// A helper function to draw the minimap. This is called from
-// renderminimap().
-Surface* draw_minimap
-	(const Widelands::Editor_Game_Base& egbase, const Widelands::Player* player,
-	 const Point& viewpt, uint32_t flags)
-{
+
+}  // namespace
+
+std::unique_ptr<Surface> draw_minimap(const Editor_Game_Base& egbase,
+                                      const Player* player,
+                                      const Point& viewpoint,
+                                      MiniMapLayer layers) {
 	// First create a temporary SDL Surface to draw the minimap.
 	// TODO: Currently the minimap is redrawn every frame. That is not really
 	//       necesary. The created surface could be cached and only redrawn two
 	//       or three times per second
 	const Map& map = egbase.map();
-	const int16_t map_w = (flags & MiniMap::Zoom2) ? map.get_width() * 2 : map.get_width();
-	const int16_t map_h = (flags & MiniMap::Zoom2) ? map.get_height() * 2 : map.get_height();
+	const int16_t map_w = (layers & MiniMapLayer::Zoom2) ? map.get_width() * 2 : map.get_width();
+	const int16_t map_h = (layers & MiniMapLayer::Zoom2) ? map.get_height() * 2 : map.get_height();
 
 	Surface* surface = Surface::create(map_w, map_h);
 	assert(surface->format().BytesPerPixel == sizeof(Uint32));
@@ -282,24 +276,15 @@
 	surface->fill_rect(Rect(0, 0, surface->width(), surface->height()), RGBAColor(0, 0, 0, 255));
 	surface->lock(Surface::Lock_Normal);
 
-	draw_minimap_int(surface, egbase, player, viewpt, flags);
+	draw_minimap_int(surface, egbase, player, viewpoint, layers);
 
 	surface->unlock(Surface::Unlock_Update);
 
-	return surface;
-}
-
-}  // namespace
-
-Surface* MiniMapRenderer::get_minimap_image
-	(const Editor_Game_Base& egbase, const Player* player, const Point& viewpoint, uint32_t flags)
-{
-	Surface* minimap_surf = draw_minimap(egbase, player, viewpoint, flags);
-	return minimap_surf;
-}
-
-void MiniMapRenderer::write_minimap_image
-	(const Editor_Game_Base& egbase, const Player* player, const Point& gviewpoint, uint32_t flags,
+	return std::unique_ptr<Surface>(surface);
+}
+
+void write_minimap_image
+	(const Editor_Game_Base& egbase, const Player* player, const Point& gviewpoint, MiniMapLayer layers,
 	 ::StreamWrite* const streamwrite)
 {
 	assert(streamwrite != nullptr);
@@ -324,8 +309,7 @@
 	viewpoint.y -= map_h / 2;
 
 	// Render minimap
-	std::unique_ptr<Surface> surface
-		(get_minimap_image(egbase, player, viewpoint, flags));
+	std::unique_ptr<Surface> surface(draw_minimap(egbase, player, viewpoint, layers));
 	std::unique_ptr<const Image> image(new_in_memory_image("minimap", surface.release()));
 	g_gr->save_png(image.get(), streamwrite);
 	image.reset();

=== modified file 'src/graphic/render/minimaprenderer.h'
--- src/graphic/render/minimaprenderer.h	2014-07-05 16:41:51 +0000
+++ src/graphic/render/minimaprenderer.h	2014-07-12 12:35:28 +0000
@@ -20,36 +20,50 @@
 #ifndef WL_GRAPHIC_RENDER_MINIMAPRENDERER_H
 #define WL_GRAPHIC_RENDER_MINIMAPRENDERER_H
 
+#include <memory>
+
 #include "graphic/rendertarget.h"
-#include <memory>
 
 class StreamWrite;
+
 namespace Widelands {
 	class Player;
 	class Editor_Game_Base;
 }
 
-/**
- * This class renders the minimap.
- */
-class MiniMapRenderer
-{
-public:
-	MiniMapRenderer() {}
-	virtual ~MiniMapRenderer() {}
-
-	/// Render the minimap. If player is not 0, it renders from that player's
-	/// point of view. The caller must dispose of the returned surface properly.
-	/// \param viewpoint: top left corner in map coordinates
-	Surface* get_minimap_image
-		(const Widelands::Editor_Game_Base& egbase, const Widelands::Player* player,
-		 const Point& viewpoint, uint32_t flags);
-
-	/// Render the minimap to a file. 1 pixel will be used for each fields.
-	/// \param viewpoint : The game point of view as returned by interactive_base.get_viewpoint();
-	void write_minimap_image
-		(const Widelands::Editor_Game_Base& egbase, Widelands::Player const* player,
-		 const Point& viewpoint, uint32_t flags, StreamWrite* const streamwrite);
+// Layers for selecting what do display on the minimap.
+enum class MiniMapLayer {
+	Terrain = 1,
+	Owner = 2,
+	Flag = 4,
+	Road = 8,
+	Building = 16,
+	Zoom2 = 32,
+	ViewWindow = 64,
 };
 
+// A bunch of operators that turn MiniMapLayer into a bitwise combinable flag class.
+inline MiniMapLayer operator|(MiniMapLayer left, MiniMapLayer right) {
+	return MiniMapLayer(static_cast<int>(left) | static_cast<int>(right));
+}
+inline int operator&(MiniMapLayer left, MiniMapLayer right) {
+	return static_cast<int>(left) & static_cast<int>(right);
+}
+inline MiniMapLayer operator ^ (MiniMapLayer left, MiniMapLayer right) {
+	return MiniMapLayer(static_cast<int>(left) ^ static_cast<int>(right));
+}
+
+/// Render the minimap. If player is not nullptr, it renders from that player's
+/// point of view.
+/// \param viewpoint: top left corner in map coordinates
+std::unique_ptr<Surface> draw_minimap
+	(const Widelands::Editor_Game_Base& egbase, const Widelands::Player* player,
+	 const Point& viewpoint, MiniMapLayer layers);
+
+/// Render the minimap to a file. 1 pixel will be used for each fields.
+/// \param viewpoint : The game point of view as returned by interactive_base.get_viewpoint();
+void write_minimap_image
+	(const Widelands::Editor_Game_Base& egbase, Widelands::Player const* player,
+	 const Point& viewpoint, MiniMapLayer layers, StreamWrite* const streamwrite);
+
 #endif  // end of include guard: WL_GRAPHIC_RENDER_MINIMAPRENDERER_H

=== modified file 'src/graphic/texture.cc'
--- src/graphic/texture.cc	2014-07-05 14:22:44 +0000
+++ src/graphic/texture.cc	2014-07-12 12:35:28 +0000
@@ -24,6 +24,7 @@
 #include "base/deprecated.h"
 #include "base/log.h"
 #include "base/wexception.h"
+#include "graphic/image_io.h"
 #include "io/fileread.h"
 #include "io/filesystem/layered_filesystem.h"
 
@@ -54,12 +55,8 @@
 			throw wexception("Could not find %s.", fname.c_str());
 		}
 
-		SDL_Surface * surf;
 		m_texture_image = fname;
-		FileRead fr;
-		fr.Open(*g_fs, fname);
-
-		surf = IMG_Load_RW(SDL_RWFromMem(fr.Data(0), fr.GetSize()), 1);
+		SDL_Surface* surf = load_image_as_sdl_surface(fname, g_fs);
 		if (!surf) {
 			throw wexception("WARNING: Failed to load texture frame %s: %s\n", fname.c_str(), IMG_GetError());
 		}
@@ -71,61 +68,34 @@
 			                 TEXTURE_HEIGHT);
 		}
 
+		// calculate shades on the first frame
+		if (!m_nrframes) {
+			uint8_t top_left_pixel = static_cast<uint8_t*>(surf->pixels)[0];
+			SDL_Color top_left_pixel_color = surf->format->palette->colors[top_left_pixel];
+			for (int i = -128; i < 128; i++) {
+				const int shade = 128 + i;
+				int32_t r = std::min<int32_t>((top_left_pixel_color.r * shade) >> 7, 255);
+				int32_t g = std::min<int32_t>((top_left_pixel_color.g * shade) >> 7, 255);
+				int32_t b = std::min<int32_t>((top_left_pixel_color.b * shade) >> 7, 255);
+				m_minimap_colors[shade] = RGBColor(r, g, b);
+			}
+		}
+
 		if (g_opengl) {
 			// Note: we except the constructor to free the SDL surface
 			GLSurfaceTexture* surface = new GLSurfaceTexture(surf);
 			m_glFrames.emplace_back(surface);
 
-			// calculate shades on the first frame
-			if (!m_nrframes) {
-				surface->lock(Surface::Lock_Normal);
-				uint32_t mmap_color_base = surface->get_pixel(0, 0);
-				surface->unlock(Surface::Unlock_NoChange);
-
-				int32_t i, shade, r, g, b, a;
-				for (i = -128; i < 128; i++) {
-					shade = 128 + i;
-
-					a = (mmap_color_base & 0xff000000) >> 24;
-					b = (mmap_color_base & 0x00ff0000) >> 16;
-					g = (mmap_color_base & 0x0000ff00) >> 8;
-					r = (mmap_color_base & 0x000000ff);
-
-					b = (b * shade) >> 7;
-					g = (g * shade) >> 7;
-					r = (r * shade) >> 7;
-
-					if (b > 255) b = 255;
-					if (g > 255) g = 255;
-					if (r > 255) r = 255;
-
-					m_mmap_color[shade] = (a << 24) | (b << 16) | (g << 8) | r;
-				}
-			}
-
 			++m_nrframes;
 			continue;
 		}
 
 		// Determine color map if it's the first frame
 		if (!m_nrframes) {
-			if (surf->format->BitsPerPixel == 8) {
-				m_colormap.reset(new Colormap(*surf->format->palette->colors, format));
-			} else {
-				SDL_Color pal[256];
-
-				log("WARNING: %s: using 332 default palette\n", fname.c_str());
-
-				for (int32_t r = 0; r < 8; ++r)
-					for (int32_t g = 0; g < 8; ++g)
-						for (int32_t b = 0; b < 4; ++b) {
-							pal[(r << 5) | (g << 2) | b].r = r << 5;
-							pal[(r << 5) | (g << 2) | b].g = g << 5;
-							pal[(r << 5) | (g << 2) | b].b = b << 6;
-						}
-
-				m_colormap.reset(new Colormap(*pal, format));
+			if (surf->format->BitsPerPixel != 8) {
+				throw wexception("Terrain %s is not 8 bits per pixel.", fname.c_str());
 			}
+			m_colormap.reset(new Colormap(*surf->format->palette->colors, format));
 		}
 
 		// Convert to our palette
@@ -180,14 +150,8 @@
 /**
  * Return the basic terrain colour to be used in the minimap.
 */
-Uint32 Texture::get_minimap_color(char shade) {
-	if (not m_pixels)
-		return m_mmap_color[128 + shade];
-
-	uint8_t clr = m_pixels[0]; // just use the top-left pixel
-
-	uint32_t table = static_cast<uint8_t>(shade);
-	return static_cast<const Uint32*>(m_colormap->get_colormap())[clr | (table << 8)];
+RGBColor Texture::get_minimap_color(int8_t shade) {
+	return m_minimap_colors[128 + shade];
 }
 
 /**

=== modified file 'src/graphic/texture.h'
--- src/graphic/texture.h	2014-07-05 16:41:51 +0000
+++ src/graphic/texture.h	2014-07-12 12:35:28 +0000
@@ -56,7 +56,7 @@
 	uint8_t * get_curpixels() const {return m_curframe;}
 	void    * get_colormap () const {return m_colormap->get_colormap();}
 
-	uint32_t get_minimap_color(char shade);
+	RGBColor get_minimap_color(int8_t shade);
 
 	void animate(uint32_t time);
 	uint32_t getTexture() const
@@ -65,7 +65,7 @@
 private:
 	std::unique_ptr<Colormap> m_colormap;
 	uint8_t   * m_pixels;
-	uint32_t    m_mmap_color[256];
+	RGBColor    m_minimap_colors[256];
 	uint8_t   * m_curframe;
 	int32_t     m_frame_num;
 	std::string m_texture_image;

=== modified file 'src/logic/CMakeLists.txt'
--- src/logic/CMakeLists.txt	2014-07-08 04:23:00 +0000
+++ src/logic/CMakeLists.txt	2014-07-12 12:35:28 +0000
@@ -1,3 +1,18 @@
+wl_binary(map_info
+  SRCS
+    map_info.cc
+  DEPENDS
+    base_log
+    graphic
+    graphic_image_io
+    graphic_surface
+    io_fileread
+    io_filesystem
+    logic
+    map_io_map_loader
+    scripting
+)
+
 wl_library(logic_notification
   SRCS
     notification.h

=== modified file 'src/logic/map.cc'
--- src/logic/map.cc	2014-07-03 19:26:30 +0000
+++ src/logic/map.cc	2014-07-12 12:35:28 +0000
@@ -1634,8 +1634,7 @@
 		try {
 			result.reset(new WL_Map_Loader(g_fs->MakeSubFileSystem(filename), this));
 		} catch (...) {
-			//  If this fails, it is an illegal file (maybe old plain binary map
-			//  format)
+			//  If this fails, it is an illegal file.
 			//  TODO: catchall hides real errors! Replace with more specific code
 		}
 	} else if (boost::algorithm::ends_with(lower_filename, S2MF_SUFFIX) ||

=== added file 'src/logic/map_info.cc'
--- src/logic/map_info.cc	1970-01-01 00:00:00 +0000
+++ src/logic/map_info.cc	2014-07-12 12:35:28 +0000
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2006-2014 by the Widelands Development Team
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ */
+
+#include <memory>
+
+#include <SDL.h>
+
+#include "base/log.h"
+#include "config.h"
+#include "graphic/graphic.h"
+#include "graphic/image_io.h"
+#include "graphic/render/minimaprenderer.h"
+#include "graphic/surface.h"
+#include "io/filesystem/filesystem.h"
+#include "io/filesystem/layered_filesystem.h"
+#include "io/filewrite.h"
+#include "logic/editor_game_base.h"
+#include "logic/map.h"
+#include "map_io/widelands_map_loader.h"
+#include "scripting/scripting.h"
+
+using namespace Widelands;
+
+int main(int /* argc */, char ** argv)
+{
+	try {
+		SDL_Init(SDL_INIT_VIDEO);
+
+		g_fs = new LayeredFileSystem();
+		g_fs->AddFileSystem(&FileSystem::Create(INSTALL_PREFIX + std::string("/") + INSTALL_DATADIR));
+
+#ifdef HAS_GETENV
+		char dummy_video_env[] = "SDL_VIDEODRIVER=dummy";
+		putenv(dummy_video_env);
+#endif
+
+		g_gr = new Graphic();
+		g_gr->initialize(1, 1, false, false);
+
+		Editor_Game_Base egbase(nullptr);
+		Map* map = new Map();
+		egbase.set_map(map);
+
+		std::unique_ptr<Widelands::Map_Loader> ml(map->get_correct_loader(argv[1]));
+		assert(ml != nullptr);
+
+		ml->preload_map(true);
+		ml->load_map_complete(egbase, true);
+
+		std::unique_ptr<Surface> minimap(draw_minimap(egbase, nullptr, Point(0, 0), MiniMapLayer::Terrain));
+
+		FileWrite fw;
+		save_surface_to_png(minimap.get(), &fw);
+		std::unique_ptr<FileSystem> fs(&FileSystem::Create("."));
+		fw.Write(*fs, "minimap.png");
+	}
+	catch (std::exception& e) {
+		log("Exception: %s.\n", e.what());
+		return 1;
+	}
+	return 0;
+}

=== modified file 'src/third_party/CMakeLists.txt'
--- src/third_party/CMakeLists.txt	2014-06-30 20:44:41 +0000
+++ src/third_party/CMakeLists.txt	2014-07-12 12:35:28 +0000
@@ -63,7 +63,6 @@
     eris/ltm.h
     eris/lua.h
     eris/lua.hpp
-    eris/luac.c
     eris/luaconf.h
     eris/lualib.h
     eris/lundump.c

=== removed file 'src/third_party/eris/luac.c'
--- src/third_party/eris/luac.c	2014-02-22 14:47:28 +0000
+++ src/third_party/eris/luac.c	1970-01-01 00:00:00 +0000
@@ -1,432 +0,0 @@
-/*
-** $Id: luac.c,v 1.69 2011/11/29 17:46:33 lhf Exp $
-** Lua compiler (saves bytecodes to files; also list bytecodes)
-** See Copyright Notice in lua.h
-*/
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#define luac_c
-#define LUA_CORE
-
-#include "lua.h"
-#include "lauxlib.h"
-
-#include "lobject.h"
-#include "lstate.h"
-#include "lundump.h"
-
-static void PrintFunction(const Proto* f, int full);
-#define luaU_print	PrintFunction
-
-#define PROGNAME	"luac"		/* default program name */
-#define OUTPUT		PROGNAME ".out"	/* default output file */
-
-static int listing=0;			/* list bytecodes? */
-static int dumping=1;			/* dump bytecodes? */
-static int stripping=0;			/* strip debug information? */
-static char Output[]={ OUTPUT };	/* default output file name */
-static const char* output=Output;	/* actual output file name */
-static const char* progname=PROGNAME;	/* actual program name */
-
-static void fatal(const char* message)
-{
- fprintf(stderr,"%s: %s\n",progname,message);
- exit(EXIT_FAILURE);
-}
-
-static void cannot(const char* what)
-{
- fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno));
- exit(EXIT_FAILURE);
-}
-
-static void usage(const char* message)
-{
- if (*message=='-')
-  fprintf(stderr,"%s: unrecognized option " LUA_QS "\n",progname,message);
- else
-  fprintf(stderr,"%s: %s\n",progname,message);
- fprintf(stderr,
-  "usage: %s [options] [filenames]\n"
-  "Available options are:\n"
-  "  -l       list (use -l -l for full listing)\n"
-  "  -o name  output to file " LUA_QL("name") " (default is \"%s\")\n"
-  "  -p       parse only\n"
-  "  -s       strip debug information\n"
-  "  -v       show version information\n"
-  "  --       stop handling options\n"
-  "  -        stop handling options and process stdin\n"
-  ,progname,Output);
- exit(EXIT_FAILURE);
-}
-
-#define IS(s)	(strcmp(argv[i],s)==0)
-
-static int doargs(int argc, char* argv[])
-{
- int i;
- int version=0;
- if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
- for (i=1; i<argc; i++)
- {
-  if (*argv[i]!='-')			/* end of options; keep it */
-   break;
-  else if (IS("--"))			/* end of options; skip it */
-  {
-   ++i;
-   if (version) ++version;
-   break;
-  }
-  else if (IS("-"))			/* end of options; use stdin */
-   break;
-  else if (IS("-l"))			/* list */
-   ++listing;
-  else if (IS("-o"))			/* output file */
-  {
-   output=argv[++i];
-   if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))
-    usage(LUA_QL("-o") " needs argument");
-   if (IS("-")) output=NULL;
-  }
-  else if (IS("-p"))			/* parse only */
-   dumping=0;
-  else if (IS("-s"))			/* strip debug information */
-   stripping=1;
-  else if (IS("-v"))			/* show version */
-   ++version;
-  else					/* unknown option */
-   usage(argv[i]);
- }
- if (i==argc && (listing || !dumping))
- {
-  dumping=0;
-  argv[--i]=Output;
- }
- if (version)
- {
-  printf("%s\n",LUA_COPYRIGHT);
-  if (version==argc-1) exit(EXIT_SUCCESS);
- }
- return i;
-}
-
-#define FUNCTION "(function()end)();"
-
-static const char* reader(lua_State *L, void *ud, size_t *size)
-{
- UNUSED(L);
- if ((*(int*)ud)--)
- {
-  *size=sizeof(FUNCTION)-1;
-  return FUNCTION;
- }
- else
- {
-  *size=0;
-  return NULL;
- }
-}
-
-#define toproto(L,i) getproto(L->top+(i))
-
-static const Proto* combine(lua_State* L, int n)
-{
- if (n==1)
-  return toproto(L,-1);
- else
- {
-  Proto* f;
-  int i=n;
-  if (lua_load(L,reader,&i,"=(" PROGNAME ")",NULL)!=LUA_OK) fatal(lua_tostring(L,-1));
-  f=toproto(L,-1);
-  for (i=0; i<n; i++)
-  {
-   f->p[i]=toproto(L,i-n-1);
-   if (f->p[i]->sizeupvalues>0) f->p[i]->upvalues[0].instack=0;
-  }
-  f->sizelineinfo=0;
-  return f;
- }
-}
-
-static int writer(lua_State* L, const void* p, size_t size, void* u)
-{
- UNUSED(L);
- return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0);
-}
-
-static int pmain(lua_State* L)
-{
- int argc=(int)lua_tointeger(L,1);
- char** argv=(char**)lua_touserdata(L,2);
- const Proto* f;
- int i;
- if (!lua_checkstack(L,argc)) fatal("too many input files");
- for (i=0; i<argc; i++)
- {
-  const char* filename=IS("-") ? NULL : argv[i];
-  if (luaL_loadfile(L,filename)!=LUA_OK) fatal(lua_tostring(L,-1));
- }
- f=combine(L,argc);
- if (listing) luaU_print(f,listing>1);
- if (dumping)
- {
-  FILE* D= (output==NULL) ? stdout : fopen(output,"wb");
-  if (D==NULL) cannot("open");
-  lua_lock(L);
-  luaU_dump(L,f,writer,D,stripping);
-  lua_unlock(L);
-  if (ferror(D)) cannot("write");
-  if (fclose(D)) cannot("close");
- }
- return 0;
-}
-
-int main(int argc, char* argv[])
-{
- lua_State* L;
- int i=doargs(argc,argv);
- argc-=i; argv+=i;
- if (argc<=0) usage("no input files given");
- L=luaL_newstate();
- if (L==NULL) fatal("cannot create state: not enough memory");
- lua_pushcfunction(L,&pmain);
- lua_pushinteger(L,argc);
- lua_pushlightuserdata(L,argv);
- if (lua_pcall(L,2,0,0)!=LUA_OK) fatal(lua_tostring(L,-1));
- lua_close(L);
- return EXIT_SUCCESS;
-}
-
-/*
-** $Id: print.c,v 1.69 2013/07/04 01:03:46 lhf Exp $
-** print bytecodes
-** See Copyright Notice in lua.h
-*/
-
-#include <ctype.h>
-#include <stdio.h>
-
-#define luac_c
-#define LUA_CORE
-
-#include "ldebug.h"
-#include "lobject.h"
-#include "lopcodes.h"
-
-#define VOID(p)		((const void*)(p))
-
-static void PrintString(const TString* ts)
-{
- const char* s=getstr(ts);
- size_t i,n=ts->tsv.len;
- printf("%c",'"');
- for (i=0; i<n; i++)
- {
-  int c=(int)(unsigned char)s[i];
-  switch (c)
-  {
-   case '"':  printf("\\\""); break;
-   case '\\': printf("\\\\"); break;
-   case '\a': printf("\\a"); break;
-   case '\b': printf("\\b"); break;
-   case '\f': printf("\\f"); break;
-   case '\n': printf("\\n"); break;
-   case '\r': printf("\\r"); break;
-   case '\t': printf("\\t"); break;
-   case '\v': printf("\\v"); break;
-   default:	if (isprint(c))
-   			printf("%c",c);
-		else
-			printf("\\%03d",c);
-  }
- }
- printf("%c",'"');
-}
-
-static void PrintConstant(const Proto* f, int i)
-{
- const TValue* o=&f->k[i];
- switch (ttypenv(o))
- {
-  case LUA_TNIL:
-	printf("nil");
-	break;
-  case LUA_TBOOLEAN:
-	printf(bvalue(o) ? "true" : "false");
-	break;
-  case LUA_TNUMBER:
-	printf(LUA_NUMBER_FMT,nvalue(o));
-	break;
-  case LUA_TSTRING:
-	PrintString(rawtsvalue(o));
-	break;
-  default:				/* cannot happen */
-	printf("? type=%d",ttype(o));
-	break;
- }
-}
-
-#define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-")
-#define MYK(x)		(-1-(x))
-
-static void PrintCode(const Proto* f)
-{
- const Instruction* code=f->code;
- int pc,n=f->sizecode;
- for (pc=0; pc<n; pc++)
- {
-  Instruction i=code[pc];
-  OpCode o=GET_OPCODE(i);
-  int a=GETARG_A(i);
-  int b=GETARG_B(i);
-  int c=GETARG_C(i);
-  int ax=GETARG_Ax(i);
-  int bx=GETARG_Bx(i);
-  int sbx=GETARG_sBx(i);
-  int line=getfuncline(f,pc);
-  printf("\t%d\t",pc+1);
-  if (line>0) printf("[%d]\t",line); else printf("[-]\t");
-  printf("%-9s\t",luaP_opnames[o]);
-  switch (getOpMode(o))
-  {
-   case iABC:
-    printf("%d",a);
-    if (getBMode(o)!=OpArgN) printf(" %d",ISK(b) ? (MYK(INDEXK(b))) : b);
-    if (getCMode(o)!=OpArgN) printf(" %d",ISK(c) ? (MYK(INDEXK(c))) : c);
-    break;
-   case iABx:
-    printf("%d",a);
-    if (getBMode(o)==OpArgK) printf(" %d",MYK(bx));
-    if (getBMode(o)==OpArgU) printf(" %d",bx);
-    break;
-   case iAsBx:
-    printf("%d %d",a,sbx);
-    break;
-   case iAx:
-    printf("%d",MYK(ax));
-    break;
-  }
-  switch (o)
-  {
-   case OP_LOADK:
-    printf("\t; "); PrintConstant(f,bx);
-    break;
-   case OP_GETUPVAL:
-   case OP_SETUPVAL:
-    printf("\t; %s",UPVALNAME(b));
-    break;
-   case OP_GETTABUP:
-    printf("\t; %s",UPVALNAME(b));
-    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }
-    break;
-   case OP_SETTABUP:
-    printf("\t; %s",UPVALNAME(a));
-    if (ISK(b)) { printf(" "); PrintConstant(f,INDEXK(b)); }
-    if (ISK(c)) { printf(" "); PrintConstant(f,INDEXK(c)); }
-    break;
-   case OP_GETTABLE:
-   case OP_SELF:
-    if (ISK(c)) { printf("\t; "); PrintConstant(f,INDEXK(c)); }
-    break;
-   case OP_SETTABLE:
-   case OP_ADD:
-   case OP_SUB:
-   case OP_MUL:
-   case OP_DIV:
-   case OP_POW:
-   case OP_EQ:
-   case OP_LT:
-   case OP_LE:
-    if (ISK(b) || ISK(c))
-    {
-     printf("\t; ");
-     if (ISK(b)) PrintConstant(f,INDEXK(b)); else printf("-");
-     printf(" ");
-     if (ISK(c)) PrintConstant(f,INDEXK(c)); else printf("-");
-    }
-    break;
-   case OP_JMP:
-   case OP_FORLOOP:
-   case OP_FORPREP:
-   case OP_TFORLOOP:
-    printf("\t; to %d",sbx+pc+2);
-    break;
-   case OP_CLOSURE:
-    printf("\t; %p",VOID(f->p[bx]));
-    break;
-   case OP_SETLIST:
-    if (c==0) printf("\t; %d",(int)code[++pc]); else printf("\t; %d",c);
-    break;
-   case OP_EXTRAARG:
-    printf("\t; "); PrintConstant(f,ax);
-    break;
-   default:
-    break;
-  }
-  printf("\n");
- }
-}
-
-#define SS(x)	((x==1)?"":"s")
-#define S(x)	(int)(x),SS(x)
-
-static void PrintHeader(const Proto* f)
-{
- const char* s=f->source ? getstr(f->source) : "=?";
- if (*s=='@' || *s=='=')
-  s++;
- else if (*s==LUA_SIGNATURE[0])
-  s="(bstring)";
- else
-  s="(string)";
- printf("\n%s <%s:%d,%d> (%d instruction%s at %p)\n",
- 	(f->linedefined==0)?"main":"function",s,
-	f->linedefined,f->lastlinedefined,
-	S(f->sizecode),VOID(f));
- printf("%d%s param%s, %d slot%s, %d upvalue%s, ",
-	(int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams),
-	S(f->maxstacksize),S(f->sizeupvalues));
- printf("%d local%s, %d constant%s, %d function%s\n",
-	S(f->sizelocvars),S(f->sizek),S(f->sizep));
-}
-
-static void PrintDebug(const Proto* f)
-{
- int i,n;
- n=f->sizek;
- printf("constants (%d) for %p:\n",n,VOID(f));
- for (i=0; i<n; i++)
- {
-  printf("\t%d\t",i+1);
-  PrintConstant(f,i);
-  printf("\n");
- }
- n=f->sizelocvars;
- printf("locals (%d) for %p:\n",n,VOID(f));
- for (i=0; i<n; i++)
- {
-  printf("\t%d\t%s\t%d\t%d\n",
-  i,getstr(f->locvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1);
- }
- n=f->sizeupvalues;
- printf("upvalues (%d) for %p:\n",n,VOID(f));
- for (i=0; i<n; i++)
- {
-  printf("\t%d\t%s\t%d\t%d\n",
-  i,UPVALNAME(i),f->upvalues[i].instack,f->upvalues[i].idx);
- }
-}
-
-static void PrintFunction(const Proto* f, int full)
-{
- int i,n=f->sizep;
- PrintHeader(f);
- PrintCode(f);
- if (full) PrintDebug(f);
- for (i=0; i<n; i++) PrintFunction(f->p[i],full);
-}

=== modified file 'src/wui/interactive_base.h'
--- src/wui/interactive_base.h	2014-07-05 19:59:11 +0000
+++ src/wui/interactive_base.h	2014-07-12 12:35:28 +0000
@@ -46,7 +46,6 @@
  * Editor_Interactive share.
  */
 struct Interactive_Base : public Map_View, public DebugConsole::Handler {
-
 	friend class Sound_Handler;
 
 	enum {
@@ -65,6 +64,7 @@
 	Widelands::Editor_Game_Base & egbase() const {return m_egbase;}
 	virtual void reference_player_tribe(Widelands::Player_Number, const void * const) {}
 
+	// TODO(sirver): Public member variables and prefixed with m_. Jeesus.
 	bool m_show_workarea_preview;
 	OverlayManager::JobId show_work_area(const Workarea_Info & workarea_info, Widelands::Coords coords);
 	void hide_work_area(OverlayManager::JobId job_id);
@@ -127,12 +127,28 @@
 	void log_message(const char* message) const {
 		log_message(std::string(message));
 	}
+
+protected:
+	void toggle_minimap();
+	void hide_minimap();
+	UI::UniqueWindow::Registry & minimap_registry();
+
+	void mainview_move(int32_t x, int32_t y);
+	void minimap_warp(int32_t x, int32_t y);
+
+	virtual void draw_overlay(RenderTarget &) override;
+	bool handle_key(bool down, SDL_keysym) override;
+
+	void unset_sel_picture();
+	void set_sel_picture(const char * const);
+	void adjust_toolbar_position() {
+		m_toolbar.set_pos
+			(Point((get_inner_w() - m_toolbar.get_w()) >> 1, get_inner_h() - 34));
+	}
+	ChatOverlay     * m_chatOverlay;
+	UI::Box           m_toolbar;
+
 private:
-	void roadb_add_overlay   ();
-	void roadb_remove_overlay();
-
-	std::unique_ptr<InteractiveBaseInternals> m;
-	Widelands::Editor_Game_Base & m_egbase;
 	struct Sel_Data {
 		Sel_Data
 			(const bool Freeze = false, const bool Triangles = false,
@@ -156,6 +172,15 @@
 		OverlayManager::JobId jobid;
 	} m_sel;
 
+	void roadb_add_overlay   ();
+	void roadb_remove_overlay();
+	void cmdMapObject(const std::vector<std::string> & args);
+	void cmdLua(const std::vector<std::string> & args);
+	void update_speedlabel();
+
+	std::unique_ptr<InteractiveBaseInternals> m;
+	Widelands::Editor_Game_Base & m_egbase;
+
 	uint32_t m_display_flags;
 
 	uint32_t          m_lastframe;         //  system time (milliseconds)
@@ -168,32 +193,6 @@
 	Widelands::Player_Number m_road_build_player;
 	std::vector<const Image*> m_workarea_pics;
 
-protected:
-	void toggle_minimap();
-	void hide_minimap();
-	UI::UniqueWindow::Registry & minimap_registry();
-
-	void mainview_move(int32_t x, int32_t y);
-	void minimap_warp(int32_t x, int32_t y);
-
-	virtual void draw_overlay(RenderTarget &) override;
-	bool handle_key(bool down, SDL_keysym) override;
-
-	void unset_sel_picture();
-	void set_sel_picture(const char * const);
-	void adjust_toolbar_position() {
-		m_toolbar.set_pos
-			(Point((get_inner_w() - m_toolbar.get_w()) >> 1, get_inner_h() - 34));
-	}
-	ChatOverlay     * m_chatOverlay;
-	UI::Box           m_toolbar;
-
-
-private:
-	void cmdMapObject(const std::vector<std::string> & args);
-	void cmdLua(const std::vector<std::string> & args);
-	void update_speedlabel();
-
 	UI::Textarea m_label_speed_shadow;
 	UI::Textarea m_label_speed;
 

=== modified file 'src/wui/minimap.cc'
--- src/wui/minimap.cc	2014-06-08 21:47:45 +0000
+++ src/wui/minimap.cc	2014-07-12 12:35:28 +0000
@@ -33,7 +33,7 @@
 
 
 MiniMap::View::View
-	(UI::Panel & parent, int8_t * flags,
+	(UI::Panel & parent, MiniMapLayer * flags,
 	 int32_t const x, int32_t const y, uint32_t const, uint32_t const,
 	 Interactive_Base & ibase)
 :
@@ -63,16 +63,13 @@
 
 void MiniMap::View::draw(RenderTarget & dst)
 {
-	MiniMapRenderer mmr;
-
-	std::unique_ptr<Surface> surface
-		(mmr.get_minimap_image
-			(m_ibase.egbase(),
-			m_ibase.get_player(),
-			(*m_flags) & (MiniMap::Zoom2) ?
-				Point((m_viewx - get_w() / 4), (m_viewy - get_h() / 4)):
-				Point((m_viewx - get_w() / 2), (m_viewy - get_h() / 2)),
-			*m_flags));
+	std::unique_ptr<Surface> surface(
+	   draw_minimap(m_ibase.egbase(),
+	                m_ibase.get_player(),
+	                (*m_flags) & (MiniMapLayer::Zoom2) ?
+	                   Point((m_viewx - get_w() / 4), (m_viewy - get_h() / 4)) :
+	                   Point((m_viewx - get_w() / 2), (m_viewy - get_h() / 2)),
+	                *m_flags | MiniMapLayer::ViewWindow));
 	// Give ownership of the surface to the new image
 	std::unique_ptr<const Image> im(new_in_memory_image("minimap", surface.release()));
 	dst.blit(Point(), im.get());
@@ -91,7 +88,7 @@
 
 	//  calculates the coordinates corresponding to the mouse position
 	Widelands::Coords c;
-	if (*m_flags & MiniMap::Zoom2)
+	if (*m_flags & MiniMapLayer::Zoom2)
 		c = Widelands::Coords
 			(m_viewx + 1 - (get_w() / 2 - x) / 2,
 			 m_viewy + 1 - (get_h() / 2 - y) / 2);
@@ -182,12 +179,13 @@
 		 g_gr->images().get("pics/button_zoom.png"),
 		 _("Zoom"))
 {
-	button_terrn.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), Terrn));
-	button_owner.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), Owner));
-	button_flags.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), Flags));
-	button_roads.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), Roads));
-	button_bldns.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), Bldns));
-	button_zoom.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), Zoom2));
+	button_terrn.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), MiniMapLayer::Terrain));
+	button_owner.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), MiniMapLayer::Owner));
+	button_flags.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), MiniMapLayer::Flag));
+	button_roads.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), MiniMapLayer::Road));
+	button_bldns.sigclicked.connect(
+	   boost::bind(&MiniMap::toggle, boost::ref(*this), MiniMapLayer::Building));
+	button_zoom.sigclicked.connect(boost::bind(&MiniMap::toggle, boost::ref(*this), MiniMapLayer::Zoom2));
 
 	set_cache(false);
 
@@ -200,15 +198,15 @@
 }
 
 
-void MiniMap::toggle(Layers const button) {
-	*m_view.m_flags ^= button;
-	if (button == Zoom2)
+void MiniMap::toggle(MiniMapLayer const button) {
+	*m_view.m_flags = MiniMapLayer(*m_view.m_flags ^ button);
+	if (button == MiniMapLayer::Zoom2)
 		resize();
 	update_button_permpressed();
 }
 
 void MiniMap::resize() {
-	m_view.set_zoom(*m_view.m_flags & Zoom2 ? 2 : 1);
+	m_view.set_zoom(*m_view.m_flags & MiniMapLayer::Zoom2 ? 2 : 1);
 	set_inner_size
 		(m_view.get_w(), m_view.get_h() + number_of_button_rows() * but_h());
 	button_terrn.set_pos(Point(but_w() * 0, m_view.get_h() + but_h() * 0));
@@ -228,10 +226,10 @@
 
 // Makes the buttons reflect the selected layers
 void MiniMap::update_button_permpressed() {
-	button_terrn.set_perm_pressed(*m_view.m_flags & Terrn);
-	button_owner.set_perm_pressed(*m_view.m_flags & Owner);
-	button_flags.set_perm_pressed(*m_view.m_flags & Flags);
-	button_roads.set_perm_pressed(*m_view.m_flags & Roads);
-	button_bldns.set_perm_pressed(*m_view.m_flags & Bldns);
-	button_zoom .set_perm_pressed(*m_view.m_flags & Zoom2);
+	button_terrn.set_perm_pressed(*m_view.m_flags & MiniMapLayer::Terrain);
+	button_owner.set_perm_pressed(*m_view.m_flags & MiniMapLayer::Owner);
+	button_flags.set_perm_pressed(*m_view.m_flags & MiniMapLayer::Flag);
+	button_roads.set_perm_pressed(*m_view.m_flags & MiniMapLayer::Road);
+	button_bldns.set_perm_pressed(*m_view.m_flags & MiniMapLayer::Building);
+	button_zoom .set_perm_pressed(*m_view.m_flags & MiniMapLayer::Zoom2);
 }

=== modified file 'src/wui/minimap.h'
--- src/wui/minimap.h	2014-07-05 16:41:51 +0000
+++ src/wui/minimap.h	2014-07-12 12:35:28 +0000
@@ -22,6 +22,7 @@
 
 #include <boost/signals2.hpp>
 
+#include "graphic/render/minimaprenderer.h"
 #include "ui_basic/button.h"
 #include "ui_basic/unique_window.h"
 
@@ -29,9 +30,13 @@
 
 struct MiniMap : public UI::UniqueWindow {
 	struct Registry : public UI::UniqueWindow::Registry {
-		int8_t flags; /**< Combination of \ref Layers flags */
+		MiniMapLayer flags; /**< Combination of \ref MiniMapLayer flags */
 
-		Registry() : flags(Terrn | Owner | Flags | Roads | Bldns) {}
+		Registry()
+		   : flags(MiniMapLayer::Terrain | MiniMapLayer::Owner |
+		                           MiniMapLayer::Flag | MiniMapLayer::Road |
+		                           MiniMapLayer::Building) {
+		}
 	};
 
 	MiniMap(Interactive_Base & parent, Registry *);
@@ -42,10 +47,8 @@
 		m_view.set_view_pos(x, y);
 	}
 
-	enum Layers {Terrn = 1, Owner = 2, Flags = 4, Roads = 8, Bldns = 16, Zoom2 = 32};
-
 private:
-	void toggle(Layers);
+	void toggle(MiniMapLayer);
 	void update_button_permpressed();
 	void resize();
 
@@ -60,7 +63,7 @@
 	 */
 	struct View : public UI::Panel {
 		View
-			(UI::Panel & parent, int8_t * flags,
+			(UI::Panel & parent, MiniMapLayer * flags,
 			 int32_t x, int32_t y, uint32_t w, uint32_t h,
 			 Interactive_Base &);
 
@@ -79,7 +82,7 @@
 		int32_t                m_viewx, m_viewy;
 		const Image* m_pic_map_spot;
 	public:
-		int8_t * m_flags;
+		MiniMapLayer * m_flags;
 	};
 
 	uint32_t number_of_buttons_per_row() const;


Follow ups