# HG changeset patch
# User Ru5tK1ng
# Date 1704409279 21600
#      Thu Jan 04 17:01:19 2024 -0600
# Branch floatbobfix
# Node ID 7ed88f8055972c6205cfe8b16357acf5373108da
# Parent  4f775318d2ecf6db1d7e93a967964defdea7eb19
Fixed: Floatbob items having incorrect z-height after a map reset and glitchy GL floor clipping (addresses 2361).

diff -r 4f775318d2ec -r 7ed88f805597 docs/zandronum-history.txt
--- a/docs/zandronum-history.txt	Wed Dec 20 22:00:46 2023 -0500
+++ b/docs/zandronum-history.txt	Thu Jan 04 17:01:19 2024 -0600
@@ -110,6 +110,7 @@
 -	- Fixed: flags in CTF could be captured after the round was over. [auratoostronk]
 -	- Fixed: opening the text scaling menu sometimes changed the user's con_virtualwidth and/or con_virtualheight CVars when it shouldn't. [Kaminsky]
 -	- Fixed: the coop info wasn't getting drawn in clientside demos. [Kaminsky]
+-   - Fixed: Floatbob items having incorrect z-height after a map reset and glitchy GL floor clipping (addresses 2361). [Ru5tK1ng]
 !	- The result value of GAMEEVENT_MEDALS event scripts can now be used to determine whether or not the player receives the medal. [Kaminsky]
 !	- GAMEMODE flags are now validated after all GAMEMODE lumps have been parsed instead of after each one. The internal game mode name (e.g. "TeamLMS") is now printed with the error message instead of the actual name. [Kaminsky]
 !	- Added an extra check to ensure that game modes have a (short) name. [Kaminsky]
diff -r 4f775318d2ec -r 7ed88f805597 src/g_game.cpp
--- a/src/g_game.cpp	Wed Dec 20 22:00:46 2023 -0500
+++ b/src/g_game.cpp	Thu Jan 04 17:01:19 2024 -0600
@@ -3928,7 +3928,7 @@
 				else if ( pActorInfo->flags2 & MF2_SPAWNFLOAT )
 					Z = FLOATRANDZ;
 				else if ( pActorInfo->flags2 & MF2_FLOATBOB )
-					Z = pActor->SpawnPoint[2];
+					Z = pActor->floorz + pActor->SpawnPoint[2];
 				else
 					Z = ONFLOORZ;
 
@@ -4075,7 +4075,7 @@
 		else if ( pActorInfo->flags2 & MF2_SPAWNFLOAT )
 			Z = FLOATRANDZ;
 		else if ( pActorInfo->flags2 & MF2_FLOATBOB )
-			Z = pActor->SpawnPoint[2];
+			Z = pActor->floorz + pActor->SpawnPoint[2];
 		else
 			Z = ONFLOORZ;
 
diff -r 4f775318d2ec -r 7ed88f805597 src/gl/scene/gl_sprite.cpp
--- a/src/gl/scene/gl_sprite.cpp	Wed Dec 20 22:00:46 2023 -0500
+++ b/src/gl/scene/gl_sprite.cpp	Thu Jan 04 17:01:19 2024 -0600
@@ -642,7 +642,8 @@
 		float spriteheight = FIXED2FLOAT(spritescaleY) * gltexture->GetScaledHeightFloat(GLUSE_SPRITE);
 		
 		// Tests show that this doesn't look good for many decorations and corpses
-		if (spriteheight>0 && gl_spriteclip>0)
+		// [RK] tests also show this looks terrible for floatbob items
+		if (spriteheight>0 && gl_spriteclip>0 && !thing->flags2 & MF2_FLOATBOB)
 		{
 			bool smarterclip = false; // Set to true if one condition triggers the test below
 			if (((thing->player || thing->flags3&MF3_ISMONSTER ||
