From fff6a103cf0873ea6e72148500d8259d12d86418 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Thu, 11 Feb 2010 09:25:36 +0000 Subject: [PATCH] Bug 527: Limit tilemap and background layers to (LAYER_GUI - 100). This way tilemaps and backgrounds can no longer overlap the menu. Resolves #527. SVN-Revision: 6318 --- src/object/background.cpp | 6 ++++++ src/object/tilemap.cpp | 16 +++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) 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 -- 2.11.0