diff --git a/server/gameserver/pbutils.cc b/server/gameserver/pbutils.cc index f7b4db13..10ad954f 100644 --- a/server/gameserver/pbutils.cc +++ b/server/gameserver/pbutils.cc @@ -44,6 +44,8 @@ #include "sandtable.h" #include "frameeventdata.h" #include "batchsync.h" +#include "mobabattle.h" +#include "roommgr.h" #include "mt/Param.h" #include "mt/Buff.h" @@ -2242,6 +2244,49 @@ void Room::NotifyKillList(const std::vector& uniid_list) int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr msg, std::shared_ptr p) { + p->TraverseMemberList + ( + [p, msg, ip_saddr, socket_handle] (MobaMember* m) -> bool + { + Player* hum = p->GetRoom()->NewPlayer(); + hum->room = p->GetRoom(); + hum->proto_version = msg->proto_version(); +#if 0 + hum->hero_uniid = a8::XValue(msg.hero_uniid()); +#endif + //hum->battle_uuid = member->GetNetData()->battle_uuid; + //hum->is_valid_battle = member->GetNetData()->is_valid_battle; + //hum->payload = member->GetNetData()->payload; + //msg.set_session_id(member->GetSessionId()); + //msg.set_team_uuid(team->GetTeamUuid()); + PlayerMgr::Instance()-> + CreatePlayerByCMJoin(hum, + ip_saddr, + socket_handle, + *msg + ); + hum->meta = mt::Hero::GetById(msg->hero_id()); + if (!hum->meta) { + hum->meta = mt::Param::s().human_meta; + } + //hum->SetBattleContext(member->GetNetData()); + hum->GetBattleContext()->Init(hum); + { + long long hero_uniid = 0; + int hero_lv = 1; + int quality = 1; + hum->GetBattleContext()->GetHeroLvQuality(hero_uniid, hero_lv, quality); + hum->hero_uniid = hero_uniid; + } + p->GetRoom()->AddPlayer(hum); + hum->ProcSkillList(); + hum->SetHP(hum->GetBattleContext()->GetMaxHP()); + hum->SetMaxHP(hum->GetHP()); + //member->Join(hum); + PlayerMgr::Instance()->IncAccountNum(msg->account_id()); + RoomMgr::Instance()->OnJoinRoomOk(*msg, hum); + return true; + }); return 0; } diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 6078c5f3..646d6a41 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -1189,49 +1189,7 @@ void RoomMgr::_CMJoinMoba(f8::MsgHdr* hdr, const cs::CMJoin& msg) msg.mapid(), nullptr); p->SetRoom(room.get()); - p->TraverseMemberList - ( - [p, msg, ip_saddr, socket_handle] (MobaMember* m) -> bool - { - Player* hum = p->GetRoom()->NewPlayer(); - hum->room = p->GetRoom(); - hum->proto_version = msg.proto_version(); -#if 0 - hum->hero_uniid = a8::XValue(msg.hero_uniid()); -#endif - //hum->battle_uuid = member->GetNetData()->battle_uuid; - //hum->is_valid_battle = member->GetNetData()->is_valid_battle; - //hum->payload = member->GetNetData()->payload; - //msg.set_session_id(member->GetSessionId()); - //msg.set_team_uuid(team->GetTeamUuid()); - PlayerMgr::Instance()-> - CreatePlayerByCMJoin(hum, - ip_saddr, - socket_handle, - msg - ); - hum->meta = mt::Hero::GetById(msg.hero_id()); - if (!hum->meta) { - hum->meta = mt::Param::s().human_meta; - } - //hum->SetBattleContext(member->GetNetData()); - hum->GetBattleContext()->Init(hum); - { - long long hero_uniid = 0; - int hero_lv = 1; - int quality = 1; - hum->GetBattleContext()->GetHeroLvQuality(hero_uniid, hero_lv, quality); - hum->hero_uniid = hero_uniid; - } - p->GetRoom()->AddPlayer(hum); - hum->ProcSkillList(); - hum->SetHP(hum->GetBattleContext()->GetMaxHP()); - hum->SetMaxHP(hum->GetHP()); - //member->Join(hum); - PlayerMgr::Instance()->IncAccountNum(msg.account_id()); - RoomMgr::Instance()->OnJoinRoomOk(msg, hum); - return true; - }); + room->InitWithMobaBattle(ip_saddr, socket_handle, join_msg, p); }; SendGetMobaBattleData(join_msg, cb); } diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index d54ae63b..99c87004 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -90,6 +90,7 @@ class RoomMgr : public a8::Singleton int GetMatchMode() { return match_mode_; }; void SetMatchMode(int mode); bool HasTask(); + void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum); private: void InstallReportStateTimer(); @@ -116,7 +117,6 @@ class RoomMgr : public a8::Singleton std::shared_ptr custom_battle); void JoinErrorHandle(const cs::CMJoin& msg, int error_code, int socket_handle); std::string GenTeamHashData(const std::string& team_uuid, std::map* team_hash); - void OnJoinRoomOk(const cs::CMJoin& msg, Player* hum); void TeamRoomTimeOut(const std::string& team_uuid); void AdjustCMJoin(cs::CMJoin* msg); std::shared_ptr GetCustomRoom(const std::string& room_uuid);