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 skin_t skin_cache[MAX_CACHED_SKINS];
extern int skin_textures; extern int skin_textures;
extern int skin_fb_textures; extern int skin_fb_textures;
extern int numskins;
extern int fullfb;
struct tex_s; struct tex_s;
struct tex_s *Skin_Cache (skin_t *skin); 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); skin_t *Skin_NewTempSkin (void);
void Skin_ClearTempSkins (void); void Skin_ClearTempSkins (void);
int Skin_FbPercent (const char *skin_name); // * 10
extern char allskins[128]; extern char allskins[128];
#endif #endif

View file

@ -59,16 +59,15 @@ cvar_t *baseskin;
char allskins[128]; char allskins[128];
skin_t skin_cache[MAX_CACHED_SKINS]; skin_t skin_cache[MAX_CACHED_SKINS];
hashtab_t *skin_hash; static hashtab_t *skin_hash;
int numskins; static int numskins;
static skin_t temp_skins[MAX_TEMP_SKINS];
skin_t temp_skins[MAX_TEMP_SKINS]; static int num_temp_skins;
int num_temp_skins; static int fullfb;
int skin_textures; int skin_textures;
int skin_fb_textures; int skin_fb_textures;
int fullfb;
static const char * static const char *
skin_get_key (void *_skin, void *unused) skin_get_key (void *_skin, void *unused)
@ -262,3 +261,21 @@ Skin_Init_Cvars (void)
baseskin = Cvar_Get ("baseskin", "base", CVAR_NONE, NULL, baseskin = Cvar_Get ("baseskin", "base", CVAR_NONE, NULL,
"default base skin name"); "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 * char *
Team_F_Skins (char *args) Team_F_Skins (char *args)
{ {
int totalfb, i, l; int totalfb, l;
skin_t *skin;
while(isspace(*args)) while(isspace(*args))
args++; args++;
for (l = 0;args[l] && !isspace(args[l]);l++); for (l = 0;args[l] && !isspace(args[l]);l++);
if (l == 0) { if (l == 0) {
for (i = 0, totalfb = 0; i < numskins; i++) totalfb = Skin_FbPercent (0);
totalfb += skin_cache[i].numfb; return va("say Average percent fullbright for all loaded skins is %d.%d%%", totalfb / 10, totalfb % 10);
return va("say Average percent fullbright for all loaded skins is %.1f", (float)totalfb/(float)(numskins * fullfb)*100.0);
} }
for (i = 0, skin = 0; i < numskins; i++) { totalfb = Skin_FbPercent (args);
if (!strncmp(skin_cache[i].name, args, l)) {
skin = &skin_cache[i];
break;
}
}
if (skin) if (totalfb >= 0)
return va("say \"Skin %s is %.1f%% fullbright\"", return va("say \"Skin %s is %d.%d%% fullbright\"",
skin->name, args, totalfb / 10, totalfb % 10);
(float)skin->numfb/(float)fullfb*100.0);
else else
return ("say \"Skin not currently loaded.\""); return ("say \"Skin not currently loaded.\"");
} }