Try to find another mirror wall if the assigned one breaks.

This fixes mirrors consisting of more than one walls not drawing when the
first assigned mirror wall breaks. It still does not let you have more
than one mirror (i.e. mirror sectors) showing up at the same time in
the scene.  Affects classic and Polymost only.

git-svn-id: https://svn.eduke32.com/eduke32@2387 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-02-25 15:59:44 +00:00
parent f524f8f98c
commit 925b27e3cd

View file

@ -3315,7 +3315,6 @@ void G_AnalyzeSprites(void)
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio)
{
if ((gotpic[MIRROR>>3]&(1<<(MIRROR&7)))
#ifdef POLYMER
&& (getrendermode() != 4)
@ -3324,6 +3323,16 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, i
{
int32_t j, i = 0, k, dst = 0x7fffffff;
if (g_mirrorCount==0)
{
// XXX: can we have g_mirrorCount==0 but gotpic'd MIRROR?
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
#ifdef DEBUGGINGAIDS
initprintf("Called G_HandleMirror() with g_mirrorCount==0!\n");
#endif
return;
}
for (k=g_mirrorCount-1; k>=0; k--)
{
j = klabs(wall[g_mirrorWall[k]].x - x);
@ -3331,6 +3340,24 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, i
if (j < dst) dst = j, i = k;
}
if (wall[g_mirrorWall[i]].overpicnum != MIRROR)
{
// try to find a new mirror wall
int32_t startwall = sector[g_mirrorSector[i]].wallptr;
int32_t endwall = startwall + sector[g_mirrorSector[i]].wallnum;
for (k=startwall; k<endwall; k++)
{
j = wall[k].nextwall;
if (j >= 0 && (wall[j].cstat&32) && wall[j].overpicnum==MIRROR) // cmp. premap.c
{
g_mirrorWall[i] = j;
break;
}
}
}
if (wall[g_mirrorWall[i]].overpicnum == MIRROR)
{
int32_t tposx,tposy;