From d0c2ffd45a401cdf7482ca2cee3dbe4a86e07b35 Mon Sep 17 00:00:00 2001
From: Mircea Kitsune <sonichedgehog_hyperblast00@yahoo.com>
Date: Mon, 21 May 2012 22:32:37 +0300
Subject: [PATCH] Don't spawn an empty entity for fallback origin, that's bad.
 Use a vector instead and pass it further on

---
 qcsrc/server/t_plats.qc | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc
index 719359e2d..8882d2099 100644
--- a/qcsrc/server/t_plats.qc
+++ b/qcsrc/server/t_plats.qc
@@ -279,21 +279,24 @@ void train_wait()
 void train_next()
 {
 	entity targ, cp;
+	vector cp_org;
+
 	targ = find(world, targetname, self.target);
 	self.target = targ.target;
 	if (self.spawnflags & 1)
 	{
 		entity prev;
 		prev = find(world, target, targ.targetname); // get the previous corner first
-		cp = find(world, targetname, prev.target2); // now get its second target
+		cp = find(world, targetname, prev.target2); // now get its second target (the control point)
 		if(cp.targetname == "") // none found
 		{
-			// when using bezier curves, you must have a control point for each corner in the train's path
+			// when using bezier curves, you must have a control point for each corner in the path
 			if(autocvar_developer)
 				dprint(strcat("Warning: func_train using beizer curves reached the path_corner '", prev.targetname, "' which does not have a control point. Please add a target2 for each path_corner used by this train!\n"));
-			cp = spawn();
-			setorigin(cp, targ.origin - self.mins); // assume a straight line to the destination as fallback
+			cp_org = targ.origin - self.mins; // assume a straight line to the destination as fallback
 		}
+		else
+			cp_org = cp.origin;
 	}
 	if (!self.target)
 		objerror("train_next: no next target");
@@ -304,14 +307,14 @@ void train_next()
 	if (targ.speed)
 	{
 		if (self.spawnflags & 1)
-			SUB_CalcMove_Bezier(cp.origin, targ.origin - self.mins, targ.speed, train_wait);
+			SUB_CalcMove_Bezier(cp_org, targ.origin - self.mins, targ.speed, train_wait);
 		else
 			SUB_CalcMove(targ.origin - self.mins, targ.speed, train_wait);
 	}
 	else
 	{
 		if (self.spawnflags & 1)
-			SUB_CalcMove_Bezier(cp.origin, targ.origin - self.mins, self.speed, train_wait);
+			SUB_CalcMove_Bezier(cp_org, targ.origin - self.mins, self.speed, train_wait);
 		else
 			SUB_CalcMove(targ.origin - self.mins, self.speed, train_wait);
 	}
-- 
2.39.5