This commit is contained in:
aozhiwei 2023-04-02 19:43:10 +08:00
parent 0ab3a0a8a4
commit f30d8cffb1

View File

@ -3094,22 +3094,26 @@ Obstacle* Creature::SummonObstacle(Buff* buff,
void Creature::RemoveSurplusObstacle(int id, int num) void Creature::RemoveSurplusObstacle(int id, int num)
{ {
#if 0 auto itr = slave_things2_.find(id);
if (slave_things_.size() >= num && num > 0) { if (itr != slave_things2_.end() && num >= 0) {
std::vector<RoomObstacleWeakPtr> matched_things; int exists_num = 0;
for (auto& itr : slave_things_) { {
if (std::get<0>(itr) == buff_id && list_head* pos = nullptr;
std::get<1>(itr).Get() && list_head* next = nullptr;
std::get<1>(itr).Get()->meta->thing_id() == id) { list_head* head = &itr->second;
matched_things.push_back(std::get<1>(itr)); list_for_each_safe(pos, next, head) {
++exists_num;
} }
} }
while (matched_things.size() > num) { while (exists_num > num) {
matched_things[0].Get()->Destory(); RoomObstacle* ob = list_first_entry(&itr->second,
matched_things.erase(matched_things.begin()); RoomObstacle,
entry);
ob->Destory();
list_del_init(&ob->entry);
--exists_num;
} }
} }
#endif
} }
Obstacle* Creature::InternalSummonObstacle(Buff* buff, const mt::MapThing* thing_meta, Obstacle* Creature::InternalSummonObstacle(Buff* buff, const mt::MapThing* thing_meta,