Merge pull request #90907 from KoBeWi/null_tile_exception
Don't store TileMapLayer data if empty
This commit is contained in:
commit
7599be9437
2 changed files with 10 additions and 1 deletions
|
@ -268,7 +268,7 @@
|
||||||
The quadrant size does not apply on a Y-sorted [TileMapLayer], as tiles are be grouped by Y position instead in that case.
|
The quadrant size does not apply on a Y-sorted [TileMapLayer], as tiles are be grouped by Y position instead in that case.
|
||||||
[b]Note:[/b] As quadrants are created according to the map's coordinate system, the quadrant's "square shape" might not look like square in the [TileMapLayer]'s local coordinate system.
|
[b]Note:[/b] As quadrants are created according to the map's coordinate system, the quadrant's "square shape" might not look like square in the [TileMapLayer]'s local coordinate system.
|
||||||
</member>
|
</member>
|
||||||
<member name="tile_map_data" type="PackedByteArray" setter="set_tile_map_data_from_array" getter="get_tile_map_data_as_array" default="PackedByteArray("AAA=")">
|
<member name="tile_map_data" type="PackedByteArray" setter="set_tile_map_data_from_array" getter="get_tile_map_data_as_array" default="PackedByteArray()">
|
||||||
The raw tile map data as a byte array.
|
The raw tile map data as a byte array.
|
||||||
</member>
|
</member>
|
||||||
<member name="tile_set" type="TileSet" setter="set_tile_set" getter="get_tile_set">
|
<member name="tile_set" type="TileSet" setter="set_tile_set" getter="get_tile_set">
|
||||||
|
|
|
@ -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) {
|
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;
|
const int cell_data_struct_size = 12;
|
||||||
|
|
||||||
int size = p_data.size();
|
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;
|
const int cell_data_struct_size = 12;
|
||||||
|
|
||||||
Vector<uint8_t> tile_map_data_array;
|
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);
|
tile_map_data_array.resize(2 + tile_map_layer_data.size() * cell_data_struct_size);
|
||||||
uint8_t *ptr = tile_map_data_array.ptrw();
|
uint8_t *ptr = tile_map_data_array.ptrw();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue