From 443be60a747b6eaa75c8e93d9f0692a12f450f85 Mon Sep 17 00:00:00 2001 From: Jonathan Date: Fri, 22 Oct 2021 03:50:15 -0400 Subject: [PATCH] Compress texinfo a bit --- light/light.cc | 52 ++++++++++++++++++++++++++++++++----------- qbsp/map.cc | 4 ++-- qbsp/writebsp.cc | 58 +++++++++++++++++++++++++++++++++++------------- 3 files changed, 84 insertions(+), 30 deletions(-) diff --git a/light/light.cc b/light/light.cc index b2f20911..541909e4 100644 --- a/light/light.cc +++ b/light/light.cc @@ -523,19 +523,45 @@ static void LoadExtendedTexinfoFlags(const std::filesystem::path &sourcefilename auto &val = it.value(); auto &flags = extended_texinfo_flags[index]; - flags.is_skip = val.at("is_skip").get(); - flags.is_hint = val.at("is_hint").get(); - flags.no_dirt = val.at("no_dirt").get(); - flags.no_shadow = val.at("no_shadow").get(); - flags.no_bounce = val.at("no_bounce").get(); - flags.no_minlight = val.at("no_minlight").get(); - flags.no_expand = val.at("no_expand").get(); - flags.light_ignore = val.at("light_ignore").get(); - flags.phong_angle = val.at("phong_angle").get(); - flags.phong_angle_concave = val.at("phong_angle_concave").get(); - flags.minlight = val.at("minlight").get(); - flags.minlight_color = val.at("minlight_color").get(); - flags.light_alpha = val.at("light_alpha").get(); + if (val.contains("is_skip")) { + flags.is_skip = val.at("is_skip").get(); + } + if (val.contains("is_hint")) { + flags.is_hint = val.at("is_hint").get(); + } + if (val.contains("no_dirt")) { + flags.no_dirt = val.at("no_dirt").get(); + } + if (val.contains("no_shadow")) { + flags.no_shadow = val.at("no_shadow").get(); + } + if (val.contains("no_bounce")) { + flags.no_bounce = val.at("no_bounce").get(); + } + if (val.contains("no_minlight")) { + flags.no_minlight = val.at("no_minlight").get(); + } + if (val.contains("no_expand")) { + flags.no_expand = val.at("no_expand").get(); + } + if (val.contains("light_ignore")) { + flags.light_ignore = val.at("light_ignore").get(); + } + if (val.contains("phong_angle")) { + flags.phong_angle = val.at("phong_angle").get(); + } + if (val.contains("phong_angle_concave")) { + flags.phong_angle_concave = val.at("phong_angle_concave").get(); + } + if (val.contains("minlight")) { + flags.minlight = val.at("minlight").get(); + } + if (val.contains("minlight_color")) { + flags.minlight_color = val.at("minlight_color").get(); + } + if (val.contains("light_alpha")) { + flags.light_alpha = val.at("light_alpha").get(); + } } } diff --git a/qbsp/map.cc b/qbsp/map.cc index ae8d4a0a..7c6dca0a 100644 --- a/qbsp/map.cc +++ b/qbsp/map.cc @@ -2192,11 +2192,11 @@ void WriteEntitiesToString() for (auto &ep : entity.epairs) { if (ep.first.size() >= options.target_game->max_entity_key - 1) { - LogPrint("WARNING: {} at {} (approx. line {}) has long key {} ({} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, entity.mapbrush(0).face(0).linenum, ep.first, ep.first.size(), options.target_game->max_entity_key - 1); + LogPrint("WARNING: {} at {} (approx. line {}) has long key {} (length {} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, entity.mapbrush(0).face(0).linenum, ep.first, ep.first.size(), options.target_game->max_entity_key - 1); } if (ep.second.size() >= options.target_game->max_entity_value - 1) { - LogPrint("WARNING: {} at {} (approx. line {}) has long value for key {} ({} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, entity.mapbrush(0).face(0).linenum, ep.first, ep.second.size(), options.target_game->max_entity_value - 1); + LogPrint("WARNING: {} at {} (approx. line {}) has long value for key {} (length {} >= {})\n", ValueForKey(&entity, "classname"), entity.origin, entity.mapbrush(0).face(0).linenum, ep.first, ep.second.size(), options.target_game->max_entity_value - 1); } fmt::format_to(std::back_inserter(map.bsp.dentdata), "\"{}\" \"{}\"\n", ep.first, ep.second); diff --git a/qbsp/writebsp.cc b/qbsp/writebsp.cc index eb32d0ba..0e48403a 100644 --- a/qbsp/writebsp.cc +++ b/qbsp/writebsp.cc @@ -341,21 +341,49 @@ static void WriteExtendedTexinfoFlags(void) Q_assert(count == tx.outputnum.value()); // check we are outputting them in the proper sequence - texinfofile[std::to_string(*tx.outputnum)] = { - { "is_skip", tx.flags.is_skip }, - { "is_hint", tx.flags.is_hint }, - { "no_dirt", tx.flags.no_dirt }, - { "no_shadow", tx.flags.no_shadow }, - { "no_bounce", tx.flags.no_bounce }, - { "no_minlight", tx.flags.no_minlight }, - { "no_expand", tx.flags.no_expand }, - { "light_ignore", tx.flags.light_ignore }, - { "phong_angle", tx.flags.phong_angle }, - { "phong_angle_concave", tx.flags.phong_angle_concave }, - { "minlight", tx.flags.minlight }, - { "minlight_color", tx.flags.minlight_color }, - { "light_alpha", tx.flags.light_alpha } - }; + json t = json::object(); + + if (tx.flags.is_skip) { + t["is_skip"] = tx.flags.is_skip; + } + if (tx.flags.is_hint) { + t["is_hint"] = tx.flags.is_hint; + } + if (tx.flags.no_dirt) { + t["no_dirt"] = tx.flags.no_dirt; + } + if (tx.flags.no_shadow) { + t["no_shadow"] = tx.flags.no_shadow; + } + if (tx.flags.no_bounce) { + t["no_bounce"] = tx.flags.no_bounce; + } + if (tx.flags.no_minlight) { + t["no_minlight"] = tx.flags.no_minlight; + } + if (tx.flags.no_expand) { + t["no_expand"] = tx.flags.no_expand; + } + if (tx.flags.light_ignore) { + t["light_ignore"] = tx.flags.light_ignore; + } + if (tx.flags.phong_angle) { + t["phong_angle"] = tx.flags.phong_angle; + } + if (tx.flags.phong_angle_concave) { + t["phong_angle_concave"] = tx.flags.phong_angle_concave; + } + if (tx.flags.minlight) { + t["minlight"] = tx.flags.minlight; + } + if (!qv::emptyExact(tx.flags.minlight_color)) { + t["minlight_color"] = tx.flags.minlight_color; + } + if (tx.flags.light_alpha) { + t["light_alpha"] = tx.flags.light_alpha; + } + + texinfofile[std::to_string(*tx.outputnum)].swap(t); count++; } Q_assert(count == map.bsp.texinfo.size());