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

summaryrefslogtreecommitdiff
path: root/source/game/StarUniverseClient.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/StarUniverseClient.cpp
parentb17b935c10d5ecc82a7ad2d08903c418049d8dae (diff)
Allow desired entity ID to be specified in addEntity
Diffstat (limited to 'source/game/StarUniverseClient.cpp')
-rw-r--r--source/game/StarUniverseClient.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/source/game/StarUniverseClient.cpp b/source/game/StarUniverseClient.cpp
index 4f1dc27..f12ae28 100644
--- a/source/game/StarUniverseClient.cpp
+++ b/source/game/StarUniverseClient.cpp
@@ -479,16 +479,19 @@ void UniverseClient::stopLua() {
bool UniverseClient::reloadPlayer(Json const& data, Uuid const& uuid) {
auto player = mainPlayer();
- auto world = worldClient();
- bool inWorld = player->inWorld();
- EntityId entityId = player->entityId();
+ bool playerInWorld = player->inWorld();
+ auto world = as<WorldClient>(player->world());
+
+ EntityId entityId = (playerInWorld || !world->inWorld())
+ ? player->entityId()
+ : connectionEntitySpace(world->connection()).first;
if (m_playerReloadPreCallback)
m_playerReloadPreCallback();
- if (inWorld)
- world->removeEntity(entityId, false);
- else {
+ if (playerInWorld) {
+ world->removeEntity(player->entityId(), false);
+ } else {
m_respawning = false;
m_respawnTimer.reset();
}
@@ -505,7 +508,7 @@ bool UniverseClient::reloadPlayer(Json const& data, Uuid const& uuid) {
exception = std::current_exception();
}
- world->addEntity(player);
+ world->addEntity(player, entityId);
CelestialCoordinate coordinate = m_systemWorldClient->location();
player->universeMap()->addMappedCoordinate(coordinate);