From 87ddd2f794f092c1905d5c86b9f266adad0ebc6a Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Wed, 22 May 2024 21:54:40 +0200 Subject: [PATCH 1/9] Fix servant hand not being properly flipped --- src/objects/servant-hand.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/objects/servant-hand.c b/src/objects/servant-hand.c index 59499cd92..c140a0139 100644 --- a/src/objects/servant-hand.c +++ b/src/objects/servant-hand.c @@ -28,11 +28,19 @@ void Obj_ServantHandSpawning(player_t *player) { player->handtimer++; if (player->hand == NULL && player->handtimer == TICRATE) - { + { + fixed_t heightOffset = player->mo->height + 30*mapobjectscale; + if (P_IsObjectFlipped(player->mo)) + { + // This counteracts the offset added by K_FlipFromObject so it looks seamless from non-flipped. + heightOffset += player->mo->height - FixedMul(player->mo->scale, player->mo->height); + heightOffset *= P_MobjFlip(player->mo); // Fleep. + } + mobj_t *hand = P_SpawnMobj( player->mo->x, player->mo->y, - player->mo->z + player->mo->height + 30*mapobjectscale, + player->mo->z + heightOffset, MT_SERVANTHAND ); @@ -115,13 +123,17 @@ void Obj_ServantHandThink(mobj_t *hand) { hand->color = player->skincolor; hand->angle = player->besthanddirection; + + fixed_t heightOffset = player->mo->height + 30*mapobjectscale; + if (P_IsObjectFlipped(player->mo)) + heightOffset *= P_MobjFlip(player->mo); // Fleep. + K_FlipFromObject(hand, player->mo); P_MoveOrigin(hand, player->mo->x + xoffs, player->mo->y + yoffs, - player->mo->z + player->mo->height + 30*mapobjectscale + player->mo->z + heightOffset ); - K_FlipFromObject(hand, player->mo); hand->sprzoff = player->mo->sprzoff; From bdb15028a1eef2efc7bd44edd83ddd1b645d2a51 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Sat, 18 May 2024 17:19:11 +0200 Subject: [PATCH 2/9] Fix ring debt object not being properly flipped --- src/k_kart.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 98ca7268d..f29404872 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8647,12 +8647,20 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // GROSS. In order to have a transparent version of this for a splitscreen local player, we actually need to spawn two! for (doubler = 0; doubler < 2; doubler++) { + fixed_t heightOffset = player->mo->height + (24*player->mo->scale); + if (P_IsObjectFlipped(player->mo)) + { + // This counteracts the offset added by K_FlipFromObject so it looks seamless from non-flipped. + heightOffset += player->mo->height - FixedMul(player->mo->scale, player->mo->height); + heightOffset *= P_MobjFlip(player->mo); // Fleep. + } + mobj_t *debtflag = P_SpawnMobj(player->mo->x + player->mo->momx, player->mo->y + player->mo->momy, - player->mo->z + P_GetMobjZMovement(player->mo) + player->mo->height + (24*player->mo->scale), MT_THOK); + player->mo->z + P_GetMobjZMovement(player->mo) + heightOffset, MT_THOK); debtflag->old_x = player->mo->old_x; debtflag->old_y = player->mo->old_y; - debtflag->old_z = player->mo->old_z + P_GetMobjZMovement(player->mo) + player->mo->height + (24*player->mo->scale); + debtflag->old_z = player->mo->old_z + P_GetMobjZMovement(player->mo) + heightOffset; P_SetMobjState(debtflag, S_RINGDEBT); P_SetScale(debtflag, (debtflag->destscale = player->mo->scale)); From 4439ce8940b6ee5a6cedc4d0aaf90b878a17123a Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Sat, 18 May 2024 19:17:21 +0200 Subject: [PATCH 3/9] Fix soft landing mobj not being properly flipped --- src/k_kart.c | 2 +- src/p_mobj.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index f29404872..f1ad55a70 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -11636,7 +11636,7 @@ void K_KartEbrakeVisuals(player_t *p) { if (p->ebrakefor % 20 == 0) { - wave = P_SpawnMobj(p->mo->x, p->mo->y, p->mo->floorz, MT_SOFTLANDING); + wave = P_SpawnMobj(p->mo->x, p->mo->y, P_GetMobjGround(p->mo), MT_SOFTLANDING); P_InstaScale(wave, p->mo->scale); P_SetTarget(&wave->target, p->mo); P_SetTarget(&wave->owner, p->mo); diff --git a/src/p_mobj.c b/src/p_mobj.c index e6effb1fc..9c8a53db7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -10552,8 +10552,8 @@ void P_SceneryThinker(mobj_t *mobj) if (!P_MobjWasRemoved(mobj->target)) { // Cast like a shadow on the ground - P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->floorz); - mobj->standingslope = mobj->target->standingslope; + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, P_GetMobjGround(mobj->target)); + mobj->standingslope = P_IsObjectOnGround(mobj->target) ? mobj->target->standingslope : NULL; if (!P_IsObjectOnGround(mobj->target) && mobj->target->momz < -24 * mapobjectscale) { From c275f9b3cb4f18a4af67f4c8408180935e2d89fd Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Sun, 19 May 2024 15:57:48 +0200 Subject: [PATCH 4/9] Fix tricks fail threshold when under gravflip, fix Charge Aura's visuals not being flipped --- src/k_kart.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index f1ad55a70..b02f264c3 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -9273,6 +9273,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) for(i = 0;i < 5;i++) { mobj_t *aura = P_SpawnMobjFromMobj(player->mo, 0, 0, player->mo->height/2, MT_CHARGEAURA); + aura->eflags &= ~MFE_VERTICALFLIP; aura->angle = player->mo->angle + i*ANG15; P_SetTarget(&aura->target, player->mo); if (i == 0) @@ -13632,7 +13633,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) // debug shit //CONS_Printf("%d\n", player->mo->momz / mapobjectscale); - if (momz < -10*FRACUNIT) // :youfuckedup: + if (momz * P_MobjFlip(player->mo) < -10*FRACUNIT) // :youfuckedup: { // tumble if you let your chance pass!! player->tumbleBounces = 1; From dbac44927232c178ad36e604a18887c820d44748 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Tue, 21 May 2024 19:27:15 +0200 Subject: [PATCH 5/9] Fix hyudoro being incorrectly flipped during roaming status --- src/objects/hyudoro.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/objects/hyudoro.c b/src/objects/hyudoro.c index 1f3b3521a..c7705a1d8 100644 --- a/src/objects/hyudoro.c +++ b/src/objects/hyudoro.c @@ -111,7 +111,10 @@ sine_bob fixed_t sineofs) { hyu->sprzoff = FixedMul(HYU_VISUAL_HEIGHT * hyu->scale, - sineofs + FINESINE(a >> ANGLETOFINESHIFT)); + sineofs + FINESINE(a >> ANGLETOFINESHIFT)) * P_MobjFlip(hyu); + + if (P_IsObjectFlipped(hyu)) + hyu->sprzoff -= hyu->height; } static void @@ -155,11 +158,6 @@ project_hyudoro (mobj_t *hyu) hyu->z = P_GetZAt(center->standingslope, hyu->x, hyu->y, P_GetMobjGround(center)); - - if (P_IsObjectFlipped(hyu)) - { - hyu->z -= hyu->height; - } } static void From 20138f3d6791407b4d1bd8a3db8b90b8778e522c Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Wed, 22 May 2024 16:20:24 +0200 Subject: [PATCH 6/9] Fix name/splitscreen/rival tags not being flipped properly when player was flipped --- src/k_hud.cpp | 52 +++++++++++++++++++++++++++++++++------------ src/k_hud.h | 2 +- src/k_hud_track.cpp | 2 +- 3 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/k_hud.cpp b/src/k_hud.cpp index 6f74c996b..5a792be6a 100644 --- a/src/k_hud.cpp +++ b/src/k_hud.cpp @@ -3810,24 +3810,24 @@ static boolean K_ShowPlayerNametag(player_t *p) return true; } -static void K_DrawLocalTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT8 id) +static void K_DrawLocalTagForPlayer(fixed_t x, fixed_t y, player_t *p, UINT8 id, UINT32 flags) { UINT8 blink = ((leveltime / 7) & 1); UINT8 *colormap = R_GetTranslationColormap(TC_RAINBOW, static_cast(p->skincolor), GTC_CACHE); - V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN, kp_localtag[id][blink], colormap); + V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_localtag[id][blink], colormap); } -static void K_DrawRivalTagForPlayer(fixed_t x, fixed_t y) +static void K_DrawRivalTagForPlayer(fixed_t x, fixed_t y, UINT32 flags) { UINT8 blink = ((leveltime / 7) & 1); - V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN, kp_rival[blink], NULL); + V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_rival[blink], NULL); } static void K_DrawTypingDot(fixed_t x, fixed_t y, UINT8 duration, player_t *p, INT32 flags) { if (p->typing_duration > duration) { - V_DrawFixedPatch(x, y, FRACUNIT, V_HUDTRANS|V_SPLITSCREEN|flags, kp_typdot, NULL); + V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_typdot, NULL); } } @@ -3849,8 +3849,19 @@ static void K_DrawNameTagItemSpy(INT32 x, INT32 y, player_t *p, INT32 flags) { using srb2::Draw; bool tiny = r_splitscreen > 1; + SINT8 flip = 1, flipboxoffset = 0; + if ((flags & V_VFLIP) == V_VFLIP) + { + // Remove the v_vflip flag - it makes things messy, but we also understand + // that we want to make this look okay for flipped players, so simply use this + // opportunity to flip vertical offsets accordingly instead. + flags &= ~V_VFLIP; + flip = P_MobjFlip(p->mo); + flipboxoffset = 8; + } + Draw bar = Draw(x, y).flags(V_NOSCALESTART|flags); - Draw box = tiny ? bar.xy(-22 * vid.dupx, -17 * vid.dupy) : bar.xy(-40 * vid.dupx, -26 * vid.dupy); + Draw box = tiny ? bar.xy(-22 * vid.dupx, (-17+flipboxoffset) * vid.dupy) : bar.xy(-40 * vid.dupx, (-26+flipboxoffset) * vid.dupy); box.colorize(p->skincolor).patch(kp_itembg[tiny ? 4 : 2]); @@ -3877,8 +3888,8 @@ static void K_DrawNameTagItemSpy(INT32 x, INT32 y, player_t *p, INT32 flags) if (p->itemamount > 1) { (tiny ? - bar.xy(-3 * vid.dupx, -4 * vid.dupy).font(Draw::Font::kPing) : - bar.xy(-4 * vid.dupx, -2 * vid.dupy).font(Draw::Font::kThinTimer) + bar.xy(-3 * vid.dupx, (-4*flip) * vid.dupy).font(Draw::Font::kPing) : + bar.xy(-4 * vid.dupx, (-2*flip) * vid.dupy).font(Draw::Font::kThinTimer) ) .align(Draw::Align::kRight) .text("{}", p->itemamount); @@ -3924,6 +3935,13 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag UINT8 *colormap = V_GetStringColormap(clr); INT32 barx = 0, bary = 0, barw = 0; + INT32 flipped = P_MobjFlip(p->mo), flipfilloffset = 0, flipfontoffset = 0, flipspheresoffset = 0; + if (flipped == -1) + { + flipfilloffset = -3; // You cannot really flip drawfill. + flipfontoffset = -9; // Accounts for font height. + flipspheresoffset = 2; + } UINT8 cnum = R_GetViewNumber(); @@ -3946,7 +3964,7 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag bary = (y * vid.dupy) / FRACUNIT; barx += (6 * vid.dupx); - bary -= (16 * vid.dupx); + bary -= ((16 + flipfilloffset) * vid.dupx) * flipped; // Center it if necessary if (vid.width != BASEVIDWIDTH * vid.dupx) @@ -3967,7 +3985,7 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag if (gametyperules & GTR_SPHERES) { - K_DrawNameTagSphereMeter(barx, bary + (4 * vid.dupy), barw, p->spheres, flags); + K_DrawNameTagSphereMeter(barx, bary + (((4 + flipspheresoffset) * vid.dupy) * P_MobjFlip(p->mo)), barw, p->spheres, flags); } // Lat: 10/06/2020: colormap can be NULL on the frame you join a game, just arbitrarily use palette indexes 31 and 0 instead of whatever the colormap would give us instead to avoid crashes. @@ -3979,7 +3997,7 @@ static void K_DrawNameTagForPlayer(fixed_t x, fixed_t y, player_t *p, INT32 flag V_DrawFixedPatch(x, y, FRACUNIT, flags, kp_nametagstem, colormap); // Draw the name itself - V_DrawThinStringAtFixed(x + (5*FRACUNIT), y - (26*FRACUNIT), clr|flags, player_names[p - players]); + V_DrawThinStringAtFixed(x + (5*FRACUNIT), y - (((26 + flipfontoffset) * FRACUNIT) * P_MobjFlip(p->mo)), clr|flags, player_names[p - players]); } playertagtype_t K_WhichPlayerTag(player_t *p) @@ -4009,19 +4027,25 @@ playertagtype_t K_WhichPlayerTag(player_t *p) return PLAYERTAG_NONE; } -void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, INT32 flags) +void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, boolean foreground) { + INT32 flags = P_IsObjectFlipped(p->mo) ? V_VFLIP : 0; + switch (type) { case PLAYERTAG_LOCAL: - K_DrawLocalTagForPlayer(x, y, p, G_PartyPosition(p - players)); + flags |= V_HUDTRANS|V_SPLITSCREEN; + K_DrawLocalTagForPlayer(x, y, p, G_PartyPosition(p - players), flags); break; case PLAYERTAG_RIVAL: - K_DrawRivalTagForPlayer(x, y); + flags |= V_HUDTRANS|V_SPLITSCREEN; + K_DrawRivalTagForPlayer(x, y, flags); break; case PLAYERTAG_NAME: + // We only care about the trans flag here (based?) as well as V_VFLIP. + flags |= foreground ? 0 : V_60TRANS; K_DrawNameTagForPlayer(x, y, p, flags); K_DrawTypingNotifier(x, y, p, flags); break; diff --git a/src/k_hud.h b/src/k_hud.h index 07cea4774..b319e399a 100644 --- a/src/k_hud.h +++ b/src/k_hud.h @@ -116,7 +116,7 @@ typedef enum playertagtype_t; playertagtype_t K_WhichPlayerTag(player_t *p); -void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, INT32 flags); +void K_DrawPlayerTag(fixed_t x, fixed_t y, player_t *p, playertagtype_t type, boolean foreground); #ifdef __cplusplus } // extern "C" diff --git a/src/k_hud_track.cpp b/src/k_hud_track.cpp index 4dd89cfcc..4593673e4 100644 --- a/src/k_hud_track.cpp +++ b/src/k_hud_track.cpp @@ -466,7 +466,7 @@ void K_DrawTargetTracking(const TargetTracking& target) { if (target.nametag != PLAYERTAG_NONE) { - K_DrawPlayerTag(target.result.x, target.result.y, target.mobj->player, target.nametag, target.foreground ? 0 : V_60TRANS); + K_DrawPlayerTag(target.result.x, target.result.y, target.mobj->player, target.nametag, target.foreground); return; } From 4c7ec4bae0643dbf533238ab98fa57c4d0404190 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Wed, 22 May 2024 21:00:22 +0200 Subject: [PATCH 7/9] Fix shield objects not being properly flipped --- src/k_kart.c | 3 +++ src/p_mobj.c | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index b02f264c3..6cbaf9ae2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -13285,6 +13285,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (player->curshield != KSHIELD_BUBBLE) { mobj_t *shield = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_BUBBLESHIELD); + // MT_BUBBLESHIELD doesn't have MF_NOBLOCKMAP so we need to remove this manually. + // Otherwise if you roll a bubble shield while flipped, the visuals look too mismatched. + shield->eflags &= ~MFE_VERTICALFLIP; P_SetScale(shield, (shield->destscale = (5*shield->destscale)>>2)); P_SetTarget(&shield->target, player->mo); S_StartSound(player->mo, sfx_s3k3f); diff --git a/src/p_mobj.c b/src/p_mobj.c index 9c8a53db7..8b1862fab 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8355,6 +8355,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_SetScale(mobj, (mobj->destscale = (5*mobj->target->scale)>>2)); P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + mobj->target->height/2); + // Taken from K_FlipFromObject. We just want to flip the visual according to its target, but that's it. + mobj->eflags = (mobj->eflags & ~MFE_VERTICALFLIP)|(mobj->target->eflags & MFE_VERTICALFLIP); + break; } case MT_BUBBLESHIELD: @@ -8460,9 +8463,15 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->extravalue2 = mobj->target->player->bubbleblowup; P_SetScale(mobj, (mobj->destscale = scale)); + + // For some weird reason, the Bubble Shield is the exception flip-wise, it has the offset baked into the sprite. + // So instead of simply flipping the object, we have to do a position offset. + fixed_t positionOffset = 0; + if (P_IsObjectFlipped(mobj->target)) + positionOffset -= 8 * mobj->scale; mobj->flags &= ~(MF_NOCLIPTHING); - P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z); + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + positionOffset); mobj->flags |= MF_NOCLIPTHING; break; } @@ -8550,6 +8559,8 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } } + // Taken from K_FlipFromObject. We just want to flip the visual according to its target, but that's it. + mobj->eflags = (mobj->eflags & ~MFE_VERTICALFLIP)|(mobj->target->eflags & MFE_VERTICALFLIP); P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + mobj->target->height/2); mobj->angle = K_MomentumAngle(mobj->target); From cea8b9566e9ea4183a9aa6b6adb7f96469f5f4a3 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Wed, 22 May 2024 21:19:00 +0200 Subject: [PATCH 8/9] Fix super flicky bobbing not being flipped, as well as the object itself --- src/objects/super-flicky.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/objects/super-flicky.cpp b/src/objects/super-flicky.cpp index 9cd482268..aa5e659f4 100644 --- a/src/objects/super-flicky.cpp +++ b/src/objects/super-flicky.cpp @@ -93,7 +93,10 @@ sine_bob // slightly modified from objects/hyudoro.c hyu->sprzoff = FixedMul(kBobHeight, - sineofs + FINESINE(a >> ANGLETOFINESHIFT)); + sineofs + FINESINE(a >> ANGLETOFINESHIFT)) * P_MobjFlip(hyu); + + if (P_IsObjectFlipped(hyu)) + hyu->sprzoff -= hyu->height; } void @@ -303,6 +306,7 @@ struct Flicky : mobj_t color = super_color(); } + K_FlipFromObject(this, source()); bob_in_place(this, phase() * 8, 32); } From 586e4c4cd84c31fc5beef946f0888cfb4e52f854 Mon Sep 17 00:00:00 2001 From: JugadorXEI Date: Wed, 22 May 2024 20:53:17 +0200 Subject: [PATCH 9/9] Fix powerup aura being unflipped --- src/objects/powerup-aura.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/objects/powerup-aura.cpp b/src/objects/powerup-aura.cpp index d415c61f0..ef716d62d 100644 --- a/src/objects/powerup-aura.cpp +++ b/src/objects/powerup-aura.cpp @@ -17,6 +17,7 @@ #include "../p_local.h" #include "../p_mobj.h" #include "../tables.h" +#include "../k_kart.h" // copied from objects/monitor.c #define FINE90 (FINEANGLES/4) @@ -91,8 +92,11 @@ struct Aura : mobj_t { return; } + + K_FlipFromObject(this, origin()); + fixed_t flipoffset = P_IsObjectFlipped(origin()) ? origin()->height : 0; - P_MoveOrigin(this, origin()->x, origin()->y, origin()->z); + P_MoveOrigin(this, origin()->x, origin()->y, origin()->z - flipoffset); P_InstaScale(this, 11 * origin()->scale / 10); translate();