From 4029b36c59fd3fe8ecd2d4f0930bcaef41b691a4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 20 Sep 2023 17:58:35 +0800 Subject: [PATCH] 1 --- server/gameserver/roommgr.cc | 50 +++++++++++++++++++++++++++++------- 1 file changed, 41 insertions(+), 9 deletions(-) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 3b3856fc..b3ea47f0 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -188,15 +188,6 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) hum->SetHP(hum->GetBattleContext()->GetMaxHP()); hum->SetMaxHP(hum->GetHP()); PlayerMgr::Instance()->IncAccountNum(msg.account_id()); - if (JsonDataMgr::Instance()->channel != 0 && - JsonDataMgr::Instance()->channel != channel) { - f8::UdpLog::Instance()->Warning - ("join room channel not match channel:%d account_id:%s", - { - JsonDataMgr::Instance()->channel, - msg.account_id() - }); - } RoomMgr::Instance()->OnJoinRoomOk(msg, hum); }; SendGetBattleData(0, join_msgs, cb); @@ -864,6 +855,7 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg) auto cb = [join_msg, socket_handle] (int errcode, const std::string errmsg, std::shared_ptr p) { + auto& msg = *join_msg; if (!errcode) { RoomMgr::Instance()->JoinErrorHandle(*join_msg, 2, socket_handle); return; @@ -887,6 +879,46 @@ void RoomMgr::_CMJoinCustomBattle(f8::MsgHdr& hdr, const cs::CMJoin& msg) 0, //msg.mapid()); p); } + Player* hum = p->GetRoom()->NewPlayer(); + hum->proto_version = msg.proto_version(); + #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 + PlayerMgr::Instance()-> + CreatePlayerByCMJoin(hum, + 0, //ip_saddr, + socket_handle, + msg + ); + hum->meta = mt::Hero::GetById(msg.hero_id()); + if (!hum->meta) { + hum->meta = mt::Param::s().human_meta; + } + hum->room = p->GetRoom(); + #if 0 + hum->SetBattleContext(results.at(0)); + #endif + 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()); + PlayerMgr::Instance()->IncAccountNum(msg.account_id()); + RoomMgr::Instance()->OnJoinRoomOk(msg, hum); }; SendGetCustomBattleData(join_msg, cb); }