This commit is contained in:
aozhiwei 2020-05-29 19:09:49 +08:00
parent 6320004441
commit 9dc9ae6cde
3 changed files with 24 additions and 9 deletions

View File

@ -19,7 +19,6 @@ enum HumanStatus
HS_AlreadyLordMode = 1, HS_AlreadyLordMode = 1,
HS_Disable = 2, HS_Disable = 2,
HS_NewBieNpc = 3, HS_NewBieNpc = 3,
HS_AlreadyShow = 4,
HS_AlreadyEquip = 5, HS_AlreadyEquip = 5,
HS_AlreadyProcNewBieLogic = 6, HS_AlreadyProcNewBieLogic = 6,
HS_End HS_End

View File

@ -229,7 +229,6 @@ void Room::ShowAndroid(Human* target, int num)
hum->born_point = target->born_point; hum->born_point = target->born_point;
IncBornPointHumanNum(hum->born_point, hum); IncBornPointHumanNum(hum->born_point, hum);
hum->SetPos(hum->born_point->RandPoint()); hum->SetPos(hum->born_point->RandPoint());
a8::SetBitFlag(hum->status, HS_AlreadyShow);
EnableHuman(hum); EnableHuman(hum);
++i; ++i;
if (i >= num) { if (i >= num) {
@ -1270,7 +1269,7 @@ void Room::RandRemoveAndroid()
{ {
Human* hum = nullptr; Human* hum = nullptr;
for (auto& pair : human_hash_) { for (auto& pair : human_hash_) {
if (pair.second->entity_subtype == EST_Android) { if (pair.second->IsAndroid()) {
hum = pair.second; hum = pair.second;
break; break;
} }
@ -1280,7 +1279,7 @@ void Room::RandRemoveAndroid()
team_hash_.erase(hum->team_id); team_hash_.erase(hum->team_id);
} }
if (hum->born_point) { if (hum->born_point) {
--hum->born_point->android_num; DecBornPointHumanNum(hum->born_point, hum);
} }
for (auto& cell : hum->grid_list) { for (auto& cell : hum->grid_list) {
for (Human* target : cell->human_list[room_idx_]) { for (Human* target : cell->human_list[room_idx_]) {
@ -1288,9 +1287,9 @@ void Room::RandRemoveAndroid()
} }
cell->human_list[room_idx_].erase(hum); cell->human_list[room_idx_].erase(hum);
} }
moveable_hash_.erase(hum->entity_uniid); RemoveFromMoveableHash(hum);
uniid_hash_.erase(hum->entity_uniid); RemoveFromEntityHash(hum);
human_hash_.erase(hum->entity_uniid); RemoveFromHuamnHash(hum);
removed_robot_hash_[hum->entity_uniid] = hum; removed_robot_hash_[hum->entity_uniid] = hum;
--alive_count_; --alive_count_;
--App::Instance()->perf.alive_count; --App::Instance()->perf.alive_count;
@ -1781,8 +1780,7 @@ void Room::ShuaNewBieAndroid(Human* target)
#endif #endif
for (auto& pair : human_hash_) { for (auto& pair : human_hash_) {
if (pair.second->entity_subtype == EST_Android && if (pair.second->entity_subtype == EST_Android &&
a8::HasBitFlag(pair.second->status, HS_Disable) && a8::HasBitFlag(pair.second->status, HS_Disable)
!a8::HasBitFlag(pair.second->status, HS_AlreadyShow)
) { ) {
Android* hum = (Android*)pair.second; Android* hum = (Android*)pair.second;
a8::Vec2 pos = target->GetPos(); a8::Vec2 pos = target->GetPos();
@ -2410,3 +2408,18 @@ void Room::AddPlayerPostProc(Player* hum)
&hum->xtimer_attacher.timer_list_); &hum->xtimer_attacher.timer_list_);
#endif #endif
} }
void Room::RemoveFromEntityHash(Entity* entity)
{
uniid_hash_.erase(entity->entity_uniid);
}
void Room::RemoveFromMoveableHash(Human* hum)
{
moveable_hash_.erase(hum->entity_uniid);
}
void Room::RemoveFromHuamnHash(Human* hum)
{
human_hash_.erase(hum->entity_uniid);
}

View File

@ -167,6 +167,9 @@ private:
void AddToAliveHumanHash(Human* hum); void AddToAliveHumanHash(Human* hum);
void AddToMoveableHash(MoveableEntity* entity); void AddToMoveableHash(MoveableEntity* entity);
void AddToAccountHash(Player* hum); void AddToAccountHash(Player* hum);
void RemoveFromEntityHash(Entity* entity);
void RemoveFromMoveableHash(Human* hum);
void RemoveFromHuamnHash(Human* hum);
void AddPlayerPostProc(Player* hum); void AddPlayerPostProc(Player* hum);