]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
First read the whole default player model description file, then read only the transl... terencehill/menu_translated_playermodel_description
authorterencehill <piuntn@gmail.com>
Thu, 17 Dec 2015 18:39:24 +0000 (19:39 +0100)
committerterencehill <piuntn@gmail.com>
Thu, 17 Dec 2015 18:39:24 +0000 (19:39 +0100)
models/player/erebus.iqm_0.txt.it
qcsrc/common/util.qc

index 5fbf1b33cd55aa914d616ec34187a319dcbff7b3..ea749413e598c774c103335790b72c8c39769389 100644 (file)
@@ -1,13 +1,5 @@
 name Erebus
 species umano
 sex Maschio
-weight 105
-age 26
 description Soldato peso massimo di Xonotic
-bone_upperbody spine2
-bone_aim0 0.25 spine2
-bone_aim1 0.4 spine4
-bone_aim2 0.2 upperarm_L
-bone_aim3 0.35 bip01 r hand
-bone_weapon bip01 r hand
-fixbone 1
+
index 73433252c8ad2c4a0a1490cbe74f69b5e7436e6d..851c52bcddbc98df444cfe23efb93882beeafcb9 100644 (file)
@@ -1170,51 +1170,18 @@ string get_model_datafilename(string m, float sk, string fil)
        return strcat(m, ".", fil);
 }
 
-float get_model_parameters(string m, float sk)
+float read_model_parameters_file(string m, float sk, bool from_translated_file)
 {
-       get_model_parameters_modelname = string_null;
-       get_model_parameters_modelskin = -1;
-       get_model_parameters_name = string_null;
-       get_model_parameters_species = -1;
-       get_model_parameters_sex = string_null;
-       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(int 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;
-
-#ifndef MENUQC
-       MUTATOR_CALLHOOK(ClearModelParams);
-#endif
-
-       if (!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")
-                       return 0;
-               if(substring(m, -6, 1) != "_")
-                       return 0;
-               sk = stof(substring(m, -5, 1));
-               m = substring(m, 0, -7);
-       }
-
-       string fn = language_filename(get_model_datafilename(m, sk, "txt"));
+       string fn = get_model_datafilename(m, sk, "txt");
+       if(from_translated_file)
+               fn = language_filename(fn);
        int fh = fopen(fn, FILE_READ);
        if(fh < 0)
        {
                sk = 0;
-               fn = language_filename(get_model_datafilename(m, sk, "txt"));
+               fn = get_model_datafilename(m, sk, "txt");
+               if(from_translated_file)
+                       fn = language_filename(fn);
                fh = fopen(fn, FILE_READ);
                if(fh < 0)
                        return 0;
@@ -1231,6 +1198,15 @@ float get_model_parameters(string m, float sk)
                s = cdr(s);
                if(c == "name")
                        get_model_parameters_name = s;
+               if(c == "sex")
+                       get_model_parameters_sex = s;
+               if(c == "description")
+                       get_model_parameters_description = s;
+
+               if(from_translated_file)
+                       continue;
+
+               // technical/non-translatable fields start here
                if(c == "species")
                        switch(s)
                        {
@@ -1242,14 +1218,10 @@ float get_model_parameters(string m, float sk)
                                case "animal":      get_model_parameters_species = SPECIES_ANIMAL;      break;
                                case "reserved":    get_model_parameters_species = SPECIES_RESERVED;    break;
                        }
-               if(c == "sex")
-                       get_model_parameters_sex = s;
                if(c == "weight")
                        get_model_parameters_weight = stof(s);
                if(c == "age")
                        get_model_parameters_age = stof(s);
-               if(c == "description")
-                       get_model_parameters_description = s;
                if(c == "bone_upperbody")
                        get_model_parameters_bone_upperbody = s;
                if(c == "bone_weapon")
@@ -1267,6 +1239,7 @@ float get_model_parameters(string m, float sk)
                        get_model_parameters_fixbone = stof(s);
        }
 
+       // FIXME
        while((s = fgets(fh)))
        {
                if(get_model_parameters_desc)
@@ -1280,6 +1253,50 @@ float get_model_parameters(string m, float sk)
        return 1;
 }
 
+float get_model_parameters(string m, float sk)
+{
+       get_model_parameters_modelname = string_null;
+       get_model_parameters_modelskin = -1;
+       get_model_parameters_name = string_null;
+       get_model_parameters_species = -1;
+       get_model_parameters_sex = string_null;
+       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(int 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;
+
+#ifndef MENUQC
+       MUTATOR_CALLHOOK(ClearModelParams);
+#endif
+
+       if (!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")
+                       return 0;
+               if(substring(m, -6, 1) != "_")
+                       return 0;
+               sk = stof(substring(m, -5, 1));
+               m = substring(m, 0, -7);
+       }
+
+       float ret_value = read_model_parameters_file(m, sk, false);
+       read_model_parameters_file(m, sk, true); // overrides translateble fields
+       return ret_value;
+}
+
 // x-encoding (encoding as zero length invisible string)
 const string XENCODE_2  = "xX";
 const string XENCODE_22 = "0123456789abcdefABCDEF";