From bf751cafe029d45b7817eaca177e72e8042131cc Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Sat, 26 May 2012 12:04:23 +0900 Subject: [PATCH] Split nq's colors into topcolor/bottomcolor. The protocol is not affected: the incoming colors byte is split into the two fields when read from the packet. This simplifies a lot of code elsewhere. --- nq/include/client.h | 3 ++- nq/source/cl_parse.c | 15 +++++++++------ nq/source/sbar.c | 18 ++++++------------ 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/nq/include/client.h b/nq/include/client.h index 50d6b4ccf..11efad0d2 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -57,7 +57,8 @@ typedef struct char name[MAX_SCOREBOARDNAME]; float entertime; int frags; - int colors; // two 4 bit fields + int topcolor; + int bottomcolor; } scoreboard_t; diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index 6fd998685..0efd4a861 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -533,8 +533,8 @@ CL_ParseUpdate (int bits) ent->skinnum = skin; if (num <= cl.maxclients) { ent->skin = mod_funcs->Skin_SetColormap (ent->skin, num); - mod_funcs->Skin_SetTranslation (num, cl.scores[num].colors >> 4, - cl.scores[num].colors & 0xf); + mod_funcs->Skin_SetTranslation (num, cl.scores[num].topcolor, + cl.scores[num].bottomcolor); } } @@ -1053,10 +1053,13 @@ CL_ParseServerMessage (void) } else { entity_t *ent = &cl_entities[i+1]; byte col = MSG_ReadByte (net_message); - if (col != cl.scores[i].colors) - mod_funcs->Skin_SetTranslation (i + 1, col >> 4, - col & 0xf); - cl.scores[i].colors = col; + byte top = col >> 4; + byte bot = col & 0xf; + if (top != cl.scores[i].topcolor + || bot != cl.scores[i].bottomcolor) + mod_funcs->Skin_SetTranslation (i + 1, top, bot); + cl.scores[i].topcolor = top; + cl.scores[i].bottomcolor = bot; ent->skin = mod_funcs->Skin_SetColormap (ent->skin, i + 1); } break; diff --git a/nq/source/sbar.c b/nq/source/sbar.c index a8d3473fb..1ca3b0ae6 100644 --- a/nq/source/sbar.c +++ b/nq/source/sbar.c @@ -596,10 +596,8 @@ draw_frags (view_t *view) continue; // draw background - top = (((unsigned) s->colors) >> 4) & 0x0f; - bottom = s->colors & 0x0f; - top = Sbar_ColorForMap (top); - bottom = Sbar_ColorForMap (bottom); + top = Sbar_ColorForMap (s->topcolor); + bottom = Sbar_ColorForMap (s->bottomcolor); draw_fill (view, x + 4, 1, 28, 4, top); draw_fill (view, x + 4, 5, 28, 3, bottom); @@ -811,10 +809,8 @@ draw_rogue_face (view_t *view) s = &cl.scores[cl.viewentity - 1]; - top = (((unsigned) s->colors) >> 4) & 0x0f; - bottom = s->colors & 0x0f; - top = Sbar_ColorForMap (top); - bottom = Sbar_ColorForMap (bottom); + top = Sbar_ColorForMap (s->topcolor); + bottom = Sbar_ColorForMap (s->bottomcolor); draw_pic (view, 112, 0, rsb_teambord); draw_fill (view, 113, 3, 22, 9, top); @@ -1052,10 +1048,8 @@ Sbar_DeathmatchOverlay (view_t *view) continue; // draw background - top = (((unsigned) s->colors) >> 4) & 0x0f; - bottom = s->colors & 0x0f; - top = Sbar_ColorForMap (top); - bottom = Sbar_ColorForMap (bottom); + top = Sbar_ColorForMap (s->topcolor); + bottom = Sbar_ColorForMap (s->bottomcolor); draw_fill (view, x, y, 40, 4, top); draw_fill (view, x, y + 4, 40, 4, bottom);