mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-26 03:30:46 +00:00
Clean up legacy ROR code and introduce LEGACY_ROR define in game.h.
Also, bound-check two .yvel meant as sprite indices in actors.c. git-svn-id: https://svn.eduke32.com/eduke32@4228 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
parent
9b045deb4b
commit
2dd9b7e495
4 changed files with 71 additions and 78 deletions
|
@ -2781,7 +2781,7 @@ ACTOR_STATIC void Proj_MoveCustom(int32_t i)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(proj->workslike & PROJECTILE_BOUNCESOFFWALLS) &&
|
if (!(proj->workslike & PROJECTILE_BOUNCESOFFWALLS) &&
|
||||||
s->yvel >= 0 && sprite[s->yvel].sectnum != MAXSECTORS)
|
(unsigned)s->yvel < MAXSPRITES && sprite[s->yvel].sectnum != MAXSECTORS)
|
||||||
if (FindDistance2D(s->x-sprite[s->yvel].x, s->y-sprite[s->yvel].y) < 256)
|
if (FindDistance2D(s->x-sprite[s->yvel].x, s->y-sprite[s->yvel].y) < 256)
|
||||||
j = 49152|s->yvel;
|
j = 49152|s->yvel;
|
||||||
|
|
||||||
|
@ -3059,7 +3059,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (s->picnum == RPG && s->yvel >= 0)
|
if (s->picnum == RPG && (unsigned)s->yvel < MAXSPRITES)
|
||||||
if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256)
|
if (FindDistance2D(s->x-sprite[s->yvel].x,s->y-sprite[s->yvel].y) < 256)
|
||||||
j = 49152|s->yvel;
|
j = 49152|s->yvel;
|
||||||
|
|
||||||
|
|
|
@ -4026,22 +4026,55 @@ void G_DrawBackground(void)
|
||||||
pus = pub = NUMPAGES;
|
pus = pub = NUMPAGES;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t ror_sprite = -1;
|
#ifdef LEGACY_ROR
|
||||||
|
|
||||||
extern float r_ambientlight;
|
|
||||||
|
|
||||||
char ror_protectedsectors[MAXSECTORS];
|
char ror_protectedsectors[MAXSECTORS];
|
||||||
static int32_t drawing_ror = 0;
|
static int32_t drawing_ror = 0;
|
||||||
|
static int32_t ror_sprite = -1;
|
||||||
|
|
||||||
|
static void G_OROR_DupeSprites(const spritetype *sp)
|
||||||
|
{
|
||||||
|
// dupe the sprites touching the portal to the other sector
|
||||||
|
int32_t k;
|
||||||
|
const spritetype *refsp;
|
||||||
|
|
||||||
|
if ((unsigned)sp->yvel >= (unsigned)playerswhenstarted)
|
||||||
|
return;
|
||||||
|
|
||||||
|
refsp = &sprite[sp->yvel];
|
||||||
|
|
||||||
|
for (SPRITES_OF_SECT(sp->sectnum, k))
|
||||||
|
{
|
||||||
|
if (spritesortcnt >= MAXSPRITESONSCREEN)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (sprite[k].picnum != SECTOREFFECTOR && sprite[k].z >= sp->z)
|
||||||
|
{
|
||||||
|
Bmemcpy(&tsprite[spritesortcnt], &sprite[k], sizeof(spritetype));
|
||||||
|
|
||||||
|
tsprite[spritesortcnt].x += (refsp->x - sp->x);
|
||||||
|
tsprite[spritesortcnt].y += (refsp->y - sp->y);
|
||||||
|
tsprite[spritesortcnt].z = tsprite[spritesortcnt].z - sp->z + actor[sp->yvel].ceilingz;
|
||||||
|
tsprite[spritesortcnt].sectnum = refsp->sectnum;
|
||||||
|
tsprite[spritesortcnt].owner = k;
|
||||||
|
|
||||||
|
// OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsprite[spritesortcnt].picnum,tsprite[spritesortcnt].x,tsprite[spritesortcnt].y,tsprite[spritesortcnt].z);
|
||||||
|
spritesortcnt++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void G_SE40(int32_t smoothratio)
|
static void G_SE40(int32_t smoothratio)
|
||||||
{
|
{
|
||||||
if (ror_sprite != -1)
|
if ((unsigned)ror_sprite < MAXSPRITES)
|
||||||
{
|
{
|
||||||
int32_t x, y, z;
|
int32_t x, y, z;
|
||||||
int16_t sect;
|
int16_t sect;
|
||||||
int32_t level = 0;
|
int32_t level = 0;
|
||||||
spritetype *sp = &sprite[ror_sprite];
|
const spritetype *const sp = &sprite[ror_sprite];
|
||||||
int32_t sprite2 = sp->yvel;
|
const int32_t sprite2 = sp->yvel;
|
||||||
|
|
||||||
|
if ((unsigned)sprite2 >= MAXSPRITES)
|
||||||
|
return;
|
||||||
|
|
||||||
if (klabs(sector[sp->sectnum].floorz - sp->z) < klabs(sector[sprite[sprite2].sectnum].floorz - sprite[sprite2].z))
|
if (klabs(sector[sp->sectnum].floorz - sp->z) < klabs(sector[sprite[sprite2].sectnum].floorz - sprite[sprite2].z))
|
||||||
level = 1;
|
level = 1;
|
||||||
|
@ -4056,6 +4089,7 @@ static void G_SE40(int32_t smoothratio)
|
||||||
if (sect != -1)
|
if (sect != -1)
|
||||||
{
|
{
|
||||||
int32_t renderz, picnum;
|
int32_t renderz, picnum;
|
||||||
|
// XXX: PK: too large stack allocation for my taste
|
||||||
int16_t backupstat[MAXSECTORS];
|
int16_t backupstat[MAXSECTORS];
|
||||||
int32_t backupz[MAXSECTORS];
|
int32_t backupz[MAXSECTORS];
|
||||||
int32_t i;
|
int32_t i;
|
||||||
|
@ -4111,35 +4145,12 @@ static void G_SE40(int32_t smoothratio)
|
||||||
if (getrendermode() == REND_POLYMER)
|
if (getrendermode() == REND_POLYMER)
|
||||||
polymer_setanimatesprites(G_DoSpriteAnimations, CAMERA(pos.x), CAMERA(pos.y), CAMERA(ang), smoothratio);
|
polymer_setanimatesprites(G_DoSpriteAnimations, CAMERA(pos.x), CAMERA(pos.y), CAMERA(ang), smoothratio);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
drawrooms(sprite[sprite2].x + x, sprite[sprite2].y + y,
|
drawrooms(sprite[sprite2].x + x, sprite[sprite2].y + y,
|
||||||
z + renderz, CAMERA(ang), CAMERA(horiz), sect);
|
z + renderz, CAMERA(ang), CAMERA(horiz), sect);
|
||||||
drawing_ror = 1 + level;
|
drawing_ror = 1 + level;
|
||||||
|
|
||||||
// dupe the sprites touching the portal to the other sector
|
|
||||||
|
|
||||||
if (drawing_ror == 2) // viewing from top
|
if (drawing_ror == 2) // viewing from top
|
||||||
{
|
G_OROR_DupeSprites(sp);
|
||||||
int32_t k = headspritesect[sp->sectnum];
|
|
||||||
|
|
||||||
while (k != -1 && spritesortcnt < MAXSPRITESONSCREEN)
|
|
||||||
{
|
|
||||||
if (sprite[k].picnum != SECTOREFFECTOR && (sprite[k].z >= sp->z))
|
|
||||||
{
|
|
||||||
Bmemcpy((spritetype *)&tsprite[spritesortcnt],(spritetype *)&sprite[k],sizeof(spritetype));
|
|
||||||
|
|
||||||
tsprite[spritesortcnt].x += (sprite[sp->yvel].x-sp->x);
|
|
||||||
tsprite[spritesortcnt].y += (sprite[sp->yvel].y-sp->y);
|
|
||||||
tsprite[spritesortcnt].z = tsprite[spritesortcnt].z - sp->z + actor[sp->yvel].ceilingz;
|
|
||||||
tsprite[spritesortcnt].sectnum = sprite[sp->yvel].sectnum;
|
|
||||||
tsprite[spritesortcnt].owner = k;
|
|
||||||
|
|
||||||
//OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsprite[spritesortcnt].picnum,tsprite[spritesortcnt].x,tsprite[spritesortcnt].y,tsprite[spritesortcnt].z);
|
|
||||||
spritesortcnt++;
|
|
||||||
}
|
|
||||||
k = nextspritesect[k];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
G_DoSpriteAnimations(CAMERA(pos.x),CAMERA(pos.y),CAMERA(ang),smoothratio);
|
G_DoSpriteAnimations(CAMERA(pos.x),CAMERA(pos.y),CAMERA(ang),smoothratio);
|
||||||
drawmasks();
|
drawmasks();
|
||||||
|
@ -4166,6 +4177,7 @@ static void G_SE40(int32_t smoothratio)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio)
|
void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, int32_t smoothratio)
|
||||||
{
|
{
|
||||||
|
@ -4258,36 +4270,6 @@ void G_HandleMirror(int32_t x, int32_t y, int32_t z, int32_t a, int32_t horiz, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void G_OROR_DupeSprites(void)
|
|
||||||
{
|
|
||||||
// dupe the sprites touching the portal to the other sector
|
|
||||||
// viewing from bottom
|
|
||||||
int32_t k;
|
|
||||||
spritetype *sp;
|
|
||||||
|
|
||||||
if ((unsigned) ror_sprite >= MAXSPRITES || drawing_ror != 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
sp = &sprite[ror_sprite];
|
|
||||||
|
|
||||||
for (k = headspritesect[sp->sectnum]; k != -1; k = nextspritesect[k])
|
|
||||||
{
|
|
||||||
if (sprite[k].picnum != SECTOREFFECTOR && (sprite[k].z >= sp->z))
|
|
||||||
{
|
|
||||||
Bmemcpy(&tsprite[spritesortcnt], &sprite[k], sizeof(spritetype));
|
|
||||||
|
|
||||||
tsprite[spritesortcnt].x += (sprite[sp->yvel].x - sp->x);
|
|
||||||
tsprite[spritesortcnt].y += (sprite[sp->yvel].y - sp->y);
|
|
||||||
tsprite[spritesortcnt].z = tsprite[spritesortcnt].z - sp->z + actor[sp->yvel].ceilingz;
|
|
||||||
tsprite[spritesortcnt].sectnum = sprite[sp->yvel].sectnum;
|
|
||||||
tsprite[spritesortcnt].owner = k;
|
|
||||||
|
|
||||||
//OSD_Printf("duped sprite of pic %d at %d %d %d\n",tsprite[spritesortcnt].picnum,tsprite[spritesortcnt].x,tsprite[spritesortcnt].y,tsprite[spritesortcnt].z);
|
|
||||||
spritesortcnt++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef USE_OPENGL
|
#ifdef USE_OPENGL
|
||||||
static void G_ReadGLFrame(void)
|
static void G_ReadGLFrame(void)
|
||||||
{
|
{
|
||||||
|
@ -4375,9 +4357,9 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
|
||||||
|
|
||||||
CAMERA(ang) = actor[ud.camerasprite].tempang +
|
CAMERA(ang) = actor[ud.camerasprite].tempang +
|
||||||
mulscale16(((s->ang+1024-actor[ud.camerasprite].tempang)&2047)-1024, smoothratio);
|
mulscale16(((s->ang+1024-actor[ud.camerasprite].tempang)&2047)-1024, smoothratio);
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
G_SE40(smoothratio);
|
G_SE40(smoothratio);
|
||||||
|
#endif
|
||||||
#ifdef POLYMER
|
#ifdef POLYMER
|
||||||
if (getrendermode() == REND_POLYMER)
|
if (getrendermode() == REND_POLYMER)
|
||||||
polymer_setanimatesprites(G_DoSpriteAnimations, s->x, s->y, CAMERA(ang), smoothratio);
|
polymer_setanimatesprites(G_DoSpriteAnimations, s->x, s->y, CAMERA(ang), smoothratio);
|
||||||
|
@ -4603,9 +4585,9 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
|
||||||
"other values are reserved.\n");
|
"other values are reserved.\n");
|
||||||
|
|
||||||
G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(ang), CAMERA(horiz), smoothratio);
|
G_HandleMirror(CAMERA(pos.x), CAMERA(pos.y), CAMERA(pos.z), CAMERA(ang), CAMERA(horiz), smoothratio);
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
G_SE40(smoothratio);
|
G_SE40(smoothratio);
|
||||||
|
#endif
|
||||||
#ifdef POLYMER
|
#ifdef POLYMER
|
||||||
if (getrendermode() == REND_POLYMER)
|
if (getrendermode() == REND_POLYMER)
|
||||||
polymer_setanimatesprites(G_DoSpriteAnimations, CAMERA(pos.x),CAMERA(pos.y),CAMERA(ang),smoothratio);
|
polymer_setanimatesprites(G_DoSpriteAnimations, CAMERA(pos.x),CAMERA(pos.y),CAMERA(ang),smoothratio);
|
||||||
|
@ -4619,12 +4601,14 @@ void G_DrawRooms(int32_t snum, int32_t smoothratio)
|
||||||
yax_preparedrawrooms();
|
yax_preparedrawrooms();
|
||||||
drawrooms(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(ang),CAMERA(horiz),CAMERA(sect));
|
drawrooms(CAMERA(pos.x),CAMERA(pos.y),CAMERA(pos.z),CAMERA(ang),CAMERA(horiz),CAMERA(sect));
|
||||||
yax_drawrooms(G_DoSpriteAnimations, CAMERA(sect), 0, smoothratio);
|
yax_drawrooms(G_DoSpriteAnimations, CAMERA(sect), 0, smoothratio);
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
G_OROR_DupeSprites();
|
if ((unsigned)ror_sprite < MAXSPRITES && drawing_ror == 1) // viewing from bottom
|
||||||
|
G_OROR_DupeSprites(&sprite[ror_sprite]);
|
||||||
|
#endif
|
||||||
G_DoSpriteAnimations(CAMERA(pos.x),CAMERA(pos.y),CAMERA(ang),smoothratio);
|
G_DoSpriteAnimations(CAMERA(pos.x),CAMERA(pos.y),CAMERA(ang),smoothratio);
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
drawing_ror = 0;
|
drawing_ror = 0;
|
||||||
|
#endif
|
||||||
drawmasks();
|
drawmasks();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -6293,6 +6277,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
|
||||||
|
|
||||||
switch (sp->lotag)
|
switch (sp->lotag)
|
||||||
{
|
{
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
case 40:
|
case 40:
|
||||||
case 41:
|
case 41:
|
||||||
sp->cstat = 32;
|
sp->cstat = 32;
|
||||||
|
@ -6311,6 +6296,7 @@ int32_t A_Spawn(int32_t j, int32_t pn)
|
||||||
case 46:
|
case 46:
|
||||||
ror_protectedsectors[sp->sectnum] = 1;
|
ror_protectedsectors[sp->sectnum] = 1;
|
||||||
/* XXX: fall-through intended? */
|
/* XXX: fall-through intended? */
|
||||||
|
#endif
|
||||||
case SE_49_POINT_LIGHT:
|
case SE_49_POINT_LIGHT:
|
||||||
case SE_50_SPOT_LIGHT:
|
case SE_50_SPOT_LIGHT:
|
||||||
{
|
{
|
||||||
|
@ -7081,9 +7067,9 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
|
||||||
#endif
|
#endif
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
ror_sprite = -1;
|
ror_sprite = -1;
|
||||||
|
#endif
|
||||||
for (j=spritesortcnt-1; j>=0; j--)
|
for (j=spritesortcnt-1; j>=0; j--)
|
||||||
{
|
{
|
||||||
spritetype *const t = &tsprite[j];
|
spritetype *const t = &tsprite[j];
|
||||||
|
@ -7096,8 +7082,10 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
|
||||||
if (s->lotag == 40 || s->lotag == 41)
|
if (s->lotag == 40 || s->lotag == 41)
|
||||||
{
|
{
|
||||||
t->cstat = 32768;
|
t->cstat = 32768;
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
if (ror_sprite == -1) ror_sprite = i;
|
if (ror_sprite == -1)
|
||||||
|
ror_sprite = i;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (t->lotag == SE_27_DEMO_CAM && ud.recstat == 1)
|
if (t->lotag == SE_27_DEMO_CAM && ud.recstat == 1)
|
||||||
|
|
|
@ -25,6 +25,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
|
|
||||||
#include "premap.h"
|
#include "premap.h"
|
||||||
|
|
||||||
|
// Compile game-side legacy Room over Room code?
|
||||||
|
#define LEGACY_ROR 1
|
||||||
|
|
||||||
#define USERQUOTE_LEFTOFFSET 5
|
#define USERQUOTE_LEFTOFFSET 5
|
||||||
#define USERQUOTE_RIGHTOFFSET 14
|
#define USERQUOTE_RIGHTOFFSET 14
|
||||||
|
|
||||||
|
@ -254,7 +257,9 @@ extern const char *G_DefaultRtsFile(void);
|
||||||
|
|
||||||
extern char g_modDir[BMAX_PATH];
|
extern char g_modDir[BMAX_PATH];
|
||||||
extern char inputloc;
|
extern char inputloc;
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
extern char ror_protectedsectors[MAXSECTORS];
|
extern char ror_protectedsectors[MAXSECTORS];
|
||||||
|
#endif
|
||||||
|
|
||||||
extern float r_ambientlight;
|
extern float r_ambientlight;
|
||||||
|
|
||||||
|
@ -263,7 +268,7 @@ extern int32_t althud_numberpal;
|
||||||
extern int32_t althud_numbertile;
|
extern int32_t althud_numbertile;
|
||||||
extern int32_t althud_shadows;
|
extern int32_t althud_shadows;
|
||||||
extern int32_t cacnum;
|
extern int32_t cacnum;
|
||||||
//extern int32_t drawing_ror;
|
|
||||||
extern int32_t g_Shareware;
|
extern int32_t g_Shareware;
|
||||||
#if !defined LUNATIC
|
#if !defined LUNATIC
|
||||||
extern int32_t g_cameraClock;
|
extern int32_t g_cameraClock;
|
||||||
|
|
|
@ -1028,9 +1028,9 @@ static inline void prelevel(char g)
|
||||||
G_GameExit("OUT OF MEMORY in prelevel()");
|
G_GameExit("OUT OF MEMORY in prelevel()");
|
||||||
|
|
||||||
Bmemset(show2dsector, 0, sizeof(show2dsector));
|
Bmemset(show2dsector, 0, sizeof(show2dsector));
|
||||||
|
#ifdef LEGACY_ROR
|
||||||
Bmemset(ror_protectedsectors, 0, MAXSECTORS);
|
Bmemset(ror_protectedsectors, 0, MAXSECTORS);
|
||||||
|
#endif
|
||||||
resetprestat(0,g);
|
resetprestat(0,g);
|
||||||
g_numClouds = 0;
|
g_numClouds = 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue