diff options
Diffstat (limited to 'src/proto2')
-rw-r--r-- | src/proto2/include_clif_t_test.cpp | 2 | ||||
-rw-r--r-- | src/proto2/map-user.hpp | 46 | ||||
-rw-r--r-- | src/proto2/types.hpp | 40 |
3 files changed, 35 insertions, 53 deletions
diff --git a/src/proto2/include_clif_t_test.cpp b/src/proto2/include_clif_t_test.cpp index 93c7f90..75d36a0 100644 --- a/src/proto2/include_clif_t_test.cpp +++ b/src/proto2/include_clif_t_test.cpp @@ -34,3 +34,5 @@ using Test_PickupFail = PickupFail; using Test_DamageType = DamageType; using Test_SP = SP; using Test_LOOK = LOOK; +using Test_IOff2 = IOff2; +using Test_SOff1 = SOff1; diff --git a/src/proto2/map-user.hpp b/src/proto2/map-user.hpp index b4ea4d8..598ef3b 100644 --- a/src/proto2/map-user.hpp +++ b/src/proto2/map-user.hpp @@ -510,7 +510,7 @@ struct Packet_Fixed<0x00a0> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint16_t amount = {}; ItemNameId name_id = {}; uint8_t identify = {}; @@ -542,7 +542,7 @@ struct Packet_Fixed<0x00a2> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint16_t amount = {}; }; @@ -561,7 +561,7 @@ struct Packet_Repeat<0x00a4> { static const uint16_t PACKET_ID = 0x00a4; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; ItemNameId name_id = {}; ItemType item_type = {}; uint8_t identify = {}; @@ -590,7 +590,7 @@ struct Packet_Repeat<0x00a6> { static const uint16_t PACKET_ID = 0x00a6; - uint16_t soff1 = {}; + SOff1 soff1 = {}; ItemNameId name_id = {}; ItemType item_type = {}; uint8_t identify = {}; @@ -611,7 +611,7 @@ struct Packet_Fixed<0x00a7> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint32_t unused_id = {}; }; @@ -622,7 +622,7 @@ struct Packet_Fixed<0x00a8> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint16_t amount = {}; uint8_t ok = {}; }; @@ -634,7 +634,7 @@ struct Packet_Fixed<0x00a9> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; EPOS epos_ignored = {}; }; @@ -645,7 +645,7 @@ struct Packet_Fixed<0x00aa> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; EPOS epos = {}; uint8_t ok = {}; }; @@ -657,7 +657,7 @@ struct Packet_Fixed<0x00ab> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; }; template<> @@ -667,7 +667,7 @@ struct Packet_Fixed<0x00ac> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; EPOS epos = {}; uint8_t ok = {}; }; @@ -679,7 +679,7 @@ struct Packet_Fixed<0x00af> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint16_t amount = {}; }; @@ -971,7 +971,7 @@ struct Packet_Repeat<0x00c7> { static const uint16_t PACKET_ID = 0x00c7; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint32_t base_price = {}; uint32_t actual_price = {}; }; @@ -1010,7 +1010,7 @@ struct Packet_Repeat<0x00c9> { static const uint16_t PACKET_ID = 0x00c9; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint16_t count = {}; }; @@ -1091,7 +1091,7 @@ struct Packet_Fixed<0x00e8> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t zeny_or_ioff2 = {}; + IOff2 zeny_or_ioff2 = {}; uint32_t amount = {}; }; @@ -1187,7 +1187,7 @@ struct Packet_Fixed<0x00f3> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint32_t amount = {}; }; @@ -1198,7 +1198,7 @@ struct Packet_Fixed<0x00f4> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t soff1 = {}; + SOff1 soff1 = {}; uint32_t amount = {}; ItemNameId name_id = {}; uint8_t identify = {}; @@ -1217,7 +1217,7 @@ struct Packet_Fixed<0x00f5> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t soff1 = {}; + SOff1 soff1 = {}; uint32_t amount = {}; }; @@ -1228,7 +1228,7 @@ struct Packet_Fixed<0x00f6> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t soff1 = {}; + SOff1 soff1 = {}; uint32_t amount = {}; }; @@ -1582,7 +1582,7 @@ struct Packet_Fixed<0x013c> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; }; template<> @@ -1723,7 +1723,7 @@ struct Packet_Fixed<0x01b1> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; uint16_t amount = {}; uint8_t fail = {}; }; @@ -1735,7 +1735,7 @@ struct Packet_Fixed<0x01c8> // TODO remove this uint16_t magic_packet_id = PACKET_ID; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; ItemNameId name_id = {}; BlockId block_id = {}; uint16_t amount = {}; @@ -1923,7 +1923,7 @@ struct Packet_Repeat<0x01ee> { static const uint16_t PACKET_ID = 0x01ee; - uint16_t ioff2 = {}; + IOff2 ioff2 = {}; ItemNameId name_id = {}; ItemType item_type = {}; uint8_t identify = {}; @@ -1950,7 +1950,7 @@ struct Packet_Repeat<0x01f0> { static const uint16_t PACKET_ID = 0x01f0; - uint16_t soff1 = {}; + SOff1 soff1 = {}; ItemNameId name_id = {}; ItemType item_type = {}; uint8_t identify = {}; diff --git a/src/proto2/types.hpp b/src/proto2/types.hpp index f46acf3..e6730c1 100644 --- a/src/proto2/types.hpp +++ b/src/proto2/types.hpp @@ -58,42 +58,22 @@ struct NetArray { T data[N]; }; -template<class T, class U, size_t N> -bool native_to_network(NetArray<T, N> *network, Array<U, N> native) +template<class T, class U, class I> +bool native_to_network(NetArray<T, I::alloc_size> *network, GenericArray<U, I> native) { - for (size_t i = 0; i < N; ++i) + for (size_t i = 0; i < I::alloc_size; ++i) { - if (!native_to_network(&(*network).data[i], native[i])) + if (!native_to_network(&(*network).data[i], native[I::offset_to_index(i)])) return false; } return true; } -template<class T, class U, size_t N> -bool network_to_native(Array<U, N> *native, NetArray<T, N> network) +template<class T, class U, class I> +bool network_to_native(GenericArray<U, I> *native, NetArray<T, I::alloc_size> network) { - for (size_t i = 0; i < N; ++i) + for (size_t i = 0; i < I::alloc_size; ++i) { - if (!network_to_native(&(*native)[i], network.data[i])) - return false; - } - return true; -} -template<class T, class U, size_t N, class I> -bool native_to_network(NetArray<T, N> *network, earray<U, I, static_cast<I>(N)> native) -{ - for (size_t i = 0; i < N; ++i) - { - if (!native_to_network(&(*network).data[i], native[static_cast<I>(i)])) - return false; - } - return true; -} -template<class T, class U, size_t N, class I> -bool network_to_native(earray<U, I, static_cast<I>(N)> *native, NetArray<T, N> network) -{ - for (size_t i = 0; i < N; ++i) - { - if (!network_to_native(&(*native)[static_cast<I>(i)], network.data[i])) + if (!network_to_native(&(*native)[I::offset_to_index(i)], network.data[i])) return false; } return true; @@ -1184,7 +1164,7 @@ struct CharData uint16_t mapport = {}; Point last_point = {}; Point save_point = {}; - Array<Item, MAX_INVENTORY> inventory = {}; + GenericArray<Item, InventoryIndexing<IOff0, MAX_INVENTORY>> inventory = {}; earray<SkillValue, SkillID, MAX_SKILL> skill = {}; uint32_t global_reg_num = {}; Array<GlobalReg, GLOBAL_REG_NUM> global_reg = {}; @@ -1403,7 +1383,7 @@ struct Storage AccountId account_id = {}; uint16_t storage_status = {}; uint16_t storage_amount = {}; - Array<Item, MAX_STORAGE> storage_ = {}; + GenericArray<Item, InventoryIndexing<SOff0, MAX_STORAGE>> storage_ = {}; }; struct NetStorage { |