From ff56964e1b7e870c02f291ecd9a6e83560562912 Mon Sep 17 00:00:00 2001 From: helixhorned Date: Sat, 25 Jul 2015 17:23:22 +0000 Subject: [PATCH] Game: fix displayed viewscreen when its x/yrepeat isn't evenly divisible by 4. git-svn-id: https://svn.eduke32.com/eduke32@5312 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/actors.c | 4 +++- polymer/eduke32/source/duke3d.h | 4 +++- polymer/eduke32/source/game.c | 15 +++++++++------ polymer/eduke32/source/game.h | 17 +++++++++++++++++ polymer/eduke32/source/sector.c | 13 ++++++++----- 5 files changed, 40 insertions(+), 13 deletions(-) diff --git a/polymer/eduke32/source/actors.c b/polymer/eduke32/source/actors.c index e928efe61..9ba0cee00 100644 --- a/polymer/eduke32/source/actors.c +++ b/polymer/eduke32/source/actors.c @@ -2235,7 +2235,9 @@ DETONATE: g_curViewscreen = -1; sprite[i].yvel = 0; // VIEWSCREEN_YVEL T1 = 0; - walock[TILE_VIEWSCR] = 199; + + for (int ii=0; ii < VIEWSCREENFACTOR; ii++) + walock[TILE_VIEWSCR-ii] = 199; } } diff --git a/polymer/eduke32/source/duke3d.h b/polymer/eduke32/source/duke3d.h index 71c3e5b9b..d0ae62abc 100644 --- a/polymer/eduke32/source/duke3d.h +++ b/polymer/eduke32/source/duke3d.h @@ -105,7 +105,9 @@ enum { #define TILE_TILT (MAXTILES-2) #define TILE_ANIM (MAXTILES-4) #define TILE_VIEWSCR (MAXTILES-5) -EDUKE32_STATIC_ASSERT(5 <= MAXTILES-MAXUSERTILES); +// Reserved: TILE_VIEWSCR_1 (MAXTILES-6) +// Reserved: TILE_VIEWSCR_2 (MAXTILES-7) +EDUKE32_STATIC_ASSERT(7 <= MAXTILES-MAXUSERTILES); // sprites with these statnums should be considered for fixing #define ROTFIXSPR_STATNUMP(k) ((k)==STAT_DEFAULT || (k)==STAT_STANDABLE || (k)==STAT_FX || \ diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index f67adb4af..b10c78157 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -7518,6 +7518,10 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo continue; case VIEWSCREEN__STATIC: case VIEWSCREEN2__STATIC: + { + const int viewscrShift = G_GetViewscreenSizeShift(t); + const int viewscrTile = TILE_VIEWSCR-viewscrShift; + if (g_curViewscreen >= 0 && actor[OW].t_data[0] == 1) { t->picnum = STATIC; @@ -7525,7 +7529,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo t->xrepeat += 10; t->yrepeat += 9; } - else if (g_curViewscreen == i && display_mirror != 3 && waloff[TILE_VIEWSCR] && walock[TILE_VIEWSCR] > 200) + else if (g_curViewscreen == i && display_mirror != 3 && waloff[viewscrTile] && walock[viewscrTile] > 200) { // this exposes a sprite sorting issue which needs to be debugged further... #if 0 @@ -7541,16 +7545,15 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo updatesector(newt->x, newt->y, &newt->sectnum); } #endif - - t->picnum = TILE_VIEWSCR; - + t->picnum = viewscrTile; #if VIEWSCREENFACTOR > 0 - t->xrepeat = (t->xrepeat>>VIEWSCREENFACTOR) + (t->xrepeat & 1); - t->yrepeat = (t->yrepeat>>VIEWSCREENFACTOR) + (t->yrepeat & 1); + t->xrepeat >>= viewscrShift; + t->yrepeat >>= viewscrShift; #endif } break; + } case SHRINKSPARK__STATIC: t->picnum = SHRINKSPARK+((totalclock>>4)&3); diff --git a/polymer/eduke32/source/game.h b/polymer/eduke32/source/game.h index 16772275c..7ba27bb20 100644 --- a/polymer/eduke32/source/game.h +++ b/polymer/eduke32/source/game.h @@ -613,6 +613,23 @@ static inline int32_t G_GetMusicIdx(const char *str) return (ep * MAXLEVELS) + lev; } +static inline int G_GetViewscreenSizeShift(const tspritetype *tspr) +{ +#if VIEWSCREENFACTOR == 0 + UNREFERENCED_PARAMETER(tspr); + return VIEWSCREENFACTOR; +#else + static const int mask = (1<xrepeat & mask) | (tspr->yrepeat & mask); + + for (int i=0; i < VIEWSCREENFACTOR; i++) + if (rem & (1<= 0 && dist(&sprite[ps->i], &sprite[i]) < VIEWSCREEN_ACTIVE_DISTANCE) { - if (waloff[TILE_VIEWSCR] == 0) - allocatepermanenttile(TILE_VIEWSCR, tilesiz[PN].x<