From 558c4343d337d178932ab36bafcd8b6357cac216 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 26 Dec 2022 18:12:54 +0800 Subject: [PATCH] 1 --- f8/protoutils.cc | 19 +++++++++++++++++++ f8/protoutils.h | 26 +++++++++++++++++--------- f8/types.cc | 19 ------------------- f8/types.h | 17 +---------------- 4 files changed, 37 insertions(+), 44 deletions(-) diff --git a/f8/protoutils.cc b/f8/protoutils.cc index ae4b15f..c5fb086 100644 --- a/f8/protoutils.cc +++ b/f8/protoutils.cc @@ -254,4 +254,23 @@ namespace f8 return sizeof(WSProxyPackHead_S) + packlen; } + 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; + } + + void MsgHdr::Destroy(MsgHdr* hdr) + { + if (hdr->buf) { + free((void*)hdr->buf); + } + free((void*)hdr); + } + } diff --git a/f8/protoutils.h b/f8/protoutils.h index 1123e35..34490d9 100644 --- a/f8/protoutils.h +++ b/f8/protoutils.h @@ -1,23 +1,31 @@ #pragma once -class Player; -namespace google -{ - namespace protobuf - { - class Message; - } -} - namespace a8 { class TcpClient; class TcpListener; } +class Player; namespace f8 { + struct MsgHdr + { + unsigned int seqid; + unsigned short msgid; + int socket_handle; + unsigned long ip_saddr; + const char* buf; + int buflen; + int offset; + Player *hum = nullptr; + const void* user_data = nullptr; + + MsgHdr* Clone(); + static void Destroy(MsgHdr* hdr); + }; + //普通消息头部 struct PackHead { diff --git a/f8/types.cc b/f8/types.cc index 5475f13..e32f537 100644 --- a/f8/types.cc +++ b/f8/types.cc @@ -27,23 +27,4 @@ namespace f8 return a8::HttpResponse(response); } - 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; - } - - void MsgHdr::Destroy(MsgHdr* hdr) - { - if (hdr->buf) { - free((void*)hdr->buf); - } - free((void*)hdr); - } - } diff --git a/f8/types.h b/f8/types.h index 956ac39..f601286 100644 --- a/f8/types.h +++ b/f8/types.h @@ -5,7 +5,6 @@ namespace a8 class MutableXObject; } -class Player; namespace f8 { struct JsonHttpRequest @@ -36,20 +35,6 @@ namespace f8 IM_SysEnd = 99, }; - struct MsgHdr - { - unsigned int seqid; - unsigned short msgid; - int socket_handle; - unsigned long ip_saddr; - const char* buf; - int buflen; - int offset; - Player *hum = nullptr; - const void* user_data = nullptr; - - MsgHdr* Clone(); - static void Destroy(MsgHdr* hdr); - }; + struct MsgHdr; }