From: Rudolf Polzer Date: Thu, 24 May 2012 12:38:52 +0000 (+0200) Subject: set_platmovetype: more consistency X-Git-Tag: xonotic-v0.8.0~295^2~26 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=5433e6502011a7397bf31551afdc29edc29b337c;p=xonotic%2Fxonotic-data.pk3dir.git set_platmovetype: more consistency --- diff --git a/qcsrc/server/t_plats.qc b/qcsrc/server/t_plats.qc index 558786fbd..fcad92f69 100644 --- a/qcsrc/server/t_plats.qc +++ b/qcsrc/server/t_plats.qc @@ -182,25 +182,41 @@ void plat_reset() } } -void set_platmovetype(entity e, string s) +float 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 > 0) + e.platmovetype_start = stof(argv(0)); + else + e.platmovetype_start = 0; + if(n > 1) e.platmovetype_end = stof(argv(1)); + else + e.platmovetype_end = e.platmovetype_start; + + if(n > 2) + if(argv(2) == "force") + return TRUE; // no checking, return immediately + + if(!cubic_speedfunc_is_sane(e.platmovetype_start, e.platmovetype_end)) + { + objerror("Invalid platform move type; platform would go in reverse, which is not allowed."); + return FALSE; + } + + return TRUE; } void spawnfunc_path_corner() { // 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); + if(!set_platmovetype(self, self.platmovetype)) + return; } void spawnfunc_func_plat() {