aboutsummaryrefslogtreecommitdiff
path: root/src/tool.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool.cpp')
-rw-r--r--src/tool.cpp25
1 files changed, 12 insertions, 13 deletions
diff --git a/src/tool.cpp b/src/tool.cpp
index 38508c5fe..839b1e387 100644
--- a/src/tool.cpp
+++ b/src/tool.cpp
@@ -27,7 +27,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const
{
- writeU8(os, 2); // version (protocol >= 18)
+ writeU8(os, 3); // protocol_version >= 36
writeF1000(os, full_punch_interval);
writeS16(os, max_drop_level);
writeU32(os, groupcaps.size());
@@ -55,33 +55,32 @@ void ToolCapabilities::serialize(std::ostream &os, u16 protocol_version) const
void ToolCapabilities::deSerialize(std::istream &is)
{
int version = readU8(is);
- if(version != 1 && version != 2) throw SerializationError(
- "unsupported ToolCapabilities version");
+ if (version < 3)
+ throw SerializationError("unsupported ToolCapabilities version");
+
full_punch_interval = readF1000(is);
max_drop_level = readS16(is);
groupcaps.clear();
u32 groupcaps_size = readU32(is);
- for(u32 i=0; i<groupcaps_size; i++){
+ for (u32 i = 0; i < groupcaps_size; i++) {
std::string name = deSerializeString(is);
ToolGroupCap cap;
cap.uses = readS16(is);
cap.maxlevel = readS16(is);
u32 times_size = readU32(is);
- for(u32 i=0; i<times_size; i++){
+ for(u32 i = 0; i < times_size; i++) {
int level = readS16(is);
float time = readF1000(is);
cap.times[level] = time;
}
groupcaps[name] = cap;
}
- if(version == 2)
- {
- u32 damage_groups_size = readU32(is);
- for(u32 i=0; i<damage_groups_size; i++){
- std::string name = deSerializeString(is);
- s16 rating = readS16(is);
- damageGroups[name] = rating;
- }
+
+ u32 damage_groups_size = readU32(is);
+ for (u32 i = 0; i < damage_groups_size; i++) {
+ std::string name = deSerializeString(is);
+ s16 rating = readS16(is);
+ damageGroups[name] = rating;
}
}