This commit is contained in:
aozhiwei 2024-02-04 14:58:52 +08:00
parent d97da9c4ca
commit 11b60d40f8
3 changed files with 12 additions and 10 deletions

View File

@ -3353,7 +3353,7 @@ void Human::OnWatcherDie(Human* watcher)
void Human::TraverseObservers(std::function<void (Human*, bool&)> func)
{
bool stop;
bool stop = false;
for (auto& observer : observers_) {
func(observer, stop);
if (stop) {

View File

@ -1728,19 +1728,20 @@ void Human::SendUIUpdate()
notifymsg.set_b_team_id(room->GetMobaTeamB()->GetTeamId());
notifymsg.set_b_kill_count(room->GetMobaTeamB()->GetKillCount());
}
#ifdef MYDEBUG
a8::XPrintf("zzzzzzzzzzzzz self_team_id:%d data:%s\n",
{
GetTeam()->GetTeamId(),
f8::PbToJson(&notifymsg)
});
#endif
}
TraverseObservers
(
[this, &notifymsg] (Human* ele_hum, bool& stop)
{
if (ele_hum == this || ele_hum->IsOb()) {
#ifdef MYDEBUG
a8::XPrintf("SendUIUpdate self_team_id:%d is_ob:%d data:%s\n",
{
ele_hum->GetTeam()->GetTeamId(),
ele_hum->IsOb() ? 1 : 0,
f8::PbToJson(&notifymsg)
});
#endif
ele_hum->SendNotifyMsg(notifymsg);
}
});

View File

@ -2248,10 +2248,11 @@ void Room::NotifyUiUpdate()
[this] (int event, const a8::Args* args)
{
if (a8::TIMER_EXEC_EVENT == event) {
TraversePlayerList(
[] (Player * hum)
TraverseHumanList(
[] (Human * hum) -> bool
{
hum->SendUIUpdate();
return true;
});
}
},