Tweak the behavior of viewscreens to what is more logical IMO.

- At a given time, at most one viewscreen may display TILE_VIEWSCR, namely
  that one which is g_curViewscreen
- sync kinds of distance to compare against VIEWSCREEN_ACTIVE_DISTANCE (was
  Manhattan vs. dist(), now both the latter)
- fix resetting to VIEWSCREEN tile when player is greater from it than that
  distance. When the player is closer to it again, it is *not* reset to
  TILE_VIEWSCR.
- more sync'd g_curViewscreen and sprite[i].yvel (for 'i' being the viewscreen
  sprite)

Note: in a multiplayer context, this needs to be thought about once more.

git-svn-id: https://svn.eduke32.com/eduke32@4843 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2014-12-26 17:30:00 +00:00
parent 843894dd57
commit 51fe706907
4 changed files with 28 additions and 25 deletions

View file

@ -3872,6 +3872,8 @@ void polymost_drawsprite(int32_t snum)
} }
else if (tspr->cstat & 32) else if (tspr->cstat & 32)
{ {
// XXX: such a z offset can be relatively large; for a given
// tsprite, not independent of the rest of the scene.
if ((tspr->z - sec->ceilingz) < (sec->floorz - tspr->z)) if ((tspr->z - sec->ceilingz) < (sec->floorz - tspr->z))
tspr->z += snum; tspr->z += snum;
else tspr->z -= snum; else tspr->z -= snum;

View file

@ -2232,20 +2232,24 @@ DETONATE:
if (s->xrepeat == 0) if (s->xrepeat == 0)
KILLIT(i); KILLIT(i);
A_FindPlayer(s, &x); {
const int32_t p = A_FindPlayer(s, &x);
const DukePlayer_t *const ps = g_player[p].ps;
if (x < VIEWSCREEN_ACTIVE_DISTANCE) if (dist(&sprite[ps->i], s) < VIEWSCREEN_ACTIVE_DISTANCE)
{ {
if (SP == 1) #if 0
g_curViewscreen = i; if (sprite[i].yvel == 1) // VIEWSCREEN_YVEL
} g_curViewscreen = i;
else if (g_curViewscreen != -1 && T1 == 1) #endif
{ }
g_curViewscreen = -1; else if (g_curViewscreen == i /*&& T1 == 1*/)
T1 = 0; {
//loadtile(s->picnum); g_curViewscreen = -1;
//invalidatetile(s->picnum,-1,255); sprite[i].yvel = 0; // VIEWSCREEN_YVEL
walock[TILE_VIEWSCR] = 199; T1 = 0;
walock[TILE_VIEWSCR] = 199;
}
} }
goto BOLT; goto BOLT;

View file

@ -7163,7 +7163,7 @@ static inline void G_DoEventAnimSprites(int32_t j)
void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothratio) void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoothratio)
{ {
int32_t j, k, p, sect; int32_t j, k, p;
intptr_t l; intptr_t l;
if (spritesortcnt == 0) if (spritesortcnt == 0)
@ -7317,6 +7317,8 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
if (t->statnum == TSPR_TEMP) if (t->statnum == TSPR_TEMP)
continue; continue;
Bassert(i >= 0);
{ {
int32_t snum = P_GetP(s); int32_t snum = P_GetP(s);
const DukePlayer_t *const ps = g_player[snum].ps; const DukePlayer_t *const ps = g_player[snum].ps;
@ -7339,9 +7341,8 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
} }
} }
sect = s->sectnum; const int32_t sect = s->sectnum;
Bassert(i >= 0);
curframe = AC_CURFRAME(actor[i].t_data); curframe = AC_CURFRAME(actor[i].t_data);
#if !defined LUNATIC #if !defined LUNATIC
scrofs_action = AC_ACTION_ID(actor[i].t_data); scrofs_action = AC_ACTION_ID(actor[i].t_data);
@ -7435,7 +7436,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
t->xrepeat += 8; t->xrepeat += 8;
t->yrepeat += 8; t->yrepeat += 8;
} }
else if (g_curViewscreen >= 0 && OW != i && display_mirror != 3 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200) else if (g_curViewscreen == i && display_mirror != 3 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200)
{ {
// this exposes a sprite sorting issue which needs to be debugged further... // this exposes a sprite sorting issue which needs to be debugged further...
#if 0 #if 0
@ -7457,11 +7458,6 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo
t->yrepeat = t->yrepeat & 1 ? (t->yrepeat>>2) + 1 : t->yrepeat>>2; t->yrepeat = t->yrepeat & 1 ? (t->yrepeat>>2) + 1 : t->yrepeat>>2;
} }
#if 0 // moved to polymost
t->x += (sintable[(t->ang+512)&2047]>>13);
t->y += (sintable[t->ang&2047]>>13);
updatesector(t->x, t->y, &t->sectnum);
#endif
break; break;
case SHRINKSPARK__STATIC: case SHRINKSPARK__STATIC:

View file

@ -2828,7 +2828,7 @@ CHECKINV1:
p->holoduke_on = i = A_InsertSprite(p->cursectnum,p->pos.x,p->pos.y, p->holoduke_on = i = A_InsertSprite(p->cursectnum,p->pos.x,p->pos.y,
p->pos.z+(30<<8),APLAYER,-64,0,0,p->ang,0,0,-1,10); p->pos.z+(30<<8),APLAYER,-64,0,0,p->ang,0,0,-1,10);
T4 = T5 = 0; T4 = T5 = 0;
SP = snum; sprite[i].yvel = snum;
sprite[i].extra = 0; sprite[i].extra = 0;
P_DoQuote(QUOTE_HOLODUKE_ON,p); P_DoQuote(QUOTE_HOLODUKE_ON,p);
A_PlaySound(TELEPORTER,p->holoduke_on); A_PlaySound(TELEPORTER,p->holoduke_on);
@ -3220,11 +3220,12 @@ void P_CheckSectors(int32_t snum)
{ {
if (PN == CAMERA1 && SP == 0 && sprite[neartagsprite].hitag == SLT) if (PN == CAMERA1 && SP == 0 && sprite[neartagsprite].hitag == SLT)
{ {
SP = 1; //Using this camera sprite[i].yvel = 1; // Using this camera
A_PlaySound(MONITOR_ACTIVE,p->i); A_PlaySound(MONITOR_ACTIVE,p->i);
sprite[neartagsprite].owner = i; sprite[neartagsprite].owner = i;
sprite[neartagsprite].yvel = 1; sprite[neartagsprite].yvel = 1; // VIEWSCREEN_YVEL
g_curViewscreen = neartagsprite;
{ {
int32_t j = p->cursectnum; int32_t j = p->cursectnum;