From: florianf Date: Thu, 11 Feb 2010 09:25:36 +0000 (+0000) Subject: Bug 527: Limit tilemap and background layers to (LAYER_GUI - 100). X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=0f98e8bb35814f8f810e49276396f7c0249a754e;p=supertux.git Bug 527: Limit tilemap and background layers to (LAYER_GUI - 100). This way tilemaps and backgrounds can no longer overlap the menu. Resolves #527. git-svn-id: http://supertux.lethargik.org/svn/supertux/trunk/supertux@6318 837edb03-e0f3-0310-88ca-d4d4e8b29345 --- diff --git a/src/object/background.cpp b/src/object/background.cpp index 67cf854e6..422592b38 100644 --- a/src/object/background.cpp +++ b/src/object/background.cpp @@ -105,6 +105,12 @@ Background::Background(const Reader& reader) : reader.get("scroll-speed-y", scroll_speed.y); reader.get("layer", layer); + if (layer > (LAYER_GUI - 100)) { + log_warning << "Layer of background (" << layer << ") is too large. " + << "Clipping to " << (LAYER_GUI - 100) << "." << std::endl; + layer = LAYER_GUI - 100; + } + if(!reader.get("image", imagefile) || !reader.get("speed", speed)) throw std::runtime_error("Must specify image and speed for background"); diff --git a/src/object/tilemap.cpp b/src/object/tilemap.cpp index 7dce250ab..6f2019588 100644 --- a/src/object/tilemap.cpp +++ b/src/object/tilemap.cpp @@ -80,6 +80,14 @@ TileMap::TileMap(const Reader& reader) : speed_y = 1; } + if (z_pos > (LAYER_GUI - 100)) { + log_warning << "z-pos of " + << ((name == "") ? "unnamed tilemap" : name) << " (" << z_pos << ") " + << "is too large. " + << "Clipping to " << (LAYER_GUI - 100) << "." << std::endl; + z_pos = LAYER_GUI - 100; + } + const lisp::Lisp* pathLisp = reader.get_lisp("path"); if (pathLisp) { path.reset(new Path()); @@ -147,6 +155,9 @@ TileMap::TileMap(const TileSet *new_tileset, std::string name, int z_pos, { this->name = name; + if (this->z_pos > (LAYER_GUI - 100)) + this->z_pos = LAYER_GUI - 100; + resize(width, height); } @@ -280,7 +291,10 @@ TileMap::set(int newwidth, int newheight, const std::vector&newt, tiles.resize(newt.size()); tiles = newt; - z_pos = new_z_pos; + if (new_z_pos > (LAYER_GUI - 100)) + z_pos = LAYER_GUI - 100; + else + z_pos = new_z_pos; solid = newsolid; // make sure all tiles are loaded