X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fpathlib%2Futility.qc;h=77f5330ef789d2b75e04c29fa35e00612dda01bd;hb=fc15d72b041c9a748b605ba28735380fbe5b5b01;hp=7a0aec8652ed0ae8f32b2594da45ad49459a6165;hpb=786db02b0c9aa618c581b7c3fe7392ad114797d8;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/pathlib/utility.qc b/qcsrc/server/pathlib/utility.qc index 7a0aec865..77f5330ef 100644 --- a/qcsrc/server/pathlib/utility.qc +++ b/qcsrc/server/pathlib/utility.qc @@ -1,18 +1,6 @@ -float fsnap(float val,float fsize) -{ - return rint(val / fsize) * fsize; -} - -vector vsnap(vector point,float fsize) -{ - vector vret; - - vret_x = rint(point_x / fsize) * fsize; - vret_y = rint(point_y / fsize) * fsize; - vret_z = ceil(point_z / fsize) * fsize; +#include "utility.qh" - return vret; -} +#include "pathlib.qh" float location_isok(vector point, float water_isok, float air_isok) { @@ -68,22 +56,22 @@ entity pathlib_nodeatpoint(vector where) ++pathlib_searched_cnt; - where_x = fsnap(where_x,pathlib_gridsize); - where_y = fsnap(where_y,pathlib_gridsize); + where.x = fsnap(where.x,pathlib_gridsize); + where.y = fsnap(where.y,pathlib_gridsize); node = findradius(where,pathlib_gridsize * 0.5); while(node) { - if(node.is_path_node == TRUE) + if(node.is_path_node == true) return node; node = node.chain; } - return world; + return NULL; } -float tile_check_cross(vector where) +float tile_check_cross(entity this, vector where) { vector p,f,r; @@ -93,32 +81,32 @@ float tile_check_cross(vector where) // forward-right p = where + f + r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (!location_isok(trace_endpos, 1, 0)) return 0; // Forward-left p = where + f - r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (!location_isok(trace_endpos, 1, 0)) return 0; // Back-right p = where - f + r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (!location_isok(trace_endpos, 1 ,0)) return 0; //Back-left p = where - f - r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (!location_isok(trace_endpos, 1, 0)) return 0; return 1; } -float tile_check_plus(vector where) +float tile_check_plus(entity this, vector where) { vector p,f,r; @@ -127,33 +115,33 @@ float tile_check_plus(vector where) // forward p = where + f; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (!location_isok(trace_endpos,1,0)) return 0; //left p = where - r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (!location_isok(trace_endpos,1,0)) return 0; // Right p = where + r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (!location_isok(trace_endpos,1,0)) return 0; //Back p = where - f; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (!location_isok(trace_endpos,1,0)) return 0; return 1; } -float tile_check_plus2(vector where) +float tile_check_plus2(entity this, vector where) { vector p,f,r; float i = 0, e = 0; @@ -168,7 +156,7 @@ float tile_check_plus2(vector where) // forward p = where + f; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (location_isok(trace_endpos,1,0)) { ++i; @@ -178,7 +166,7 @@ float tile_check_plus2(vector where) //left p = where - r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (location_isok(trace_endpos,1,0)) { ++i; @@ -188,7 +176,7 @@ float tile_check_plus2(vector where) // Right p = where + r; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (location_isok(trace_endpos,1,0)) { ++i; @@ -197,7 +185,7 @@ float tile_check_plus2(vector where) //Back p = where - f; - traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,self); + traceline(p+tile_check_up,p-tile_check_down,MOVE_WORLDONLY,this); if (location_isok(trace_endpos,1,0)) { ++i; @@ -206,7 +194,7 @@ float tile_check_plus2(vector where) // forward-right p = where + f + r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (location_isok(trace_endpos, 1, 0)) { ++i; @@ -215,7 +203,7 @@ float tile_check_plus2(vector where) // Forward-left p = where + f - r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (location_isok(trace_endpos, 1, 0)) { ++i; @@ -224,7 +212,7 @@ float tile_check_plus2(vector where) // Back-right p = where - f + r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (location_isok(trace_endpos, 1 ,0)) { ++i; @@ -233,7 +221,7 @@ float tile_check_plus2(vector where) //Back-left p = where - f - r; - traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, self); + traceline(p + tile_check_up, p - tile_check_down, MOVE_WORLDONLY, this); if (location_isok(trace_endpos, 1, 0)) { ++i; @@ -247,10 +235,10 @@ float tile_check_plus2(vector where) return e; } -float tile_check_star(vector where) +float tile_check_star(entity this, vector where) { - if(tile_check_plus(where)) - return tile_check_cross(where); + if(tile_check_plus(this, where)) + return tile_check_cross(this, where); return 0; }