diff --git a/Quake/host_cmd.c b/Quake/host_cmd.c index 0978f343..9ed07349 100644 --- a/Quake/host_cmd.c +++ b/Quake/host_cmd.c @@ -20,12 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "q_stdinc.h" -#include "arch_def.h" -#include "net_sys.h" /* for net_defs.h */ -#include #include "quakedef.h" -#include "net_defs.h" /* for struct qsocket_s details */ +#include extern cvar_t pausable; @@ -533,7 +529,7 @@ void Host_Status_f (void) { if (!client->active) continue; - seconds = (int)(net_time - client->netconnection->connecttime); + seconds = (int)(net_time - NET_QSocketGetTime(client->netconnection)); minutes = seconds / 60; if (minutes) { @@ -545,7 +541,7 @@ void Host_Status_f (void) else hours = 0; print_fn ("#%-2u %-16.16s %3i %2i:%02i:%02i\n", j+1, client->name, (int)client->edict->v.frags, hours, minutes, seconds); - print_fn (" %s\n", client->netconnection->address); + print_fn (" %s\n", NET_QSocketGetAddressString(client->netconnection)); } } @@ -1632,7 +1628,7 @@ void Host_Spawn_f (void) pr_global_struct->self = EDICT_TO_PROG(sv_player); PR_ExecuteProgram (pr_global_struct->ClientConnect); - if ((Sys_DoubleTime() - host_client->netconnection->connecttime) <= sv.time) + if ((Sys_DoubleTime() - NET_QSocketGetTime(host_client->netconnection)) <= sv.time) Sys_Printf ("%s entered the game\n", host_client->name); PR_ExecuteProgram (pr_global_struct->PutClientInServer); diff --git a/Quake/menu.c b/Quake/menu.c index 75f02d28..43e8844c 100644 --- a/Quake/menu.c +++ b/Quake/menu.c @@ -19,11 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "q_stdinc.h" -#include "arch_def.h" -#include "net_sys.h" /* FIXME */ #include "quakedef.h" -#include "net_defs.h" /* FIXME */ #include "bgmusic.h" void (*vid_menucmdfn)(void); //johnfitz @@ -2341,42 +2337,19 @@ void M_Menu_ServerList_f (void) void M_ServerList_Draw (void) { - int n; - char string [64]; + int n; qpic_t *p; if (!slist_sorted) { - if (hostCacheCount > 1) - { - int i,j; - hostcache_t temp; - for (i = 0; i < hostCacheCount; i++) - { - for (j = i + 1; j < hostCacheCount; j++) - { - if (strcmp(hostcache[j].name, hostcache[i].name) < 0) - { - Q_memcpy(&temp, &hostcache[j], sizeof(hostcache_t)); - Q_memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t)); - Q_memcpy(&hostcache[i], &temp, sizeof(hostcache_t)); - } - } - } - } slist_sorted = true; + NET_SlistSort (); } p = Draw_CachePic ("gfx/p_multi.lmp"); M_DrawPic ( (320-p->width)/2, 4, p); for (n = 0; n < hostCacheCount; n++) - { - if (hostcache[n].maxusers) - sprintf(string, "%-15.15s %-15.15s %2u/%2u\n", hostcache[n].name, hostcache[n].map, hostcache[n].users, hostcache[n].maxusers); - else - sprintf(string, "%-15.15s %-15.15s\n", hostcache[n].name, hostcache[n].map); - M_Print (16, 32 + 8*n, string); - } + M_Print (16, 32 + 8*n, NET_SlistPrintServer (n)); M_DrawCharacter (0, 32 + slist_cursor*8, 12+((int)(realtime*4)&1)); if (*m_return_reason) @@ -2420,7 +2393,7 @@ void M_ServerList_Key (int k) IN_Activate(); key_dest = key_game; m_state = m_none; - Cbuf_AddText ( va ("connect \"%s\"\n", hostcache[slist_cursor].cname) ); + Cbuf_AddText ( va ("connect \"%s\"\n", NET_SlistPrintServerName(slist_cursor)) ); break; default: diff --git a/Quake/net.h b/Quake/net.h index ef9d73ed..45d40fdf 100644 --- a/Quake/net.h +++ b/Quake/net.h @@ -54,6 +54,9 @@ struct qsocket_s *NET_CheckNewConnections (void); struct qsocket_s *NET_Connect (const char *host); // called by client to connect to a host. Returns -1 if not able to +double NET_QSocketGetTime (struct qsocket_s *sock); +const char *NET_QSocketGetAddressString (struct qsocket_s *sock); + qboolean NET_CanSendMessage (struct qsocket_s *sock); // Returns true or false if the given qsocket can currently accept a // message to be transmitted. @@ -92,7 +95,12 @@ extern qboolean slistInProgress; extern qboolean slistSilent; extern qboolean slistLocal; +extern int hostCacheCount; + void NET_Slist_f (void); +void NET_SlistSort (void); +const char *NET_SlistPrintServer (int n); +const char *NET_SlistPrintServerName (int n); /* FIXME: driver related, but public: diff --git a/Quake/net_main.c b/Quake/net_main.c index 07fb8c48..c32a39a6 100644 --- a/Quake/net_main.c +++ b/Quake/net_main.c @@ -156,6 +156,18 @@ void NET_FreeQSocket(qsocket_t *sock) } +double NET_QSocketGetTime (qsocket_t *s) +{ + return s->connecttime; +} + + +const char *NET_QSocketGetAddressString (qsocket_t *s) +{ + return s->address; +} + + static void NET_Listen_f (void) { if (Cmd_Argc () != 2) @@ -296,6 +308,59 @@ void NET_Slist_f (void) } +void NET_SlistSort (void) +{ + if (hostCacheCount > 1) + { + int i, j; + hostcache_t temp; + for (i = 0; i < hostCacheCount; i++) + { + for (j = i + 1; j < hostCacheCount; j++) + { + if (strcmp(hostcache[j].name, hostcache[i].name) < 0) + { + memcpy(&temp, &hostcache[j], sizeof(hostcache_t)); + memcpy(&hostcache[j], &hostcache[i], sizeof(hostcache_t)); + memcpy(&hostcache[i], &temp, sizeof(hostcache_t)); + } + } + } + } +} + + +const char *NET_SlistPrintServer (int idx) +{ + static char string[64]; + + if (idx < 0 || idx >= hostCacheCount) + return ""; + + if (hostcache[idx].maxusers) + { + q_snprintf(string, sizeof(string), "%-15.15s %-15.15s %2u/%2u\n", + hostcache[idx].name, hostcache[idx].map, + hostcache[idx].users, hostcache[idx].maxusers); + } + else + { + q_snprintf(string, sizeof(string), "%-15.15s %-15.15s\n", + hostcache[idx].name, hostcache[idx].map); + } + + return string; +} + + +const char *NET_SlistPrintServerName (int idx) +{ + if (idx < 0 || idx >= hostCacheCount) + return ""; + return hostcache[idx].cname; +} + + static void Slist_Send (void *unused) { for (net_driverlevel = 0; net_driverlevel < net_numdrivers; net_driverlevel++) diff --git a/Quake/sv_main.c b/Quake/sv_main.c index 5012aab5..61f62f51 100644 --- a/Quake/sv_main.c +++ b/Quake/sv_main.c @@ -20,11 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // sv_main.c -- server main program -#include "q_stdinc.h" -#include "arch_def.h" -#include "net_sys.h" /* for net_defs.h */ #include "quakedef.h" -#include "net_defs.h" /* for struct qsocket_s details */ server_t sv; server_static_t svs; @@ -329,7 +325,7 @@ void SV_ConnectClient (int clientnum) client = svs.clients + clientnum; - Con_DPrintf ("Client %s connected\n", client->netconnection->address); + Con_DPrintf ("Client %s connected\n", NET_QSocketGetAddressString(client->netconnection)); edictnum = clientnum+1; @@ -919,7 +915,7 @@ qboolean SV_SendClientDatagram (client_t *client) msg.cursize = 0; //johnfitz -- if client is nonlocal, use smaller max size so packets aren't fragmented - if (Q_strcmp (client->netconnection->address, "LOCAL") != 0) + if (Q_strcmp(NET_QSocketGetAddressString(client->netconnection), "LOCAL") != 0) msg.maxsize = DATAGRAM_MTU; //johnfitz