X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fcommon%2Futil.qc;h=5990f1c9d63cbfab22bd097bca7bfa140801f7ce;hp=83ea8e3e5827fedbc29f9f7534aec14f8865ca80;hb=b3531989fe085982b9fa1b4c8e3a35947936e441;hpb=ee1bc52fd8269edac22ce73ddecc88583fa1d623 diff --git a/qcsrc/common/util.qc b/qcsrc/common/util.qc index 83ea8e3e5..5990f1c9d 100644 --- a/qcsrc/common/util.qc +++ b/qcsrc/common/util.qc @@ -360,7 +360,10 @@ float buf_load(string pFilename) return -1; fh = fopen(pFilename, FILE_READ); if(fh < 0) - return buf; + { + buf_del(buf); + return -1; + } i = 0; while((l = fgets(fh))) { @@ -1837,7 +1840,13 @@ float get_model_parameters(string m, float sk) fn = get_model_datafilename(m, sk, "txt"); fh = fopen(fn, FILE_READ); if(fh < 0) - return 0; + { + sk = 0; + fn = get_model_datafilename(m, sk, "txt"); + fh = fopen(fn, FILE_READ); + if(fh < 0) + return 0; + } get_model_parameters_modelname = m; get_model_parameters_modelskin = sk; @@ -1973,3 +1982,27 @@ float u8_strsize(string s) } return l; } + +// translation helpers +string language_filename(string s) +{ + string fn; + float fh; + fn = prvm_language; + if(fn == "" || fn == "dump") + return s; + fn = strcat(s, ".", fn); + if((fh = fopen(fn, FILE_READ)) >= 0) + { + fclose(fh); + return fn; + } + return s; +} +string CTX(string s) +{ + float p = strstrofs(s, "^", 0); + if(p < 0) + return s; + return substring(s, p+1, -1); +}