From 4e702143efa3f9b64701beec09a7dedf88b1b6a5 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 17 Sep 2019 00:12:45 +0800 Subject: [PATCH] 1 --- server/gameserver/constant.h | 96 ++++++++++++++++++++++++++ server/gameserver/dbengine.cc | 4 +- server/gameserver/global.cc | 18 +++-- server/gameserver/handlermgr.cc | 1 + server/gameserver/playermgr.cc | 9 ++- server/gameserver/playermgr.h | 3 + server/tools/protobuild/cs_msgid.proto | 9 ++- server/tools/protobuild/cs_proto.proto | 10 +++ third_party/framework | 2 +- 9 files changed, 140 insertions(+), 12 deletions(-) diff --git a/server/gameserver/constant.h b/server/gameserver/constant.h index 901105d..2eabfe8 100755 --- a/server/gameserver/constant.h +++ b/server/gameserver/constant.h @@ -19,5 +19,101 @@ enum NetHandler_e HID_Plyaer }; +enum ResponseCodes +{ + RESPONSE_SUCCESS = 0x00, + RESPONSE_FAILURE = 0x01, + RESPONSE_CANCELLED = 0x02, + RESPONSE_DISCONNECTED = 0x03, + RESPONSE_FAILED_TO_CONNECT = 0x04, + RESPONSE_CONNECTED = 0x05, + RESPONSE_VERSION_MISMATCH = 0x06, + + CSTATUS_CONNECTING = 0x07, + CSTATUS_NEGOTIATING_SECURITY = 0x08, + CSTATUS_NEGOTIATION_COMPLETE = 0x09, + CSTATUS_NEGOTIATION_FAILED = 0x0A, + CSTATUS_AUTHENTICATING = 0x0B, + + AUTH_OK = 0x0C, + AUTH_FAILED = 0x0D, + AUTH_REJECT = 0x0E, + AUTH_BAD_SERVER_PROOF = 0x0F, + AUTH_UNAVAILABLE = 0x10, + AUTH_SYSTEM_ERROR = 0x11, + AUTH_BILLING_ERROR = 0x12, + AUTH_BILLING_EXPIRED = 0x13, + AUTH_VERSION_MISMATCH = 0x14, + AUTH_UNKNOWN_ACCOUNT = 0x15, + AUTH_INCORRECT_PASSWORD = 0x16, + AUTH_SESSION_EXPIRED = 0x17, + AUTH_SERVER_SHUTTING_DOWN = 0x18, + AUTH_ALREADY_LOGGING_IN = 0x19, + AUTH_LOGIN_SERVER_NOT_FOUND = 0x1A, + AUTH_WAIT_QUEUE = 0x1B, + AUTH_BANNED = 0x1C, + AUTH_ALREADY_ONLINE = 0x1D, + AUTH_NO_TIME = 0x1E, + AUTH_DB_BUSY = 0x1F, + AUTH_SUSPENDED = 0x20, + AUTH_PARENTAL_CONTROL = 0x21, + + REALM_LIST_IN_PROGRESS = 0x22, + REALM_LIST_SUCCESS = 0x23, + REALM_LIST_FAILED = 0x24, + REALM_LIST_INVALID = 0x25, + REALM_LIST_REALM_NOT_FOUND = 0x26, + + ACCOUNT_CREATE_IN_PROGRESS = 0x27, + ACCOUNT_CREATE_SUCCESS = 0x28, + ACCOUNT_CREATE_FAILED = 0x29, + + CHAR_LIST_RETRIEVING = 0x2A, + CHAR_LIST_RETRIEVED = 0x2B, + CHAR_LIST_FAILED = 0x2C, + + CHAR_CREATE_IN_PROGRESS = 0x2D, + CHAR_CREATE_SUCCESS = 0x2E, + CHAR_CREATE_ERROR = 0x2F, + CHAR_CREATE_FAILED = 0x30, + CHAR_CREATE_NAME_IN_USE = 0x31, + CHAR_CREATE_DISABLED = 0x32, + CHAR_CREATE_PVP_TEAMS_VIOLATION = 0x33, + CHAR_CREATE_SERVER_LIMIT = 0x34, + CHAR_CREATE_ACCOUNT_LIMIT = 0x35, + CHAR_CREATE_SERVER_QUEUE = 0x36, + CHAR_CREATE_ONLY_EXISTING = 0x37, + + CHAR_DELETE_IN_PROGRESS = 0x38, + CHAR_DELETE_SUCCESS = 0x39, + CHAR_DELETE_FAILED = 0x3A, + CHAR_DELETE_FAILED_LOCKED_FOR_TRANSFER = 0x3B, + + CHAR_LOGIN_IN_PROGRESS = 0x3C, + CHAR_LOGIN_SUCCESS = 0x3D, + CHAR_LOGIN_NO_WORLD = 0x3E, + CHAR_LOGIN_DUPLICATE_CHARACTER = 0x3F, + CHAR_LOGIN_NO_INSTANCES = 0x40, + CHAR_LOGIN_FAILED = 0x41, + CHAR_LOGIN_DISABLED = 0x42, + CHAR_LOGIN_NO_CHARACTER = 0x43, + CHAR_LOGIN_LOCKED_FOR_TRANSFER = 0x44, + + CHAR_NAME_NO_NAME = 0x45, + CHAR_NAME_TOO_SHORT = 0x46, + CHAR_NAME_TOO_LONG = 0x47, + CHAR_NAME_INVALID_CHARACTER = 0x48, + CHAR_NAME_MIXED_LANGUAGES = 0x49, + CHAR_NAME_PROFANE = 0x4A, + CHAR_NAME_RESERVED = 0x4B, + CHAR_NAME_INVALID_APOSTROPHE = 0x4C, + CHAR_NAME_MULTIPLE_APOSTROPHES = 0x4D, + CHAR_NAME_THREE_CONSECUTIVE = 0x4E, + CHAR_NAME_INVALID_SPACE = 0x4F, + CHAR_NAME_CONSECUTIVE_SPACES = 0x50, + CHAR_NAME_FAILURE = 0x51, + CHAR_NAME_SUCCESS = 0x52, +}; + const char* const PROJ_NAME_FMT = "game%d_gameserver"; const char* const PROJ_ROOT_FMT = "/data/logs/%s"; diff --git a/server/gameserver/dbengine.cc b/server/gameserver/dbengine.cc index 4b65612..a652bb3 100644 --- a/server/gameserver/dbengine.cc +++ b/server/gameserver/dbengine.cc @@ -31,10 +31,10 @@ void DBEngine::Init() 3306, "root", "keji178", - "zero_relam" + "zero_realm" ) ); - f8::InitMysqlConnection(imp_->query_); + // f8::InitMysqlConnection(imp_->query_); auto checkdb_func = [] (const a8::XParams& param) { f8::CheckMysqlConnection( diff --git a/server/gameserver/global.cc b/server/gameserver/global.cc index eb0941d..3c62301 100755 --- a/server/gameserver/global.cc +++ b/server/gameserver/global.cc @@ -149,12 +149,18 @@ bool CustomPbSerialize(char* buf, int buflen, google::protobuf::Message* msg) break; case google::protobuf::FieldDescriptor::CPPTYPE_INT32: { - if (offset + sizeof(int) > (size_t)buflen) { + int val_size = fixed_len == 0 ? 4 : fixed_len; + if (offset + val_size > buflen) { abort(); } int val = reflection->GetInt32(*msg, field_desc); - memmove(buf + offset, &val, sizeof(val)); - offset += sizeof(val); + if (val_size == 1) { + unsigned char byte_val = val; + memmove(buf + offset, &byte_val, val_size); + } else { + memmove(buf + offset, &val, val_size); + } + offset += val_size; } break; case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: @@ -225,11 +231,11 @@ int CustomPbSerializeSize(google::protobuf::Message* msg) for (int i = 0; i < descriptor->field_count(); ++i) { const google::protobuf::FieldDescriptor* field_desc = descriptor->field(i); + int fixed_len = field_desc->options().GetExtension(cs::fixed_len); switch (field_desc->cpp_type()) { case google::protobuf::FieldDescriptor::CPPTYPE_STRING: { std::string val = reflection->GetString(*msg, field_desc); - int fixed_len = field_desc->options().GetExtension(cs::fixed_len); if (field_desc->type() == google::protobuf::FieldDescriptor::TYPE_BYTES && fixed_len > 0) { byte_size += fixed_len; } else { @@ -240,13 +246,13 @@ int CustomPbSerializeSize(google::protobuf::Message* msg) case google::protobuf::FieldDescriptor::CPPTYPE_INT32: case google::protobuf::FieldDescriptor::CPPTYPE_UINT32: { - byte_size += 4; + byte_size += fixed_len == 0 ? 4 : fixed_len; } break; case google::protobuf::FieldDescriptor::CPPTYPE_INT64: case google::protobuf::FieldDescriptor::CPPTYPE_UINT64: { - byte_size += 8; + byte_size += fixed_len == 0 ? 8 : fixed_len; } break; case google::protobuf::FieldDescriptor::CPPTYPE_FLOAT: diff --git a/server/gameserver/handlermgr.cc b/server/gameserver/handlermgr.cc index d8632f1..2067b99 100644 --- a/server/gameserver/handlermgr.cc +++ b/server/gameserver/handlermgr.cc @@ -40,6 +40,7 @@ void HandlerMgr::UnInit() void HandlerMgr::RegisterNetMsgHandlers() { RegisterNetMsgHandler(&gcmsghandler, &PlayerMgr::_CMAuthSession, CustomParser); + RegisterNetMsgHandler(&gcmsghandler, &PlayerMgr::_CMCharEnum, CustomParser); } void HandlerMgr::ProcGMMsg(unsigned long saddr, int sockhandle, diff --git a/server/gameserver/playermgr.cc b/server/gameserver/playermgr.cc index 6cf9bd8..cee76a3 100644 --- a/server/gameserver/playermgr.cc +++ b/server/gameserver/playermgr.cc @@ -19,16 +19,21 @@ void PlayerMgr::_CMAuthSession(f8::MsgHdr& hdr, const cs::CMAuthSession& msg) { std::string digest = msg.digest(); int ret = DBEngine::Instance()->ExecQuery("SELECT id, gmlevel, sessionkey, last_ip, locked, v, s, mutetime," - " locale, os FROM zeor_realm.account WHERE username='%s';", + " locale, os FROM zero_realm.account WHERE username='%s';", { msg.account() }); assert(ret > 0); cs::SMAuthResponse respmsg; - respmsg.set_errcode(0); + respmsg.set_errcode(AUTH_OK); GCListener::Instance()->SendMsg(hdr.socket_handle, respmsg); } +void PlayerMgr::_CMCharEnum(f8::MsgHdr& hdr, const cs::CMCharEnum& msg) +{ + int i = 0; +} + int PlayerMgr::OnlineNum() { return 0; diff --git a/server/gameserver/playermgr.h b/server/gameserver/playermgr.h index 544b4f1..0863e7e 100644 --- a/server/gameserver/playermgr.h +++ b/server/gameserver/playermgr.h @@ -3,6 +3,7 @@ namespace cs { class CMAuthSession; + class CMCharEnum; } class Player; @@ -20,6 +21,8 @@ class PlayerMgr : public a8::Singleton void UnInit(); void _CMAuthSession(f8::MsgHdr& hdr, const cs::CMAuthSession& msg); + void _CMCharEnum(f8::MsgHdr& hdr, const cs::CMCharEnum& msg); + int OnlineNum(); Player* GetPlayerBySocket(int socket); void OnClientDisconnect(a8::XParams& param); diff --git a/server/tools/protobuild/cs_msgid.proto b/server/tools/protobuild/cs_msgid.proto index 6c82728..cefed7a 100644 --- a/server/tools/protobuild/cs_msgid.proto +++ b/server/tools/protobuild/cs_msgid.proto @@ -3,6 +3,13 @@ package cs; //消息id定义 enum CMMessageId_e { - _SMAuthChallenge = 0x1EC; _CMAuthSession = 0x1ED; + _CMCharEnum = 0x037; } + +enum SMMessageId_e +{ + _SMAuthChallenge = 0x1EC; + _SMAuthResponse = 0x1EE; + _SMCharEnum = 0x03B; +} \ No newline at end of file diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index e77d10d..4bf99fb 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -27,3 +27,13 @@ message CMAuthSession optional uint32 client_seed = 4; optional bytes digest = 5 [(fixed_len) = 20]; } + +message CMCharEnum +{ + +} + +message SMCharEnum +{ + +} \ No newline at end of file diff --git a/third_party/framework b/third_party/framework index f7c0890..47aa7d4 160000 --- a/third_party/framework +++ b/third_party/framework @@ -1 +1 @@ -Subproject commit f7c0890bc84974c2770688378696bd8d74cfa7c2 +Subproject commit 47aa7d49ae3f12cef4d3d60b4a3fc07671ca767d