summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
authorGilles Roudière <gilles.roudiere@gmail.com>2023-01-16 12:14:40 +0100
committerGilles Roudière <gilles.roudiere@gmail.com>2023-01-16 12:14:40 +0100
commit0dbcf8f735c4cc29312582f3b2b4046581c36886 (patch)
treed859cb0a03e3fb63e221b267d29c938b9cce5d17 /scene/resources
parent3c9bf4bc210a8e6a208f30ca59de4d4d7e18c04d (diff)
Fixes TileDate::add_source accepting invalid ID values
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/tile_set.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 4043b73b71..94e78fc3aa 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -473,6 +473,7 @@ void TileSet::_compute_next_source_id() {
int TileSet::add_source(Ref<TileSetSource> p_tile_set_source, int p_atlas_source_id_override) {
ERR_FAIL_COND_V(!p_tile_set_source.is_valid(), TileSet::INVALID_SOURCE);
ERR_FAIL_COND_V_MSG(p_atlas_source_id_override >= 0 && (sources.has(p_atlas_source_id_override)), TileSet::INVALID_SOURCE, vformat("Cannot create TileSet atlas source. Another atlas source exists with id %d.", p_atlas_source_id_override));
+ ERR_FAIL_COND_V_MSG(p_atlas_source_id_override < 0 && p_atlas_source_id_override != TileSet::INVALID_SOURCE, TileSet::INVALID_SOURCE, vformat("Provided source ID %d is not valid. Negative source IDs are not allowed.", p_atlas_source_id_override));
int new_source_id = p_atlas_source_id_override >= 0 ? p_atlas_source_id_override : next_source_id;
sources[new_source_id] = p_tile_set_source;