From 4fc1974292861485729ef72609311cb47632d47f Mon Sep 17 00:00:00 2001 From: Erik Schilling Date: Sun, 4 Aug 2013 19:03:03 +0200 Subject: Do not make all attributes persistent By default they are not persistent now (meaning that they wont get stored in the database). --- src/game-server/attributeinfo.h | 3 ++- src/game-server/attributemanager.cpp | 2 ++ src/game-server/character.cpp | 15 +++++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/game-server/attributeinfo.h b/src/game-server/attributeinfo.h index 8b9adfe6..b18e8f6d 100644 --- a/src/game-server/attributeinfo.h +++ b/src/game-server/attributeinfo.h @@ -60,6 +60,7 @@ struct AttributeInfo AttributeInfo(int id, const std::string &name): id(id), name(name), + persistent(false), minimum(std::numeric_limits::min()), maximum(std::numeric_limits::max()), modifiable(false) @@ -67,7 +68,7 @@ struct AttributeInfo int id; std::string name; - + bool persistent; double minimum; double maximum; bool modifiable; diff --git a/src/game-server/attributemanager.cpp b/src/game-server/attributemanager.cpp index cb922511..3a19e1b6 100644 --- a/src/game-server/attributemanager.cpp +++ b/src/game-server/attributemanager.cpp @@ -114,6 +114,8 @@ void AttributeManager::readAttributeNode(xmlNodePtr attributeNode) AttributeInfo *attribute = new AttributeInfo(id, name); + attribute->persistent = XML::getBoolProperty(attributeNode, "persistent", + false); attribute->modifiers = std::vector(); attribute->minimum = XML::getFloatProperty(attributeNode, "minimum", std::numeric_limits::min()); diff --git a/src/game-server/character.cpp b/src/game-server/character.cpp index 74df2122..0944f757 100644 --- a/src/game-server/character.cpp +++ b/src/game-server/character.cpp @@ -223,12 +223,19 @@ void CharacterComponent::serialize(Entity &entity, MessageOut &msg) const AttributeMap &attributes = beingComponent->getAttributes(); - msg.writeInt16(attributes.size()); - for (auto attributeIt : attributes) + std::map attributesToSend; + for (auto &attributeIt : attributes) + { + if (attributeIt.first->persistent) + attributesToSend.insert(std::make_pair(attributeIt.first, + &attributeIt.second)); + } + msg.writeInt16(attributesToSend.size()); + for (auto &attributeIt : attributesToSend) { msg.writeInt16(attributeIt.first->id); - msg.writeDouble(attributeIt.second.getBase()); - msg.writeDouble(attributeIt.second.getModifiedAttribute()); + msg.writeDouble(attributeIt.second->getBase()); + msg.writeDouble(attributeIt.second->getModifiedAttribute()); } // status effects currently affecting the character -- cgit v1.2.3-70-g09d2