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

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/game/StarPlayer.cpp14
-rw-r--r--source/game/StarWorldServer.cpp19
2 files changed, 23 insertions, 10 deletions
diff --git a/source/game/StarPlayer.cpp b/source/game/StarPlayer.cpp
index 4e29bd2..47ded48 100644
--- a/source/game/StarPlayer.cpp
+++ b/source/game/StarPlayer.cpp
@@ -285,7 +285,6 @@ void Player::init(World* world, EntityId entityId, EntityMode mode) {
Entity::init(world, entityId, mode);
auto speciesDefinition = Root::singleton().speciesDatabase()->species(m_identity.species);
- m_statusController->setStatusProperty("ouchNoise", speciesDefinition->ouchNoise(m_identity.gender));
m_tools->init(this);
m_movementController->init(world);
@@ -295,6 +294,7 @@ void Player::init(World* world, EntityId entityId, EntityMode mode) {
m_techController->init(this, m_movementController.get(), m_statusController.get());
if (mode == EntityMode::Master) {
+ m_statusController->setStatusProperty("ouchNoise", speciesDefinition->ouchNoise(m_identity.gender));
m_emoteState = HumanoidEmote::Idle;
m_questManager->init(world);
m_companions->init(this, world);
@@ -1088,7 +1088,10 @@ Json Player::getGenericProperty(String const& name, Json const& defaultValue) co
}
void Player::setGenericProperty(String const& name, Json const& value) {
- m_genericProperties.set(name, value);
+ if (value.isNull())
+ m_genericProperties.erase(name);
+ else
+ m_genericProperties.set(name, value);
}
PlayerInventoryPtr Player::inventory() const {
@@ -2086,8 +2089,11 @@ QuestManagerPtr Player::questManager() const {
Json Player::diskStore() {
JsonObject genericScriptStorage;
- for (auto& p : m_genericScriptContexts)
- genericScriptStorage[p.first] = p.second->getScriptStorage();
+ for (auto& p : m_genericScriptContexts) {
+ auto scriptStorage = p.second->getScriptStorage();
+ if (!scriptStorage.empty())
+ genericScriptStorage[p.first] = move(scriptStorage);
+ }
return JsonObject{
{"uuid", *uniqueId()},
diff --git a/source/game/StarWorldServer.cpp b/source/game/StarWorldServer.cpp
index bf36e62..417c718 100644
--- a/source/game/StarWorldServer.cpp
+++ b/source/game/StarWorldServer.cpp
@@ -2037,12 +2037,19 @@ Json WorldServer::getProperty(String const& propertyName, Json const& def) const
}
void WorldServer::setProperty(String const& propertyName, Json const& property) {
- if (m_worldProperties.value(propertyName) == property)
- return;
-
- m_worldProperties[propertyName] = property;
- for (auto const& pair : m_clientInfo)
- pair.second->outgoingPackets.append(make_shared<UpdateWorldPropertiesPacket>(JsonObject{{propertyName, property}}));
+ // Kae: Properties set to null (nil from Lua) should be erased instead of lingering around
+ auto entry = m_worldProperties.find(propertyName);
+ bool missing = entry == m_worldProperties.end();
+ if (missing ? !property.isNull() : property != entry->second) {
+ if (missing) // property can't be null if we're doing this when missing is true
+ m_worldProperties.emplace(propertyName, property);
+ else if (property.isNull())
+ m_worldProperties.erase(entry);
+ else
+ entry->second = property;
+ for (auto const& pair : m_clientInfo)
+ pair.second->outgoingPackets.append(make_shared<UpdateWorldPropertiesPacket>(JsonObject{ {propertyName, property} }));
+ }
}
void WorldServer::timer(int stepsDelay, WorldAction worldAction) {