From: Maik Merten Date: Sun, 21 Nov 2010 16:36:26 +0000 (+0100) Subject: make sure the SUB_CalcMove controller cannot set a velocity after the think function... X-Git-Tag: xonotic-v0.5.0~311^2~37^2^2~11 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=a90db3e7016d8c3ef7fa9961ba56107c2c97da9d;p=xonotic%2Fxonotic-data.pk3dir.git make sure the SUB_CalcMove controller cannot set a velocity after the think function to stop the animation has been called. Also: remove the controller when the job is done. --- diff --git a/qcsrc/server/g_subs.qc b/qcsrc/server/g_subs.qc index d287b1a53..bcbf6336e 100644 --- a/qcsrc/server/g_subs.qc +++ b/qcsrc/server/g_subs.qc @@ -179,13 +179,14 @@ void SUB_CalcMoveDone (void) void SUB_CalcMove_controller_think (void) { + entity oldself; float movephase; float traveltime; float phasepos; vector delta; vector veloc; if(time < self.animstate_endtime) { - delta = self.finaldest - self.origin; + delta = self.destvec; traveltime = self.animstate_endtime - self.animstate_starttime; movephase = (time - self.animstate_starttime) / traveltime; @@ -208,6 +209,12 @@ void SUB_CalcMove_controller_think (void) self.owner.velocity = veloc; self.nextthink = time + 0.1; + } else { + oldself = self; + self.owner.think = self.think1; + self = self.owner; + remove(oldself); + self.think(); } } @@ -246,12 +253,15 @@ void SUB_CalcMove (vector tdest, float tspeed, void() func) controller.owner = self; controller.origin = self.origin; // starting point controller.finaldest = tdest; // where do we want to end? + controller.destvec = delta; controller.animstate_starttime = time; controller.animstate_endtime = time + traveltime; controller.think = SUB_CalcMove_controller_think; + controller.think1 = self.think; // let the controller handle the velocity compuation //self.velocity = delta * (1/traveltime); // QuakeC doesn't allow vector/float division + self.think = SUB_Null; self.nextthink = self.ltime + traveltime; // invoke controller