From 41cb389ed210ba25d2a9bd86e0cac2e43856948c Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 20 Apr 2023 10:52:51 +0800 Subject: [PATCH] 1 --- server/gameserver/roommgr.cc | 77 ++++++++++++++++++++++++++++++++++++ server/gameserver/roommgr.h | 1 + 2 files changed, 78 insertions(+) diff --git a/server/gameserver/roommgr.cc b/server/gameserver/roommgr.cc index 3a870afd..89ca424f 100644 --- a/server/gameserver/roommgr.cc +++ b/server/gameserver/roommgr.cc @@ -158,6 +158,10 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg) }); #endif } + if (msg.force_enter_newbie_room()) { + EnterNewBie(hdr, msg); + return; + } if (MatchMgr::Instance()->NeedMatch(msg)) { MatchMgr::Instance()->_CMJoin(hdr, msg); return; @@ -861,6 +865,9 @@ void RoomMgr::SetMatchMode(int mode) void RoomMgr::AdjustCMJoin(cs::CMJoin* msg) { +#ifdef NEWBIE_ROOM + msg->set_force_enter_newbie_room(true); +#endif if (msg->room_mode() < kPvpMode || msg->room_mode() >= kRoomModeEnd) { #ifdef DEBUG @@ -903,3 +910,73 @@ void RoomMgr::AdjustCMJoin(cs::CMJoin* msg) } } } + +void RoomMgr::EnterNewBie(f8::MsgHdr& hdr, const cs::CMJoin& msg) +{ + int game_times = 0; + RoomType_e self_room_type = GetHumanRoomType(msg, game_times); + if (self_room_type < RT_OldBrid1) { + self_room_type = RT_OldBrid1; + } + time_t register_time = f8::ExtractRegisterTimeFromSessionId(msg.session_id()); + int proto_version = msg.proto_version(); + int channel = f8::ExtractChannelIdFromAccountId(msg.account_id()); + Room* room = RoomMgr::Instance()->GetJoinableRoom + ( + msg, + self_room_type, + game_times, + register_time, + proto_version, + channel + ); + Player* hum = room->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, + hdr.ip_saddr, + hdr.socket_handle, + msg + ); + hum->meta = mt::Hero::GetById(msg.hero_id()); + if (!hum->meta) { + hum->meta = mt::Param::s().human_meta; + } + hum->room = room; + #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; + } + room->AddPlayer(hum); + hum->ProcSkillList(); + 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); +} diff --git a/server/gameserver/roommgr.h b/server/gameserver/roommgr.h index 67e4ec7f..dd7a790c 100644 --- a/server/gameserver/roommgr.h +++ b/server/gameserver/roommgr.h @@ -100,6 +100,7 @@ class RoomMgr : public a8::Singleton void ReportServerState(int instance_id, const std::string& host, int port); void FreeOverRoom(long long room_uuid); bool IsLimitJoin(); + void EnterNewBie(f8::MsgHdr& hdr, const cs::CMJoin& msg); int AllocRoomIdx(); Room* CreateRoom(const cs::CMJoin& msg,