# HG changeset patch
# User Ru5tK1ng
# Date 1704832182 21600
#      Tue Jan 09 14:29:42 2024 -0600
# Branch flechettefix
# Node ID 1034c0ddd4243cedd482331b4e7f76061084a499
# Parent  17757ad8e820f40edf930d64f27b5641c62d1fa6
Fighter's flechettes weren't working properly online (addresses 796, 2948 and 2949).

diff -r 17757ad8e820 -r 1034c0ddd424 docs/zandronum-history.txt
--- a/docs/zandronum-history.txt	Thu Jan 04 17:01:19 2024 -0600
+++ b/docs/zandronum-history.txt	Tue Jan 09 14:29:42 2024 -0600
@@ -111,6 +111,7 @@
 -	- 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]
+-   - 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 17757ad8e820 -r 1034c0ddd424 src/g_hexen/a_flechette.cpp
--- a/src/g_hexen/a_flechette.cpp	Thu Jan 04 17:01:19 2024 -0600
+++ b/src/g_hexen/a_flechette.cpp	Tue Jan 09 14:29:42 2024 -0600
@@ -106,6 +106,10 @@
 {
 	AActor *mo;
 
+	// [RK] Only the server handles this.
+	if (NETWORK_InClientMode())
+		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;
 	}
