Factor out two nearly identical pieces of code in game.c and gameexec.c

into G_HandleMirror().

git-svn-id: https://svn.eduke32.com/eduke32@2217 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2011-12-28 20:33:40 +00:00
parent 7c245875cb
commit 8007da7190
3 changed files with 59 additions and 89 deletions

View File

@ -3314,11 +3314,63 @@ void G_AnalyzeSprites(void)
}
#endif
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)
#endif
)
{
int32_t j, i = 0, k, dst = 0x7fffffff;
for (k=g_mirrorCount-1; k>=0; k--)
{
j = klabs(wall[g_mirrorWall[k]].x - x);
j += klabs(wall[g_mirrorWall[k]].y - y);
if (j < dst) dst = j, i = k;
}
if (wall[g_mirrorWall[i]].overpicnum == MIRROR)
{
int32_t tposx,tposy;
int16_t tang;
preparemirror(x,y,z,a,horiz,g_mirrorWall[i],g_mirrorSector[i],&tposx,&tposy,&tang);
j = visibility;
visibility = (j>>1) + (j>>2);
if (getrendermode()==0)
{
yax_preparedrawrooms();
drawrooms(tposx,tposy,z,tang,horiz,g_mirrorSector[i]+MAXSECTORS);
g_yax_smoothratio = smoothratio;
yax_drawrooms(G_AnalyzeSprites, horiz, g_mirrorSector[i]);
}
#ifdef USE_OPENGL
else
drawrooms(tposx,tposy,ud.camera.z,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS);
// XXX: Sprites don't get drawn with TROR/Polymost
#endif
display_mirror = 1;
G_DoSpriteAnimations(tposx,tposy,tang,smoothratio);
display_mirror = 0;
drawmasks();
completemirror(); //Reverse screen x-wise in this function
visibility = j;
}
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
}
}
void G_DrawRooms(int32_t snum, int32_t smoothratio)
{
int32_t dst,j,fz,cz;
int32_t tposx,tposy,i;
int16_t k;
int32_t j,fz,cz;
int32_t i;
DukePlayer_t *p = g_player[snum].ps;
int16_t tang;
int32_t tiltcx,tiltcy,tiltcs=0; // JBF 20030807
@ -3540,50 +3592,7 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
if (apScriptGameEvent[EVENT_DISPLAYROOMS])
VM_OnEvent(EVENT_DISPLAYROOMS, g_player[screenpeek].ps->i, screenpeek, -1);
if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
#ifdef USE_OPENGL
&& (getrendermode() != 4)
#endif
)
{
dst = 0x7fffffff;
i = 0;
for (k=g_mirrorCount-1; k>=0; k--)
{
j = klabs(wall[g_mirrorWall[k]].x-ud.camera.x);
j += klabs(wall[g_mirrorWall[k]].y-ud.camera.y);
if (j < dst) dst = j, i = k;
}
if (wall[g_mirrorWall[i]].overpicnum == MIRROR)
{
preparemirror(ud.camera.x,ud.camera.y,ud.camera.z,ud.cameraang,ud.camerahoriz,g_mirrorWall[i],g_mirrorSector[i],&tposx,&tposy,&tang);
j = visibility;
visibility = (j>>1) + (j>>2);
if (getrendermode()==0)
{
yax_preparedrawrooms();
drawrooms(tposx,tposy,ud.camera.z,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS);
g_yax_smoothratio = smoothratio;
yax_drawrooms(G_AnalyzeSprites, ud.camerahoriz, g_mirrorSector[i]);
}
#ifdef USE_OPENGL
else
drawrooms(tposx,tposy,ud.camera.z,tang,ud.camerahoriz,g_mirrorSector[i]+MAXSECTORS);
#endif
display_mirror = 1;
G_DoSpriteAnimations(tposx,tposy,tang,smoothratio);
display_mirror = 0;
drawmasks();
completemirror(); //Reverse screen x-wise in this function
visibility = j;
}
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
}
G_HandleMirror(ud.camera.x, ud.camera.y, ud.camera.z, ud.cameraang, ud.camerahoriz, smoothratio);
G_SE40(smoothratio);

View File

@ -240,7 +240,7 @@ extern uint8_t *basepaltable[BASEPALCOUNT];
extern user_defs ud;
extern int32_t g_yax_smoothratio;
//extern int32_t g_yax_smoothratio;
int32_t A_CheckInventorySprite(spritetype *s);
int32_t A_InsertSprite(int32_t whatsect,int32_t s_x,int32_t s_y,int32_t s_z,int32_t s_pn,int32_t s_s,int32_t s_xr,int32_t s_yr,int32_t s_a,int32_t s_ve,int32_t s_zv,int32_t s_ow,int32_t s_ss);
@ -275,6 +275,7 @@ void G_DisplayRest(int32_t smoothratio);
void G_DoSpriteAnimations(int32_t x,int32_t y,int32_t a,int32_t smoothratio);
void G_DrawBackground(void);
void G_DrawFrags(void);
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio);
void G_DrawRooms(int32_t snum,int32_t smoothratio);
void G_DrawTXDigiNumZ(int32_t starttile,int32_t x,int32_t y,int32_t n,int32_t s,int32_t pal,int32_t cs,int32_t x1,int32_t y1,int32_t x2,int32_t y2,int32_t z);
void G_DrawTile(int32_t x,int32_t y,int32_t tilenum,int32_t shade,int32_t orientation);

View File

@ -2372,47 +2372,7 @@ nullquote:
#endif
G_DoInterpolations(smoothratio);
if (((gotpic[MIRROR>>3]&(1<<(MIRROR&7))) > 0)
#if defined(POLYMER) && defined(USE_OPENGL)
&& (getrendermode() != 4)
#endif
)
{
int32_t j, i = 0, k, dst = 0x7fffffff;
for (k=g_mirrorCount-1; k>=0; k--)
{
j = klabs(wall[g_mirrorWall[k]].x-x);
j += klabs(wall[g_mirrorWall[k]].y-y);
if (j < dst) dst = j, i = k;
}
if (wall[g_mirrorWall[i]].overpicnum == MIRROR)
{
int32_t tposx,tposy;
int16_t tang;
preparemirror(x,y,z,a,horiz,g_mirrorWall[i],g_mirrorSector[i],&tposx,&tposy,&tang);
j = visibility;
visibility = (j>>1) + (j>>2);
yax_preparedrawrooms();
drawrooms(tposx,tposy,z,tang,horiz,g_mirrorSector[i]+MAXSECTORS);
g_yax_smoothratio = smoothratio;
yax_drawrooms(G_AnalyzeSprites, horiz, g_mirrorSector[i]);
display_mirror = 1;
G_DoSpriteAnimations(tposx,tposy,tang,smoothratio);
display_mirror = 0;
drawmasks();
completemirror(); //Reverse screen x-wise in this function
visibility = j;
}
gotpic[MIRROR>>3] &= ~(1<<(MIRROR&7));
}
G_HandleMirror(x, y, z, a, horiz, smoothratio);
#ifdef POLYMER
if (getrendermode() == 4)
polymer_setanimatesprites(G_DoSpriteAnimations, x,y,a,smoothratio);