diff --git a/server/gameserver/mapservice.cc b/server/gameserver/mapservice.cc index 4db4d26..945b8b6 100644 --- a/server/gameserver/mapservice.cc +++ b/server/gameserver/mapservice.cc @@ -90,10 +90,17 @@ void MapService::AddCollider(ColliderComponent* collider) float min_y = (collider->owner->pos + aabb._min).y - 2; float max_x = (collider->owner->pos + aabb._max).x + 2; float max_y = (collider->owner->pos + aabb._max).y + 2; + #if 1 + int min_grid_x = floor(min_x / cell_width_); + int min_grid_y = floor(min_y / cell_width_); + int max_grid_x = ceil(max_x / cell_width_); + int max_grid_y = ceil(max_y / cell_width_); + #else int min_grid_x = ceil(min_x / cell_width_) - 1; int min_grid_y = ceil(min_y / cell_width_) - 1; int max_grid_x = ceil(max_x / cell_width_) - 1; int max_grid_y = ceil(max_y / cell_width_) - 1; + #endif if (min_grid_x < 0 || max_grid_x >= map_width_) { abort(); } @@ -148,17 +155,6 @@ void MapService::RemoveCollider(ColliderComponent* collider) } } -bool MapService::Walkable(float world_x, float world_y) -{ - int grid_id = GetGridId(world_x, world_y); - if (grid_id < 0 || grid_id >= max_grid_id_) { - return false; - } - list_head& node = map_cells_[grid_id]; - return (node.next == nullptr && node.prev == nullptr) || - list_empty(&node); -} - void MapService::GetColliders(float world_x, float world_y, std::set& colliders) { int center_grid_id = GetGridId(world_x, world_y); diff --git a/server/gameserver/mapservice.h b/server/gameserver/mapservice.h index dcf71f0..6cf8cd8 100644 --- a/server/gameserver/mapservice.h +++ b/server/gameserver/mapservice.h @@ -20,7 +20,6 @@ class MapService void AddCollider(ColliderComponent* collider); void RemoveCollider(ColliderComponent* collider); - bool Walkable(float world_x, float world_y); void GetColliders(float world_x, float world_y, std::set& colliders); private: