From 653c1b8acd83e6e37e2c08119b153f215c72bf87 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Mon, 21 Apr 2014 17:00:51 +0000 Subject: [PATCH] Classic: prevent visibility overflow on sloped ceilings/floors at large distances. git-svn-id: https://svn.eduke32.com/eduke32@4453 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/engine.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/polymer/eduke32/build/src/engine.c b/polymer/eduke32/build/src/engine.c index f4f4ef193..448a45cc2 100644 --- a/polymer/eduke32/build/src/engine.c +++ b/polymer/eduke32/build/src/engine.c @@ -4416,10 +4416,16 @@ static void grouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat) asm1 = -(globalzd>>(16-BITSOFPRECISION)); - globvis = globalvisibility; - if (sec->visibility != 0) globvis = mulscale4(globvis, (uint8_t)(sec->visibility+16)); - globvis = mulscale13(globvis,daz); - globvis = mulscale16(globvis,xdimscale); + { + int32_t vis = globalvisibility; + int64_t lvis; + + if (sec->visibility != 0) vis = mulscale4(vis, (uint8_t)(sec->visibility+16)); + lvis = ((uint64_t)vis*daz) >> 13; + lvis = (lvis * xdimscale) >> 16; + globvis = lvis > INT32_MAX ? INT32_MAX : lvis; + } + j = FP_OFF(palookup[globalpal]); setupslopevlin_alsotrans((picsiz[globalpicnum]&15) + ((picsiz[globalpicnum]>>4)<<8),