From 52b714ea5755e327e68fc0151e7e95d84807ae7e Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Thu, 31 Jan 2013 17:18:29 +0900 Subject: [PATCH] Move qw's player_info_t to client/state.h And use it instead of scoreboard_t in nq. --- include/client/state.h | 58 ++++++++++++++++++++++++++++++++++++++++++ nq/include/client.h | 13 ++-------- nq/source/cl_main.c | 2 +- nq/source/cl_parse.c | 6 ++--- nq/source/sbar.c | 6 ++--- qw/include/client.h | 26 +------------------ 6 files changed, 68 insertions(+), 43 deletions(-) create mode 100644 include/client/state.h diff --git a/include/client/state.h b/include/client/state.h new file mode 100644 index 000000000..a06890822 --- /dev/null +++ b/include/client/state.h @@ -0,0 +1,58 @@ +/* + state.h + + client state + + Copyright (C) 2013 Bill Currie + + Author: Bill Currie + Date: 2013/01/31 + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to: + + Free Software Foundation, Inc. + 59 Temple Place - Suite 330 + Boston, MA 02111-1307, USA + +*/ + +#ifndef __client_state_h +#define __client_state_h + +typedef struct player_info_s { + int userid; + struct info_s *userinfo; + + // scoreboard information + struct info_key_s *name; + struct info_key_s *team; + struct info_key_s *chat; + float entertime; + int frags; + int ping; + byte pl; + + // skin information + int topcolor; + int bottomcolor; + struct info_key_s *skinname; + struct skin_s *skin; + + int spectator; + int stats[MAX_CL_STATS]; // health, etc + int prevcount; +} player_info_t; + +#endif//__client_state_h diff --git a/nq/include/client.h b/nq/include/client.h index e6dc80e97..4c99e6993 100644 --- a/nq/include/client.h +++ b/nq/include/client.h @@ -38,6 +38,7 @@ #include "QF/render.h" #include "client/entities.h" +#include "client/state.h" #include "game.h" #include "netmain.h" @@ -53,16 +54,6 @@ typedef struct usercmd_s { float upmove; } usercmd_t; -typedef struct { - struct info_s *info; - struct info_key_s *name; - float entertime; - int frags; - int topcolor; - int bottomcolor; -} scoreboard_t; - - // client_state_t should hold all pieces of the client state typedef enum { @@ -225,7 +216,7 @@ typedef struct { int cdtrack; // cd audio // frag scoreboard - scoreboard_t *scores; // [cl.maxclients] + player_info_t *scores; // [cl.maxclients] lightstyle_t lightstyle[MAX_LIGHTSTYLES]; } client_state_t; diff --git a/nq/source/cl_main.c b/nq/source/cl_main.c index 052b45189..995f7f073 100644 --- a/nq/source/cl_main.c +++ b/nq/source/cl_main.c @@ -205,7 +205,7 @@ CL_ClearState (void) int i; for (i = 0; i < cl.maxclients; i++) - Info_Destroy (cl.scores[i].info); + Info_Destroy (cl.scores[i].userinfo); } // wipe the entire cl structure diff --git a/nq/source/cl_parse.c b/nq/source/cl_parse.c index 2b9597e8a..0a1fe5a61 100644 --- a/nq/source/cl_parse.c +++ b/nq/source/cl_parse.c @@ -361,8 +361,8 @@ CL_ParseServerInfo (void) } cl.scores = Hunk_AllocName (cl.maxclients * sizeof (*cl.scores), "scores"); for (i = 0; i < cl.maxclients; i++) { - cl.scores[i].info = Info_ParseString ("name\\", 0, 0); - cl.scores[i].name = Info_Key (cl.scores[i].info, "name"); + cl.scores[i].userinfo = Info_ParseString ("name\\", 0, 0); + cl.scores[i].name = Info_Key (cl.scores[i].userinfo, "name"); cl.scores[i].topcolor = 0; cl.scores[i].bottomcolor = 0; } @@ -983,7 +983,7 @@ CL_ParseServerMessage (void) if (i >= cl.maxclients) Host_Error ("CL_ParseServerMessage: svc_updatename > " "MAX_SCOREBOARD"); - Info_SetValueForKey (cl.scores[i].info, "name", + Info_SetValueForKey (cl.scores[i].userinfo, "name", MSG_ReadString (net_message), 0); break; diff --git a/nq/source/sbar.c b/nq/source/sbar.c index e77ff103a..e2a12c17c 100644 --- a/nq/source/sbar.c +++ b/nq/source/sbar.c @@ -574,7 +574,7 @@ draw_frags (view_t *view) int i, k, l, p = -1; int top, bottom; int x; - scoreboard_t *s; + player_info_t *s; if (cl.maxclients == 1) return; @@ -800,7 +800,7 @@ static void draw_rogue_face (view_t *view) { int top, bottom; - scoreboard_t *s; + player_info_t *s; // PGM 01/19/97 - team color drawing @@ -1032,7 +1032,7 @@ Sbar_DeathmatchOverlay (view_t *view) int i, k, l; int top, bottom; int x, y; - scoreboard_t *s; + player_info_t *s; r_data->scr_copyeverything = 1; r_data->scr_fullupdate = 0; diff --git a/qw/include/client.h b/qw/include/client.h index 23d22e893..de55b73ed 100644 --- a/qw/include/client.h +++ b/qw/include/client.h @@ -36,6 +36,7 @@ #include "QF/plugin/vid_render.h" #include "client/entities.h" +#include "client/state.h" #include "netchan.h" #include "qw/bothdefs.h" @@ -62,31 +63,6 @@ typedef struct player_state_s { } player_state_t; -typedef struct player_info_s { - int userid; - struct info_s *userinfo; - - // scoreboard information - struct info_key_s *name; - struct info_key_s *team; - struct info_key_s *chat; - float entertime; - int frags; - int ping; - byte pl; - - // skin information - int topcolor; - int bottomcolor; - struct info_key_s *skinname; - struct skin_s *skin; - - int spectator; - int stats[MAX_CL_STATS]; // health, etc - int prevcount; -} player_info_t; - - typedef struct { // generated on client side usercmd_t cmd; // cmd that generated the frame