X-Git-Url: http://git.tdb.fi/?p=libs%2Fnet.git;a=blobdiff_plain;f=source%2Fnet%2Fprotocol.h;fp=source%2Fnet%2Fprotocol.h;h=e766733cb6a6373839ecefd32c8e95dd9eb24d52;hp=248b97ea5a1d14cb4fde4589ccaf355685370019;hb=3f46fef7032d97b0dd82971ffece1062fd6b05b8;hpb=f17a55dc7fc44d1516db445550f55ed31e7534fa diff --git a/source/net/protocol.h b/source/net/protocol.h index 248b97e..e766733 100644 --- a/source/net/protocol.h +++ b/source/net/protocol.h @@ -191,12 +191,12 @@ private: }; PacketTypeDef header_def; - unsigned next_packet_id; + unsigned next_packet_id = 1; std::map> packet_class_defs; std::map packet_id_defs; protected: - Protocol(unsigned = 1); + Protocol(); private: static unsigned get_next_packet_class_id(); @@ -207,12 +207,6 @@ private: void add_packet(std::unique_ptr); protected: - template - PacketDefBuilder> add(unsigned); - - template - auto add(unsigned id, T P::*field, Rest P::*...rest) { return add

(id).fields(field, rest...); } - template PacketDefBuilder> add(); @@ -253,20 +247,14 @@ unsigned Protocol::get_packet_class_id() } template -Protocol::PacketDefBuilder> Protocol::add(unsigned id) +Protocol::PacketDefBuilder> Protocol::add() { - std::unique_ptr> pdef = std::make_unique>(id); + std::unique_ptr> pdef = std::make_unique>(next_packet_id++); PacketDefBuilder> next(*this, *pdef, Serializer

()); add_packet(move(pdef)); return next; } -template -Protocol::PacketDefBuilder> Protocol::add() -{ - return add

(next_packet_id++); -} - template const Protocol::PacketTypeDef

&Protocol::get_packet_by_class() const {