1
This commit is contained in:
parent
4c7db9a16f
commit
b9c01688c3
@ -1701,14 +1701,6 @@ void Creature::SlaveOnRemove(Entity* slave)
|
||||
switch (slave->GetEntityType()) {
|
||||
case ET_Hero:
|
||||
{
|
||||
#if 0
|
||||
for (auto itr = slave_heros_.begin(); itr != slave_heros_.end(); ++itr) {
|
||||
if ((Entity*)std::get<1>(*itr) == slave) {
|
||||
slave_heros_.erase(itr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case ET_Obstacle:
|
||||
@ -1732,21 +1724,25 @@ void Creature::SlaveOnRemove(Entity* slave)
|
||||
|
||||
void Creature::RemoveSurplusHero(int hero_id, int num)
|
||||
{
|
||||
#if 0
|
||||
if (slave_heros_.size() >= num && num > 0) {
|
||||
std::vector<Hero*> matched_heros;
|
||||
for (auto& itr : slave_heros_) {
|
||||
if (std::get<0>(itr) == buff_id &&
|
||||
std::get<1>(itr)->meta->id() == id) {
|
||||
matched_heros.push_back(std::get<1>(itr));
|
||||
auto itr = slave_heros_.find(hero_id);
|
||||
if (itr != slave_heros_.end()) {
|
||||
int exists_num = 0;
|
||||
{
|
||||
list_head* pos = nullptr;
|
||||
list_head* next = nullptr;
|
||||
list_head* head = &itr->second;
|
||||
list_for_each_safe(pos, next, head) {
|
||||
++exists_num;
|
||||
}
|
||||
}
|
||||
while (matched_heros.size() > num) {
|
||||
matched_heros[0]->Destory();
|
||||
matched_heros.erase(matched_heros.begin());
|
||||
while (exists_num > num) {
|
||||
Hero* hero = list_first_entry(&itr->second,
|
||||
Hero,
|
||||
entry);
|
||||
list_del_init(&hero->entry);
|
||||
--exists_num;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Creature::RemoveSurplusObstacle(int buff_id, int id, int num)
|
||||
|
@ -221,7 +221,7 @@ void Hero::DetachFromMaster()
|
||||
}
|
||||
detached_ = true;
|
||||
}
|
||||
if (list_empty(&entry)) {
|
||||
if (!list_empty(&entry)) {
|
||||
list_del_init(&entry);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user