X-Git-Url: http://de.git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=blobdiff_plain;f=qcsrc%2Fclient%2Fmiscfunctions.qc;h=247dc4b35a64dedc2c7de722420154e9084df48e;hp=1ee799a7774810117ec7c50cc5e773e55a08323b;hb=30b10531b2a91c90b25120a5b339f04f35135eb0;hpb=e2671eb26f096af4023a0119bbc87a4801a5e66d diff --git a/qcsrc/client/miscfunctions.qc b/qcsrc/client/miscfunctions.qc index 1ee799a77..247dc4b35 100644 --- a/qcsrc/client/miscfunctions.qc +++ b/qcsrc/client/miscfunctions.qc @@ -325,34 +325,11 @@ float PreviewExists(string name) if(autocvar_cl_readpicture_force) return false; - file = strcat(name, ".tga"); - f = fopen(file, FILE_READ); - if(f >= 0) - { - fclose(f); - return true; - } - file = strcat(name, ".png"); - f = fopen(file, FILE_READ); - if(f >= 0) - { - fclose(f); - return true; - } - file = strcat(name, ".jpg"); - f = fopen(file, FILE_READ); - if(f >= 0) - { - fclose(f); - return true; - } - file = strcat(name, ".pcx"); - f = fopen(file, FILE_READ); - if(f >= 0) - { - fclose(f); - return true; - } + if (fexists(strcat(name, ".tga"))) return true; + if (fexists(strcat(name, ".png"))) return true; + if (fexists(strcat(name, ".jpg"))) return true; + if (fexists(strcat(name, ".pcx"))) return true; + return false; } @@ -375,6 +352,33 @@ string ColorTranslateRGB(string s) return s; } +string Team_ColorCode(float teamid) +{ + if (teamid == COLOR_TEAM1) + return "^1"; + else if (teamid == COLOR_TEAM2) + return "^4"; + else if (teamid == COLOR_TEAM3) + return "^3"; + else if (teamid == COLOR_TEAM4) + return "^6"; + else + return "^7"; +} + +// decolorizes and team colors the player name when needed +string playername(string thename, float teamid) +{ + string t; + if (teamplay) + { + t = Team_ColorCode(teamid); + return strcat(t, strdecolorize(thename)); + } + else + return strdecolorize(thename); +} + float cvar_or(string cv, float v) { string s;