cleanup skin's namespace polution

This commit is contained in:
Bill Currie 2001-12-04 20:13:12 +00:00
parent 52b0c8f3fc
commit f6ef79b7e3
3 changed files with 32 additions and 23 deletions

View file

@ -54,8 +54,6 @@ extern byte player_8bit_texels[320 * 200];
extern skin_t skin_cache[MAX_CACHED_SKINS];
extern int skin_textures;
extern int skin_fb_textures;
extern int numskins;
extern int fullfb;
struct tex_s;
struct tex_s *Skin_Cache (skin_t *skin);
@ -77,6 +75,8 @@ void Skin_Process (skin_t *skin, struct tex_s *);
skin_t *Skin_NewTempSkin (void);
void Skin_ClearTempSkins (void);
int Skin_FbPercent (const char *skin_name); // * 10
extern char allskins[128];
#endif

View file

@ -59,16 +59,15 @@ cvar_t *baseskin;
char allskins[128];
skin_t skin_cache[MAX_CACHED_SKINS];
hashtab_t *skin_hash;
int numskins;
skin_t temp_skins[MAX_TEMP_SKINS];
int num_temp_skins;
static hashtab_t *skin_hash;
static int numskins;
static skin_t temp_skins[MAX_TEMP_SKINS];
static int num_temp_skins;
static int fullfb;
int skin_textures;
int skin_fb_textures;
int fullfb;
static const char *
skin_get_key (void *_skin, void *unused)
@ -262,3 +261,21 @@ Skin_Init_Cvars (void)
baseskin = Cvar_Get ("baseskin", "base", CVAR_NONE, NULL,
"default base skin name");
}
int
Skin_FbPercent (const char *skin_name)
{
int i, totalfb = 0;
skin_t *skin = 0;
if (skin_name) {
skin = Hash_Find (skin_hash, skin_name);
if (skin)
return skin->numfb * 1000 / fullfb;
return -1;
}
for (i = 0; i < numskins; i++)
totalfb += skin_cache[i].numfb;
return totalfb * 1000 / (numskins * fullfb);
}

View file

@ -414,30 +414,22 @@ Team_F_Version (char *args)
char *
Team_F_Skins (char *args)
{
int totalfb, i, l;
skin_t *skin;
int totalfb, l;
while(isspace(*args))
args++;
for (l = 0;args[l] && !isspace(args[l]);l++);
if (l == 0) {
for (i = 0, totalfb = 0; i < numskins; i++)
totalfb += skin_cache[i].numfb;
return va("say Average percent fullbright for all loaded skins is %.1f", (float)totalfb/(float)(numskins * fullfb)*100.0);
totalfb = Skin_FbPercent (0);
return va("say Average percent fullbright for all loaded skins is %d.%d%%", totalfb / 10, totalfb % 10);
}
for (i = 0, skin = 0; i < numskins; i++) {
if (!strncmp(skin_cache[i].name, args, l)) {
skin = &skin_cache[i];
break;
}
}
totalfb = Skin_FbPercent (args);
if (skin)
return va("say \"Skin %s is %.1f%% fullbright\"",
skin->name,
(float)skin->numfb/(float)fullfb*100.0);
if (totalfb >= 0)
return va("say \"Skin %s is %d.%d%% fullbright\"",
args, totalfb / 10, totalfb % 10);
else
return ("say \"Skin not currently loaded.\"");
}