From cd016100b954cc6e16941ae735e6080a85f72f1a Mon Sep 17 00:00:00 2001 From: Mircea Kitsune Date: Thu, 24 May 2012 15:31:18 +0300 Subject: [PATCH] Attempt to get overriding working, needs to be tested. Note that in order to avoid storing extra values for no reason, each path_corner tokenizes self.platmovetype when the train reaches it. It's a more logical implementation, but if it's harmful I'll store two more values for start_default and end_default --- qcsrc/server/t_plats.qc | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index bf8ee01ee..558786fbd 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -182,19 +182,25 @@ void plat_reset() } } +void set_platmovetype(entity e, string s) +{ + // sets platmovetype_start and platmovetype_end based on a string consisting of two values + if(s == "") + return; + + float n; + n = tokenize_console(s); + e.platmovetype_start = stof(argv(0)); + e.platmovetype_end = stof(argv(0)); + if(n > 1) + e.platmovetype_end = stof(argv(1)); +} + void spawnfunc_path_corner() { - if(self.platmovetype && self.platmovetype != "") - { - // setup values for overriding train movement - // if a second value does not exist, both start and end speeds are the single value specified - float n; - n = tokenize_console(self.platmovetype); - self.platmovetype_start = stof(argv(0)); - self.platmovetype_end = stof(argv(0)); - if(n > 1) - self.platmovetype_end = stof(argv(1)); - } + // setup values for overriding train movement + // if a second value does not exist, both start and end speeds are the single value specified + set_platmovetype(self, self.platmovetype); } void spawnfunc_func_plat() { @@ -325,12 +331,11 @@ void train_next() if (!self.wait) self.wait = 0.1; + // override train movement type if necessary if(targ.platmovetype_start || targ.platmovetype_end) - { - // override train movement type - self.platmovetype_start = targ.platmovetype_start; - self.platmovetype_end = targ.platmovetype_end; - } + set_platmovetype(self, targ.platmovetype); + else + set_platmovetype(self, self.platmovetype); if (targ.speed) { @@ -396,6 +401,8 @@ void spawnfunc_func_train() self.dmgtime = 0.25; self.dmgtime2 = time; + set_platmovetype(self, self.platmovetype); + // TODO make a reset function for this one } -- 2.39.2