summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorErik Schilling <ablu.erikschilling@googlemail.com>2013-08-04 19:03:03 +0200
committerErik Schilling <ablu.erikschilling@googlemail.com>2013-09-01 00:52:17 +0200
commit4fc1974292861485729ef72609311cb47632d47f (patch)
treec71390916ec55373edfa5ffb7587ea016e80578e /src
parentb4ddc47bd54a0de8be8798a0416dd09cc4da662b (diff)
downloadmanaserv-4fc1974292861485729ef72609311cb47632d47f.tar.gz
manaserv-4fc1974292861485729ef72609311cb47632d47f.tar.bz2
manaserv-4fc1974292861485729ef72609311cb47632d47f.tar.xz
manaserv-4fc1974292861485729ef72609311cb47632d47f.zip
Do not make all attributes persistent
By default they are not persistent now (meaning that they wont get stored in the database).
Diffstat (limited to 'src')
-rw-r--r--src/game-server/attributeinfo.h3
-rw-r--r--src/game-server/attributemanager.cpp2
-rw-r--r--src/game-server/character.cpp15
3 files changed, 15 insertions, 5 deletions
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<double>::min()),
maximum(std::numeric_limits<double>::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<AttributeModifier>();
attribute->minimum = XML::getFloatProperty(attributeNode, "minimum",
std::numeric_limits<double>::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<const AttributeInfo *, const Attribute *> 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