This commit is contained in:
aozhiwei 2023-02-01 13:50:10 +08:00
parent dc1b5a00e8
commit 93495e51e0
2 changed files with 41 additions and 4 deletions

View File

@ -719,7 +719,6 @@ void MapInstance::LoadHeightData()
list.height() != (int)GetMapMeta()->map_height()) {
A8_ABORT();
}
std::vector<std::tuple<int, int>> height_sorted;
{
std::map<int, int> height_hash;
for (auto& itr : list.datas()) {
@ -732,6 +731,7 @@ void MapInstance::LoadHeightData()
}
}
}
std::vector<std::tuple<int, int>> height_sorted;
for (auto& pair : height_hash) {
height_sorted.push_back(std::make_tuple((int)pair.first, (int)pair.second));
}
@ -745,11 +745,46 @@ void MapInstance::LoadHeightData()
}
}
if ((int)GetMapMeta()->map_width() % MAP_HEIGHT_GRID_SIZE != 0 ||
(int)GetMapMeta()->map_height() % MAP_HEIGHT_GRID_SIZE != 0 ) {
abort();
}
grid_width_ = GetMapMeta()->map_width() / MAP_HEIGHT_GRID_SIZE;
grid_height_ = GetMapMeta()->map_height() / MAP_HEIGHT_GRID_SIZE;
height_datas_.resize(grid_width_ * grid_height_);
{
int curr_x = 0;
int curr_y = 0;
for (auto& itr : list.datas()) {
if (itr.x() != curr_x) {
abort();
}
if (itr.y() != curr_y) {
abort();
}
curr_x = itr.x() + 1;
if (itr.has_endx()) {
curr_x = itr.endx() + 1;
}
//a8::XPrintf("x:%d y:%d end_x:%d\n", {itr.x(), itr.y(), itr.endx()});
if (curr_x > (int)GetMapMeta()->map_width()) {
abort();
}
if (curr_x == (int)GetMapMeta()->map_width()) {
curr_x = 0;
++curr_y;
}
if (curr_y > (int)GetMapMeta()->map_height()) {
abort();
}
for (auto& itr2 : itr.infos()) {
}
}
if (curr_y != (int)GetMapMeta()->map_height()) {
abort();
}
}
free(p);

View File

@ -14,8 +14,8 @@ struct HeightInfo
struct GridInfo
{
bool is_perfect = false;
HeightInfo* layers = nullptr;
HeightInfo* details = nullptr;
std::vector<HeightInfo*> layers;
std::vector<std::list<HeightInfo*>> details;
};
class Entity;
@ -75,7 +75,9 @@ class MapInstance : public std::enable_shared_from_this<MapInstance>
std::vector<int> poly_ext_datas_;
std::vector<HeightInfo> height_datas_;
int grid_width_ = 0;
int grid_height_ = 0;
std::vector<GridInfo> height_datas_;
std::string map_tpl_name_;
const mt::Map* map_meta_ = nullptr;