diff options
author | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-08-04 19:03:03 +0200 |
---|---|---|
committer | Erik Schilling <ablu.erikschilling@googlemail.com> | 2013-09-01 00:52:17 +0200 |
commit | 4fc1974292861485729ef72609311cb47632d47f (patch) | |
tree | c71390916ec55373edfa5ffb7587ea016e80578e | |
parent | b4ddc47bd54a0de8be8798a0416dd09cc4da662b (diff) | |
download | manaserv-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).
-rw-r--r-- | example/attributes.xml | 18 | ||||
-rw-r--r-- | src/game-server/attributeinfo.h | 3 | ||||
-rw-r--r-- | src/game-server/attributemanager.cpp | 2 | ||||
-rw-r--r-- | src/game-server/character.cpp | 15 |
4 files changed, 27 insertions, 11 deletions
diff --git a/example/attributes.xml b/example/attributes.xml index 09868892..ee567f26 100644 --- a/example/attributes.xml +++ b/example/attributes.xml @@ -11,7 +11,8 @@ modifiable="true" scope="character" minimum="0" - maximum="255"> + maximum="255" + persistent="true"> <modifier stacktype="stackable" modtype="additive" tag="str" effect="Strength %+.1f" /> </attribute> <attribute id="2" name="Agility" @@ -19,7 +20,8 @@ modifiable="true" scope="character" minimum="0" - maximum="255"> + maximum="255" + persistent="true"> <modifier stacktype="stackable" modtype="additive" tag="agi" effect="Agility %+.1f" /> </attribute> <attribute id="3" name="Vitality" @@ -27,7 +29,8 @@ modifiable="true" scope="character" minimum="0" - maximum="255"> + maximum="255" + persistent="true"> <modifier stacktype="stackable" modtype="additive" tag="vit" effect="Vitality %+.1f" /> </attribute> <attribute id="4" name="Intelligence" @@ -35,7 +38,8 @@ modifiable="true" scope="character" minimum="0" - maximum="255"> + maximum="255" + persistent="true"> <modifier stacktype="stackable" modtype="additive" tag="int" effect="Intelligence %+.1f" /> </attribute> <attribute id="5" name="Dexterity" @@ -43,7 +47,8 @@ modifiable="true" scope="character" minimum="0" - maximum="255"> + maximum="255" + persistent="true"> <modifier stacktype="stackable" modtype="additive" tag="dex" effect="Dexterity %+.1f" /> </attribute> <attribute id="6" name="Willpower" @@ -51,7 +56,8 @@ modifiable="true" scope="character" minimum="0" - maximum="255"> + maximum="255" + persistent="true"> <modifier stacktype="stackable" modtype="additive" tag="wil" effect="Willpower %+.1f" /> </attribute> <attribute id="7" name="Accuracy" 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 |