From 226785dcd6e676c91ed80557a9a02dd2c4e00c5e Mon Sep 17 00:00:00 2001
From: toasterbabe <rollerorbital@gmail.com>
Date: Sat, 16 Jul 2016 14:45:22 +0100
Subject: [PATCH] Putting the swim animation checks in one place.

---
 src/p_mobj.c |  6 ++++++
 src/p_user.c | 13 +------------
 2 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/src/p_mobj.c b/src/p_mobj.c
index bff4bb09c3..22d06e34d4 100644
--- a/src/p_mobj.c
+++ b/src/p_mobj.c
@@ -167,6 +167,12 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
 	if ((state == S_PLAY_JUMP) && (player->charflags & SF_NOJUMPSPIN) && (P_MobjFlip(mobj)*mobj->momz < 0 || player->pflags & PF_THOKKED))
 		return P_SetPlayerMobjState(mobj, S_PLAY_FALL);
 
+	// Catch swimming versus flying
+	if (state == S_PLAY_FLY && player->mo->eflags & MFE_UNDERWATER)
+		return P_SetPlayerMobjState(player->mo, S_PLAY_SWIM);
+	else if (state == S_PLAY_SWIM && !(player->mo->eflags & MFE_UNDERWATER))
+		return P_SetPlayerMobjState(player->mo, S_PLAY_FLY);
+
 	// Catch state changes for Super Sonic
 	if (player->powers[pw_super] && (player->charflags & SF_SUPERANIMS))
 	{
diff --git a/src/p_user.c b/src/p_user.c
index f624d3b102..ce6c01d949 100644
--- a/src/p_user.c
+++ b/src/p_user.c
@@ -4111,10 +4111,7 @@ static void P_DoJumpStuff(player_t *player, ticcmd_t *cmd)
 						; // Can't do anything if you're a fish out of water!
 					else if (!(player->pflags & PF_THOKKED) && !(player->powers[pw_tailsfly]))
 					{
-						if (player->mo->eflags & MFE_UNDERWATER)
-							P_SetPlayerMobjState(player->mo, S_PLAY_SWIM); // Change to the swimming animation
-						else
-							P_SetPlayerMobjState(player->mo, S_PLAY_FLY); // Change to the flying animation
+						P_SetPlayerMobjState(player->mo, S_PLAY_FLY); // Change to the flying animation
 
 						player->powers[pw_tailsfly] = tailsflytics + 1; // Set the fly timer
 
@@ -6737,14 +6734,6 @@ static void P_MovePlayer(player_t *player)
 	if (player->panim != PA_ABILITY)
 		player->powers[pw_tailsfly] = 0;
 
-	if (player->charability == CA_FLY || player->charability == CA_SWIM) // Frustratingly has to remain seperate from the below block.
-	{
-		if (player->mo->state-states == S_PLAY_FLY && player->mo->eflags & MFE_UNDERWATER)
-			P_SetPlayerMobjState(player->mo, S_PLAY_SWIM); // Change to the swimming animation
-		else if (player->mo->state-states == S_PLAY_SWIM && !(player->mo->eflags & MFE_UNDERWATER))
-			P_SetPlayerMobjState(player->mo, S_PLAY_FLY); // Change to the flying animation
-	}
-
 	if (player->charability == CA_FLY || (player->charability == CA_SWIM && player->mo->eflags & MFE_UNDERWATER))
 	{
 		// Fly counter for Tails.
-- 
GitLab