From 98a020fde7121285cbed739c1776874ccb1cc8ef Mon Sep 17 00:00:00 2001 From: Eric Wasylishen Date: Fri, 4 Mar 2016 15:38:08 -0700 Subject: [PATCH] vis: fix ambient sounds when using func_detail, broken in tyrutils-ericw-v0.15.3 --- include/vis/vis.h | 1 + vis/soundpvs.c | 6 +++++- vis/vis.c | 5 ++--- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/include/vis/vis.h b/include/vis/vis.h index 5e92d34e..72c3918d 100644 --- a/include/vis/vis.h +++ b/include/vis/vis.h @@ -110,6 +110,7 @@ typedef struct { extern int numportals; extern int portalleafs; extern int portalleafs_real; +extern int *clustermap; extern portal_t *portals; extern leaf_t *leafs; diff --git a/vis/soundpvs.c b/vis/soundpvs.c index 76a2352b..1f77f774 100644 --- a/vis/soundpvs.c +++ b/vis/soundpvs.c @@ -94,7 +94,11 @@ CalcAmbientSounds(bsp2_t *bsp) for (j = 0; j < NUM_AMBIENTS; j++) dists[j] = 1020; - vis = &uncompressed[i * leafbytes_real]; + if (portalleafs != portalleafs_real) { + vis = &uncompressed[clustermap[i] * leafbytes_real]; + } else { + vis = &uncompressed[i * leafbytes_real]; + } for (j = 0; j < portalleafs_real; j++) { if (!(vis[j >> 3] & (1 << (j & 7)))) diff --git a/vis/vis.c b/vis/vis.c index 7da73e4b..af81e98c 100644 --- a/vis/vis.c +++ b/vis/vis.c @@ -33,7 +33,7 @@ static byte *vismap_end; // past visfile int originalvismapsize; -byte *uncompressed; // [leafbytes_real*portalleafs_real] +byte *uncompressed; // [leafbytes_real*portalleafs] int leafbytes; // (portalleafs+63)>>3 int leaflongs; @@ -1275,8 +1275,7 @@ main(int argc, char **argv) StripExtension(statetmpfile); DefaultExtension(statetmpfile, ".vi0"); - uncompressed = malloc(leafbytes_real * portalleafs_real); - memset(uncompressed, 0, leafbytes_real * portalleafs_real); + uncompressed = calloc(portalleafs, leafbytes_real); // CalcPassages ();