diff --git a/bspinfo/bspinfo.cc b/bspinfo/bspinfo.cc index c93d5620..24893742 100644 --- a/bspinfo/bspinfo.cc +++ b/bspinfo/bspinfo.cc @@ -21,12 +21,24 @@ #include #include +#include #include #include +#include #include using namespace nlohmann; +static std::string hex_string(const uint8_t* bytes, const size_t count) { + std::stringstream str; + + for (size_t i = 0; i < count; ++i) { + fmt::print(str, "{:x}", bytes[i]); + } + + return str.str(); +} + static void serialize_bsp(const mbsp_t &bsp, const char *name) { json j = json::object(); @@ -46,6 +58,18 @@ static void serialize_bsp(const mbsp_t &bsp, const char *name) { model.push_back({ "numfaces", src_model.numfaces }); } } + + if (bsp.visdatasize) { + j["visdata"] = hex_string(bsp.dvisdata, bsp.visdatasize); + } + + if (bsp.lightdatasize) { + j["lightdata"] = hex_string(bsp.dlightdata, bsp.lightdatasize); + } + + if (bsp.entdatasize) { + j["entdata"] = std::string(bsp.dentdata, static_cast(bsp.entdatasize)); + } if (bsp.numleafs) { json &leafs = (j.emplace("leafs", json::array())).first.value(); @@ -81,6 +105,16 @@ static void serialize_bsp(const mbsp_t &bsp, const char *name) { } } + if (bsp.numvertexes) { + json &vertexes = (j.emplace("vertexes", json::array())).first.value(); + + for (int32_t i = 0; i < bsp.numvertexes; i++) { + auto &src_vertex = bsp.dvertexes[i]; + + vertexes.insert(vertexes.end(), json::array({src_vertex.point[0], src_vertex.point[1], src_vertex.point[2]})); + } + } + if (bsp.numnodes) { json &nodes = (j.emplace("nodes", json::array())).first.value();