]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/command/radarmap.qc
Nades: always throw with weapon drop in case offhand is occupied
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / command / radarmap.qc
index 9c644bfc559c3f76496fb4ed2923eab9a571d817..8c15819e05ad174a0ea24f09e573b92061554048 100644 (file)
@@ -1,3 +1,13 @@
+#include "../../common/command/command.qh"
+#include "radarmap.qh"
+#include "../_all.qh"
+
+#include "../g_world.qh"
+
+#include "../../common/util.qh"
+
+#include "../../csqcmodellib/sv_model.qh"
+
 // ===============================================
 //     Generates radar map images for use in the HUD
 // ===============================================
@@ -35,7 +45,7 @@ float FullTraceFraction(vector a, vector mi, vector ma, vector b)
        }
 
        if(n > 200)
-               dprint("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n");
+               LOG_TRACE("HOLY SHIT! FullTraceFraction: ", ftos(n), " total traces, ", ftos(m), " iterations\n");
 
        return white / (black + white);
 }
@@ -142,9 +152,9 @@ float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, flo
        for(i = 0; i < q; ++i)
        {
                vector v;
-               v_x = a.x + random() * b.x;
-               v_y = a.y + random() * b.y;
-               v_z = a.z + random() * b.z;
+               v.x = a.x + random() * b.x;
+               v.y = a.y + random() * b.y;
+               v.z = a.z + random() * b.z;
                traceline(v, v, MOVE_WORLDONLY, world);
                if(trace_startsolid)
                        ++c;
@@ -152,11 +162,11 @@ float RadarMapAtPoint_Sample(float x, float y, float w, float h, float zmin, flo
 
        return c / q;
 }
-void sharpen_set(float x, float v)
+void sharpen_set(int x, float v)
 {
        sharpen_buffer[x + 2 * RADAR_WIDTH_MAX] = v;
 }
-float sharpen_getpixel(float x, float y)
+float sharpen_getpixel(int x, int y)
 {
        if(x < 0)
                return 0;
@@ -170,8 +180,7 @@ float sharpen_getpixel(float x, float y)
 }
 float sharpen_get(float x, float a)
 {
-       float sum;
-       sum = sharpen_getpixel(x, 1);
+       float sum = sharpen_getpixel(x, 1);
        if(a == 0)
                return sum;
        sum *= (8 + 1/a);
@@ -185,20 +194,18 @@ float sharpen_get(float x, float a)
        sum -= sharpen_getpixel(x, 2);
        return bound(0, sum * a, 1);
 }
-void sharpen_shift(float w)
+void sharpen_shift(int w)
 {
-       float i;
-       for(i = 0; i < w; ++i)
+       for(int i = 0; i < w; ++i)
        {
                sharpen_buffer[i] = sharpen_buffer[i + RADAR_WIDTH_MAX];
                sharpen_buffer[i + RADAR_WIDTH_MAX] = sharpen_buffer[i + 2 * RADAR_WIDTH_MAX];
                sharpen_buffer[i + 2 * RADAR_WIDTH_MAX] = 0;
        }
 }
-void sharpen_init(float w)
+void sharpen_init(int w)
 {
-       float i;
-       for(i = 0; i < w; ++i)
+       for(int i = 0; i < w; ++i)
        {
                sharpen_buffer[i] = 0;
                sharpen_buffer[i + RADAR_WIDTH_MAX] = 0;
@@ -220,7 +227,7 @@ void RadarMap_Next()
        radarmapper = world;
 }
 void RadarMap_Think()
-{
+{SELFPARAM();
        // rough map entity
        //   cnt: current line
        //   size: pixel width/height
@@ -238,7 +245,7 @@ void RadarMap_Think()
                self.maxs_x = (mi_picmax.x - mi_picmin.x) / self.size.x;
                self.maxs_y = (mi_picmax.y - mi_picmin.y) / self.size.y;
                self.maxs_z = mi_max.z - mi_min.z;
-               print("Picture mins/maxs: ", ftos(self.maxs.x), " and ", ftos(self.maxs.y), " should match\n");
+               LOG_INFO("Picture mins/maxs: ", ftos(self.maxs.x), " and ", ftos(self.maxs.y), " should match\n");
                self.netname = strzone(strcat("gfx/", mi_shortname, "_radar.xpm"));
                if(!(self.count & 1))
                {
@@ -259,7 +266,7 @@ void RadarMap_Think()
                        {
                                fclose(self.cnt);
 
-                               print(self.netname, " already exists, aborting (you may want to specify --force)\n");
+                               LOG_INFO(self.netname, " already exists, aborting (you may want to specify --force)\n");
                                RadarMap_Next();
                                return;
                        }
@@ -267,12 +274,12 @@ void RadarMap_Think()
                self.cnt = fopen(self.netname, FILE_WRITE);
                if(self.cnt < 0)
                {
-                       print("Error writing ", self.netname, "\n");
+                       LOG_INFO("Error writing ", self.netname, "\n");
                        remove(self);
                        radarmapper = world;
                        return;
                }
-               print("Writing to ", self.netname, "...\n");
+               LOG_INFO("Writing to ", self.netname, "...\n");
                fputs(self.cnt, "/* XPM */\n");
                fputs(self.cnt, "static char *RadarMap[] = {\n");
                fputs(self.cnt, "/* columns rows colors chars-per-pixel */\n");
@@ -340,7 +347,7 @@ void RadarMap_Think()
                        else
                        {
                                fputs(self.cnt, "\",\n");
-                               print(ftos(self.size.y - self.frame), " lines left\n");
+                               LOG_INFO(ftos(self.size.y - self.frame), " lines left\n");
                        }
                }
 
@@ -360,7 +367,7 @@ void RadarMap_Think()
                        else
                        {
                                fputs(self.cnt, "\",\n");
-                               print(ftos(self.size.y - self.frame), " lines left\n");
+                               LOG_INFO(ftos(self.size.y - self.frame), " lines left\n");
                        }
                }
 
@@ -372,7 +379,7 @@ void RadarMap_Think()
                // close the file
                fputs(self.cnt, "};\n");
                fclose(self.cnt);
-               print("Finished. Please edit data/", self.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
+               LOG_INFO("Finished. Please edit data/", self.netname, " with an image editing application and place it in the TGA format in the gfx folder.\n");
                RadarMap_Next();
        }
 }
@@ -418,7 +425,7 @@ float RadarMap_Make(float argc)
 
                if(radarmapper) // after doing the arguments, see if we successfully went forward.
                {
-                       print("Radarmap entity spawned.\n");
+                       LOG_INFO("Radarmap entity spawned.\n");
                        return true; // if so, don't print usage.
                }
        }