In dosetaspect(), bail out calculating radarang2[] instead of failing assertion.

When this happens, parallaxmodes other than 0 will be unavailable and silently
draw as parallaxmode 0.  This usually happens with extremely wide resolutions.

git-svn-id: https://svn.eduke32.com/eduke32@2990 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-09-02 14:10:55 +00:00
parent dd681886c3
commit 1fdc464568

View file

@ -157,6 +157,7 @@ static char *artptrs[MAXTILEFILES];
# define B_ENGINE_STATIC static # define B_ENGINE_STATIC static
#endif #endif
static int32_t no_radarang2 = 0;
static int16_t radarang2[MAXXDIM]; static int16_t radarang2[MAXXDIM];
B_ENGINE_STATIC uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256]; B_ENGINE_STATIC uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[4096+256];
const char pow2char[8] = {1,2,4,8,16,32,64,128}; const char pow2char[8] = {1,2,4,8,16,32,64,128};
@ -4412,7 +4413,7 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i
{ {
if (x == -1) x = xb1[z]; if (x == -1) x = xb1[z];
if (parallaxtype == 0) if (parallaxtype == 0 || no_radarang2)
{ {
n = mulscale16(xdimenrecip,viewingrange); n = mulscale16(xdimenrecip,viewingrange);
for (j=xb1[z]; j<=xb2[z]; j++) for (j=xb1[z]; j<=xb2[z]; j++)
@ -4423,7 +4424,8 @@ static void parascan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat, i
for (j=xb1[z]; j<=xb2[z]; j++) for (j=xb1[z]; j<=xb2[z]; j++)
lplc[j] = ((radarang2[j]+globalang)&2047)>>k; lplc[j] = ((radarang2[j]+globalang)&2047)>>k;
} }
if (parallaxtype == 2)
if (parallaxtype == 2 && !no_radarang2)
{ {
n = mulscale16(xdimscale,viewingrange); n = mulscale16(xdimscale,viewingrange);
for (j=xb1[z]; j<=xb2[z]; j++) for (j=xb1[z]; j<=xb2[z]; j++)
@ -7446,7 +7448,7 @@ static inline void initksqrt(void)
// //
static void dosetaspect(void) static void dosetaspect(void)
{ {
int32_t i, j, k, x, xinc; int32_t i, j;
if (xyaspect != oxyaspect) if (xyaspect != oxyaspect)
{ {
@ -7460,21 +7462,40 @@ static void dosetaspect(void)
horizlookup2[i] = divscale14(klabs(horizlookup[i]),j); horizlookup2[i] = divscale14(klabs(horizlookup[i]),j);
} }
} }
if ((xdimen != oxdimen) || (viewingrange != oviewingrange))
if (xdimen != oxdimen || viewingrange != oviewingrange)
{ {
int32_t k, x, xinc;
no_radarang2 = 0;
oxdimen = xdimen; oxdimen = xdimen;
oviewingrange = viewingrange; oviewingrange = viewingrange;
xinc = mulscale32(viewingrange*320,xdimenrecip); xinc = mulscale32(viewingrange*320,xdimenrecip);
x = (640<<16)-mulscale1(xinc,xdimen); x = (640<<16)-mulscale1(xinc,xdimen);
for (i=0; i<xdimen; i++) for (i=0; i<xdimen; i++)
{ {
j = (x&65535); k = (x>>16); x += xinc; j = (x&65535); k = (x>>16); x += xinc;
Bassert(k >= 0 && k < (int32_t)(sizeof(radarang)/sizeof(radarang[0]))-1);
if (j != 0) j = mulscale16(radarang[k+1]-radarang[k], j); if (k < 0 || k >= (int32_t)(sizeof(radarang)/sizeof(radarang[0]))-1)
{
no_radarang2 = 1;
#ifdef DEBUGGINGAIDS
if (editstatus)
initprintf("no rad2\n");
#endif
break;
}
if (j != 0)
j = mulscale16(radarang[k+1]-radarang[k], j);
radarang2[i] = (int16_t)((radarang[k]+j)>>6); radarang2[i] = (int16_t)((radarang[k]+j)>>6);
} }
for (i=1; i<(int32_t)(sizeof(distrecip)/sizeof(distrecip[0])); i++) for (i=1; i<(int32_t)(sizeof(distrecip)/sizeof(distrecip[0])); i++)
distrecip[i] = divscale20(xdimen,i); distrecip[i] = divscale20(xdimen,i);
nytooclose = xdimen*2100; nytooclose = xdimen*2100;
nytoofar = 65536*16384-1048576; nytoofar = 65536*16384-1048576;
} }