]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/radarmap.qc
Merge branch 'master' into Mario/stats_eloranking
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / radarmap.qc
index acf2d40aee5233935b6569cb445a0c52c4d1ca88..87bcef82f7124e1f001603129320b0684d46af5f 100644 (file)
@@ -1,9 +1,9 @@
 #include "radarmap.qh"
+#ifdef RADARMAP
+
 #include <common/command/_mod.qh>
-#include "radarmap.qh"
 
 #include "../g_world.qh"
-#include "../g_subs.qh"
 
 #include <common/util.qh>
 
@@ -26,7 +26,7 @@ float FullTraceFraction(vector a, vector mi, vector ma, vector b)
        float n, m;
        n = m = 0;
 
-       while (vlen(c - b) > 1)
+       while (vdist(c - b, >, 1))
        {
                ++m;
 
@@ -49,18 +49,18 @@ float FullTraceFraction(vector a, vector mi, vector ma, vector b)
 
        return white / (black + white);
 }
-float RadarMapAtPoint_Trace(float x, float y, float w, float h, float zmin, float zsize, float q)
+float RadarMapAtPoint_Trace(float e, float f, float w, float h, float zmin, float zsize, float q)
 {
        vector a, b, mi, ma;
 
        mi = '0 0 0';
        ma = '1 0 0' * w + '0 1 0' * h;
-       a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
-       b = '1 0 0' * x + '0 1 0' * y + '0 0 1' * (zsize + zmin);
+       a = '1 0 0' * e + '0 1 0' * f + '0 0 1' * zmin;
+       b = '1 0 0' * e + '0 1 0' * f + '0 0 1' * (zsize + zmin);
 
        return FullTraceFraction(a, mi, ma, b);
 }
-float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin, float zsize, float q)
+float RadarMapAtPoint_LineBlock(float e, float f, float w, float h, float zmin, float zsize, float q)
 {
        vector o, mi, ma;
        float i, r;
@@ -72,12 +72,12 @@ float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin,
        mi = '0 0 0';
        dz = (zsize / q) * '0 0 1';
        ma = '1 0 0' * w + '0 1 0' * h + dz;
-       o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
+       o = '1 0 0' * e + '0 1 0' * f + '0 0 1' * zmin;
 
-       if (x < world.absmin.x - w) return 0;
-       if (y < world.absmin.y - h) return 0;
-       if (x > world.absmax.x) return 0;
-       if (y > world.absmax.y) return 0;
+       if (e < world.absmin.x - w) return 0;
+       if (f < world.absmin.y - h) return 0;
+       if (e > world.absmax.x) return 0;
+       if (f > world.absmax.y) return 0;
 
        r = 0;
        for (i = 0; i < q; ++i)
@@ -95,7 +95,7 @@ float RadarMapAtPoint_LineBlock(float x, float y, float w, float h, float zmin,
        }
        return r / q;
 }
-float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, float zsize, float q)
+float RadarMapAtPoint_Block(float e, float f, float w, float h, float zmin, float zsize, float q)
 {
        vector o, mi, ma;
        float i, r;
@@ -107,12 +107,12 @@ float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, floa
        mi = '0 0 0';
        dz = (zsize / q) * '0 0 1';
        ma = '1 0 0' * w + '0 1 0' * h + dz;
-       o = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
+       o = '1 0 0' * e + '0 1 0' * f + '0 0 1' * zmin;
 
-       if (x < world.absmin.x - w) return 0;
-       if (y < world.absmin.y - h) return 0;
-       if (x > world.absmax.x) return 0;
-       if (y > world.absmax.y) return 0;
+       if (e < world.absmin.x - w) return 0;
+       if (f < world.absmin.y - h) return 0;
+       if (e > world.absmax.x) return 0;
+       if (f > world.absmax.y) return 0;
 
        r = 0;
        for (i = 0; i < q; ++i)
@@ -122,7 +122,7 @@ float RadarMapAtPoint_Block(float x, float y, float w, float h, float zmin, floa
        }
        return r / q;
 }
-float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, float zsize, float q)
+float RadarMapAtPoint_Sample(float e, float f, float w, float h, float zmin, float zsize, float q)
 {
        vector a, b, mi, ma;
 
@@ -133,7 +133,7 @@ float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, flo
 
        mi = '0 0 0';
        ma = '1 0 0' * w + '0 1 0' * h;
-       a = '1 0 0' * x + '0 1 0' * y + '0 0 1' * zmin;
+       a = '1 0 0' * e + '0 1 0' * f + '0 0 1' * zmin;
        b = '1 0 0' * w + '0 1 0' * h + '0 0 1' * zsize;
 
        float c, i;
@@ -151,31 +151,31 @@ float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, flo
 
        return c / q;
 }
-void sharpen_set(int x, float v)
+void sharpen_set(int b, float v)
 {
-       sharpen_buffer[x + 2 * RADAR_WIDTH_MAX] = v;
+       sharpen_buffer[b + 2 * RADAR_WIDTH_MAX] = v;
 }
-float sharpen_getpixel(int x, int y)
+float sharpen_getpixel(int b, int c)
 {
-       if (x < 0) return 0;
-       if (x >= RADAR_WIDTH_MAX) return 0;
-       if (y < 0) return 0;
-       if (y > 2) return 0;
-       return sharpen_buffer[x + y * RADAR_WIDTH_MAX];
+       if (b < 0) return 0;
+       if (b >= RADAR_WIDTH_MAX) return 0;
+       if (c < 0) return 0;
+       if (c > 2) return 0;
+       return sharpen_buffer[b + c * RADAR_WIDTH_MAX];
 }
-float sharpen_get(float x, float a)
+float sharpen_get(float b, float a)
 {
-       float sum = sharpen_getpixel(x, 1);
+       float sum = sharpen_getpixel(b, 1);
        if (a == 0) return sum;
        sum *= (8 + 1 / a);
-       sum -= sharpen_getpixel(x - 1, 0);
-       sum -= sharpen_getpixel(x - 1, 1);
-       sum -= sharpen_getpixel(x - 1, 2);
-       sum -= sharpen_getpixel(x + 1, 0);
-       sum -= sharpen_getpixel(x + 1, 1);
-       sum -= sharpen_getpixel(x + 1, 2);
-       sum -= sharpen_getpixel(x, 0);
-       sum -= sharpen_getpixel(x, 2);
+       sum -= sharpen_getpixel(b - 1, 0);
+       sum -= sharpen_getpixel(b - 1, 1);
+       sum -= sharpen_getpixel(b - 1, 2);
+       sum -= sharpen_getpixel(b + 1, 0);
+       sum -= sharpen_getpixel(b + 1, 1);
+       sum -= sharpen_getpixel(b + 1, 2);
+       sum -= sharpen_getpixel(b, 0);
+       sum -= sharpen_getpixel(b, 2);
        return bound(0, sum * a, 1);
 }
 void sharpen_shift(int w)
@@ -229,7 +229,7 @@ void RadarMap_Think(entity this)
                this.maxs_x = (mi_picmax.x - mi_picmin.x) / this.size.x;
                this.maxs_y = (mi_picmax.y - mi_picmin.y) / this.size.y;
                this.maxs_z = mi_max.z - mi_min.z;
-               LOG_INFO("Picture mins/maxs: ", ftos(this.maxs.x), " and ", ftos(this.maxs.y), " should match\n");
+               LOG_INFO("Picture mins/maxs: ", ftos(this.maxs.x), " and ", ftos(this.maxs.y), " should match");
                this.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm"));
                if (!(this.count & 1))
                {
@@ -244,7 +244,7 @@ void RadarMap_Think(entity this)
                        {
                                fclose(this.cnt);
 
-                               LOG_INFO(this.netname, " already exists, aborting (you may want to specify --force)\n");
+                               LOG_INFO(this.netname, " already exists, aborting (you may want to specify --force)");
                                RadarMap_Next();
                                return;
                        }
@@ -252,12 +252,12 @@ void RadarMap_Think(entity this)
                this.cnt = fopen(this.netname, FILE_WRITE);
                if (this.cnt < 0)
                {
-                       LOG_INFO("Error writing ", this.netname, "\n");
+                       LOG_INFO("Error writing ", this.netname);
                        delete(this);
                        radarmapper = NULL;
                        return;
                }
-               LOG_INFO("Writing to ", this.netname, "...\n");
+               LOG_INFO("Writing to ", this.netname, "...");
                fputs(this.cnt, "/* XPM */\n");
                fputs(this.cnt, "static char *RadarMap[] = {\n");
                fputs(this.cnt, "/* columns rows colors chars-per-pixel */\n");
@@ -327,7 +327,7 @@ void RadarMap_Think(entity this)
                        else
                        {
                                fputs(this.cnt, "\",\n");
-                               LOG_INFO(ftos(this.size.y - this.frame), " lines left\n");
+                               LOG_INFO(ftos(this.size.y - this.frame), " lines left");
                        }
                }
 
@@ -349,7 +349,7 @@ void RadarMap_Think(entity this)
                        else
                        {
                                fputs(this.cnt, "\",\n");
-                               LOG_INFO(ftos(this.size.y - this.frame), " lines left\n");
+                               LOG_INFO(ftos(this.size.y - this.frame), " lines left");
                        }
                }
 
@@ -361,12 +361,12 @@ void RadarMap_Think(entity this)
                // close the file
                fputs(this.cnt, "};\n");
                fclose(this.cnt);
-               LOG_INFO("Finished. Please edit data/", this.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
+               LOG_INFO("Finished. Please edit data/", this.netname, " with an image editing application and place it in the TGA format in the gfx folder.");
                RadarMap_Next();
        }
 }
 
-float RadarMap_Make(float argc)
+bool RadarMap_Make(float argc)
 {
        float i;
 
@@ -447,10 +447,11 @@ float RadarMap_Make(float argc)
 
                if (radarmapper)  // after doing the arguments, see if we successfully went forward.
                {
-                       LOG_INFO("Radarmap entity spawned.\n");
+                       LOG_INFO("Radarmap entity spawned.");
                        return true;  // if so, don't print usage.
                }
        }
 
        return false;
 }
+#endif