This commit is contained in:
aozhiwei 2024-07-31 09:24:05 +08:00
parent d7eaa2b5d6
commit cf4689b373
7 changed files with 18 additions and 10 deletions

View File

@ -47,9 +47,10 @@ void BatchSync::AddGlobalObject(Creature* c)
std::get<1>(*tuple).FillSMSyncPosition(sync_msg);
room_->TraversePlayerList
(
[&sync_msg] (Player* hum) mutable
[&sync_msg] (Player* hum) mutable -> bool
{
hum->SendNotifyMsg(sync_msg);
return true;
});
}
},

View File

@ -181,11 +181,12 @@ bool BoxDrop::FillAccountIdSessionId(std::string account_id, std::string session
{
bool ok = false;
room_->TraversePlayerList
([&ok, &account_id, &session_id] (Player* hum)
([&ok, &account_id, &session_id] (Player* hum) -> bool
{
ok = true;
account_id = hum->account_id;
session_id = hum->session_id;
return true;
});
return ok;
}

View File

@ -484,7 +484,7 @@ void Incubator::NextWave()
#if 1
room->TraversePlayerList
(
[this] (Player* hum)
[this] (Player* hum) -> bool
{
int next_wave = hum->room->pve_data.GetWave() + 1 + 1;
int max_wave = room->pve_data.max_wave;

View File

@ -2514,9 +2514,10 @@ void Room::NotifyNewsTicker(int msg_type, std::vector<std::string> msg_content)
}
TraversePlayerList
(
[&notify_msg] (Player* hum)
[&notify_msg] (Player* hum) -> bool
{
hum->SendNotifyMsg(notify_msg);
return true;
});
}
@ -2529,9 +2530,10 @@ void Room::NotifyKillList(const std::vector<int>& uniid_list)
}
TraversePlayerList
(
[&notify_msg] (Player* hum)
[&notify_msg] (Player* hum) -> bool
{
hum->SendNotifyMsg(notify_msg);
return true;
});
}

View File

@ -1316,9 +1316,10 @@ void Player::_CMVoice(f8::MsgHdr* hdr, const cs::CMVoice& msg)
cs::SMVoiceNotify notifymsg;
notifymsg.set_account_id(account_id);
notifymsg.set_download_url(msg.download_url());
auto send_func = [&notifymsg] (Player* hum)
auto send_func = [&notifymsg] (Player* hum) -> bool
{
hum->SendNotifyMsg(notifymsg);
return true;
};
room->TraversePlayerList(send_func);
}

View File

@ -1231,11 +1231,13 @@ std::shared_ptr<Team> Room::NewViewTeam()
return team;
}
void Room::TraversePlayerList(std::function<void (Player*)> cb)
void Room::TraversePlayerList(std::function<bool (Player*)> cb)
{
for (auto& pair : accountid_hash_) {
if (pair.second && !pair.second->IsOb()) {
cb(pair.second);
if (!cb(pair.second)){
break;
}
}
}
}
@ -3678,7 +3680,7 @@ void Room::GMFastForward()
}
TraversePlayerList
(
[this] (Player* hum)
[this] (Player* hum) -> bool
{
glm::vec3 src_point = glm::vec3(GetGasData().new_area_meta->GetLastArea()->x1(),
6.0f,
@ -3700,6 +3702,7 @@ void Room::GMFastForward()
grid_service->MoveCreature(hum);
}
}
return true;
});
GetIncubator()->Clear(5);
TraverseHumanList

View File

@ -154,7 +154,7 @@ public:
void FillSMJoinedNotify(Human* self_hum, cs::SMJoinedNotify& msg);
void TraversePlayerList(std::function<void (Player*)> cb);
void TraversePlayerList(std::function<bool (Player*)> cb);
void TraverseRawPlayerList(std::function<void (Player*)> cb);
void TraverseHumanList(std::function<bool (Human*)> cb);
void TraverseRawHumanList(std::function<bool (Human*)> cb);