From 5e07199fe793c2df4f9429c88edc88ce61e90c62 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Tue, 26 Mar 2024 21:27:10 +0800 Subject: [PATCH] 1 --- server/gameserver/pbutils.cc | 54 +++++++++++--------------- server/gameserver/playermgr.h | 4 +- server/gameserver/room.cc | 5 +-- server/gameserver/roommgr.cc | 1 - server/tools/protobuild/cs_proto.proto | 32 +++++++-------- 5 files changed, 43 insertions(+), 53 deletions(-) diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index 7fe8369e..97a784ba 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -146,23 +146,13 @@ static Player* InternalCreatePlayer(std::shared_ptr p, hum->battle_uuid = m->GetNetData()->battle_uuid; hum->is_valid_battle = m->GetNetData()->is_valid_battle; hum->payload = m->GetNetData()->payload; -#if 1 - join_msg.set_account_id(m->GetAccountId()); - join_msg.set_session_id(m->GetSessionId()); - join_msg.set_team_uuid(m->GetTeam()->GetTeamUuid()); - join_msg.set_name(m->GetName()); - join_msg.set_avatar_url(m->GetAvatarUrl()); - join_msg.set_head_frame(m->GetHeadFrame()); - join_msg.set_sex(m->GetSex()); - join_msg.set_hero_id(m->GetNetData()->GetHeroId()); -#endif PlayerMgr::Instance()-> - CreatePlayerByCMJoin(hum, - 0, - 0, - join_msg - ); - hum->meta = mt::Hero::GetById(join_msg.hero_id()); + CreatePlayerByCustomMember(hum, + 0, + 0, + m + ); + hum->meta = mt::Hero::GetById(m->GetNetData()->GetHeroId()); if (!hum->meta) { hum->meta = mt::Param::s().human_meta; } @@ -2398,26 +2388,26 @@ void GGListener::ForceCloseChildSocket(int sockhandle) SendProxyMsg(sockhandle, msg); } -Player* PlayerMgr::CreatePlayerByCMJoin(Player* hum, - long ip_saddr, - int socket, - const cs::CMJoin& msg) +Player* PlayerMgr::CreatePlayerByCustomMember(Player* hum, + long ip_saddr, + int socket, + std::shared_ptr member) { hum->socket_handle = socket; hum->ip_saddr = ip_saddr; - hum->account_id = msg.account_id(); - hum->session_id = msg.session_id(); - hum->name = msg.name(); - hum->team_uuid = msg.team_uuid(); - hum->team_mode = msg.team_mode(); - hum->auto_fill = msg.auto_fill(); - hum->avatar_url = msg.avatar_url(); + hum->account_id = member->GetAccountId(); + hum->session_id = member->GetSessionId(); + hum->name = member->GetName(); + hum->team_uuid = member->GetTeam()->GetTeamUuid(); + hum->team_mode = 1; + hum->auto_fill = 1; + hum->avatar_url = member->GetAvatarUrl(); hum->create_tick = a8::XGetTickCount(); - hum->account_registertime = f8::ExtractRegisterTimeFromSessionId(msg.session_id()); - hum->channel = f8::ExtractChannelIdFromAccountId(msg.account_id()); - hum->head_frame = msg.head_frame(); - hum->sex = msg.sex(); - hum->user_data = msg.user_data(); + hum->account_registertime = f8::ExtractRegisterTimeFromSessionId(member->GetSessionId()); + hum->channel = f8::ExtractChannelIdFromAccountId(member->GetAccountId()); + hum->head_frame = member->GetHeadFrame(); + hum->sex = member->GetSex(); + hum->user_data = ""; #if 0 for (auto& weapon : msg.weapons()) { if (weapon.weapon_id() != 0) { diff --git a/server/gameserver/playermgr.h b/server/gameserver/playermgr.h index c9ff8190..94031692 100644 --- a/server/gameserver/playermgr.h +++ b/server/gameserver/playermgr.h @@ -14,6 +14,7 @@ namespace ss } class Player; +class CustomMember; class PlayerMgr : public a8::Singleton { public: @@ -31,7 +32,8 @@ class PlayerMgr : public a8::Singleton int OnlineNum(); Player* GetPlayerBySocket(int socket); - Player* CreatePlayerByCMJoin(Player* hum, long ip_saddr, int socket, const cs::CMJoin& msg); + Player* CreatePlayerByCustomMember(Player* hum, long ip_saddr, int socket, + std::shared_ptr member); size_t GetAccountNum() { return account_num_hash_.size(); } void IncAccountNum(const std::string& account_id); void DecAccountNum(const std::string& account_id); diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 69653725..6500a954 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -1146,9 +1146,7 @@ bool Room::CanJoin(const std::string& accountid, if (GetGasData().GetGasMode() != GasInactive) { return false; } - if (msg.pve_instance_id() && !pve_instance){ - return false; - } +#if 0 if (pve_instance) { if (pve_instance->gemini_id() != msg.pve_instance_id()) { return false; @@ -1167,6 +1165,7 @@ bool Room::CanJoin(const std::string& accountid, } #endif } +#endif if (init_map_id != 0) { auto map_instance = MapMgr::Instance()->GetMapInstance(init_map_id); if (map_instance && map_instance->GetMapMeta()->map_mode() == room_mode_ && diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 278fa1d8..d76f25d2 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -469,7 +469,6 @@ void RoomMgr::SetMatchMode(int mode) void RoomMgr::AdjustCMJoin(cs::CMJoin* msg) { - msg->set_pve_instance_id(0); } std::shared_ptr RoomMgr::GetCustomRoom(const std::string& room_uuid) diff --git a/server/tools/protobuild/cs_proto.proto b/server/tools/protobuild/cs_proto.proto index 94098d01..27dd2a9c 100755 --- a/server/tools/protobuild/cs_proto.proto +++ b/server/tools/protobuild/cs_proto.proto @@ -1541,24 +1541,24 @@ message CMJoin optional int32 server_id = 1; //serverid optional string team_uuid = 2; //队伍唯一id (没组队时为空字符串) optional string account_id = 3; //账号id account_id - optional int32 team_mode = 4; //队伍模式 0:单人 1:多人 + optional int32 _team_mode = 4; //队伍模式 0:单人 1:多人 optional int32 proto_version = 5; //协议版本号Constant_e.ProtoVersion - optional bool auto_fill = 6; //是否自动填充玩家 - optional string name = 8; //角色名 - optional string avatar_url = 11; //头像 - repeated MFWeapon weapons = 17; //武器列表 + optional bool _auto_fill = 6; //是否自动填充玩家 + optional string _name = 8; //角色名 + optional string _avatar_url = 11; //头像 + repeated MFWeapon _weapons = 17; //武器列表 optional string session_id = 20; //session_id - optional int32 head_frame = 36 [default = 0]; //头像框 - optional int32 sex = 37 [default = 0]; //性别 - repeated MFTeamMember team_members = 51; //包括自己 - optional int32 room_mode = 52; //0:吃鸡模式 1:pve 2:排位赛 3:moba - optional int32 mapid = 53; //地图id 0:随机地图 - optional string user_data = 60 [default = ""]; //用户自定义数据 - optional int32 hero_id = 61; //英雄id - optional string hero_uniid = 71; //英雄唯一id - optional int32 pve_instance_id = 72; //pve副本id - optional int32 team_slot_num = 73; //队伍槽位数1-4 - optional int32 force_enter_newbie_room = 74; //强制进新手房 + optional int32 _head_frame = 36 [default = 0]; //头像框 + optional int32 _sex = 37 [default = 0]; //性别 + repeated MFTeamMember _team_members = 51; //包括自己 + optional int32 _room_mode = 52; //0:吃鸡模式 1:pve 2:排位赛 3:moba + optional int32 _mapid = 53; //地图id 0:随机地图 + optional string _user_data = 60 [default = ""]; //用户自定义数据 + optional int32 _hero_id = 61; //英雄id + optional string _hero_uniid = 71; //英雄唯一id + optional int32 _pve_instance_id = 72; //pve副本id + optional int32 _team_slot_num = 73; //队伍槽位数1-4 + optional int32 _force_enter_newbie_room = 74; //强制进新手房 optional string payload_data = 75; //透传数据 }