summaryrefslogtreecommitdiffstats
path: root/scene/2d/tile_map_layer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'scene/2d/tile_map_layer.cpp')
-rw-r--r--scene/2d/tile_map_layer.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/scene/2d/tile_map_layer.cpp b/scene/2d/tile_map_layer.cpp
index 873cfeebda..ab3c48562c 100644
--- a/scene/2d/tile_map_layer.cpp
+++ b/scene/2d/tile_map_layer.cpp
@@ -2588,6 +2588,11 @@ TileMapLayer::HighlightMode TileMapLayer::get_highlight_mode() const {
}
void TileMapLayer::set_tile_map_data_from_array(const Vector<uint8_t> &p_data) {
+ if (p_data.is_empty()) {
+ clear();
+ return;
+ }
+
const int cell_data_struct_size = 12;
int size = p_data.size();
@@ -2630,6 +2635,10 @@ Vector<uint8_t> TileMapLayer::get_tile_map_data_as_array() const {
const int cell_data_struct_size = 12;
Vector<uint8_t> tile_map_data_array;
+ if (tile_map_layer_data.is_empty()) {
+ return tile_map_data_array;
+ }
+
tile_map_data_array.resize(2 + tile_map_layer_data.size() * cell_data_struct_size);
uint8_t *ptr = tile_map_data_array.ptrw();