]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/waypointsprites.qc
Release loaded rockets when the player dies
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / waypointsprites.qc
index 8584d24f2b26a52fad6a308b753bfdf3dcab4463..bcd8c433e07b185d3eb997f60d976daee526b2d2 100644 (file)
@@ -336,7 +336,6 @@ void Ent_WaypointSprite()
                        else
                                self.build_starthealth = 0;
                        self.build_finished = servertime + t / 32;
-                       //print("build: ", ftos(self.build_finished - self.build_started), "\n");
                }
        }
        else
@@ -407,9 +406,32 @@ void Ent_WaypointSprite()
        self.entremove = Ent_RemoveWaypointSprite;
 }
 
+void WaypointSprite_Load_Frames(string ext)
+{
+       float dh, n, i, o, f;
+       string s, sname, sframes;
+       dh = search_begin(strcat("models/sprites/*_frame*", ext), FALSE, FALSE);
+       if (dh < 0)
+                return;
+       float ext_len = strlen(ext);
+       n = search_getsize(dh);
+       for(i = 0; i < n; ++i)
+       {
+               s = search_getfilename(dh, i);
+               s = substring(s, 15, strlen(s) - 15 - ext_len); // strip models/sprites/ and extension
+
+               o = strstrofs(s, "_frame", 0);
+               sname = strcat("/spriteframes/", substring(s, 0, o));
+               sframes = substring(s, o + 6, strlen(s) - o - 6);
+               f = stof(sframes) + 1;
+               db_put(tempdb, sname, ftos(max(f, stof(db_get(tempdb, sname)))));
+       }
+       search_end(dh);
+}
+
 void WaypointSprite_Load()
 {
-       waypointsprite_fadedistance = vlen(mi_max - mi_min);
+       waypointsprite_fadedistance = vlen(mi_scale);
        waypointsprite_normdistance = autocvar_g_waypointsprite_normdistance;
        waypointsprite_minscale = autocvar_g_waypointsprite_minscale;
        waypointsprite_minalpha = autocvar_g_waypointsprite_minalpha;
@@ -424,43 +446,13 @@ void WaypointSprite_Load()
        waypointsprite_crosshairfadedistance = autocvar_g_waypointsprite_crosshairfadedistance;
        waypointsprite_distancefadealpha = autocvar_g_waypointsprite_distancefadealpha;
        waypointsprite_distancefadescale = autocvar_g_waypointsprite_distancefadescale;
-       waypointsprite_distancefadedistance = vlen(mi_max - mi_min) * autocvar_g_waypointsprite_distancefadedistancemultiplier;
+       waypointsprite_distancefadedistance = waypointsprite_fadedistance * autocvar_g_waypointsprite_distancefadedistancemultiplier;
        waypointsprite_alpha = autocvar_g_waypointsprite_alpha * (1 - autocvar__menu_alpha);
 
        if(!waypointsprite_initialized)
        {
-               float dh, n, i, o, f;
-               string s, sname, sframes;
-
-               dh = search_begin("models/sprites/*_frame*.tga", FALSE, FALSE);
-               n = search_getsize(dh);
-               for(i = 0; i < n; ++i)
-               {
-                       s = search_getfilename(dh, i);
-                       s = substring(s, 15, strlen(s) - 15 - 4); // strip models/sprites/ and .tga
-
-                       o = strstrofs(s, "_frame", 0);
-                       sname = strcat("/spriteframes/", substring(s, 0, o));
-                       sframes = substring(s, o + 6, strlen(s) - o - 6);
-                       f = stof(sframes) + 1;
-                       db_put(tempdb, sname, ftos(max(f, stof(db_get(tempdb, sname)))));
-               }
-               search_end(dh);
-
-               dh = search_begin("models/sprites/*_frame*.jpg", FALSE, FALSE);
-               n = search_getsize(dh);
-               for(i = 0; i < n; ++i)
-               {
-                       s = search_getfilename(dh, i);
-                       s = substring(s, 15, strlen(s) - 15 - 4); // strip models/sprites/ and .jpg
-
-                       o = strstrofs(s, "_frame", 0);
-                       sname = strcat("/spriteframes/", substring(s, 0, o));
-                       sframes = substring(s, o + 6, strlen(s) - o - 6);
-                       f = stof(sframes) + 1;
-                       db_put(tempdb, sname, ftos(max(f, stof(db_get(tempdb, sname)))));
-               }
-               search_end(dh);
+               WaypointSprite_Load_Frames(".tga");
+               WaypointSprite_Load_Frames(".jpg");
+               waypointsprite_initialized = true;
        }
-       waypointsprite_initialized = 1;
 }