From 084be76825416050aeaa88ffe98d2f613ee4bc84 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Mon, 5 Oct 2015 16:19:20 +0200 Subject: [PATCH] new command mapareacheck Calculate some key values to determine map geometry viability. mapareacheck Returns different sets of statistics, depending on the keyword "what": vdelta Returns table of numbers of cubes within a certain range of vdelta differences (steepness)". First entry is "0..2 cubes steep", next is "2..4" and so on. steepest Returns the coordinates of the steepest heightfield cube. total Returns the number of non-solid cubes on the map. pprest Returns the number of cubes _not_ visible from one of the probe positions. pp (default) Returns a table of all (currently 64) probe points of the map. Each probe point is listed with: - x-coordinate - y-coordinate - floor height - area visible - volume of visible area - average height in visible area DOCREF mapareacheck --- config/scripts.cfg | 1 + source/src/world.cpp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/config/scripts.cfg b/config/scripts.cfg index 74b3cf52..d1d63ed9 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -86,6 +86,7 @@ looplist [ ] [ cmd options ] [ listcomplete $cmd (listoptions $options) ] listcomplete getvarrange "min max default" +listcomplete mapareacheck "vdelta steepest total pprest pp" looplist [ addzipmod zipmodremove zipmodgetdesc ] cmd [complete $cmd "mods" zip] // set up list of skymaps diff --git a/source/src/world.cpp b/source/src/world.cpp index 52163e24..896047d1 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -928,3 +928,36 @@ void mapmrproper(bool manual) } } COMMANDF(mapmrproper, "", () { mapmrproper(true); }); + +void mapareacheck(char *what) // "vdelta" | "steepest" | "total" | "pprest" | "pp"(default) +{ + mapareastats_s ms; + mapdim_s md; + stopwatch ti; + ti.start(); + servsqr *sw = createservworld(world, cubicsize); + calcmapdims(md, sw, ssize); + calcmapareastats(ms, sw, ssize, md); + delete[] sw; + vector res; + if(!strcasecmp(what, "vdelta")) + { + loopi(MAS_VDELTA_TABSIZE) cvecprintf(res, "%d ", ms.vdd[i]); + } + else if(!strcasecmp(what, "steepest")) cvecprintf(res, "%d.5 %d.5 %d ", ms.steepest % ssize, ms.steepest / ssize, world[ms.steepest % cubicsize].floor); + else if(!strcasecmp(what, "total")) cvecprintf(res, "%d ", ms.total); + else if(!strcasecmp(what, "pprest")) cvecprintf(res, "%d ", ms.rest); + else // default + { + loopi(MAS_GRID2) + { + int x = ms.ppp[i] % ssize, y = ms.ppp[i] / ssize, z = OUTBORD(x, y) ? 0 : S(x, y)->floor; + cvecprintf(res, "%d %d %d %d %d %.5g\n", x, y, z, ms.ppa[i], ms.ppv[i], ms.ppa[i] ? float(ms.ppv[i]) / ms.ppa[i] : 0.0f); + } + } + res.last() = '\0'; + result(res.getbuf()); +} + +COMMAND(mapareacheck, "s"); +