From 6872a533d458ace0685cd727c59eaae28851746f Mon Sep 17 00:00:00 2001 From: Indev Date: Fri, 1 Mar 2024 11:03:55 +0300 Subject: [PATCH] Fix nametag offsets with reverse gravity and flipcam --- src/k_kart.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 4592bf17d..86237796a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9002,16 +9002,22 @@ static void K_drawNameTags(void) char *tag; patch_t *icon; INT32 hudtransflag = V_LocalTransFlag(); + boolean flipcam; if (!stplyr->mo || (stplyr->spectator && !cv_shownametagspectator.value) || splitscreen || (stplyr->exiting && !cv_shownametagfinish.value)) return; + // True if currently viewed player is flipped and has flipcam on + flipcam = (stplyr->pflags & PF_FLIPCAM) && (stplyr->mo->eflags & MFE_VERTICALFLIP); + for (i = 0; i < MAXPLAYERS; i++) { UINT8 *cm; fixed_t distance = 0; fixed_t maxdistance = (10*cv_nametagdist.value)* mapobjectscale; angle_t an; + flipped = 0; + fixed_t z; if (i > PLAYERSMASK) continue; @@ -9066,8 +9072,24 @@ static void K_drawNameTags(void) dup = vid.dupx; - K_GetScreenCoords(&pos, stplyr, camera, players[i].mo->x, players[i].mo->y, players[i].mo->z + players[i].mo->height); - + // If flipcam is on, other player is flipped relative to us when we have different + // verticalflip flag value. Otherwise, they are simply flipped when verticalflip flag says + // so + if (flipcam) + flipped = (players[i].mo->eflags & MFE_VERTICALFLIP) != (stplyr->mo->eflags & MFE_VERTICALFLIP); + else + flipped = players[i].mo->eflags & MFE_VERTICALFLIP; + + z = players[i].mo->z; + + z += (players[i].mo->eflags & MFE_VERTICALFLIP) ? -players[i].mo->height/2 : players[i].mo->height; + + //Saltyhop hehe + if (cv_saltyhop.value && cv_nametaghop.value) + z += (players[i].mo->eflags & MFE_VERTICALFLIP) ? -players[i].mo->spriteyoffset : players[i].mo->spriteyoffset; + + K_GetScreenCoords(&pos, stplyr, camera, players[i].mo->x, players[i].mo->y, z); + //Check for negative screencoords if (pos.x == -1 || pos.y == -1) continue; @@ -9077,22 +9099,6 @@ static void K_drawNameTags(void) if (tagsdisplayed > cv_nametagmaxplayers.value) break; - //Flipcam off - if (players[i].mo->eflags & MFE_VERTICALFLIP && !(players[i].pflags & PF_FLIPCAM)) - pos.y += players[i].mo->height; - - //Flipcam on - if (players[i].mo->eflags & MFE_VERTICALFLIP && (players[i].pflags & PF_FLIPCAM)) - pos.y -= ((30*dup)<eflags & MFE_VERTICALFLIP && !(players[i].pflags & PF_FLIPCAM)) - flipped = players[i].mo->eflags & MFE_VERTICALFLIP && !(players[i].pflags & PF_FLIPCAM); - - //Saltyhop hehe - if (cv_saltyhop.value && cv_nametaghop.value) - pos.y -= flipped ? -players[i].mo->spriteyoffset : players[i].mo->spriteyoffset; - namex = pos.x>>FRACBITS; namey = pos.y>>FRACBITS;