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_Disable = 2,
HS_NewBieNpc = 3,
HS_AlreadyShow = 4,
HS_AlreadyEquip = 5,
HS_AlreadyProcNewBieLogic = 6,
HS_End

View File

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