From: Tobias Markus Date: Mon, 6 Oct 2014 23:39:23 +0000 (+0200) Subject: Fixing falling layer for most of the cases X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c2cdad4bfdf83a0066753b1162e3b7fd9dd63c93;p=supertux.git Fixing falling layer for most of the cases --- diff --git a/src/supertux/sector.cpp b/src/supertux/sector.cpp index efc5ff82f..ebf134411 100644 --- a/src/supertux/sector.cpp +++ b/src/supertux/sector.cpp @@ -58,6 +58,7 @@ #include "supertux/savegame.hpp" #include "supertux/spawn_point.hpp" #include "supertux/tile.hpp" +#include "trigger/secretarea_trigger.hpp" #include "trigger/sequence_trigger.hpp" #include "util/file_system.hpp" @@ -656,13 +657,25 @@ int Sector::calculate_foremost_layer() { int layer = 0; + std::vector secret_area_layers; + for(auto i = gameobjects.begin(); i != gameobjects.end(); ++i) + { + SecretAreaTrigger* trigger = dynamic_cast(i->get()); + if (!trigger) continue; + secret_area_layers.push_back(trigger->get_fade_tilemap_name()); + } + for(auto i = gameobjects.begin(); i != gameobjects.end(); ++i) { TileMap* tm = dynamic_cast(i->get()); if (!tm) continue; if(tm->get_layer() > foremost_layer) { - layer = tm->get_layer(); + if (std::find(secret_area_layers.begin(), secret_area_layers.end(), tm->get_name()) + != secret_area_layers.end() || tm->is_solid()) + { + layer = tm->get_layer(); + } } } return layer; diff --git a/src/trigger/secretarea_trigger.cpp b/src/trigger/secretarea_trigger.cpp index 85872b521..3242f45e9 100644 --- a/src/trigger/secretarea_trigger.cpp +++ b/src/trigger/secretarea_trigger.cpp @@ -66,6 +66,12 @@ SecretAreaTrigger::~SecretAreaTrigger() { } +std::string +SecretAreaTrigger::get_fade_tilemap_name() +{ + return fade_tilemap; +} + void SecretAreaTrigger::draw(DrawingContext& context) { diff --git a/src/trigger/secretarea_trigger.hpp b/src/trigger/secretarea_trigger.hpp index 3160afeac..4aa48969e 100644 --- a/src/trigger/secretarea_trigger.hpp +++ b/src/trigger/secretarea_trigger.hpp @@ -19,6 +19,7 @@ #include "trigger/trigger_base.hpp" +#include "object/tilemap.hpp" #include "supertux/timer.hpp" #include "util/reader_fwd.hpp" #include "util/writer_fwd.hpp" @@ -36,6 +37,7 @@ public: void event(Player& player, EventType type); void draw(DrawingContext& context); + std::string get_fade_tilemap_name(); private: Timer message_timer;