From 55d2da2201f43f1a1e64b7172d617c85dfcea6ff Mon Sep 17 00:00:00 2001
From: mazmazz <mar.marcoz@outlook.com>
Date: Wed, 15 Aug 2018 18:42:20 -0400
Subject: [PATCH] Fix NiGHTS Bumper player positioning

---
 src/p_inter.c | 8 +-------
 src/p_user.c  | 9 +++++++++
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/src/p_inter.c b/src/p_inter.c
index ce8bba6b6e..21f580a99c 100644
--- a/src/p_inter.c
+++ b/src/p_inter.c
@@ -1005,13 +1005,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
 						player->flyangle = special->threshold;
 
 					player->speed = FixedMul(special->info->speed, special->scale);
-					// Potentially causes axis transfer failures.
-					// Also rarely worked properly anyway.
-					//P_UnsetThingPosition(player->mo);
-					//player->mo->x = special->x;
-					//player->mo->y = special->y;
-					//P_SetThingPosition(player->mo);
-					toucher->z = special->z+(special->height/4);
+					P_SetTarget(&player->mo->hnext, special); // Reference bumper for position correction on next tic
 				}
 				else // More like a spring
 				{
diff --git a/src/p_user.c b/src/p_user.c
index fd09b08475..595e9566e3 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -6175,6 +6175,15 @@ static void P_NiGHTSMovement(player_t *player)
 		S_ChangeMusicInternal((((maptol & TOL_NIGHTS) && !G_IsSpecialStage(gamemap)) ? "_ntime" : "_drown"), false);
 
 
+	if (player->bumpertime == TICRATE/2)
+	{
+		// Center player to bumper here because if you try to set player's position in P_TouchSpecialThing case MT_NIGHTSBUMPER,
+		// that position is fudged in the time between that routine in the previous tic
+		// and reaching here in the current tic
+		P_TeleportMove(player->mo, player->mo->hnext->x, player->mo->hnext->y, player->mo->hnext->z + (player->mo->hnext->height/4));
+		P_SetTarget(&player->mo->hnext, NULL);
+	}
+
 	if (player->mo->z < player->mo->floorz)
 		player->mo->z = player->mo->floorz;
 
-- 
GitLab