This commit is contained in:
aozhiwei 2023-04-06 17:37:02 +08:00
parent 9cbec34fe7
commit e85ffde38e

View File

@ -123,7 +123,22 @@ void GridService::AddCreature(Creature* c)
int x = (int)c->GetPos().GetX() + cell_width_;
int y = (int)c->GetPos().GetZ() + cell_width_;
if (BroderOverFlow(x, y)) {
#if 1
f8::UdpLog::Instance()->Warning
(
"AddCreature broder over pos:%f,%f,%f new:%f,%f",
{
c->GetPos().GetX(),
c->GetPos().GetY(),
c->GetPos().GetZ(),
x,
y
}
);
return;
#else
A8_ABORT();
#endif
}
c->SetGridId(x/cell_width_ + (y/cell_width_) * cell_count_per_row_);
if (c->GetGridId() == 0 || c->GetGridId() > max_grid_id_) {
@ -145,7 +160,22 @@ void GridService::MoveCreature(Creature* c)
int new_y = (int)c->GetPos().GetZ() + cell_width_;
int new_grid_id = new_x/cell_width_ + (new_y/cell_width_) * cell_count_per_row_;
if (BroderOverFlow(new_x, new_y)) {
#if 1
f8::UdpLog::Instance()->Warning
(
"MoveCreature broder over pos:%f,%f,%f new:%f,%f",
{
c->GetPos().GetX(),
c->GetPos().GetY(),
c->GetPos().GetZ(),
new_x,
new_y
}
);
return;
#else
A8_ABORT();
#endif
}
if (new_grid_id == 0 || new_grid_id > max_grid_id_) {
A8_ABORT();
@ -173,7 +203,22 @@ void GridService::AddRoomEntity(Room* room, Entity* entity)
int x = (int)entity->GetPos().GetX() + cell_width_;
int y = (int)entity->GetPos().GetZ() + cell_width_;
if (BroderOverFlow(x, y)) {
#if 1
f8::UdpLog::Instance()->Warning
(
"AddRoomEntity broder over pos:%f,%f,%f new:%f,%f",
{
entity->GetPos().GetX(),
entity->GetPos().GetY(),
entity->GetPos().GetZ(),
x,
y
}
);
return;
#else
A8_ABORT();
#endif
}
entity->SetGridId(x/cell_width_ + (y/cell_width_) * cell_count_per_row_);
if (entity->GetGridId() == 0 || entity->GetGridId() > max_grid_id_) {
@ -194,7 +239,22 @@ void GridService::AddPermanentEntity(Entity* entity)
int x = (int)entity->GetPos().GetX() + cell_width_;
int y = (int)entity->GetPos().GetZ() + cell_width_;
if (BroderOverFlow(x, y)) {
#if 1
f8::UdpLog::Instance()->Warning
(
"AddPermanentEntity broder over pos:%f,%f,%f new:%f,%f",
{
entity->GetPos().GetX(),
entity->GetPos().GetY(),
entity->GetPos().GetZ(),
x,
y
}
);
return;
#else
A8_ABORT();
#endif
}
entity->SetGridId(x/cell_width_ + (y/cell_width_) * cell_count_per_row_);
if (entity->GetGridId() == 0 || entity->GetGridId() > max_grid_id_) {
@ -398,7 +458,22 @@ void GridService::MoveBullet(Bullet* bullet)
int new_y = (int)bullet->GetPos().GetZ() + cell_width_;
int new_grid_id = new_x/cell_width_ + (new_y/cell_width_) * cell_count_per_row_;
if (BroderOverFlow(new_x, new_y)) {
#if 1
f8::UdpLog::Instance()->Warning
(
"MoveBullet broder over pos:%f,%f,%f new:%f,%f",
{
bullet->GetPos().GetX(),
bullet->GetPos().GetY(),
bullet->GetPos().GetZ(),
new_x,
new_y
}
);
return;
#else
A8_ABORT();
#endif
}
if (new_grid_id == 0 || new_grid_id > max_grid_id_) {
A8_ABORT();