#include <cstring>
#include <string>
+#include <msp/core/hash.h>
#include <msp/core/maputils.h>
+#include <msp/strings/format.h>
#include <msp/strings/lexicalcast.h>
#include "protocol.h"
+#include "protocol_impl.h"
using namespace std;
-
namespace Msp {
namespace Net {
{
PacketDefBase *&ptr = packet_class_defs[pdef->get_class_id()];
if(ptr)
+ {
+ packet_id_defs.erase(ptr->get_id());
delete ptr;
+ }
ptr = pdef;
- packet_id_defs[pdef->get_id()] = pdef;
+ if(unsigned id = pdef->get_id())
+ packet_id_defs[id] = pdef;
}
const Protocol::PacketDefBase &Protocol::get_packet_by_class_id(unsigned id) const
return header.length;
}
-unsigned Protocol::get_hash() const
+UInt64 Protocol::get_hash() const
{
- // TODO
- return 123;
+ string description;
+ for(PacketMap::const_iterator i=packet_id_defs.begin(); i!=packet_id_defs.end(); ++i)
+ description += format("%d:%s\n", i->first, i->second->describe());
+ return hash64(description);
}