From c08b8dc17b3cbf140d93f857e4851b2101f88c89 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 5 Jul 2020 11:54:50 +0200 Subject: [PATCH] - camera display fix. This is one fucked up mess of code. --- source/games/duke/src/sectors_d.cpp | 1 + source/games/duke/src/zz_game.cpp | 4 ++-- source/games/duke/src/zz_sector.cpp | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 8a528de22..d72a186d6 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1713,6 +1713,7 @@ void checksectors_d(int snum) sprite[neartagsprite].owner = i; sprite[neartagsprite].yvel = 1; + camsprite = neartagsprite; j = p->cursectnum; diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 9c21d105b..362ef830f 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -1303,8 +1303,8 @@ int GameInterface::app_main() if (RR) tileDelete(0); - if (RRRA) - tileDelete(13); + + tileDelete(13); if (numplayers == 1 && boardfilename[0] != 0) { diff --git a/source/games/duke/src/zz_sector.cpp b/source/games/duke/src/zz_sector.cpp index cdaa77df6..1049347ee 100644 --- a/source/games/duke/src/zz_sector.cpp +++ b/source/games/duke/src/zz_sector.cpp @@ -37,7 +37,7 @@ void G_AnimateCamSprite(int smoothRatio) if (g_curViewscreen < 0) return; - int const spriteNum = g_curViewscreen; + int spriteNum = g_curViewscreen; if (totalclock >= T1(spriteNum) + ud.camera_time) { @@ -46,11 +46,13 @@ void G_AnimateCamSprite(int smoothRatio) if (pPlayer->newowner >= 0) OW(spriteNum) = pPlayer->newowner; + if (OW(spriteNum) >= 0 && dist(&sprite[pPlayer->i], &sprite[spriteNum]) < VIEWSCREEN_ACTIVE_DISTANCE) { TileFiles.MakeCanvas(TILE_VIEWSCR, tilesiz[PN(spriteNum)].x, tilesiz[PN(spriteNum)].y); - vec3_t const camera = G_GetCameraPosition(spriteNum, smoothRatio); + vec3_t const camera = G_GetCameraPosition(OW(spriteNum), smoothRatio); + int ang = SA(OW(spriteNum)); int const saveMirror = display_mirror; auto canvas = renderSetTarget(TILE_VIEWSCR); @@ -59,10 +61,10 @@ void G_AnimateCamSprite(int smoothRatio) screen->RenderTextureView(canvas, [=](IntRect& rect) { yax_preparedrawrooms(); - drawrooms(camera.x, camera.y, camera.z, SA(spriteNum), 100 + sprite[spriteNum].shade, SECT(spriteNum)); + drawrooms(camera.x, camera.y, camera.z, ang, 100 + sprite[OW(spriteNum)].shade, SECT(OW(spriteNum))); display_mirror = 3; - fi.animatesprites(camera.x, camera.y, SA(spriteNum), smoothRatio); + fi.animatesprites(camera.x, camera.y, ang, smoothRatio); display_mirror = saveMirror; renderDrawMasks();