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

summaryrefslogtreecommitdiff
path: root/source/game/StarWorldClient.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-08-02 21:28:37 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-08-02 21:28:37 +1000
commitc80b2d2dbc32c45b4eaeb802af6dcdf921b8410b (patch)
tree41cbe5205b48c6e7d49ccf04d9a2818e68afbc05 /source/game/StarWorldClient.cpp
parent994c533a0f7b4aa1a1530405505a53546252e1d1 (diff)
Add loading icon when swapping character
Diffstat (limited to 'source/game/StarWorldClient.cpp')
-rw-r--r--source/game/StarWorldClient.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp
index 24199c3..5ade948 100644
--- a/source/game/StarWorldClient.cpp
+++ b/source/game/StarWorldClient.cpp
@@ -1275,6 +1275,7 @@ void WorldClient::addEntity(EntityPtr const& entity, EntityId entityId) {
if (entity->clientEntityMode() != ClientEntityMode::ClientSlaveOnly) {
entity->init(this, m_entityMap->reserveEntityId(entityId), EntityMode::Master);
m_entityMap->addEntity(entity);
+ notifyEntityCreate(entity);
} else {
auto entityFactory = Root::singleton().entityFactory();
m_outgoingPackets.append(make_shared<SpawnEntityPacket>(entity->entityType(), entityFactory->netStoreEntity(entity), entity->writeNetState().first));
@@ -1358,15 +1359,7 @@ void WorldClient::queueUpdatePackets() {
if (m_currentStep % m_clientConfig.getInt("worldClientStateUpdateDelta") == 0)
m_outgoingPackets.append(make_shared<WorldClientStateUpdatePacket>(m_clientState.writeDelta()));
- m_entityMap->forAllEntities([&](EntityPtr const& entity) {
- if (entity->isMaster() && !m_masterEntitiesNetVersion.contains(entity->entityId())) {
- // Server was unaware of this entity until now
- auto firstNetState = entity->writeNetState();
- m_masterEntitiesNetVersion[entity->entityId()] = firstNetState.second;
- m_outgoingPackets.append(make_shared<EntityCreatePacket>(entity->entityType(),
- entityFactory->netStoreEntity(entity), move(firstNetState.first), entity->entityId()));
- }
- });
+ m_entityMap->forAllEntities([&](EntityPtr const& entity) { notifyEntityCreate(entity); });
if (m_currentStep % m_interpolationTracker.entityUpdateDelta() == 0) {
auto entityUpdateSet = make_shared<EntityUpdateSetPacket>();
@@ -1742,6 +1735,16 @@ void WorldClient::tryGiveMainPlayerItem(ItemPtr item) {
addEntity(ItemDrop::createRandomizedDrop(spill->descriptor(), m_mainPlayer->position()));
}
+void WorldClient::notifyEntityCreate(EntityPtr const& entity) {
+ if (entity->isMaster() && !m_masterEntitiesNetVersion.contains(entity->entityId())) {
+ // Server was unaware of this entity until now
+ auto firstNetState = entity->writeNetState();
+ m_masterEntitiesNetVersion[entity->entityId()] = firstNetState.second;
+ m_outgoingPackets.append(make_shared<EntityCreatePacket>(entity->entityType(),
+ Root::singleton().entityFactory()->netStoreEntity(entity), move(firstNetState.first), entity->entityId()));
+ }
+}
+
Vec2I WorldClient::environmentBiomeTrackPosition() const {
if (!inWorld())
return {};