]> git.tdb.fi Git - libs/net.git/blobdiff - source/net/protocol.cpp
Add a base id parameter to Protocol's serialization functions
[libs/net.git] / source / net / protocol.cpp
index 63cc6f16c1dac82b14baebad1b4556f245c1b147..c6112923c9692db7f4b646f11d68e0a8e6e753a0 100644 (file)
@@ -44,13 +44,13 @@ const Protocol::PacketDefBase &Protocol::get_packet_by_id(unsigned id) const
        return *get_item(packet_id_defs, id);
 }
 
-size_t Protocol::dispatch(ReceiverBase &rcv, const char *buf, size_t size) const
+size_t Protocol::dispatch(ReceiverBase &rcv, const char *buf, size_t size, unsigned base_id) const
 {
        PacketHeader header;
        const char *ptr = header_def.deserialize(header, buf, buf+size);
        if(header.length>size)
                throw bad_packet("truncated");
-       const PacketDefBase &pdef = get_packet_by_id(header.type);
+       const PacketDefBase &pdef = get_packet_by_id(header.type-base_id);
        ptr = pdef.dispatch(rcv, ptr, ptr+header.length);
        return ptr-buf;
 }