# HG changeset patch
# User Ru5tK1ng
# Date 1706501492 21600
#      Sun Jan 28 22:11:32 2024 -0600
# Branch flechette
# Node ID 2eb06da4916a3b06097067736e2ba0e6b723255d
# Parent  1c3ed4429cec06e060d1c6e40493a8e9abbf02ba
Fixed: Fighter's flechettes weren't working properly online (addresses 796, 2948 and 2949).

diff -r 1c3ed4429cec -r 2eb06da4916a docs/zandronum-history.txt
--- a/docs/zandronum-history.txt	Sun Jan 28 13:59:46 2024 -0800
+++ b/docs/zandronum-history.txt	Sun Jan 28 22:11:32 2024 -0600
@@ -119,6 +119,7 @@
 -	- Fixed: Floatbob items having incorrect z-height after a map reset and glitchy GL floor clipping (addresses 2361). [Ru5tK1ng]
 -	- Fixed: Monsters spawned by BossBrain cubes would move before being spawned on the clients therefore triggering warning messages (addresses 2655). [Ru5tK1ng]
 -	- Fixed: Cleric's CircleFlame projectile did not rotate properly online (addresses 2101). [Ru5tK1ng]
+-   - Fixed: Fighter's flechettes weren't working properly online (addresses 796, 2948 and 2949). [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 1c3ed4429cec -r 2eb06da4916a src/g_hexen/a_flechette.cpp
--- a/src/g_hexen/a_flechette.cpp	Sun Jan 28 13:59:46 2024 -0800
+++ b/src/g_hexen/a_flechette.cpp	Sun Jan 28 22:11:32 2024 -0600
@@ -106,6 +106,10 @@
 {
 	AActor *mo;
 
+	// [RK] Only the server handles this unlless inventory item is client-sided.
+	if ( NETWORK_InClientModeAndActorNotClientHandled (this))
+		return false;
+
 	mo = Spawn("ThrowingBomb", Owner->x, Owner->y, 
 		Owner->z-Owner->floorclip+35*FRACUNIT + (Owner->player? Owner->player->crouchoffset : 0), ALLOW_REPLACE);
 	if (mo)
@@ -137,6 +141,11 @@
 
 		mo->target = Owner;
 		mo->tics -= pr_poisonbag()&3;
+
+		// [RK] Spawn the flechette on the clients.
+		if ( NETWORK_GetState() == NETSTATE_SERVER )
+			SERVERCOMMANDS_SpawnMissile(mo);
+
 		P_CheckMissileSpawn(mo, Owner->radius);
 		return true;
 	}
