This commit is contained in:
aozhiwei 2019-05-15 17:38:11 +08:00
parent dca17a2d72
commit fd72ea5605
2 changed files with 14 additions and 0 deletions

View File

@ -10,6 +10,18 @@
namespace f8 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) int Net_GetMessageId(::google::protobuf::Message& msg)
{ {
std::string msgname; std::string msgname;

View File

@ -83,6 +83,8 @@ namespace f8
int offset; int offset;
Player *hum = nullptr; Player *hum = nullptr;
const void* user_data = nullptr; const void* user_data = nullptr;
MsgHdr* Clone();
}; };
const unsigned short MAGIC_CODE = (((unsigned short)'S') << 8) | ((unsigned short)'K'); const unsigned short MAGIC_CODE = (((unsigned short)'S') << 8) | ((unsigned short)'K');