From 1d3be3300cd995ec91cbd6ae5f462ad0c65543cb Mon Sep 17 00:00:00 2001 From: ZbychuButItWasTaken Date: Mon, 12 Sep 2022 22:00:59 +0200 Subject: [PATCH] fixed tile map loading --- src-core/common/tile_map/map.cpp | 11 ++++++----- src-ui/main.cpp | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src-core/common/tile_map/map.cpp b/src-core/common/tile_map/map.cpp index 9f6f85aa0..ef3f66993 100644 --- a/src-core/common/tile_map/map.cpp +++ b/src-core/common/tile_map/map.cpp @@ -125,11 +125,12 @@ image::Image tileMap::getMapImage(std::pair coor, std::pa } } while (xtiles * ytiles > TILE_DL_LIMIT && zoom >= 13); - int offX = TILE_SIZE * (cf.first - (int)cf.first); - int offY = TILE_SIZE * (cf.second - (int)cf.second); - image::Image img(abs(cf.first - cf1.first) * TILE_SIZE, abs(cf.second - cf1.second) * TILE_SIZE, 3); + int offX = TILE_SIZE * (cf.first - (float)(int)cf.first); + int offY = TILE_SIZE - (TILE_SIZE * (cf.second - (float)(int)cf.second)); + image::Image img(std::round(abs(cf.first - cf1.first) * TILE_SIZE), std::round(abs(cf.second - cf1.second) * TILE_SIZE), 3); for (int x = 0; x < xtiles; x++) - for (int y = 0; y < ytiles; y++) - img.draw_image(0, downloadTile({std::min(cf.first, cf1.first) + x, std::min(cf.second, cf1.second) + y}, zoom).data, x * TILE_SIZE - offX, y * TILE_SIZE - offY); + for (int y = 0; y < ytiles; y++){ + img.draw_image(0, downloadTile({std::min(cf.first, cf1.first) + (float) x, std::min(cf.second, cf1.second) + (float) y}, zoom).data, x * TILE_SIZE - offX, y * TILE_SIZE - offY); + } return img; } \ No newline at end of file diff --git a/src-ui/main.cpp b/src-ui/main.cpp index a3911fe6e..1e9a171a1 100644 --- a/src-ui/main.cpp +++ b/src-ui/main.cpp @@ -13,6 +13,8 @@ //#include "tle.h" #include "common/cli_utils.h" +#include "common/tile_map/map.h" + extern bool recorder_running; static void glfw_error_callback(int error, const char *description)