From 4d66fc175a96622065fa4807eaef0c1a4a403eb3 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Tue, 24 Jan 2012 10:28:07 +0900 Subject: [PATCH] Avoid processing skins every frame. Processing skins every frame would slow things down unnecessarily, so call the skin functions only when something changes. --- include/qw/protocol.h | 2 ++ qw/include/client.h | 1 + qw/source/cl_entparse.c | 8 ++++++-- qw/source/cl_ents.c | 13 ++++--------- qw/source/cl_parse.c | 5 +++-- 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/include/qw/protocol.h b/include/qw/protocol.h index c3a058dd4..1a2e16759 100644 --- a/include/qw/protocol.h +++ b/include/qw/protocol.h @@ -313,6 +313,8 @@ typedef struct { byte colormap; byte skinnum; + struct skin_s *skin; + // QSG 2 byte alpha; byte scale; diff --git a/qw/include/client.h b/qw/include/client.h index 28884ec52..d4933786c 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -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; diff --git a/qw/source/cl_entparse.c b/qw/source/cl_entparse.c index 477af00f2..32a62fbae 100644 --- a/qw/source/cl_entparse.c +++ b/qw/source/cl_entparse.c @@ -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); diff --git a/qw/source/cl_ents.c b/qw/source/cl_ents.c index 03cceeaa0..97f744ea9 100644 --- a/qw/source/cl_ents.c +++ b/qw/source/cl_ents.c @@ -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 diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 1b7ccbcf2..ccf17bb20 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -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 (); }