From: terencehill Date: Thu, 17 Dec 2015 18:39:24 +0000 (+0100) Subject: First read the whole default player model description file, then read only the transl... X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4f6409508ab6108bfff415fcf46010f7013f7197;p=xonotic%2Fxonotic-data.pk3dir.git First read the whole default player model description file, then read only the translatable fields from the translation file --- diff --git a/models/player/erebus.iqm_0.txt.it b/models/player/erebus.iqm_0.txt.it index 5fbf1b33c..ea749413e 100644 --- a/models/player/erebus.iqm_0.txt.it +++ b/models/player/erebus.iqm_0.txt.it @@ -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 + diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 73433252c..851c52bcd 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -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";