local custom player skins

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@3036 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
ac_stef
2008-10-15 15:16:28 +00:00
parent 3f35b934ba
commit 9e74dfc7d2
6 changed files with 103 additions and 26 deletions
+36
View File
@@ -532,3 +532,39 @@ COMMAND(resetsecuremaps, ARG_NONE);
COMMAND(securemap, ARG_1STR);
COMMAND(getdemo, ARG_1INT);
COMMAND(listdemos, ARG_NONE);
static cvector playerskinlist;
const char *getclientskin(const char *name, const char *suf)
{
static string tmp;
int suflen = strlen(suf), namelen = strlen(name);
const char *s, *r = NULL;
loopv(playerskinlist)
{
s = playerskinlist[i];
int sl = strlen(s) - suflen;
if(sl > 0 && !strcmp(s + sl, suf))
{
if(!strncmp(name, s, namelen)) return s; // exact match
if(s[sl - 1] == '_')
{
s_strcpy(tmp, s);
tmp[sl - 1] = '\0';
if(strstr(name, tmp)) r = s; // partial match
}
}
}
return r;
}
void updateclientname(playerent *d)
{
static bool gotlist = false;
if(!gotlist) listfiles("packages/models/playermodels/custom", "jpg", playerskinlist);
gotlist = true;
if(!d || !playerskinlist.length()) return;
d->skin_noteam = getclientskin(d->name, "_ffa");
d->skin_cla = getclientskin(d->name, "_cla");
d->skin_rvsf = getclientskin(d->name, "_rvsf");
}