diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index fb65eb97..2b7497c1 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -306,7 +306,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic() target = hum->last_human_target; } else { if (rand() % 100 < 70) { - hum->room->TouchPlayerList + hum->room->TraversePlayerList ( a8::XParams(), [hum, &target] (Player* player, a8::XParams& param) @@ -323,7 +323,7 @@ void AndroidNewAI::UpdateNewBieRoomLogic() } }); } else { - hum->room->TouchHumanList + hum->room->TraverseHumanList ( a8::XParams(), [hum, &target] (Human* huma, a8::XParams& param) @@ -718,7 +718,7 @@ Creature* AndroidNewAI::GetTarget() } Creature* target = nullptr; - myself->TouchProperTargets + myself->TraverseProperTargets ( [myself, &target] (Creature* hum, bool& stop) { diff --git a/server/gameserver/bullet.cc b/server/gameserver/bullet.cc index 8e83b3aa..1b3e48bf 100644 --- a/server/gameserver/bullet.cc +++ b/server/gameserver/bullet.cc @@ -59,7 +59,7 @@ void Bullet::ProcBomb() { self_collider_->rad = gun_meta->i->explosion_range(); std::set objects; - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, &objects] (Human* hum, bool& stop) { @@ -75,7 +75,7 @@ void Bullet::ProcBomb() } } }); - TouchAllLayerEntityList + TraverseAllLayerEntityList ( [this, &objects] (Entity* entity, bool& stop) { @@ -232,7 +232,7 @@ float Bullet::GetAtk() void Bullet::Check(float distance) { std::set objects; - room->grid_service->TouchCreatures + room->grid_service->TraverseCreatures (room->GetRoomIdx(), GetGridList(), [this, &objects] (Creature* c, bool& stop) diff --git a/server/gameserver/car.cc b/server/gameserver/car.cc index 97765cda..6e26069c 100644 --- a/server/gameserver/car.cc +++ b/server/gameserver/car.cc @@ -318,7 +318,7 @@ void Car::Explosion(int team_id) return; } std::set objects; - TouchProperTargets + TraverseProperTargets ( [this, &objects, team_id] (Creature* c, bool& stop) { diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index 472d6dab..fbd6f5b7 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -1119,7 +1119,7 @@ bool Creature::IsEnemy(Creature* target) } } -void Creature::TouchProperTargets(std::function func) +void Creature::TraverseProperTargets(std::function func) { auto callback = [this, func] (Creature* c, bool& stop) @@ -1128,7 +1128,7 @@ void Creature::TouchProperTargets(std::function func) func(c, stop); } }; - room->grid_service->TouchCreatures(room->GetRoomIdx(), + room->grid_service->TraverseCreatures(room->GetRoomIdx(), GetGridList(), callback); } @@ -1732,7 +1732,7 @@ float Creature::GetMaxHP() void Creature::GetHitEnemys(std::set& enemys) { - room->grid_service->TouchCreatures + room->grid_service->TraverseCreatures (room->GetRoomIdx(), GetGridList(), [this, &enemys] (Creature* c, bool& stop) diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 45833ec2..43680eef 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -124,7 +124,7 @@ class Creature : public MoveableEntity int GetActionType() { return action_type; } int GetActionTargetId() { return action_target_id; } - void TouchProperTargets(std::function func); + void TraverseProperTargets(std::function func); CreatureWeakPtrChunk* GetWeakPtrChunk() { return &weak_ptr_chunk_; }; void Shot(a8::Vec2& target_dir, bool& shot_ok, float fly_distance); diff --git a/server/gameserver/entity.cc b/server/gameserver/entity.cc index 15f0dd67..e7fc48d8 100644 --- a/server/gameserver/entity.cc +++ b/server/gameserver/entity.cc @@ -95,7 +95,7 @@ void Entity::BroadcastFullState(Room* room) { std::set tmp_grids; room->grid_service->GetAllCells(room, grid_id_, tmp_grids); - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), tmp_grids, @@ -108,7 +108,7 @@ void Entity::BroadcastFullState(Room* room) void Entity::BroadcastDeleteState(Room* room) { #if 0 - room->TouchHumanList + room->TraverseHumanList ( a8::XParams(), [this] (Human* hum, a8::XParams& param) -> bool @@ -119,7 +119,7 @@ void Entity::BroadcastDeleteState(Room* room) #else std::set tmp_grids; room->grid_service->GetAllCells(room, grid_id_, tmp_grids); - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), tmp_grids, @@ -133,7 +133,7 @@ void Entity::BroadcastDeleteState(Room* room) void Entity::RemoveFromAroundPlayers(Room* room) { #if 1 - room->TouchHumanList + room->TraverseHumanList ( a8::XParams(), [this] (Human* hum, a8::XParams& param) -> bool @@ -144,7 +144,7 @@ void Entity::RemoveFromAroundPlayers(Room* room) #else std::set tmp_grids; room->grid_service->GetAllCells(room, grid_id_, tmp_grids); - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), tmp_grids, diff --git a/server/gameserver/frag_mitask.cc b/server/gameserver/frag_mitask.cc index 44317d58..e3687fd3 100644 --- a/server/gameserver/frag_mitask.cc +++ b/server/gameserver/frag_mitask.cc @@ -27,7 +27,7 @@ void FragMiTask::Done() grid_list ); std::set objects; - sender.Get()->room->grid_service->TouchCreatures + sender.Get()->room->grid_service->TraverseCreatures ( sender.Get()->room->GetRoomIdx(), grid_list, @@ -41,7 +41,7 @@ void FragMiTask::Done() } ); std::set entitys; - sender.Get()->room->grid_service->TouchAllLayerEntityList + sender.Get()->room->grid_service->TraverseAllLayerEntityList ( sender.Get()->room->GetRoomIdx(), grid_list, diff --git a/server/gameserver/frameevent.cc b/server/gameserver/frameevent.cc index 0118efa1..f6380a7d 100644 --- a/server/gameserver/frameevent.cc +++ b/server/gameserver/frameevent.cc @@ -29,7 +29,7 @@ void FrameEvent::AddEmote(Human* sender, int emote_id) } { int emote_idx = emotes_.size() - 1; - sender->TouchAllLayerHumanList + sender->TraverseAllLayerHumanList ( [emote_idx] (Human* hum, bool& stop) { @@ -60,7 +60,7 @@ void FrameEvent::AddShot(Creature* sender) } { int shot_idx = shots_.size() - 1; - sender->TouchAllLayerHumanList + sender->TraverseAllLayerHumanList ( [shot_idx] (Human* hum, bool& stop) { @@ -94,7 +94,7 @@ void FrameEvent::AddBullet(Creature* sender, } { int bullet_idx = bullets_.size() - 1; - sender->TouchAllLayerHumanList + sender->TraverseAllLayerHumanList ( [bullet_idx] (Human* hum, bool& stop) { @@ -125,7 +125,7 @@ void FrameEvent::AddExplosionEx(CreatureWeakPtr& sender, int item_id, a8::Vec2 b } { int explosion_idx = explosions_.size() - 1; - sender.Get()->TouchAllLayerHumanList + sender.Get()->TraverseAllLayerHumanList ( [explosion_idx] (Human* hum, bool& stop) { @@ -157,7 +157,7 @@ void FrameEvent::AddSmoke(Bullet* bullet, int item_id, a8::Vec2 pos) } { int idx = smokes_.size() - 1; - bullet->sender.Get()->TouchAllLayerHumanList + bullet->sender.Get()->TraverseAllLayerHumanList ( [idx] (Human* hum, bool& stop) { @@ -180,7 +180,7 @@ void FrameEvent::AddPlaySkill(CreatureWeakPtr& sender, int skill_id) } { int idx = play_skills_.size() - 1; - sender.Get()->TouchAllLayerHumanList + sender.Get()->TraverseAllLayerHumanList ( [idx] (Human* hum, bool& stop) { @@ -193,7 +193,7 @@ void FrameEvent::AddHpChg(CreatureWeakPtr& sender) { chged_hps_.push_back(sender); int idx = chged_hps_.size() - 1; - sender.Get()->TouchAllLayerHumanList + sender.Get()->TraverseAllLayerHumanList ( [idx] (Human* hum, bool& stop) { @@ -227,7 +227,7 @@ void FrameEvent::AddBuff(CreatureWeakPtr& sender, Buff* buff) } { int idx = chged_buffs_.size() - 1; - sender.Get()->TouchAllLayerHumanList + sender.Get()->TraverseAllLayerHumanList ( [idx] (Human* hum, bool& stop) { @@ -247,7 +247,7 @@ void FrameEvent::RemoveBuff(CreatureWeakPtr& sender, int buff_id) } { int idx = chged_buffs_.size() - 1; - sender.Get()->TouchAllLayerHumanList + sender.Get()->TraverseAllLayerHumanList ( [idx] (Human* hum, bool& stop) { @@ -286,7 +286,7 @@ void FrameEvent::AddZombieIdChg(Human* sender) chged_zombieids_.push_back(sender); int idx = chged_zombieids_.size() - 1; { - sender->TouchAllLayerHumanList + sender->TraverseAllLayerHumanList ( [idx] (Human* hum, bool& stop) { @@ -310,7 +310,7 @@ void FrameEvent::AddDead(CreatureWeakPtr& sender, int revive_time) } { int dead_idx = dead_alive_objs_.size() - 1; - sender.Get()->TouchAllLayerHumanList + sender.Get()->TraverseAllLayerHumanList ( [dead_idx] (Human* hum, bool& stop) { @@ -334,7 +334,7 @@ void FrameEvent::AddRevive(CreatureWeakPtr& sender) } { int revive_idx = dead_alive_objs_.size() - 1; - sender.Get()->TouchAllLayerHumanList + sender.Get()->TraverseAllLayerHumanList ( [revive_idx] (Human* hum, bool& stop) { @@ -348,7 +348,7 @@ void FrameEvent::AddCarChg(Human* sender) { chged_cars_.push_back(sender); int idx = chged_cars_.size() - 1; - sender->TouchAllLayerHumanList + sender->TraverseAllLayerHumanList ( [idx] (Human* hum, bool& stop) { diff --git a/server/gameserver/gridcell.cc b/server/gameserver/gridcell.cc index 352aed3e..43e90091 100644 --- a/server/gameserver/gridcell.cc +++ b/server/gameserver/gridcell.cc @@ -29,7 +29,7 @@ void GridCell::ClearRoomData(Room* room) creatures_[room->GetRoomIdx()].clear(); } -void GridCell::TouchHumanList(std::function func, +void GridCell::TraverseHumanList(std::function func, int room_idx, bool& stop) { @@ -45,7 +45,7 @@ void GridCell::TouchHumanList(std::function func, } } -void GridCell::TouchCreatures(std::function& func, +void GridCell::TraverseCreatures(std::function& func, int room_idx, bool& stop) { @@ -91,7 +91,7 @@ bool GridCell::EntityExists(Room* room, Entity* entity) entitys_[room->GetRoomIdx()].end(); } -void GridCell::TouchLayer0EntityList(std::function& func, +void GridCell::TraverseLayer0EntityList(std::function& func, bool& stop) { for (Entity* entity : entitys_[0]) { @@ -102,7 +102,7 @@ void GridCell::TouchLayer0EntityList(std::function& func, } } -void GridCell::TouchLayer1EntityList(std::function& func, +void GridCell::TraverseLayer1EntityList(std::function& func, int room_idx, bool& stop) { @@ -114,13 +114,13 @@ void GridCell::TouchLayer1EntityList(std::function& func, } } -void GridCell::TouchAllLayerEntityList(std::function& func, +void GridCell::TraverseAllLayerEntityList(std::function& func, int room_idx, bool& stop) { - TouchLayer0EntityList(func, stop); + TraverseLayer0EntityList(func, stop); if (!stop) { - TouchLayer1EntityList(func, room_idx, stop); + TraverseLayer1EntityList(func, room_idx, stop); } } diff --git a/server/gameserver/gridcell.h b/server/gameserver/gridcell.h index 307df702..d6188c56 100644 --- a/server/gameserver/gridcell.h +++ b/server/gameserver/gridcell.h @@ -13,10 +13,10 @@ public: GridCell(); void ClearRoomData(Room* room); - void TouchHumanList(std::function func, + void TraverseHumanList(std::function func, int room_idx, bool& stop); - void TouchCreatures(std::function& func, + void TraverseCreatures(std::function& func, int room_idx, bool& stop); @@ -29,12 +29,12 @@ public: void AddRoomEntity(Room* room, Entity* entity); void RemoveRoomEntity(Room* room, Entity* entity); bool EntityExists(Room* room, Entity* Entity); - void TouchLayer0EntityList(std::function& func, + void TraverseLayer0EntityList(std::function& func, bool& stop); - void TouchLayer1EntityList(std::function& func, + void TraverseLayer1EntityList(std::function& func, int room_idx, bool& stop); - void TouchAllLayerEntityList(std::function& func, + void TraverseAllLayerEntityList(std::function& func, int room_idx, bool& stop); diff --git a/server/gameserver/gridservice.cc b/server/gameserver/gridservice.cc index 1760d4a0..8c5f2da5 100644 --- a/server/gameserver/gridservice.cc +++ b/server/gameserver/gridservice.cc @@ -327,64 +327,64 @@ void GridService::ComputeDiff(Room* room, GetAllCells(room, new_grid_id, grid_list); } -void GridService::TouchLayer0EntityList(std::set& grid_list, +void GridService::TraverseLayer0EntityList(std::set& grid_list, std::function func) { bool stop = false; for (auto& cell : grid_list) { - cell->TouchLayer0EntityList(func, stop); + cell->TraverseLayer0EntityList(func, stop); if (stop) { return; } } } -void GridService::TouchLayer1EntityList(int room_idx, +void GridService::TraverseLayer1EntityList(int room_idx, std::set& grid_list, std::function func) { bool stop = false; for (auto& cell : grid_list) { - cell->TouchLayer1EntityList(func, room_idx, stop); + cell->TraverseLayer1EntityList(func, room_idx, stop); if (stop) { return; } } } -void GridService::TouchAllLayerEntityList(int room_idx, +void GridService::TraverseAllLayerEntityList(int room_idx, std::set& grid_list, std::function func) { bool stop = false; for (auto& cell : grid_list) { - cell->TouchAllLayerEntityList(func, room_idx, stop); + cell->TraverseAllLayerEntityList(func, room_idx, stop); if (stop) { return; } } } -void GridService::TouchAllLayerHumanList(int room_idx, +void GridService::TraverseAllLayerHumanList(int room_idx, std::set& grid_list, std::function func) { bool stop = false; for (auto& cell : grid_list) { - cell->TouchHumanList(func, room_idx, stop); + cell->TraverseHumanList(func, room_idx, stop); if (stop) { return; } } } -void GridService::TouchCreatures(int room_idx, +void GridService::TraverseCreatures(int room_idx, std::set& grid_list, std::function func) { bool stop = false; for (auto& cell : grid_list) { - cell->TouchCreatures(func, room_idx, stop); + cell->TraverseCreatures(func, room_idx, stop); if (stop) { return; } @@ -395,7 +395,7 @@ void GridService::DeatchHuman(Human* target) { for (auto& cell : target->GetGridList()) { bool stop = false; - cell->TouchHumanList + cell->TraverseHumanList ( [target] (Human* hum, bool& stop) { diff --git a/server/gameserver/gridservice.h b/server/gameserver/gridservice.h index 89dddf81..784de0dd 100644 --- a/server/gameserver/gridservice.h +++ b/server/gameserver/gridservice.h @@ -38,18 +38,18 @@ class GridService bool InView(int a_grid, int b_grid); bool InView(int grid_id, float x, float y); - void TouchLayer0EntityList(std::set& grid_list, + void TraverseLayer0EntityList(std::set& grid_list, std::function func); - void TouchLayer1EntityList(int room_idx, + void TraverseLayer1EntityList(int room_idx, std::set& grid_list, std::function func); - void TouchAllLayerEntityList(int room_idx, + void TraverseAllLayerEntityList(int room_idx, std::set& grid_list, std::function func); - void TouchAllLayerHumanList(int room_idx, + void TraverseAllLayerHumanList(int room_idx, std::set& grid_list, std::function func); - void TouchCreatures(int room_idx, + void TraverseCreatures(int room_idx, std::set& grid_list, std::function func); void DeatchHuman(Human* hum); diff --git a/server/gameserver/hero.ai.cc b/server/gameserver/hero.ai.cc index a27a415b..0982163a 100644 --- a/server/gameserver/hero.ai.cc +++ b/server/gameserver/hero.ai.cc @@ -359,7 +359,7 @@ Creature* HeroAI::GetTarget() } Creature* target = nullptr; - myself->TouchProperTargets + myself->TraverseProperTargets ( [myself, &target] (Creature* hum, bool& stop) { diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 8f064f2a..98c07fa7 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -645,7 +645,7 @@ void Human::FillSMGameOver(cs::SMGameOver& msg) { if (stats.rank <= 0) { std::vector human_list; - room->TouchHumanList(a8::XParams(), + room->TraverseHumanList(a8::XParams(), [&human_list] (Human* hum, a8::XParams& param) -> bool { if (hum->leave_frameno_ == 0 || @@ -1034,7 +1034,7 @@ bool Human::HasNoDownedTeammate() if (GetRace() == kHumanRace) { bool has_now_downed_teammate = false; Human* myself = this; - room->TouchHumanList + room->TraverseHumanList ( a8::XParams(), [myself, &has_now_downed_teammate] (Human* hum, const a8::XParams& param) @@ -1135,7 +1135,7 @@ void Human::DoGetOn(int obj_uniid) void Human::FindLocation() { Entity* target = nullptr; - TouchAllLayerEntityList + TraverseAllLayerEntityList ( [this, &target] (Entity* entity, bool& stop) { @@ -1173,7 +1173,7 @@ void Human::FindLocation() void Human::RefreshView() { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this] (Human* hum, bool& stop) { @@ -1182,7 +1182,7 @@ void Human::RefreshView() AddToNewObjects(hum); AddToPartObjects(hum); }); - TouchAllLayerEntityList + TraverseAllLayerEntityList ( [this] (Entity* entity, bool& stop) { @@ -1234,7 +1234,7 @@ void Human::SyncAroundPlayers(const char* file, int line, const char* func) }); #endif #endif - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, file, line, func] (Human* hum, bool& stop) { @@ -1534,7 +1534,7 @@ void Human::SendRollMsg(const std::string& msg, int killer_id, bool killer_team_ int killer_id = param.param1; int killer_team_id = param.param2; std::string text = param.param3.GetString(); - target->room->TouchPlayerList + target->room->TraversePlayerList (a8::XParams(), [target, killer_id, killer_team_id, text] (Human* hum, a8::XParams& param) -> bool { @@ -1979,7 +1979,7 @@ void Human::GenBattleReportData(a8::MutableXObject* params) int rank = 0; { std::vector human_list; - room->TouchHumanList(a8::XParams(), + room->TraverseHumanList(a8::XParams(), [&human_list] (Human* hum, a8::XParams& param) -> bool { human_list.push_back(hum); @@ -2157,7 +2157,7 @@ void Human::GenZbModeBattleReportData(a8::MutableXObject* params) int rank = 0; { std::vector human_list; - room->TouchHumanList(a8::XParams(), + room->TraverseHumanList(a8::XParams(), [&human_list] (Human* hum, a8::XParams& param) -> bool { human_list.push_back(hum); @@ -2449,7 +2449,7 @@ void Human::FindLocationWithTarget(Entity* target) Entity* building = nullptr; std::set tmp_grids; room->grid_service->GetAllCellsByXy(room, GetX(), GetY(), tmp_grids); - room->grid_service->TouchAllLayerEntityList + room->grid_service->TraverseAllLayerEntityList ( room->GetRoomIdx(), tmp_grids, @@ -2827,13 +2827,13 @@ void Human::OnDisable() void Human::GetViewObjects(std::set& view_objects) { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [&view_objects] (Human* hum, bool& stop) { view_objects.insert(hum); }); - TouchAllLayerEntityList + TraverseAllLayerEntityList ( [&view_objects] (Entity* entity, bool& stop) { @@ -2896,7 +2896,7 @@ void Human::ProcIncGridList(std::set& old_grids, std::set& inc_grids, std::set& dec_grids) { - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), inc_grids, @@ -2911,7 +2911,7 @@ void Human::ProcIncGridList(std::set& old_grids, RemoveOutObjects(hum); } }); - room->grid_service->TouchAllLayerEntityList + room->grid_service->TraverseAllLayerEntityList ( room->GetRoomIdx(), inc_grids, @@ -2938,7 +2938,7 @@ void Human::ProcDecGridList(std::set& old_grids, std::set& inc_grids, std::set& dec_grids) { - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), dec_grids, @@ -2958,7 +2958,7 @@ void Human::ProcDecGridList(std::set& old_grids, #endif } }); - room->grid_service->TouchAllLayerEntityList + room->grid_service->TraverseAllLayerEntityList ( room->GetRoomIdx(), dec_grids, @@ -2985,7 +2985,7 @@ void Human::ProcDecGridList(std::set& old_grids, void Human::RemoveFromScene() { room->grid_service->DeatchHuman(this); - room->TouchHumanList + room->TraverseHumanList ( a8::XParams() .SetSender(this), @@ -3509,7 +3509,7 @@ void Human::UpdateViewObjects() } } if (view_objects_.size() < 2) { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this] (Human* hum, bool& stop) { diff --git a/server/gameserver/incubator.cc b/server/gameserver/incubator.cc index 87552edf..6d46b1d1 100644 --- a/server/gameserver/incubator.cc +++ b/server/gameserver/incubator.cc @@ -80,7 +80,7 @@ void Incubator::RecycleAndroid(Human* hum) Human* nearest_hum = nullptr; Human* target = hum; float distance = 10000000; - room->TouchAlivePlayers + room->TraverseAlivePlayers ( a8::XParams(), [&nearest_hum, target, &distance] (Human* hum, a8::XParams& param) -> bool @@ -129,7 +129,7 @@ bool Incubator::CanSet(Human* hum, Human* exclude_hum) { Human* target = hum; bool can_set = true; - room->TouchAlivePlayers + room->TraverseAlivePlayers ( a8::XParams(), [target, exclude_hum, &can_set] (Human* hum, a8::XParams& param) -> bool diff --git a/server/gameserver/moveableentity.cc b/server/gameserver/moveableentity.cc index c8c75dbe..2a59b862 100644 --- a/server/gameserver/moveableentity.cc +++ b/server/gameserver/moveableentity.cc @@ -3,29 +3,29 @@ #include "room.h" #include "human.h" -void MoveableEntity::TouchLayer0EntityList(std::function func) +void MoveableEntity::TraverseLayer0EntityList(std::function func) { - room->grid_service->TouchLayer0EntityList(grid_list_, func); + room->grid_service->TraverseLayer0EntityList(grid_list_, func); } -void MoveableEntity::TouchLayer1EntityList(std::function func) +void MoveableEntity::TraverseLayer1EntityList(std::function func) { - room->grid_service->TouchLayer1EntityList(room->GetRoomIdx(), grid_list_, func); + room->grid_service->TraverseLayer1EntityList(room->GetRoomIdx(), grid_list_, func); } -void MoveableEntity::TouchAllLayerEntityList(std::function func) +void MoveableEntity::TraverseAllLayerEntityList(std::function func) { - room->grid_service->TouchAllLayerEntityList(room->GetRoomIdx(), grid_list_, func); + room->grid_service->TraverseAllLayerEntityList(room->GetRoomIdx(), grid_list_, func); } -void MoveableEntity::TouchAllLayerHumanList(std::function func) +void MoveableEntity::TraverseAllLayerHumanList(std::function func) { - room->grid_service->TouchAllLayerHumanList(room->GetRoomIdx(), grid_list_, func); + room->grid_service->TraverseAllLayerHumanList(room->GetRoomIdx(), grid_list_, func); } void MoveableEntity::RefreshView() { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this] (Human* hum, bool& stop) { @@ -40,7 +40,7 @@ void MoveableEntity::OnGridListChange(std::set& old_grids, ) { { - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), inc_grids, @@ -54,7 +54,7 @@ void MoveableEntity::OnGridListChange(std::set& old_grids, }); } { - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), dec_grids, @@ -69,7 +69,7 @@ void MoveableEntity::OnGridListChange(std::set& old_grids, void MoveableEntity::SyncAroundPlayers(const char* file, int line, const char* func) { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, file, line, func] (Human* hum, bool& stop) { diff --git a/server/gameserver/moveableentity.h b/server/gameserver/moveableentity.h index 5ac3322e..e669304d 100644 --- a/server/gameserver/moveableentity.h +++ b/server/gameserver/moveableentity.h @@ -13,10 +13,10 @@ class MoveableEntity : public RoomEntity int UpdatedTimes() { return updated_times_;} std::set& GetGridList() { return grid_list_; } - void TouchLayer0EntityList(std::function func); - void TouchLayer1EntityList(std::function func); - void TouchAllLayerEntityList(std::function func); - void TouchAllLayerHumanList(std::function func); + void TraverseLayer0EntityList(std::function func); + void TraverseLayer1EntityList(std::function func); + void TraverseAllLayerEntityList(std::function func); + void TraverseAllLayerHumanList(std::function func); virtual void RefreshView(); virtual void OnGridListChange(std::set& old_grids, diff --git a/server/gameserver/obstacle.cc b/server/gameserver/obstacle.cc index 8a1eb6b5..ae32affc 100644 --- a/server/gameserver/obstacle.cc +++ b/server/gameserver/obstacle.cc @@ -259,7 +259,7 @@ void Obstacle::Explosion(Bullet* bullet) std::set objects; std::set tmp_grids; room->grid_service->GetAllCellsByXy(room, GetX(), GetY(), tmp_grids); - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), tmp_grids, @@ -269,7 +269,7 @@ void Obstacle::Explosion(Bullet* bullet) objects.insert(hum); } }); - room->grid_service->TouchAllLayerEntityList + room->grid_service->TraverseAllLayerEntityList ( room->GetRoomIdx(), tmp_grids, diff --git a/server/gameserver/player.cc b/server/gameserver/player.cc index 30b97b9b..54382941 100644 --- a/server/gameserver/player.cc +++ b/server/gameserver/player.cc @@ -388,7 +388,7 @@ void Player::UpdateJump() [] (const a8::XParams& param) { Human* hum = (Human*)param.sender.GetUserData(); - hum->room->TouchHumanList + hum->room->TraverseHumanList ( a8::XParams() .SetSender(hum), @@ -490,7 +490,7 @@ void Player::ObstacleInteraction(Obstacle* entity) } entity->IncDoorOpenTimes(room); entity->RecalcSelfCollider(); - room->TouchHumanList(a8::XParams(), + room->TraverseHumanList(a8::XParams(), [entity] (Human* hum, a8::XParams& param) -> bool { hum->AddToNewObjects(entity); @@ -985,7 +985,7 @@ void Player::_CMReconnect(f8::MsgHdr& hdr, const cs::CMReconnect& msg) PlayerMgr::Instance()->RemovePlayerBySocket(socket_handle); } socket_handle = hdr.socket_handle; - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this] (Human* hum, bool& stop) { @@ -1313,7 +1313,7 @@ void Player::_CMVoice(f8::MsgHdr& hdr, const cs::CMVoice& msg) cs::SMVoiceNotify* msg = (cs::SMVoiceNotify*)param.sender.GetUserData(); hum->SendNotifyMsg(*msg); }; - room->TouchPlayerList(a8::XParams() + room->TraversePlayerList(a8::XParams() .SetSender(¬ifymsg), send_func); } diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 0705894a..f31c0555 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -386,7 +386,7 @@ Human* Room::FindEnemy(Human* hum) if (room_type_ == RT_MidBrid) { sub_type = EST_Android; Human* target = nullptr; - hum->room->TouchHumanList + hum->room->TraverseHumanList ( a8::XParams(), [hum, &target] (Human* huma, a8::XParams& param) @@ -413,7 +413,7 @@ Human* Room::FindEnemy(Human* hum) } return target; } - hum->TouchAllLayerHumanList + hum->TraverseAllLayerHumanList ( [&enemys, hum, sub_type] (Human* target, bool& stop) { @@ -980,7 +980,7 @@ Entity* Room::FindFirstCollisonEntity(const a8::Vec2& aabb_pos, AabbCollider& aa Entity* target = nullptr; std::set tmp_grids; grid_service->GetAllCellsByXy(this, aabb_pos.x, aabb_pos.y, tmp_grids); - grid_service->TouchAllLayerEntityList + grid_service->TraverseAllLayerEntityList ( room_idx_, tmp_grids, @@ -1109,7 +1109,7 @@ int Room::NewTeam() return current_teamid_; } -void Room::TouchPlayerList(a8::XParams param, +void Room::TraversePlayerList(a8::XParams param, std::function func) { if (!func) { @@ -1122,7 +1122,7 @@ void Room::TouchPlayerList(a8::XParams param, } } -void Room::TouchHumanList(a8::XParams param, +void Room::TraverseHumanList(a8::XParams param, std::function func) { if (!func) { @@ -1137,7 +1137,7 @@ void Room::TouchHumanList(a8::XParams param, } } -void Room::TouchEntityList(a8::XParams param, +void Room::TraverseEntityList(a8::XParams param, std::function func) { if (!func) { @@ -1152,7 +1152,7 @@ void Room::TouchEntityList(a8::XParams param, } } -void Room::TouchAlivePlayers(a8::XParams param, +void Room::TraverseAlivePlayers(a8::XParams param, std::function func) { for (auto& pair : alive_player_hash_) { @@ -1165,7 +1165,7 @@ void Room::TouchAlivePlayers(a8::XParams param, void Room::BroadcastDebugMsg(const std::string& debug_msg) { #ifdef DEBUG - TouchHumanList + TraverseHumanList ( a8::XParams() .SetParam1(debug_msg), @@ -1272,7 +1272,7 @@ void Room::UpdateGasInactive() jump_num = 1 + rand() % 2; } for (int i = 0; i < jump_num; ++i) { - room->TouchHumanList + room->TraverseHumanList ( a8::XParams() .SetSender(room), @@ -1358,7 +1358,7 @@ void Room::UpdateGasJump() ((GetFrameNo() - GetGasData().gas_start_frameno)*airline_->i->plane_speed() / SERVER_FRAME_RATE); plane.curr_pos = plane.start_point + len_vec; if ((plane.end_point - plane.start_point).Norm() <= len_vec.Norm()) { - TouchHumanList( + TraverseHumanList( a8::XParams(), [] (Human* hum, a8::XParams& param) -> bool { @@ -1909,7 +1909,7 @@ void Room::NotifyUiUpdate() [] (const a8::XParams& param) { Room* room = (Room*)param.sender.GetUserData(); - room->TouchPlayerList(a8::XParams(), + room->TraversePlayerList(a8::XParams(), [] (Player * hum, a8::XParams & param) { hum->SendUIUpdate(); @@ -1985,7 +1985,7 @@ void Room::NotifyWxVoip() [] (const a8::XParams& param) { Room* room = (Room*)param.sender.GetUserData(); - room->TouchPlayerList(a8::XParams(), + room->TraversePlayerList(a8::XParams(), [] (Player * hum, a8::XParams & param) { hum->SendWxVoip(); @@ -2747,7 +2747,7 @@ void Room::CheckAutoDie(Human* target, int check_times) { bool nodie = false; - target->TouchAllLayerHumanList + target->TraverseAllLayerHumanList ( [&nodie, target, autodie_time, autodie_distance] (Human* hum, bool& stop) { @@ -2910,7 +2910,7 @@ void Room::CheckPartObjects(Human* testa, Human* testb) for (auto& pair1 : human_hash_) { Human* huma = pair1.second; - huma->TouchAllLayerHumanList + huma->TraverseAllLayerHumanList ( [&huma, testa, testb] (Human* humb, bool& stop) { @@ -3672,7 +3672,7 @@ void Room::OnZombieAppear(Human* hum) { if (hum->GetRace() == kZombieRace && hum->meta->i->level() == 3 && !sent_zombie_boss_notify) { sent_zombie_boss_notify = true; - TouchPlayerList + TraversePlayerList ( a8::XParams() .SetParam1(hum->meta->i->name()), @@ -3892,7 +3892,7 @@ void Room::ShuaMon(const a8::Vec2& center, std::vector& airdrop_mon_list, f void Room::GetPartObjectWatchList(Entity* entity, std::vector& watch_list) { - TouchHumanList + TraverseHumanList ( a8::XParams(), [&watch_list, entity] (Human* hum, a8::XParams& param) -> bool diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 4a66b11c..bcf09bbb 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -93,13 +93,13 @@ public: void FillSMJoinedNotify(Player* self_hum, cs::SMJoinedNotify& msg); - void TouchPlayerList(a8::XParams param, + void TraversePlayerList(a8::XParams param, std::function func); - void TouchHumanList(a8::XParams param, + void TraverseHumanList(a8::XParams param, std::function func); - void TouchEntityList(a8::XParams param, + void TraverseEntityList(a8::XParams param, std::function func); - void TouchAlivePlayers(a8::XParams param, + void TraverseAlivePlayers(a8::XParams param, std::function func); void BroadcastDebugMsg(const std::string& debug_msg); diff --git a/server/gameserver/roomobstacle.cc b/server/gameserver/roomobstacle.cc index eaf5ffb1..a0e29b8f 100644 --- a/server/gameserver/roomobstacle.cc +++ b/server/gameserver/roomobstacle.cc @@ -107,7 +107,7 @@ void RoomObstacle::ActiveTimerFunc() room->grid_service->GetAllCellsByXy(room, GetPos().x, GetPos().y, *grid_list_); } bool has_hum = false; - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList (room->GetRoomIdx(), *grid_list_, [this, &has_hum] (Human* hum, bool& stop) @@ -133,7 +133,7 @@ void RoomObstacle::UpdateTimerFunc() { if (grid_list_ && master.Get() && !IsDead(room)) { std::set human_list; - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList (room->GetRoomIdx(), *grid_list_, [this, &human_list] (Human* hum, bool& stop) @@ -173,7 +173,7 @@ void RoomObstacle::Explosion() if (meta->i->damage_dia() > 0.01f && meta->i->damage() > 0.01f) { std::set objects; - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), *grid_list_, @@ -183,7 +183,7 @@ void RoomObstacle::Explosion() objects.insert(hum); } }); - room->grid_service->TouchAllLayerEntityList + room->grid_service->TraverseAllLayerEntityList ( room->GetRoomIdx(), *grid_list_, @@ -270,7 +270,7 @@ void RoomObstacle::SpecExplosion() bomb_born_offset = bomb_born_offset * a8::RandEx(1, std::max(2, meta->i->explosion_float())); a8::Vec2 bomb_pos = GetPos() + bomb_born_offset; std::set objects; - room->grid_service->TouchAllLayerHumanList + room->grid_service->TraverseAllLayerHumanList ( room->GetRoomIdx(), *grid_list_, diff --git a/server/gameserver/select_target.cc b/server/gameserver/select_target.cc index d60783f2..2c8c8678 100644 --- a/server/gameserver/select_target.cc +++ b/server/gameserver/select_target.cc @@ -11,7 +11,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std: switch (skill->meta->i->skill_target()) { case kST_All: { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { @@ -29,7 +29,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std: case kST_FriendlyIncludeSelf: { target_list.insert(this); - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { @@ -42,7 +42,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std: break; case kST_FriendlyExcludeSelf: { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { @@ -66,7 +66,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std: break; case kST_EnemyGroup: { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { @@ -79,7 +79,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std: break; case kST_EnemyAndObject: { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { @@ -92,7 +92,7 @@ void Creature::SelectSkillTargets(Skill* skill, const a8::Vec2& target_pos, std: break; case kST_EnemyAndSelf: { - TouchAllLayerHumanList + TraverseAllLayerHumanList ( [this, skill, &target_pos, &target_list] (Human* hum, bool& stop) { diff --git a/server/gameserver/smoke_mitask.cc b/server/gameserver/smoke_mitask.cc index 0d60f4be..a389523f 100644 --- a/server/gameserver/smoke_mitask.cc +++ b/server/gameserver/smoke_mitask.cc @@ -19,7 +19,7 @@ void SmokeMiTask::Check() player_set.erase(hum); } } - room->TouchPlayerList + room->TraversePlayerList (a8::XParams(), [this] (Player* hum, a8::XParams&) -> bool { diff --git a/server/gameserver/zombiemode.ai.cc b/server/gameserver/zombiemode.ai.cc index 8d50549e..3767d67b 100644 --- a/server/gameserver/zombiemode.ai.cc +++ b/server/gameserver/zombiemode.ai.cc @@ -385,7 +385,7 @@ Creature* ZombieModeAI::GetTarget() } Creature* target = nullptr; - myself->TouchProperTargets + myself->TraverseProperTargets ( [myself, &target] (Creature* c, bool& stop) {