Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarEntityMap.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-29 00:52:56 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-29 00:52:56 +1000
commit35fc2679dea7b625bf559c6855e101fc62e613f4 (patch)
treeb8dd025f4a38d71eb828be590e14a3c80231d411 /source/game/StarEntityMap.cpp
parentb17b935c10d5ecc82a7ad2d08903c418049d8dae (diff)
Allow desired entity ID to be specified in addEntity
Diffstat (limited to 'source/game/StarEntityMap.cpp')
-rw-r--r--source/game/StarEntityMap.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/source/game/StarEntityMap.cpp b/source/game/StarEntityMap.cpp
index 2232099..6a22a67 100644
--- a/source/game/StarEntityMap.cpp
+++ b/source/game/StarEntityMap.cpp
@@ -31,13 +31,15 @@ Maybe<EntityId> EntityMap::maybeReserveEntityId(EntityId entityId) {
if (m_spatialMap.size() >= (size_t)(m_endIdSpace - m_beginIdSpace))
throw EntityMapException("No more entity id space in EntityMap::reserveEntityId");
- if (m_spatialMap.contains(entityId))
+ if (entityId == NullEntityId || m_spatialMap.contains(entityId))
return {};
else
return entityId;
}
EntityId EntityMap::reserveEntityId(EntityId entityId) {
+ if (entityId == NullEntityId)
+ return reserveEntityId();
if (auto reserved = maybeReserveEntityId(entityId))
return *reserved;