diff --git a/server/gameserver/human.cc b/server/gameserver/human.cc index 52553cb..680e945 100644 --- a/server/gameserver/human.cc +++ b/server/gameserver/human.cc @@ -802,77 +802,6 @@ void Human::UpdatePoisoning() } } -void Human::SyncAroundPlayers(const char* file, int line, const char* func) -{ - if (a8::HasBitFlag(status, HS_Disable)) { - return; - } - #ifdef DEBUG - #if 0 - room->CheckPartObjects(); - a8::UdpLog::Instance()->Debug("room_idx:%d syncaround begin %s %d %s", - { - room->GetRoomIdx(), - file, - line, - func - }); - #endif - #endif - TouchAllLayerHumanList - ( - [this, file, line, func] (Human* hum, bool& stop) - { - hum->AddToNewObjects(this); -#ifdef DEBUG - #if 0 - { - std::string objs_str; - for (auto& obj : hum->part_objects) { - objs_str += a8::Format("%d ", {(long long)obj}); - } - a8::UdpLog::Instance()->Debug("hum1 %d %s", {(long long)hum, objs_str}); - } - { - std::string objs_str; - for (auto& obj : part_objects) { - objs_str += a8::Format("%d ", {(long long)obj}); - } - a8::UdpLog::Instance()->Debug("hum2 %d %s", {(long long)this, objs_str}); - } - room->CheckPartObjects(hum, this); - hum->InPartObjects(this); - #endif -#endif - assert(hum->part_objects.find(this) != hum->part_objects.end()); - if (hum->part_objects.find(this) == hum->part_objects.end()) { - static long long last_debugout_tick = 0; - if (a8::XGetTickCount() - last_debugout_tick > 1000 * 10) { - last_debugout_tick = a8::XGetTickCount(); - a8::UdpLog::Instance()->Warning - ("SyncAroundPlayers error room_idx:%d, file:%s line:%d func:%s", - { - room->GetRoomIdx(), - file, - line, - func - }); - } - } - }); -#ifdef DEBUG - #if 0 - room->CheckPartObjects(); - a8::UdpLog::Instance()->Debug("syncaround end %s %d %s", - { - file, - line, - func - }); - #endif -#endif -} - void Human::AutoLoadingBullet(bool manual) { Weapon* p_weapon = curr_weapon; @@ -1271,7 +1200,7 @@ int Human::GetPartObjectsCount() return part_objects.size(); } -bool Human::InPartObjects(Human* target) +bool Human::InPartObjects(Entity* target) { return part_objects.find(target) != part_objects.end(); } diff --git a/server/gameserver/human.h b/server/gameserver/human.h index 07bf838..8b6de6e 100644 --- a/server/gameserver/human.h +++ b/server/gameserver/human.h @@ -185,7 +185,6 @@ class Human : public MoveableEntity float GetMaxHP(); void UpdateSkill(); void UpdatePoisoning(); - void SyncAroundPlayers(const char* file, int line, const char* func); void AutoLoadingBullet(bool manual = false); void StartAction(ActionType_e action_type, int action_duration, @@ -198,7 +197,7 @@ class Human : public MoveableEntity void AddToNewObjects(Entity* entity); void AddToPartObjects(Entity* entity); void RemovePartObjects(Entity* entity); - bool InPartObjects(Human* target); + bool InPartObjects(Entity* target); int GetPartObjectsCount(); void RemoveObjects(Entity* entity); void AddOutObjects(Entity* entity); diff --git a/server/gameserver/moveableentity.cc b/server/gameserver/moveableentity.cc index 1e82651..ff07256 100644 --- a/server/gameserver/moveableentity.cc +++ b/server/gameserver/moveableentity.cc @@ -1,6 +1,7 @@ #include "precompile.h" #include "moveableentity.h" #include "room.h" +#include "human.h" void MoveableEntity::TouchLayer0EntityList(std::function func) { @@ -21,3 +22,76 @@ void MoveableEntity::TouchAllLayerHumanList(std::function { room->grid_service->TouchAllLayerHumanList(room->GetRoomIdx(), grid_list_, func); } + +void MoveableEntity::SyncAroundPlayers(const char* file, int line, const char* func) +{ + #if 0 + if (a8::HasBitFlag(status, HS_Disable)) { + return; + } + #endif + #ifdef DEBUG + #if 0 + room->CheckPartObjects(); + a8::UdpLog::Instance()->Debug("room_idx:%d syncaround begin %s %d %s", + { + room->GetRoomIdx(), + file, + line, + func + }); + #endif + #endif + TouchAllLayerHumanList + ( + [this, file, line, func] (Human* hum, bool& stop) + { + hum->AddToNewObjects(this); +#ifdef DEBUG + #if 0 + { + std::string objs_str; + for (auto& obj : hum->part_objects) { + objs_str += a8::Format("%d ", {(long long)obj}); + } + a8::UdpLog::Instance()->Debug("hum1 %d %s", {(long long)hum, objs_str}); + } + { + std::string objs_str; + for (auto& obj : part_objects) { + objs_str += a8::Format("%d ", {(long long)obj}); + } + a8::UdpLog::Instance()->Debug("hum2 %d %s", {(long long)this, objs_str}); + } + room->CheckPartObjects(hum, this); + hum->InPartObjects(this); + #endif +#endif + assert(hum->InPartObjects(this)); + if (!hum->InPartObjects(this)) { + static long long last_debugout_tick = 0; + if (a8::XGetTickCount() - last_debugout_tick > 1000 * 10) { + last_debugout_tick = a8::XGetTickCount(); + a8::UdpLog::Instance()->Warning + ("SyncAroundPlayers error room_idx:%d, file:%s line:%d func:%s", + { + room->GetRoomIdx(), + file, + line, + func + }); + } + } + }); +#ifdef DEBUG + #if 0 + room->CheckPartObjects(); + a8::UdpLog::Instance()->Debug("syncaround end %s %d %s", + { + file, + line, + func + }); + #endif +#endif +} diff --git a/server/gameserver/moveableentity.h b/server/gameserver/moveableentity.h index 653e8f9..604c645 100644 --- a/server/gameserver/moveableentity.h +++ b/server/gameserver/moveableentity.h @@ -15,6 +15,8 @@ class MoveableEntity : public RoomEntity void TouchAllLayerEntityList(std::function func); void TouchAllLayerHumanList(std::function func); + void SyncAroundPlayers(const char* file, int line, const char* func); + protected: int updated_times_ = 0;