This commit is contained in:
aozhiwei 2022-12-16 17:58:33 +08:00
parent d1f41b2a92
commit 67387583e5
7 changed files with 50 additions and 40 deletions

View File

@ -4,9 +4,10 @@
#include <google/protobuf/message.h> #include <google/protobuf/message.h>
#include <google/protobuf/descriptor.h> #include <google/protobuf/descriptor.h>
#include "f8/utils.h" #include <f8/f8.h>
#include "f8/protoutils.h" #include <f8/utils.h>
#include "f8/netmsghandler.h" #include <f8/protoutils.h>
#include <f8/netmsghandler.h>
namespace f8 namespace f8
{ {

View File

@ -1,5 +1,9 @@
#pragma once #pragma once
#include <a8/singleton.h>
#include <f8/protoutils.h>
#include <google/protobuf/generated_message_util.h> #include <google/protobuf/generated_message_util.h>
#include <google/protobuf/message.h> #include <google/protobuf/message.h>
#include <google/protobuf/repeated_field.h> #include <google/protobuf/repeated_field.h>

View File

@ -12,25 +12,6 @@
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;
}
void MsgHdr::Destroy(MsgHdr* hdr)
{
if (hdr->buf) {
free((void*)hdr->buf);
}
free((void*)hdr);
}
int Net_GetMessageId(const ::google::protobuf::Message& msg) int Net_GetMessageId(const ::google::protobuf::Message& msg)
{ {
std::string msgname; std::string msgname;

View File

@ -81,22 +81,6 @@ namespace f8
unsigned short ext_len; unsigned short ext_len;
}; };
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);
};
#ifdef MATCHVS #ifdef MATCHVS
const unsigned int MAGIC_CODE = 0xAABBCCAA; const unsigned int MAGIC_CODE = 0xAABBCCAA;
#else #else

View File

@ -1,5 +1,7 @@
#pragma once #pragma once
#include <a8/singleton.h>
namespace f8 namespace f8
{ {
struct TGLogImpl; struct TGLogImpl;

View File

@ -1,6 +1,8 @@
#include "precompile.h" #include <string.h>
#include "f8/types.h" #include <a8/a8.h>
#include <f8/f8.h>
#include <a8/mutable_xobject.h> #include <a8/mutable_xobject.h>
namespace f8 namespace f8
@ -25,4 +27,23 @@ namespace f8
return a8::HttpResponse(response); 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);
}
} }

View File

@ -5,6 +5,7 @@ namespace a8
class MutableXObject; class MutableXObject;
} }
class Player;
namespace f8 namespace f8
{ {
struct JsonHttpRequest struct JsonHttpRequest
@ -34,4 +35,20 @@ namespace f8
IM_SysEnd = 99, 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);
};
} }