This commit is contained in:
aozhiwei 2024-01-30 16:14:08 +08:00
parent a3ef9aa1e7
commit e56ab67d92
3 changed files with 23 additions and 12 deletions

View File

@ -160,10 +160,10 @@ void MobaBattle::ParseResult(a8::XObject& obj)
parse_ok_ = true; parse_ok_ = true;
} }
void MobaBattle::TraverseObList(std::function<bool (MobaMember*)> cb) void MobaBattle::TraverseObList(std::function<bool (std::shared_ptr<MobaMember>)> cb)
{ {
for (auto& pair : ob_id_hash_) { for (auto& pair : ob_id_hash_) {
if (!cb(pair.second.get())) { if (!cb(pair.second)) {
break; break;
} }
} }

View File

@ -76,7 +76,7 @@ class MobaBattle
int GetMemberNum(); int GetMemberNum();
int GetTeamNum(); int GetTeamNum();
void TraverseMemberList(std::function<bool (MobaMember*)> func); void TraverseMemberList(std::function<bool (MobaMember*)> func);
void TraverseObList(std::function<bool (MobaMember*)> func); void TraverseObList(std::function<bool (std::shared_ptr<MobaMember>)> func);
void TraverseTeam(std::function<bool (std::shared_ptr<MobaTeam>)> cb); void TraverseTeam(std::function<bool (std::shared_ptr<MobaTeam>)> cb);
private: private:

View File

@ -49,6 +49,7 @@
#include "mobabattle.h" #include "mobabattle.h"
#include "roommgr.h" #include "roommgr.h"
#include "bornpoint.h" #include "bornpoint.h"
#include "roomob.h"
#include "mt/Param.h" #include "mt/Param.h"
#include "mt/Buff.h" #include "mt/Buff.h"
@ -2530,14 +2531,11 @@ int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr<c
side = 1; side = 1;
} }
} }
#if 1
{ {
auto hum = GetPlayerByAccountId(msg->account_id()); p->TraverseObList
if (hum) { (
hum->ReJoin(ip_saddr, socket_handle, msg, p); [ip_saddr, socket_handle, join_msg, p] (std::shared_ptr<MobaMember> m) mutable -> bool
} else { {
auto m = p->GetObByAccountId(msg->account_id());
if (m) {
Player* hum = p->GetRoom()->NewPlayer(); Player* hum = p->GetRoom()->NewPlayer();
//hum->ip_saddr = ip_saddr; //hum->ip_saddr = ip_saddr;
//hum->socket_handle = socket_handle; //hum->socket_handle = socket_handle;
@ -2579,6 +2577,8 @@ int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr<c
hum->GetNetData()->GetHeroLvQuality(hero_uniid, hero_lv, quality); hum->GetNetData()->GetHeroLvQuality(hero_uniid, hero_lv, quality);
hum->hero_uniid = hero_uniid; hum->hero_uniid = hero_uniid;
} }
a8::SetBitFlag(hum->status, CS_IsOb);
p->GetRoom()->GetRoomOb()->AddOb(hum);
p->GetRoom()->AddPlayer(hum); p->GetRoom()->AddPlayer(hum);
hum->ProcSkillList(); hum->ProcSkillList();
hum->SetHP(hum->GetNetData()->GetMaxHP()); hum->SetHP(hum->GetNetData()->GetMaxHP());
@ -2586,15 +2586,26 @@ int Room::InitWithMobaBattle(long ip_saddr, int socket_handle, std::shared_ptr<c
PlayerMgr::Instance()->IncAccountNum(join_msg.account_id()); PlayerMgr::Instance()->IncAccountNum(join_msg.account_id());
RoomMgr::Instance()->OnJoinRoomOk(join_msg, hum); RoomMgr::Instance()->OnJoinRoomOk(join_msg, hum);
//new_team->AddMember(hum); //new_team->AddMember(hum);
hum->ReJoin(ip_saddr, socket_handle, msg, p); //hum->ReJoin(ip_saddr, socket_handle, msg, p);
#ifdef MYDEBUG #ifdef MYDEBUG
a8::XPrintf("moba init1 uniid:%d team_id:%d side:%d\n", a8::XPrintf("moba init11 uniid:%d team_id:%d side:%d\n",
{ {
hum->GetUniId(), hum->GetUniId(),
hum->GetTeam()->GetTeamId(), hum->GetTeam()->GetTeamId(),
hum->side hum->side
}); });
#endif #endif
return true;
});
}
#if 1
{
auto hum = GetPlayerByAccountId(msg->account_id());
if (hum) {
hum->ReJoin(ip_saddr, socket_handle, msg, p);
} else {
auto m = p->GetObByAccountId(msg->account_id());
if (m) {
} }
} }
} }