From 9e1e7a5a934788e2ed90fc6603ffabb3a9007915 Mon Sep 17 00:00:00 2001
From: bones_was_here <bones_was_here@xonotic.au>
Date: Tue, 23 May 2023 00:05:10 +1000
Subject: [PATCH] keepaway: fix bug where on certain maps the ball had no
 proper bbox

This made it annoyingly hard to pick up on eg tuhma, and it would land
in places it shouldn't fit.
---
 .../common/gamemodes/gamemode/keepaway/sv_keepaway.qc  | 10 +---------
 .../common/gamemodes/gamemode/keepaway/sv_keepaway.qh  | 10 ++++++----
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc
index 8b024dbc7b..4d432b3e7b 100644
--- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc
+++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qc
@@ -265,7 +265,7 @@ void ka_SpawnBall()
 	IL_PUSH(g_kaballs, e);
 	navigation_dynamicgoal_init(e, false);
 
-	InitializeEntity(e, ka_RespawnBall, INITPRIO_SETLOCATION); // is this the right priority? Neh, I have no idea.. Well-- it works! So.
+	ka_RespawnBall(e);
 }
 
 void ka_SpawnBalls(int ballcount)
@@ -293,14 +293,6 @@ void ka_Handler_CheckBall(entity this)
 	this.nextthink = time;
 }
 
-void ka_Initialize() // run at the start of a match, initiates game mode
-{
-	g_kaballs = IL_NEW();
-	ka_Handler = new_pure(ka_Handler);
-	setthink(ka_Handler, ka_Handler_CheckBall);
-	ka_Handler.nextthink = time;
-}
-
 
 // ================
 // Bot player logic
diff --git a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh
index 2f1f076439..38dd56197f 100644
--- a/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh
+++ b/qcsrc/common/gamemodes/gamemode/keepaway/sv_keepaway.qh
@@ -2,7 +2,8 @@
 
 #include <common/mutators/base.qh>
 #include <common/scores.qh>
-void ka_Initialize();
+
+void ka_Handler_CheckBall(entity this);
 
 IntrusiveList g_kaballs;
 REGISTER_MUTATOR(ka, false)
@@ -16,15 +17,16 @@ REGISTER_MUTATOR(ka, false)
             field(SP_KEEPAWAY_BCTIME, "bctime", SFL_SORT_PRIO_SECONDARY);
         });
 
-		ka_Initialize();
+		g_kaballs = IL_NEW();
+		entity ka_Handler = new_pure(ka_Handler);
+		setthink(ka_Handler, ka_Handler_CheckBall);
+		InitializeEntity(ka_Handler, ka_Handler_CheckBall, INITPRIO_SETLOCATION);
 	}
 	return false;
 }
 
 const int KA_BALL_COUNT = 1;
 
-entity ka_Handler;
-
 void(entity this) havocbot_role_ka_carrier;
 void(entity this) havocbot_role_ka_collector;
 
-- 
2.39.5