game2005/server/gameserver/moveableentity.cc

98 lines
3.2 KiB
C++

#include "precompile.h"
#include "moveableentity.h"
#include "room.h"
#include "human.h"
void MoveableEntity::TouchLayer0EntityList(std::function<void (Entity*, bool&)> func)
{
room->grid_service->TouchLayer0EntityList(grid_list_, func);
}
void MoveableEntity::TouchLayer1EntityList(std::function<void (Entity*, bool&)> func)
{
room->grid_service->TouchLayer1EntityList(room->GetRoomIdx(), grid_list_, func);
}
void MoveableEntity::TouchAllLayerEntityList(std::function<void (Entity*, bool&)> func)
{
room->grid_service->TouchAllLayerEntityList(room->GetRoomIdx(), grid_list_, func);
}
void MoveableEntity::TouchAllLayerHumanList(std::function<void (Human*, bool&)> func)
{
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
}