// 区块二进制:height.raw / tile.raw / attr.atr / water.wtr。 // 真值来源:PRTerrainLib/Terrain.cpp(LoadHeightMap / RAW_LoadTileMap / LoadAttrMap / // LoadWaterMapFile)+ Terrain.h / TerrainType.h 常量。SHINSOO §5.3。 // // XSIZE = 128 // height.raw : 无头,u16 LE [131*131] (HEIGHTMAP_RAW = XSIZE+3) // tile.raw : 无头,u8 [258*258] (TILEMAP_RAW = XSIZE*2+2) // attr.atr : 6B 头 {u16 magic=2634, u16 w=256, u16 h=256} + u8 [256*256] // water.wtr : 7B 头 {u16 magic=5426, u16 w=128, u16 h=128, u8 layers} // + u8 [128*128] + layers×(u16 或 u32) 层高 #pragma once #include #include #include namespace fmt { constexpr int HEIGHTMAP_RAW_XY = 131; // 128+3 constexpr int TILEMAP_RAW_XY = 258; // 128*2+2 constexpr int ATTRMAP_XY = 256; // 128*2 constexpr int WATERMAP_XY = 128; constexpr uint16_t ATTR_MAGIC = 2634; constexpr uint16_t WATER_MAGIC = 5426; struct HeightMap { std::vector raw; // 131*131, 行主序(含 1 圈边界样本) uint16_t at(int sx, int sy) const { // 与 Terrain.h GetHeight 一致:+1 偏移 return raw[(sy + 1) * HEIGHTMAP_RAW_XY + (sx + 1)]; } }; struct TileMap { std::vector raw; }; // 258*258 struct AttrMap { std::vector data; }; // 256*256(去头) struct WaterMap { uint8_t layer_count = 0; std::vector ids; // 128*128;0xFF = 无水 std::vector heights; // layer_count 个 }; bool load_height_map(const std::string& path, HeightMap& out, std::string* err); bool load_tile_map(const std::string& path, TileMap& out, std::string* err); bool load_attr_map(const std::string& path, AttrMap& out, std::string* err); bool load_water_map(const std::string& path, WaterMap& out, std::string* err); } // namespace fmt