]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/protocol.cpp
Use a static local variable for assigning packet IDs
[libs/net.git] / source / net / protocol.cpp
index 17e4310f5196c2f5c599cc103c8d8d5c6cf36430..db663821c370cef914676eb1da698cdb473f5c50 100644 (file)
@@ -5,7 +5,6 @@
 #include <msp/strings/format.h>
 #include <msp/strings/lexicalcast.h>
 #include "protocol.h"
-#include "protocol_impl.h"
 
 using namespace std;
 
@@ -26,6 +25,12 @@ Protocol::~Protocol()
                delete i->second;
 }
 
+unsigned Protocol::get_next_packet_class_id()
+{
+       static unsigned next_id = 1;
+       return next_id++;
+}
+
 void Protocol::add_packet(PacketDefBase *pdef)
 {
        PacketDefBase *&ptr = packet_class_defs[pdef->get_class_id()];
@@ -154,8 +159,6 @@ const char *Protocol::StringSerializer::deserialize(string &str, const char *buf
 }
 
 
-unsigned Protocol::PacketDefBase::next_class_id = 1;
-
 Protocol::PacketDefBase::PacketDefBase(unsigned i):
        id(i)
 { }