From 9dc9ae6cde8867e2185073424e1fdafc3007f4ef Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Fri, 29 May 2020 19:09:49 +0800 Subject: [PATCH] 1 --- server/gameserver/human.h | 1 - server/gameserver/room.cc | 29 +++++++++++++++++++++-------- server/gameserver/room.h | 3 +++ 3 files changed, 24 insertions(+), 9 deletions(-) diff --git a/server/gameserver/human.h b/server/gameserver/human.h index f7a844f..b5ffa05 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -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 diff --git a/server/gameserver/room.cc b/server/gameserver/room.cc index 335937e..44f8867 100644 --- a/server/gameserver/room.cc +++ b/server/gameserver/room.cc @@ -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); +} diff --git a/server/gameserver/room.h b/server/gameserver/room.h index 4450378..b67d14b 100644 --- a/server/gameserver/room.h +++ b/server/gameserver/room.h @@ -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);