diff --git a/server/gameserver/custom_member.h b/server/gameserver/custom_member.h index 6d22551c..cf7a1cc3 100644 --- a/server/gameserver/custom_member.h +++ b/server/gameserver/custom_member.h @@ -6,7 +6,7 @@ class CustomMember public: const std::string& GetAccountId() { return account_id_; } - std::shared_ptr& GetBattleContext() { return battle_context_; }; + std::shared_ptr& GetNetData() { return battle_context_; }; private: std::string account_id_; diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index b3ea47f0..2a2e1959 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -19,6 +19,8 @@ #include "mapmgr.h" #include "debugcmd.h" #include "custom_battle.h" +#include "custom_team.h" +#include "custom_member.h" #include "mt/Param.h" #include "mt/Text.h" @@ -864,6 +866,16 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg) RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle); return; } + auto team = p->GetTeamByAccountId(msg.account_id()); + if (!team) { + RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle); + return; + } + auto member = team->GetMember(msg.account_id()); + if (!member) { + RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle); + return; + } if (!p->CanAdd(join_msg->account_id(), join_msg->session_id())) { RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle); return; @@ -884,13 +896,9 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg) #if 0 hum->hero_uniid = a8::XValue(msg.hero_uniid()); #endif - #if 0 - hum->battle_uuid = results.at(0)->battle_uuid; - #endif - #if 0 - hum->is_valid_battle = results.at(0)->is_valid_battle; - hum->payload = results.at(0)->payload; - #endif + hum->battle_uuid = member->GetNetData()->battle_uuid; + hum->is_valid_battle = member->GetNetData()->is_valid_battle; + hum->payload = member->GetNetData()->payload; PlayerMgr::Instance()-> CreatePlayerByCMJoin(hum, 0, //ip_saddr, @@ -902,9 +910,7 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg) hum->meta = mt::Param::s().human_meta; } hum->room = p->GetRoom(); - #if 0 - hum->SetBattleContext(results.at(0)); - #endif + hum->SetBattleContext(member->GetNetData()); hum->GetBattleContext()->Init(hum); { long long hero_uniid = 0;