Move qw's player_info_t to client/state.h

And use it instead of scoreboard_t in nq.
This commit is contained in:
Bill Currie 2013-01-31 17:18:29 +09:00
parent 167dd2af9b
commit 52b714ea57
6 changed files with 68 additions and 43 deletions

58
include/client/state.h Normal file
View File

@ -0,0 +1,58 @@
/*
state.h
client state
Copyright (C) 2013 Bill Currie <bill@taniwha.org>
Author: Bill Currie <bill@taniwha.org>
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

View File

@ -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;

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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