commit c15526a0
Use the correct blocking layer for water and lava
Changed files
| M | src/saland/Game.cpp before |
| M | src/saland/model/World.cpp before |
diff --git a/src/saland/Game.cpp b/src/saland/Game.cpp
index 9e3eb10..01bf0cd 100644
--- a/src/saland/Game.cpp
+++ b/src/saland/Game.cpp
@@ -687,7 +687,7 @@ void Game::Update() {
int tile = data->slot_spell.at(data->slot_selected).tile;
if (sago::tiled::tileInBound(data->gameRegion.world.tm, tile_x, tile_y)
&& !(data->gameRegion.world.tile_protected(tile_x, tile_y)) ) {
- int layer_number = 2; // Do not hardcode
+ int layer_number = data->gameRegion.world.blockingLayer;
sago::tiled::setTileOnLayerNumber(data->gameRegion.world.tm, layer_number, tile_x, tile_y, tile);
data->gameRegion.liqudHandler["water"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y);
data->gameRegion.liqudHandler["lava"].updateFirstTile(data->gameRegion.world.tm, tile_x, tile_y);
diff --git a/src/saland/model/World.cpp b/src/saland/model/World.cpp
index ad3ed2c..b176d50 100644
--- a/src/saland/model/World.cpp
+++ b/src/saland/model/World.cpp
@@ -250,6 +250,15 @@ static void init_tilemap(sago::tiled::TileMap& tm, int& blockingLayer, int& bloc
bubble_layer_after(tm, "blocking_overlay_1", "prefab_blocking_2");
bubble_layer_after(tm, "prefab_overlay_1", "blocking_overlay_1");
bubble_layer_after(tm, "overlay_1", "prefab_overlay_1");
+ // Recheck blocking and blocking_overlay_1 layers as they might have been shifted while sorting.
+ for (size_t i=0; i < tm.layers.size(); ++i) {
+ if (tm.layers[i].name == "blocking") {
+ blockingLayer = i;
+ }
+ if (tm.layers[i].name == "blocking_overlay_1") {
+ blockingLayer_overlay_1 = i;
+ }
+ }
}
void World::init(std::shared_ptr<b2World>& world, const std::string& mapFileName) {