]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge location_isok and beamsweep_badpoint (same function reversed)
authorMario <mario@smbclan.net>
Sun, 26 Feb 2017 13:27:35 +0000 (23:27 +1000)
committerMario <mario@smbclan.net>
Sun, 26 Feb 2017 13:27:35 +0000 (23:27 +1000)
qcsrc/server/pathlib/utility.qc
qcsrc/server/pathlib/utility.qh
qcsrc/server/steerlib.qc

index 77f5330ef789d2b75e04c29fa35e00612dda01bd..be901f88668e6c2514be47125b9ec05fd0087d4a 100644 (file)
@@ -2,52 +2,23 @@
 
 #include "pathlib.qh"
 
-float location_isok(vector point, float water_isok, float air_isok)
+bool location_isok(vector point, bool waterok, bool air_isok)
 {
-    float pc,pc2;
-
     if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
-        return 0;
-
-    pc  = pointcontents(point);
-    pc2 = pointcontents(point - '0 0 1');
-
-    switch(pc)
-    {
-        case CONTENT_SOLID:
-            break;
-
-        case CONTENT_SLIME:
-            break;
-
-        case CONTENT_LAVA:
-            break;
-
-        case CONTENT_SKY:
-            break;
-
-        case CONTENT_EMPTY:
-            if (pc2 == CONTENT_SOLID)
-                return 1;
-
-            if (pc2 == CONTENT_EMPTY)
-                if(air_isok)
-                    return 1;
-
-            if (pc2 == CONTENT_WATER)
-                if(water_isok)
-                    return 1;
-
-            break;
-
-        case CONTENT_WATER:
-            if (water_isok)
-                return 1;
-
-            break;
-    }
-
-    return 0;
+        return false;
+
+    int pc = pointcontents(point);
+    int pc2 = pointcontents(point - '0 0 1');
+
+    if(pc == CONTENT_EMPTY && pc2 == CONTENT_SOLID)
+        return true;
+    if(pc == CONTENT_EMPTY && pc2 == CONTENT_WATER && waterok)
+        return true;
+    if(pc == CONTENT_EMPTY && pc2 == CONTENT_EMPTY && air_isok)
+        return true;
+    if(pc == CONTENT_WATER && waterok)
+        return true;
+    return false;
 }
 
 entity pathlib_nodeatpoint(vector where)
index da4ace73e5bd14c56c9634d4753b2588595bb390..f89a60c12dc345bbde8da9ddccf9960e43c66f3d 100644 (file)
@@ -3,3 +3,4 @@
 float fsnap(float val,float fsize);
 entity pathlib_nodeatpoint(vector where);
 float tile_check_plus2(entity this, vector where);
+bool location_isok(vector point, bool waterok, bool air_isok);
index 1544fa384a5cbbf16eb4cebf3bf89be17faf1c1f..f986fa2a84f7930b3f732964b4bd8a86aaecd4c9 100644 (file)
@@ -2,6 +2,7 @@
 #if defined(CSQC)
 #elif defined(MENUQC)
 #elif defined(SVQC)
+    #include "pathlib/utility.qh"
 #endif
 
 /**
@@ -340,51 +341,6 @@ vector steerlib_traceavoid_flat(entity this, float pitch, float length, vector v
     return normalize(leftwish + rightwish + frontwish);
 }
 
-bool beamsweep_badpoint(vector point, bool waterok)
-{
-    if(trace_dphitq3surfaceflags & Q3SURFACEFLAG_SKY)
-        return true;
-
-    int pc = pointcontents(point);
-    int pc2 = pointcontents(point - '0 0 1');
-    
-    if(pc == CONTENT_EMPTY && pc2 == CONTENT_SOLID)
-        return false;
-    if(pc == CONTENT_EMPTY && pc2 == CONTENT_WATER && waterok)
-        return false;
-    if(pc == CONTENT_WATER && waterok)
-        return false;
-    return true;
-
-    /*switch(pc)
-    {
-        case CONTENT_SOLID: break;
-        case CONTENT_SLIME: break;
-        case CONTENT_LAVA:  break;
-
-        case CONTENT_SKY:
-            return true;
-
-        case CONTENT_EMPTY:
-            if (pc2 == CONTENT_SOLID)
-                return 0;
-
-            if (pc2 == CONTENT_WATER)
-                if(waterok)
-                    return 0;
-
-            break;
-
-        case CONTENT_WATER:
-            if(waterok)
-                return 0;
-
-            break;
-    }
-
-    return true;*/
-}
-
 //#define BEAMSTEER_VISUAL
 float beamsweep(entity this, vector from, vector dir,float length, float step,float step_up, float step_down)
 {
@@ -398,7 +354,7 @@ float beamsweep(entity this, vector from, vector dir,float length, float step,fl
     if(trace_fraction == 1.0)
         return 0;
 
-    if(beamsweep_badpoint(trace_endpos,0))
+    if(!location_isok(trace_endpos, false, false))
         return 0;
 
     a = trace_endpos;
@@ -414,7 +370,7 @@ float beamsweep(entity this, vector from, vector dir,float length, float step,fl
         if(trace_fraction == 1.0)
             return i / length;
 
-        if(beamsweep_badpoint(trace_endpos,0))
+        if(!location_isok(trace_endpos, false, false))
             return i / length;
 #ifdef BEAMSTEER_VISUAL
         te_lightning1(NULL,a+u,b+u);