1
This commit is contained in:
parent
f0536c1c1e
commit
1dbbf70751
@ -101,7 +101,7 @@ void RoomMgr::_CMJoin(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
if (msg.force_enter_newbie_room()) {
|
if (msg.force_enter_newbie_room()) {
|
||||||
EnterNewBie(hdr, msg);
|
//EnterNewBie(hdr, msg);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (MatchMgr::Instance()->NeedMatch(msg)) {
|
if (MatchMgr::Instance()->NeedMatch(msg)) {
|
||||||
@ -827,118 +827,4 @@ void RoomMgr::AdjustCMJoin(cs::CMJoin* msg)
|
|||||||
msg->set_pve_instance_id(0);
|
msg->set_pve_instance_id(0);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (msg->room_mode() != kPveMode) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
a8::XPrintf("AdjustCMJoin room_mode:%d pve_instance_id:%d\n",
|
|
||||||
{
|
|
||||||
msg->room_mode(),
|
|
||||||
msg->pve_instance_id()
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
msg->set_pve_instance_id(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (msg->room_mode() == kPveMode) {
|
|
||||||
auto mode_meta = mt::PveGeminiMode::GetById(msg->room_mode());
|
|
||||||
auto pve_instance = mt::PveGemini::GetById(msg->pve_instance_id());
|
|
||||||
auto map_meta = MapMgr::Instance()->GetMapInstance(mode_meta ? mode_meta->map_id() : 0);
|
|
||||||
if (!mode_meta || !pve_instance || !map_meta) {
|
|
||||||
#ifdef DEBUG
|
|
||||||
a8::XPrintf("AdjustCMJoin room_mode:%d pve_instance_id:%d\n",
|
|
||||||
{
|
|
||||||
msg->room_mode(),
|
|
||||||
msg->pve_instance_id()
|
|
||||||
});
|
|
||||||
#endif
|
|
||||||
msg->set_room_mode(kPvpMode);
|
|
||||||
msg->set_pve_instance_id(0);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void RoomMgr::EnterNewBie(f8::MsgHdr& hdr, const cs::CMJoin& msg)
|
|
||||||
{
|
|
||||||
std::shared_ptr<BattleDataContext> context = std::make_shared<BattleDataContext>();
|
|
||||||
{
|
|
||||||
context->join_msg = std::make_shared<cs::CMJoin>();
|
|
||||||
*context->join_msg = msg;
|
|
||||||
context->battle_uuid = App::Instance()->NewUuid();
|
|
||||||
context->is_valid_battle = true;
|
|
||||||
context->errcode = 0;
|
|
||||||
context->errmsg = "";
|
|
||||||
}
|
|
||||||
|
|
||||||
int game_times = 0;
|
|
||||||
RoomType_e self_room_type = GetHumanRoomType(context);
|
|
||||||
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
|
|
||||||
hum->battle_uuid = context->battle_uuid;
|
|
||||||
hum->is_valid_battle = context->is_valid_battle;
|
|
||||||
hum->payload = context->payload;
|
|
||||||
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;
|
|
||||||
hum->SetBattleContext(context);
|
|
||||||
{
|
|
||||||
const mt::Hero* hero_meta = mt::Hero::GetById(mt::Param::s().newbie_room_hero_id);
|
|
||||||
const mt::Equip* weapon_meta = mt::Equip::GetById(mt::Param::s().newbie_room_weapon_id);
|
|
||||||
hum->meta = hero_meta;
|
|
||||||
context->ForceInit
|
|
||||||
(
|
|
||||||
App::Instance()->AllocTempHeroUniId(),
|
|
||||||
hero_meta,
|
|
||||||
App::Instance()->AllocTempWeaponUniId(),
|
|
||||||
weapon_meta,
|
|
||||||
0,
|
|
||||||
nullptr
|
|
||||||
);
|
|
||||||
}
|
|
||||||
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() * mt::Param::s().newbie_room_hp_rate);
|
|
||||||
hum->SetMaxHP(hum->GetBattleContext()->GetMaxHP());
|
|
||||||
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()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
hum->TryAddBuff(hum, kInvincibleBuffId);
|
|
||||||
RoomMgr::Instance()->OnJoinRoomOk(msg, hum);
|
|
||||||
}
|
}
|
||||||
|
@ -100,7 +100,6 @@ class RoomMgr : public a8::Singleton<RoomMgr>
|
|||||||
void ReportServerState(int instance_id, const std::string& host, int port);
|
void ReportServerState(int instance_id, const std::string& host, int port);
|
||||||
void FreeOverRoom(long long room_uuid);
|
void FreeOverRoom(long long room_uuid);
|
||||||
bool IsLimitJoin();
|
bool IsLimitJoin();
|
||||||
void EnterNewBie(f8::MsgHdr& hdr, const cs::CMJoin& msg);
|
|
||||||
|
|
||||||
int AllocRoomIdx();
|
int AllocRoomIdx();
|
||||||
Room* CreateRoom(const cs::CMJoin& msg,
|
Room* CreateRoom(const cs::CMJoin& msg,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user