Polymost: fix mirror-related oob access analogous to r1872's fix for classic.

When drawing from inside the mirror, there may be no 'bunches' (BUILD lingo,
not TROR ones) collected, but following code used the first one unconditionally.

git-svn-id: https://svn.eduke32.com/eduke32@2427 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-03-08 19:15:03 +00:00
parent 9f78a773f1
commit 07426ccc2a
2 changed files with 11 additions and 5 deletions

View file

@ -7943,7 +7943,7 @@ int32_t initengine(void)
// for (i=0; i<MAXPALOOKUPS; i++) palookup[i] = NULL;
/*
clearbuf(&waloff[0],(int32_t)MAXTILES,0L);
Bmemset(waloff, 0, sizeof(waloff));
clearbuf(&show2dsector[0],(int32_t)((MAXSECTORS+3)>>5),0L);
clearbuf(&show2dsprite[0],(int32_t)((MAXSPRITES+3)>>5),0L);
@ -8228,6 +8228,7 @@ void drawrooms(int32_t daposx, int32_t daposy, int32_t daposz,
if (inpreparemirror)
{
// INPREPAREMIRROR_NO_BUNCHES
// numbunches==0 can happen if the mirror is far away... the game code decides
// to draw it, but scansector gets zero bunches. Result: big screwup!
// Leave inpreparemirror as is, it's restored by completemirror.

View file

@ -4604,10 +4604,15 @@ void polymost_drawrooms()
{
grhalfxdown10x = -grhalfxdown10;
inpreparemirror = 0;
polymost_drawalls(0);
numbunches--;
bunchfirst[0] = bunchfirst[numbunches];
bunchlast[0] = bunchlast[numbunches];
// see engine.c: INPREPAREMIRROR_NO_BUNCHES
if (numbunches > 0)
{
polymost_drawalls(0);
numbunches--;
bunchfirst[0] = bunchfirst[numbunches];
bunchlast[0] = bunchlast[numbunches];
}
}
else
grhalfxdown10x = grhalfxdown10;