From 8ab9960ca08caaee4b26d7fc290a5dab6e295296 Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Sun, 24 Dec 2023 17:22:01 -0700 Subject: [PATCH] lightpreview: don't crash when vis is run more than once --- include/vis/vis.hh | 1 + vis/vis.cc | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/include/vis/vis.hh b/include/vis/vis.hh index b3ed0603..84e444cf 100644 --- a/include/vis/vis.hh +++ b/include/vis/vis.hh @@ -297,5 +297,6 @@ public: extern settings::vis_settings vis_options; +void vis_reset(); int vis_main(int argc, const char **argv); int vis_main(const std::vector &args); diff --git a/vis/vis.cc b/vis/vis.cc index b0e3e42e..ea06594a 100644 --- a/vis/vis.cc +++ b/vis/vis.cc @@ -677,9 +677,39 @@ static void LoadPortals(const fs::path &name, mbsp_t *bsp) void vis_reset() { - // FIXME: clear other data + numportals = 0; + portalleafs = 0; + portalleafs_real = 0; + + portals.clear(); + leafs.clear(); + + vismap.clear(); + + originalvismapsize = 0; + + uncompressed.clear(); + + leafbytes = 0; + leaflongs = 0; + leafbytes_real = 0; vis_options.reset(); + + portalfile = fs::path(); + statefile = fs::path(); + statetmpfile = fs::path(); + + portalIndex = 0; + + starttime = time_point(); + endtime = time_point(); + statetime = time_point(); + + stateinterval = duration(); + + totalvis = 0; + compressed.clear(); } int vis_main(int argc, const char **argv)