diff --git a/include/QF/info.h b/include/QF/info.h index 9d972e51d..518a35c23 100644 --- a/include/QF/info.h +++ b/include/QF/info.h @@ -40,11 +40,7 @@ #define MAX_SERVERINFO_STRING 512 #define MAX_LOCALINFO_STRING 32768 -typedef struct info_s { - struct hashtab_s *tab; - size_t maxsize; - int cursize; -} info_t; +typedef struct info_s info_t; typedef struct info_key_s { const char *key; @@ -54,6 +50,9 @@ typedef struct info_key_s { qboolean Info_FilterForKey (const char *key, const char **filter_list); void Info_Print (info_t *info); +int Info_CurrentSize (info_t *info); +info_key_t *Info_Key (info_t *info, const char *key); +info_key_t **Info_KeyList (info_t *info); void Info_RemoveKey (info_t *info, const char *key); int Info_SetValueForKey (info_t *info, const char *key, const char *value, int flags); int Info_SetValueForStarKey (info_t *info, const char *key, const char *value, int flags); diff --git a/libs/util/info.c b/libs/util/info.c index 39730147a..93862be18 100644 --- a/libs/util/info.c +++ b/libs/util/info.c @@ -45,6 +45,12 @@ #include "compat.h" +struct info_s { + struct hashtab_s *tab; + size_t maxsize; + int cursize; +}; + /* Info_FilterForKey @@ -63,6 +69,11 @@ Info_FilterForKey (const char *key, const char **filter_list) return false; } +VISIBLE int +Info_CurrentSize (info_t *info) +{ + return info->cursize; +} /* Info_ValueForKey @@ -79,6 +90,18 @@ Info_ValueForKey (info_t *info, const char *key) return ""; } +VISIBLE info_key_t * +Info_Key (info_t *info, const char *key) +{ + return Hash_Find (info->tab, key); +} + +VISIBLE info_key_t ** +Info_KeyList (info_t *info) +{ + return (info_key_t **) Hash_GetList (info->tab); +} + VISIBLE void Info_RemoveKey (info_t *info, const char *key) { diff --git a/qtv/source/client.c b/qtv/source/client.c index c5c0abeec..62dc696ca 100644 --- a/qtv/source/client.c +++ b/qtv/source/client.c @@ -207,7 +207,8 @@ cl_spawn_f (client_t *cl, void *unused) for (i = 0, pl = sv->players; i < MAX_SV_PLAYERS; i++, pl++) { if (!pl->info) continue; - msg = MSG_ReliableCheckBlock (&cl->backbuf, 24 + pl->info->cursize); + msg = MSG_ReliableCheckBlock (&cl->backbuf, + 24 + Info_CurrentSize(pl->info)); MSG_WriteByte (msg, svc_updatefrags); MSG_WriteByte (msg, i); MSG_WriteShort (msg, pl->frags); diff --git a/qw/source/cl_parse.c b/qw/source/cl_parse.c index 249f3b63b..f9fa928b2 100644 --- a/qw/source/cl_parse.c +++ b/qw/source/cl_parse.c @@ -49,7 +49,6 @@ #include "QF/draw.h" #include "QF/dstring.h" #include "QF/gib.h" -#include "QF/hash.h" #include "QF/idparse.h" #include "QF/msg.h" #include "QF/progs.h" @@ -1102,9 +1101,9 @@ CL_ProcessUserInfo (int slot, player_info_t *player) player->bottomcolor = atoi (Info_ValueForKey (player->userinfo, "bottomcolor")); - while (!(player->team = Hash_Find (player->userinfo->tab, "team"))) + while (!(player->team = Info_Key (player->userinfo, "team"))) Info_SetValueForKey (player->userinfo, "team", "", 1); - while (!(player->skinname = Hash_Find (player->userinfo->tab, "skin"))) + while (!(player->skinname = Info_Key (player->userinfo, "skin"))) Info_SetValueForKey (player->userinfo, "skin", "", 1); if (Info_ValueForKey (player->userinfo, "*spectator")[0]) diff --git a/qw/source/sv_gib.c b/qw/source/sv_gib.c index ddcc30dfa..7600805d2 100644 --- a/qw/source/sv_gib.c +++ b/qw/source/sv_gib.c @@ -36,7 +36,6 @@ #endif #include "QF/dstring.h" -#include "QF/hash.h" #include "QF/info.h" #include "QF/gib.h" @@ -88,8 +87,7 @@ SV_GIB_Client_GetKeys_f (void) GIB_Error ("uid", "No user with id '%s' was found on the server.", GIB_Argv (1)); else if (GIB_CanReturn ()) { - info_key_t **key, **keys = - (info_key_t **) Hash_GetList (cl->userinfo->tab); + info_key_t **key, **keys = Info_KeyList (cl->userinfo); for (key = keys; *key; key++) dstring_appendstr (GIB_Return (0), (*key)->key); free (keys); diff --git a/qw/source/sv_main.c b/qw/source/sv_main.c index ed15d63ad..ebe999cb9 100644 --- a/qw/source/sv_main.c +++ b/qw/source/sv_main.c @@ -452,7 +452,7 @@ SV_FullClientUpdateToClient (client_t *client, backbuf_t *backbuf) { if (client->state < cs_connected && client->state != cs_server) return; - MSG_ReliableCheckBlock (backbuf, 24 + client->userinfo->cursize); + MSG_ReliableCheckBlock (backbuf, 24 + Info_CurrentSize (client->userinfo)); if (backbuf->num_backbuf) { SV_FullClientUpdate (client, &backbuf->backbuf); MSG_Reliable_FinishWrite (backbuf); diff --git a/qw/source/sv_qtv.c b/qw/source/sv_qtv.c index 14efeecb2..a36b1c3cc 100644 --- a/qw/source/sv_qtv.c +++ b/qw/source/sv_qtv.c @@ -407,7 +407,7 @@ SV_qtvConnect (int qport, info_t *info) return; } proxy->info = info; - while (!(proxy->name_key = Hash_Find (proxy->info->tab, "name"))) + while (!(proxy->name_key = Info_Key (proxy->info, "name"))) Info_SetValueForKey (proxy->info, "name", "\"unnamed proxy\"", 1); Netchan_Setup (&proxy->netchan, net_from, qport, NC_QPORT_READ);