]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util.qc
Move time processing and counting to counting.qh
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util.qc
index dc882194e1463e12e0be9d84877d0be91ad9147c..9db09a24345d118bb3a7620204fdd954191360bc 100644 (file)
@@ -2001,7 +2001,7 @@ string get_model_datafilename(string m, float sk, string fil)
 float get_model_parameters(string m, float sk)
 {
        string fn, s, c;
-       float fh;
+       float fh, i;
 
        get_model_parameters_modelname = string_null;
        get_model_parameters_modelskin = -1;
@@ -2011,9 +2011,21 @@ float get_model_parameters(string m, float sk)
        get_model_parameters_weight = -1;
        get_model_parameters_age = -1;
        get_model_parameters_desc = string_null;
+       get_model_parameters_bone_upperbody = string_null;
+       get_model_parameters_bone_weapon = string_null;
+       for(i = 0; i < MAX_AIM_BONES; ++i)
+       {
+               get_model_parameters_bone_aim[i] = string_null;
+               get_model_parameters_bone_aimweight[i] = 0;
+       }
+       get_model_parameters_fixbone = 0;
 
        if not(m)
                return 1;
+
+       if(substring(m, -9, 5) == "_lod1" || substring(m, -9, 5) == "_lod2")
+               m = strcat(substring(m, 0, -10), substring(m, -4, -1));
+
        if(sk < 0)
        {
                if(substring(m, -4, -1) != ".txt")
@@ -2062,6 +2074,18 @@ float get_model_parameters(string m, float sk)
                        get_model_parameters_weight = stof(s);
                if(c == "age")
                        get_model_parameters_age = stof(s);
+               if(c == "bone_upperbody")
+                       get_model_parameters_bone_upperbody = s;
+               if(c == "bone_weapon")
+                       get_model_parameters_bone_weapon = s;
+               for(i = 0; i < MAX_AIM_BONES; ++i)
+                       if(c == strcat("bone_aim", ftos(i)))
+                       {
+                               get_model_parameters_bone_aimweight[i] = stof(car(s));
+                               get_model_parameters_bone_aim[i] = cdr(s);
+                       }
+               if(c == "fixbone")
+                       get_model_parameters_fixbone = stof(s);
        }
 
        while((s = fgets(fh)))
@@ -2480,32 +2504,6 @@ void FindConnectedComponent(entity e, .entity fld, findNextEntityNearFunction_t
                queue_start.FindConnectedComponent_processing = 0;
 }
 
-float Count_Proper_Strings(string improper, string...count)
-{
-       float i, total = 0;
-       string tmp;
-       
-       for(i = 0; i < count; ++i)
-       {
-               tmp = ...(i, string);
-               if((tmp) && (tmp != improper)) { ++total; }
-       }
-       
-       return total;
-}
-
-float Count_Proper_Floats(float improper, float...count)
-{
-       float i, total = 0;
-       
-       for(i = 0; i < count; ++i)
-       {
-               if(...(i, float) != improper) { ++total; }
-       }
-       
-       return total;
-}
-
 // todo: this sucks, lets find a better way to do backtraces?
 #ifndef MENUQC
 void backtrace(string msg)
@@ -2552,3 +2550,39 @@ string CCR(string input)
        input = strreplace("^N", "^7", input); // "none"-- reset to white...
        return input;
 }
+
+vector vec3(float x, float y, float z)
+{
+       vector v;
+       v_x = x;
+       v_y = y;
+       v_z = z;
+       return v;
+}
+
+#ifndef MENUQC
+vector animfixfps(entity e, vector a, vector b)
+{
+       // multi-frame anim: keep as-is
+       if(a_y == 1)
+       {
+               float dur;
+               dur = frameduration(e.modelindex, a_x);
+               if(dur <= 0 && b_y)
+               {
+                       a = b;
+                       dur = frameduration(e.modelindex, a_x);
+               }
+               if(dur > 0)
+                       a_z = 1.0 / dur;
+       }
+       return a;
+}
+#endif
+
+#ifdef SVQC
+void dedicated_print(string input) // print(), but only print if the server is not local
+{
+       if(server_is_dedicated) { print(input); }
+}
+#endif