From b353ae37eb6d374aec4127f1849a5dce81f812b5 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Tue, 24 Jun 2014 18:52:00 -0700 Subject: No one is .neutral() here (except IPv4 addresses) --- src/proto2/any-user.hpp | 5 - src/proto2/char-map.hpp | 19 +- src/proto2/char-user.hpp | 5 - src/proto2/include_consts_test.cpp | 23 ++ src/proto2/include_enums_test.cpp | 1 + src/proto2/include_mmo_test.cpp | 26 -- src/proto2/login-admin.hpp | 5 - src/proto2/login-char.hpp | 5 - src/proto2/login-user.hpp | 5 - src/proto2/map-user.hpp | 5 - src/proto2/types.hpp | 514 ++++++++++++++++++++++++++++++++++++- 11 files changed, 544 insertions(+), 69 deletions(-) create mode 100644 src/proto2/include_consts_test.cpp delete mode 100644 src/proto2/include_mmo_test.cpp (limited to 'src/proto2') diff --git a/src/proto2/any-user.hpp b/src/proto2/any-user.hpp index 4e14712..6cbf8e3 100644 --- a/src/proto2/any-user.hpp +++ b/src/proto2/any-user.hpp @@ -27,9 +27,6 @@ // This is a public protocol, and changes require client cooperation -// this is only needed for the payload packet right now, and that needs to die -# pragma pack(push, 1) - template<> struct Packet_Fixed<0x0081> { @@ -214,6 +211,4 @@ bool network_to_native(Packet_Payload<0x8000> *native, NetPacket_Payload<0x8000> } -# pragma pack(pop) - #endif // TMWA_PROTO2_ANY_USER_HPP diff --git a/src/proto2/char-map.hpp b/src/proto2/char-map.hpp index f543b90..6383130 100644 --- a/src/proto2/char-map.hpp +++ b/src/proto2/char-map.hpp @@ -27,9 +27,6 @@ // This is an internal protocol, and can be changed without notice -// this is only needed for the payload packet right now, and that needs to die -# pragma pack(push, 1) - template<> struct Packet_Fixed<0x2af7> { @@ -1033,8 +1030,8 @@ struct NetPacket_Payload<0x2afd> Little32 login_id2; Little32 connect_until; Little16 packet_tmw_version; - CharKey char_key; - CharData char_data; + NetCharKey char_key; + NetCharData char_data; }; static_assert(offsetof(NetPacket_Payload<0x2afd>, magic_packet_id) == 0, "offsetof(NetPacket_Payload<0x2afd>, magic_packet_id) == 0"); static_assert(offsetof(NetPacket_Payload<0x2afd>, magic_packet_length) == 2, "offsetof(NetPacket_Payload<0x2afd>, magic_packet_length) == 2"); @@ -1095,8 +1092,8 @@ struct NetPacket_Payload<0x2b01> Little16 magic_packet_length; Little32 account_id; Little32 char_id; - CharKey char_key; - CharData char_data; + NetCharKey char_key; + NetCharData char_data; }; static_assert(offsetof(NetPacket_Payload<0x2b01>, magic_packet_id) == 0, "offsetof(NetPacket_Payload<0x2b01>, magic_packet_id) == 0"); static_assert(offsetof(NetPacket_Payload<0x2b01>, magic_packet_length) == 2, "offsetof(NetPacket_Payload<0x2b01>, magic_packet_length) == 2"); @@ -1558,7 +1555,7 @@ struct NetPacket_Payload<0x3011> Little16 magic_packet_id; Little16 magic_packet_length; Little32 account_id; - Storage storage; + NetStorage storage; }; static_assert(offsetof(NetPacket_Payload<0x3011>, magic_packet_id) == 0, "offsetof(NetPacket_Payload<0x3011>, magic_packet_id) == 0"); static_assert(offsetof(NetPacket_Payload<0x3011>, magic_packet_length) == 2, "offsetof(NetPacket_Payload<0x3011>, magic_packet_length) == 2"); @@ -1822,7 +1819,7 @@ struct NetPacket_Payload<0x3810> Little16 magic_packet_id; Little16 magic_packet_length; Little32 account_id; - Storage storage; + NetStorage storage; }; static_assert(offsetof(NetPacket_Payload<0x3810>, magic_packet_id) == 0, "offsetof(NetPacket_Payload<0x3810>, magic_packet_id) == 0"); static_assert(offsetof(NetPacket_Payload<0x3810>, magic_packet_length) == 2, "offsetof(NetPacket_Payload<0x3810>, magic_packet_length) == 2"); @@ -1875,7 +1872,7 @@ static_assert(alignof(NetPacket_Head<0x3821>) == 1, "alignof(NetPacket_Head<0x38 template<> struct NetPacket_Option<0x3821> { - PartyMost party_most; + NetPartyMost party_most; }; static_assert(offsetof(NetPacket_Option<0x3821>, party_most) == 0, "offsetof(NetPacket_Option<0x3821>, party_most) == 0"); static_assert(alignof(NetPacket_Option<0x3821>) == 1, "alignof(NetPacket_Option<0x3821>) == 1"); @@ -3536,6 +3533,4 @@ bool network_to_native(Packet_Repeat<0x3827> *native, NetPacket_Repeat<0x3827> n } -# pragma pack(pop) - #endif // TMWA_PROTO2_CHAR_MAP_HPP diff --git a/src/proto2/char-user.hpp b/src/proto2/char-user.hpp index 2c1d1ac..2fc3856 100644 --- a/src/proto2/char-user.hpp +++ b/src/proto2/char-user.hpp @@ -27,9 +27,6 @@ // This is a public protocol, and changes require client cooperation -// this is only needed for the payload packet right now, and that needs to die -# pragma pack(push, 1) - template<> struct Packet_Fixed<0x0061> { @@ -622,6 +619,4 @@ bool network_to_native(Packet_Fixed<0x0071> *native, NetPacket_Fixed<0x0071> net } -# pragma pack(pop) - #endif // TMWA_PROTO2_CHAR_USER_HPP diff --git a/src/proto2/include_consts_test.cpp b/src/proto2/include_consts_test.cpp new file mode 100644 index 0000000..b093dab --- /dev/null +++ b/src/proto2/include_consts_test.cpp @@ -0,0 +1,23 @@ +#include "../mmo/consts.hpp" +// include_consts_test.cpp - testsuite for protocol includes +// +// Copyright © 2014 Ben Longbons +// +// This file is part of The Mana World (Athena server) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero General Public License +// along with this program. If not, see . + +#include "../poison.hpp" + +using Test_PartyMember = PartyMember; diff --git a/src/proto2/include_enums_test.cpp b/src/proto2/include_enums_test.cpp index cad9b12..6fd81f8 100644 --- a/src/proto2/include_enums_test.cpp +++ b/src/proto2/include_enums_test.cpp @@ -23,3 +23,4 @@ using Test_SEX = SEX; using Test_Option = Option; using Test_EPOS = EPOS; +using Test_ItemLook = ItemLook; diff --git a/src/proto2/include_mmo_test.cpp b/src/proto2/include_mmo_test.cpp deleted file mode 100644 index feb2de2..0000000 --- a/src/proto2/include_mmo_test.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include "../mmo/mmo.hpp" -// include_mmo_test.cpp - testsuite for protocol includes -// -// Copyright © 2014 Ben Longbons -// -// This file is part of The Mana World (Athena server) -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -#include "../poison.hpp" - -using Test_CharKey = CharKey; -using Test_CharData = CharData; -using Test_PartyMost = PartyMost; -using Test_Storage = Storage; diff --git a/src/proto2/login-admin.hpp b/src/proto2/login-admin.hpp index e3962b9..30cdb8b 100644 --- a/src/proto2/login-admin.hpp +++ b/src/proto2/login-admin.hpp @@ -27,9 +27,6 @@ // This is an internal protocol, and can be changed without notice -// this is only needed for the payload packet right now, and that needs to die -# pragma pack(push, 1) - template<> struct Packet_Head<0x2726> { @@ -2218,6 +2215,4 @@ bool network_to_native(Packet_Fixed<0x7955> *native, NetPacket_Fixed<0x7955> net } -# pragma pack(pop) - #endif // TMWA_PROTO2_LOGIN_ADMIN_HPP diff --git a/src/proto2/login-char.hpp b/src/proto2/login-char.hpp index 53e99f9..a2e0b8e 100644 --- a/src/proto2/login-char.hpp +++ b/src/proto2/login-char.hpp @@ -27,9 +27,6 @@ // This is an internal protocol, and can be changed without notice -// this is only needed for the payload packet right now, and that needs to die -# pragma pack(push, 1) - template<> struct Packet_Fixed<0x2709> { @@ -1235,6 +1232,4 @@ bool network_to_native(Packet_Fixed<0x2741> *native, NetPacket_Fixed<0x2741> net } -# pragma pack(pop) - #endif // TMWA_PROTO2_LOGIN_CHAR_HPP diff --git a/src/proto2/login-user.hpp b/src/proto2/login-user.hpp index af4a070..5eda66c 100644 --- a/src/proto2/login-user.hpp +++ b/src/proto2/login-user.hpp @@ -27,9 +27,6 @@ // This is a public protocol, and changes require client cooperation -// this is only needed for the payload packet right now, and that needs to die -# pragma pack(push, 1) - template<> struct Packet_Head<0x0063> { @@ -325,6 +322,4 @@ bool network_to_native(Packet_Fixed<0x006a> *native, NetPacket_Fixed<0x006a> net } -# pragma pack(pop) - #endif // TMWA_PROTO2_LOGIN_USER_HPP diff --git a/src/proto2/map-user.hpp b/src/proto2/map-user.hpp index ef401f4..b4ea4d8 100644 --- a/src/proto2/map-user.hpp +++ b/src/proto2/map-user.hpp @@ -27,9 +27,6 @@ // This is a public protocol, and changes require client cooperation -// this is only needed for the payload packet right now, and that needs to die -# pragma pack(push, 1) - template<> struct Packet_Fixed<0x0072> { @@ -7931,6 +7928,4 @@ bool network_to_native(Packet_Fixed<0x0212> *native, NetPacket_Fixed<0x0212> net } -# pragma pack(pop) - #endif // TMWA_PROTO2_MAP_USER_HPP diff --git a/src/proto2/types.hpp b/src/proto2/types.hpp index 0113138..f46acf3 100644 --- a/src/proto2/types.hpp +++ b/src/proto2/types.hpp @@ -21,22 +21,26 @@ # include "fwd.hpp" +# include "../generic/array.hpp" +# include "../mmo/consts.hpp" + //TODO split the includes # include # include "../ints/little.hpp" # include "../strings/vstring.hpp" # include "../net/ip.hpp" # include "../net/timer.t.hpp" +# include "../mmo/consts.hpp" # include "../mmo/enums.hpp" # include "../mmo/human_time_diff.hpp" # include "../mmo/ids.hpp" -# include "../mmo/mmo.hpp" # include "../mmo/strs.hpp" # include "../mmo/utils.hpp" # include "../mmo/version.hpp" # include "../login/login.t.hpp" # include "../map/clif.t.hpp" # include "../map/skill.t.hpp" + template bool native_to_network(T *network, T native) { @@ -49,6 +53,52 @@ bool network_to_native(T *native, T network) *native = network; return true; } +template +struct NetArray +{ + T data[N]; +}; +template +bool native_to_network(NetArray *network, Array native) +{ + for (size_t i = 0; i < N; ++i) + { + if (!native_to_network(&(*network).data[i], native[i])) + return false; + } + return true; +} +template +bool network_to_native(Array *native, NetArray network) +{ + for (size_t i = 0; i < N; ++i) + { + if (!network_to_native(&(*native)[i], network.data[i])) + return false; + } + return true; +} +template +bool native_to_network(NetArray *network, earray(N)> native) +{ + for (size_t i = 0; i < N; ++i) + { + if (!native_to_network(&(*network).data[i], native[static_cast(i)])) + return false; + } + return true; +} +template +bool network_to_native(earray(N)> *native, NetArray network) +{ + for (size_t i = 0; i < N; ++i) + { + if (!network_to_native(&(*native)[static_cast(i)], network.data[i])) + return false; + } + return true; +} + template struct NetString { @@ -415,6 +465,24 @@ bool network_to_native(EPOS *native, Little16 network) return rv; } inline __attribute__((warn_unused_result)) +bool native_to_network(Little16 *network, ItemLook native) +{ + bool rv = true; + uint16_t tmp = static_cast(native); + rv &= native_to_network(network, tmp); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(ItemLook *native, Little16 network) +{ + bool rv = true; + uint16_t tmp; + rv &= network_to_native(&tmp, network); + *native = static_cast(tmp); + // TODO this is what really should be doing a checked cast + return rv; +} +inline __attribute__((warn_unused_result)) bool native_to_network(Little16 *network, Species native) { bool rv = true; @@ -925,4 +993,448 @@ bool network_to_native(SkillInfo *native, NetSkillInfo network) return rv; } +struct Item +{ + ItemNameId nameid = {}; + uint16_t amount = {}; + EPOS equip = {}; +}; +struct NetItem +{ + Little16 nameid; + Little16 amount; + Little16 equip; +}; +static_assert(alignof(NetItem) == 1, "alignof(NetItem) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetItem *network, Item native) +{ + bool rv = true; + rv &= native_to_network(&network->nameid, native.nameid); + rv &= native_to_network(&network->amount, native.amount); + rv &= native_to_network(&network->equip, native.equip); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(Item *native, NetItem network) +{ + bool rv = true; + rv &= network_to_native(&native->nameid, network.nameid); + rv &= network_to_native(&native->amount, network.amount); + rv &= network_to_native(&native->equip, network.equip); + return rv; +} + +struct Point +{ + MapName map_ = {}; + uint16_t x = {}; + uint16_t y = {}; + Point() = default; + Point(MapName _map_, uint16_t _x, uint16_t _y) : map_(_map_), x(_x), y(_y) {} +}; +struct NetPoint +{ + NetString map_; + Little16 x; + Little16 y; +}; +static_assert(alignof(NetPoint) == 1, "alignof(NetPoint) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetPoint *network, Point native) +{ + bool rv = true; + rv &= native_to_network(&network->map_, native.map_); + rv &= native_to_network(&network->x, native.x); + rv &= native_to_network(&network->y, native.y); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(Point *native, NetPoint network) +{ + bool rv = true; + rv &= network_to_native(&native->map_, network.map_); + rv &= network_to_native(&native->x, network.x); + rv &= network_to_native(&native->y, network.y); + return rv; +} + +struct SkillValue +{ + uint16_t lv = {}; + SkillFlags flags = {}; +}; +struct NetSkillValue +{ + Little16 lv; + Little16 flags; +}; +static_assert(alignof(NetSkillValue) == 1, "alignof(NetSkillValue) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetSkillValue *network, SkillValue native) +{ + bool rv = true; + rv &= native_to_network(&network->lv, native.lv); + rv &= native_to_network(&network->flags, native.flags); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(SkillValue *native, NetSkillValue network) +{ + bool rv = true; + rv &= network_to_native(&native->lv, network.lv); + rv &= network_to_native(&native->flags, network.flags); + return rv; +} + +struct GlobalReg +{ + VarName str = {}; + uint32_t value = {}; +}; +struct NetGlobalReg +{ + NetString str; + Little32 value; +}; +static_assert(alignof(NetGlobalReg) == 1, "alignof(NetGlobalReg) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetGlobalReg *network, GlobalReg native) +{ + bool rv = true; + rv &= native_to_network(&network->str, native.str); + rv &= native_to_network(&network->value, native.value); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(GlobalReg *native, NetGlobalReg network) +{ + bool rv = true; + rv &= network_to_native(&native->str, network.str); + rv &= network_to_native(&native->value, network.value); + return rv; +} + +struct CharKey +{ + CharName name = {}; + AccountId account_id = {}; + CharId char_id = {}; + uint8_t char_num = {}; +}; +struct NetCharKey +{ + NetString name; + Little32 account_id; + Little32 char_id; + Byte char_num; +}; +static_assert(alignof(NetCharKey) == 1, "alignof(NetCharKey) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetCharKey *network, CharKey native) +{ + bool rv = true; + rv &= native_to_network(&network->name, native.name); + rv &= native_to_network(&network->account_id, native.account_id); + rv &= native_to_network(&network->char_id, native.char_id); + rv &= native_to_network(&network->char_num, native.char_num); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(CharKey *native, NetCharKey network) +{ + bool rv = true; + rv &= network_to_native(&native->name, network.name); + rv &= network_to_native(&native->account_id, network.account_id); + rv &= network_to_native(&native->char_id, network.char_id); + rv &= network_to_native(&native->char_num, network.char_num); + return rv; +} + +struct CharData +{ + CharId partner_id = {}; + uint32_t base_exp = {}; + uint32_t job_exp = {}; + uint32_t zeny = {}; + Species species = {}; + uint16_t status_point = {}; + uint16_t skill_point = {}; + uint32_t hp = {}; + uint32_t max_hp = {}; + uint32_t sp = {}; + uint32_t max_sp = {}; + Option option = {}; + uint16_t karma = {}; + uint16_t manner = {}; + uint16_t hair = {}; + uint16_t hair_color = {}; + uint16_t clothes_color = {}; + PartyId party_id = {}; + ItemLook weapon = {}; + ItemNameId shield = {}; + ItemNameId head_top = {}; + ItemNameId head_mid = {}; + ItemNameId head_bottom = {}; + uint8_t base_level = {}; + uint8_t job_level = {}; + earray attrs = {}; + SEX sex = {}; + IP4Address mapip = {}; + uint16_t mapport = {}; + Point last_point = {}; + Point save_point = {}; + Array inventory = {}; + earray skill = {}; + uint32_t global_reg_num = {}; + Array global_reg = {}; + uint32_t account_reg_num = {}; + Array account_reg = {}; + uint32_t account_reg2_num = {}; + Array account_reg2 = {}; +}; +struct NetCharData +{ + Little32 partner_id; + Little32 base_exp; + Little32 job_exp; + Little32 zeny; + Little16 species; + Little16 status_point; + Little16 skill_point; + Little32 hp; + Little32 max_hp; + Little32 sp; + Little32 max_sp; + Little16 option; + Little16 karma; + Little16 manner; + Little16 hair; + Little16 hair_color; + Little16 clothes_color; + Little32 party_id; + Little16 weapon; + Little16 shield; + Little16 head_top; + Little16 head_mid; + Little16 head_bottom; + Byte base_level; + Byte job_level; + NetArray(ATTR::COUNT)> attrs; + Byte sex; + IP4Address mapip; + Little16 mapport; + NetPoint last_point; + NetPoint save_point; + NetArray inventory; + NetArray(MAX_SKILL)> skill; + Little32 global_reg_num; + NetArray global_reg; + Little32 account_reg_num; + NetArray account_reg; + Little32 account_reg2_num; + NetArray account_reg2; +}; +static_assert(alignof(NetCharData) == 1, "alignof(NetCharData) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetCharData *network, CharData native) +{ + bool rv = true; + rv &= native_to_network(&network->partner_id, native.partner_id); + rv &= native_to_network(&network->base_exp, native.base_exp); + rv &= native_to_network(&network->job_exp, native.job_exp); + rv &= native_to_network(&network->zeny, native.zeny); + rv &= native_to_network(&network->species, native.species); + rv &= native_to_network(&network->status_point, native.status_point); + rv &= native_to_network(&network->skill_point, native.skill_point); + rv &= native_to_network(&network->hp, native.hp); + rv &= native_to_network(&network->max_hp, native.max_hp); + rv &= native_to_network(&network->sp, native.sp); + rv &= native_to_network(&network->max_sp, native.max_sp); + rv &= native_to_network(&network->option, native.option); + rv &= native_to_network(&network->karma, native.karma); + rv &= native_to_network(&network->manner, native.manner); + rv &= native_to_network(&network->hair, native.hair); + rv &= native_to_network(&network->hair_color, native.hair_color); + rv &= native_to_network(&network->clothes_color, native.clothes_color); + rv &= native_to_network(&network->party_id, native.party_id); + rv &= native_to_network(&network->weapon, native.weapon); + rv &= native_to_network(&network->shield, native.shield); + rv &= native_to_network(&network->head_top, native.head_top); + rv &= native_to_network(&network->head_mid, native.head_mid); + rv &= native_to_network(&network->head_bottom, native.head_bottom); + rv &= native_to_network(&network->base_level, native.base_level); + rv &= native_to_network(&network->job_level, native.job_level); + rv &= native_to_network(&network->attrs, native.attrs); + rv &= native_to_network(&network->sex, native.sex); + rv &= native_to_network(&network->mapip, native.mapip); + rv &= native_to_network(&network->mapport, native.mapport); + rv &= native_to_network(&network->last_point, native.last_point); + rv &= native_to_network(&network->save_point, native.save_point); + rv &= native_to_network(&network->inventory, native.inventory); + rv &= native_to_network(&network->skill, native.skill); + rv &= native_to_network(&network->global_reg_num, native.global_reg_num); + rv &= native_to_network(&network->global_reg, native.global_reg); + rv &= native_to_network(&network->account_reg_num, native.account_reg_num); + rv &= native_to_network(&network->account_reg, native.account_reg); + rv &= native_to_network(&network->account_reg2_num, native.account_reg2_num); + rv &= native_to_network(&network->account_reg2, native.account_reg2); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(CharData *native, NetCharData network) +{ + bool rv = true; + rv &= network_to_native(&native->partner_id, network.partner_id); + rv &= network_to_native(&native->base_exp, network.base_exp); + rv &= network_to_native(&native->job_exp, network.job_exp); + rv &= network_to_native(&native->zeny, network.zeny); + rv &= network_to_native(&native->species, network.species); + rv &= network_to_native(&native->status_point, network.status_point); + rv &= network_to_native(&native->skill_point, network.skill_point); + rv &= network_to_native(&native->hp, network.hp); + rv &= network_to_native(&native->max_hp, network.max_hp); + rv &= network_to_native(&native->sp, network.sp); + rv &= network_to_native(&native->max_sp, network.max_sp); + rv &= network_to_native(&native->option, network.option); + rv &= network_to_native(&native->karma, network.karma); + rv &= network_to_native(&native->manner, network.manner); + rv &= network_to_native(&native->hair, network.hair); + rv &= network_to_native(&native->hair_color, network.hair_color); + rv &= network_to_native(&native->clothes_color, network.clothes_color); + rv &= network_to_native(&native->party_id, network.party_id); + rv &= network_to_native(&native->weapon, network.weapon); + rv &= network_to_native(&native->shield, network.shield); + rv &= network_to_native(&native->head_top, network.head_top); + rv &= network_to_native(&native->head_mid, network.head_mid); + rv &= network_to_native(&native->head_bottom, network.head_bottom); + rv &= network_to_native(&native->base_level, network.base_level); + rv &= network_to_native(&native->job_level, network.job_level); + rv &= network_to_native(&native->attrs, network.attrs); + rv &= network_to_native(&native->sex, network.sex); + rv &= network_to_native(&native->mapip, network.mapip); + rv &= network_to_native(&native->mapport, network.mapport); + rv &= network_to_native(&native->last_point, network.last_point); + rv &= network_to_native(&native->save_point, network.save_point); + rv &= network_to_native(&native->inventory, network.inventory); + rv &= network_to_native(&native->skill, network.skill); + rv &= network_to_native(&native->global_reg_num, network.global_reg_num); + rv &= network_to_native(&native->global_reg, network.global_reg); + rv &= network_to_native(&native->account_reg_num, network.account_reg_num); + rv &= network_to_native(&native->account_reg, network.account_reg); + rv &= network_to_native(&native->account_reg2_num, network.account_reg2_num); + rv &= network_to_native(&native->account_reg2, network.account_reg2); + return rv; +} + +struct NetPartyMember +{ + Little32 account_id; + NetString name; + NetString map; + Little32 leader; + Little32 online; + Little32 lv; +}; +inline __attribute__((warn_unused_result)) +bool native_to_network(NetPartyMember *network, PartyMember native) +{ + bool rv = true; + AccountId account_id = native.account_id; rv &= native_to_network(&network->account_id, account_id); + CharName name = native.name; rv &= native_to_network(&network->name, name); + MapName map = native.map; rv &= native_to_network(&network->map, map); + uint32_t leader = native.leader; rv &= native_to_network(&network->leader, leader); + uint32_t online = native.online; rv &= native_to_network(&network->online, online); + uint32_t lv = native.lv; rv &= native_to_network(&network->lv, lv); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(PartyMember *native, NetPartyMember network) +{ + bool rv = true; + AccountId account_id; rv &= network_to_native(&account_id, network.account_id); native->account_id = account_id; + CharName name; rv &= network_to_native(&name, network.name); native->name = name; + MapName map; rv &= network_to_native(&map, network.map); native->map = map; + uint32_t leader; rv &= network_to_native(&leader, network.leader); native->leader = leader; + uint32_t online; rv &= network_to_native(&online, network.online); native->online = online; + uint32_t lv; rv &= network_to_native(&lv, network.lv); native->lv = lv; + return rv; +} + +struct PartyMost +{ + PartyName name = {}; + uint32_t exp = {}; + uint32_t item = {}; + Array member = {}; +}; +struct NetPartyMost +{ + NetString name; + Little32 exp; + Little32 item; + NetArray member; +}; +static_assert(alignof(NetPartyMost) == 1, "alignof(NetPartyMost) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetPartyMost *network, PartyMost native) +{ + bool rv = true; + rv &= native_to_network(&network->name, native.name); + rv &= native_to_network(&network->exp, native.exp); + rv &= native_to_network(&network->item, native.item); + rv &= native_to_network(&network->member, native.member); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(PartyMost *native, NetPartyMost network) +{ + bool rv = true; + rv &= network_to_native(&native->name, network.name); + rv &= network_to_native(&native->exp, network.exp); + rv &= network_to_native(&native->item, network.item); + rv &= network_to_native(&native->member, network.member); + return rv; +} + +struct Storage +{ + bool dirty = {}; + AccountId account_id = {}; + uint16_t storage_status = {}; + uint16_t storage_amount = {}; + Array storage_ = {}; +}; +struct NetStorage +{ + bool dirty; + Little32 account_id; + Little16 storage_status; + Little16 storage_amount; + NetArray storage_; +}; +static_assert(alignof(NetStorage) == 1, "alignof(NetStorage) == 1"); +inline __attribute__((warn_unused_result)) +bool native_to_network(NetStorage *network, Storage native) +{ + bool rv = true; + rv &= native_to_network(&network->dirty, native.dirty); + rv &= native_to_network(&network->account_id, native.account_id); + rv &= native_to_network(&network->storage_status, native.storage_status); + rv &= native_to_network(&network->storage_amount, native.storage_amount); + rv &= native_to_network(&network->storage_, native.storage_); + return rv; +} +inline __attribute__((warn_unused_result)) +bool network_to_native(Storage *native, NetStorage network) +{ + bool rv = true; + rv &= network_to_native(&native->dirty, network.dirty); + rv &= network_to_native(&native->account_id, network.account_id); + rv &= network_to_native(&native->storage_status, network.storage_status); + rv &= network_to_native(&native->storage_amount, network.storage_amount); + rv &= network_to_native(&native->storage_, network.storage_); + return rv; +} + #endif // TMWA_PROTO2_TYPES_HPP -- cgit v1.2.3-60-g2f50