Avoid processing skins every frame.

Processing skins every frame would slow things down unnecessarily, so call
the skin functions only when something changes.
This commit is contained in:
Bill Currie 2012-01-24 10:28:07 +09:00
parent 6df8867d69
commit 4d66fc175a
5 changed files with 16 additions and 13 deletions

View File

@ -313,6 +313,8 @@ typedef struct {
byte colormap;
byte skinnum;
struct skin_s *skin;
// QSG 2
byte alpha;
byte scale;

View File

@ -81,6 +81,7 @@ typedef struct player_info_s
int bottomcolor;
struct info_key_s *skinname;
struct info_key_s *team;
struct skin_s *skin;
int _topcolor;
int _bottomcolor;

View File

@ -108,8 +108,12 @@ CL_ParseDelta (entity_state_t *from, entity_state_t *to, int bits)
if (bits & U_FRAME)
to->frame = MSG_ReadByte (net_message);
if (bits & U_COLORMAP)
to->colormap = MSG_ReadByte (net_message);
if (bits & U_COLORMAP) {
byte cmap = MSG_ReadByte (net_message);
if (cmap != to->colormap)
to->skin = Skin_SetColormap (to->skin, cmap);
to->colormap = cmap;
}
if (bits & U_SKIN)
to->skinnum = MSG_ReadByte (net_message);

View File

@ -242,12 +242,7 @@ CL_LinkPacketEntities (void)
}
// set colormap
if (s1->colormap && (s1->colormap <= MAX_CLIENTS)
&& cl.players[s1->colormap - 1].name[0]) {
ent->skin = Skin_SetColormap (ent->skin, s1->colormap);
} else {
ent->skin = Skin_SetColormap (ent->skin, 0);
}
ent->skin = s1->skin;
// LordHavoc: cleaned up Endy's coding style, and fixed Endy's bugs
// Ender: Extend (Colormod) [QSG - Begin]
@ -469,7 +464,6 @@ CL_LinkPlayers (void)
ent->model = cl.model_precache[state->pls.modelindex];
ent->frame = state->pls.frame;
ent->skin = Skin_SetColormap (ent->skin, j + 1);
ent->skinnum = state->pls.skinnum;
CL_TransformEntity (ent, ang, false);
@ -479,14 +473,15 @@ CL_LinkPlayers (void)
if (state->pls.modelindex == cl_playerindex) { //XXX
// use custom skin
Skin_SetSkin (ent->skin, j + 1, info->skinname->value);
ent->skin = info->skin;
ent->min_light = min (cl.fbskins, cl_fb_players->value);
if (ent->min_light >= 1.0)
ent->fullbright = 1;
} else {
Skin_SetSkin (ent->skin, j + 1, 0);
// FIXME no team colors on nonstandard player models
ent->skin = 0;
}
// stuff entity in map

View File

@ -1117,8 +1117,9 @@ CL_ProcessUserInfo (int slot, player_info_t *player)
player->spectator = false;
Skin_SetTranslation (slot + 1, player->topcolor, player->bottomcolor);
//XXX if (cls.state == ca_active)
//XXX Skin_Find (player);
player->skin = Skin_SetSkin (player->skin, slot + 1,
player->skinname->value);
player->skin = Skin_SetColormap (player->skin, slot + 1);
Sbar_Changed ();
}