diff --git a/cpp/protoutils.cc b/cpp/protoutils.cc index aae2087..f1d4f30 100644 --- a/cpp/protoutils.cc +++ b/cpp/protoutils.cc @@ -10,6 +10,18 @@ namespace f8 { + + MsgHdr* MsgHdr::Clone() + { + MsgHdr* hdr = (MsgHdr*)malloc(sizeof(MsgHdr)); + *hdr = *this; + if (hdr->buflen > 0) { + hdr->buf = (char*)malloc(hdr->buflen); + memmove((void*)hdr->buf, (void*)buf, buflen); + } + return hdr; + } + int Net_GetMessageId(::google::protobuf::Message& msg) { std::string msgname; diff --git a/cpp/protoutils.h b/cpp/protoutils.h index 191a6d3..3b02e0a 100644 --- a/cpp/protoutils.h +++ b/cpp/protoutils.h @@ -83,6 +83,8 @@ namespace f8 int offset; Player *hum = nullptr; const void* user_data = nullptr; + + MsgHdr* Clone(); }; const unsigned short MAGIC_CODE = (((unsigned short)'S') << 8) | ((unsigned short)'K');