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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/client/starbound-largelogo.icobin370070 -> 410598 bytes
-rw-r--r--source/client/starbound.icobin370070 -> 410598 bytes
-rw-r--r--source/game/StarWorldClient.cpp2
-rw-r--r--source/game/StarWorldServer.cpp15
-rw-r--r--source/game/StarWorldServer.hpp1
5 files changed, 12 insertions, 6 deletions
diff --git a/source/client/starbound-largelogo.ico b/source/client/starbound-largelogo.ico
index 1483c81..999d921 100644
--- a/source/client/starbound-largelogo.ico
+++ b/source/client/starbound-largelogo.ico
Binary files differ
diff --git a/source/client/starbound.ico b/source/client/starbound.ico
index 1483c81..999d921 100644
--- a/source/client/starbound.ico
+++ b/source/client/starbound.ico
Binary files differ
diff --git a/source/game/StarWorldClient.cpp b/source/game/StarWorldClient.cpp
index 0dfddf8..f8942d2 100644
--- a/source/game/StarWorldClient.cpp
+++ b/source/game/StarWorldClient.cpp
@@ -656,8 +656,8 @@ void WorldClient::handleIncomingPackets(List<PacketPtr> const& packets) {
}
auto entity = entityFactory->netLoadEntity(entityCreate->entityType, entityCreate->storeData);
- entity->readNetState(entityCreate->firstNetState);
entity->init(this, entityCreate->entityId, EntityMode::Slave);
+ entity->readNetState(entityCreate->firstNetState);
m_entityMap->addEntity(entity);
if (m_interpolationTracker.interpolationEnabled()) {
diff --git a/source/game/StarWorldServer.cpp b/source/game/StarWorldServer.cpp
index 061335f..bf36e62 100644
--- a/source/game/StarWorldServer.cpp
+++ b/source/game/StarWorldServer.cpp
@@ -392,8 +392,8 @@ void WorldServer::handleIncomingPackets(ConnectionId clientId, List<PacketPtr> c
}
auto entity = entityFactory->netLoadEntity(entityCreate->entityType, entityCreate->storeData);
- entity->readNetState(entityCreate->firstNetState);
entity->init(this, entityCreate->entityId, EntityMode::Slave);
+ entity->readNetState(entityCreate->firstNetState);
m_entityMap->addEntity(entity);
if (clientInfo->interpolationTracker.interpolationEnabled())
@@ -605,6 +605,7 @@ void WorldServer::update() {
signalRegion(monitoredRegion.padded(jsonToVec2I(m_serverConfig.get("playerActiveRegionPad"))));
queueUpdatePackets(pair.first);
}
+ m_netStateCache.clear();
for (auto& pair : m_clientInfo)
pair.second->pendingForward = false;
@@ -1743,10 +1744,14 @@ void WorldServer::queueUpdatePackets(ConnectionId clientId) {
if (connectionId != clientId) {
if (auto version = clientInfo->clientSlavesNetVersion.ptr(entityId)) {
if (auto updateSetPacket = updateSetPackets.value(connectionId)) {
- auto updateAndVersion = monitoredEntity->writeNetState(*version);
- if (!updateAndVersion.first.empty())
- updateSetPacket->deltas[entityId] = move(updateAndVersion.first);
- *version = updateAndVersion.second;
+ auto pair = make_pair(entityId, *version);
+ auto i = m_netStateCache.find(pair);
+ if (i == m_netStateCache.end())
+ i = m_netStateCache.insert(pair, move(monitoredEntity->writeNetState(*version))).first;
+ const auto& netState = i->second;
+ if (!netState.first.empty())
+ updateSetPacket->deltas[entityId] = netState.first;
+ *version = netState.second;
}
} else if (!monitoredEntity->masterOnly()) {
// Client was unaware of this entity until now
diff --git a/source/game/StarWorldServer.hpp b/source/game/StarWorldServer.hpp
index 1def4f3..7609cdc 100644
--- a/source/game/StarWorldServer.hpp
+++ b/source/game/StarWorldServer.hpp
@@ -347,6 +347,7 @@ private:
CollisionGenerator m_collisionGenerator;
List<CollisionBlock> m_workingCollisionBlocks;
+ HashMap<pair<EntityId, uint64_t>, pair<ByteArray, uint64_t>> m_netStateCache;
OrderedHashMap<ConnectionId, shared_ptr<ClientInfo>> m_clientInfo;
GameTimer m_tileEntityBreakCheckTimer;