From 9265d786ba327ba8c21a822bcdcc68a3bf25d250 Mon Sep 17 00:00:00 2001 From: havoc Date: Mon, 2 Dec 2002 01:53:51 +0000 Subject: [PATCH] beginnings of some proper server list code, commented out for now git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@2670 d7cf8633-e32d-0410-b094-e92efae38249 --- net_main.c | 101 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/net_main.c b/net_main.c index 0697022f..6e055702 100644 --- a/net_main.c +++ b/net_main.c @@ -72,6 +72,107 @@ qboolean configRestored = false; int net_driverlevel; +/* +#define SLSERVERS 1024 +#define SLNAME 40 +#define SLMAPNAME 16 +#define SLMODNAME 16 +typedef struct slserver_s +{ + unsigned int ipaddr; + unsigned short port; + unsigned short ping; + char name[SLNAME]; + char mapname[SLMAPNAME]; + char modname[SLMODNAME]; +} +slserver_t; + +slserver_t sl_server[SLSERVERS]; +int sl_numservers = 0; + +void SL_ClearServers(void) +{ + sl_numservers = 0; +} + +slserver_t *SL_FindServer(unsigned int ipaddr, unsigned short port) +{ + int i; + slserver_t *sl; + for (i = 0, sl = sl_server;i < sl_numservers;i++, sl++) + if (sl->ipaddr == ipaddr && sl->port == port) + return; +} + +void SL_AddServer(unsigned int ipaddr, unsigned short port) +{ + if (SL_FindServer(ipaddr, port)) + return; + memset(sl_server + sl_numservers, 0, sizeof(slserver_t)); + sl_server[sl_numservers].ipaddr = ipaddr; + sl_server[sl_numservers].port = port; + sl_server[sl_numservers].ping = 0xFFFF; + sl_numservers++; +} + +void SL_UpdateServerName(unsigned int ipaddr, unsigned short port, const char *name); +{ + int namelen; + slserver_t *sl; + sl = SL_FindServer(ipaddr, port); + if (sl == NULL) + return; + memset(sl->name, 0, sizeof(sl->name)); + namelen = strlen(name); + if (namelen > sizeof(sl->name) - 1) + namelen = sizeof(sl->name) - 1; + if (namelen) + memcpy(sl->name, name, namelen); +} + +void SL_UpdateServerModName(unsigned int ipaddr, unsigned short port, const char *name); +{ + int namelen; + slserver_t *sl; + sl = SL_FindServer(ipaddr, port); + if (sl == NULL) + return; + memset(sl->modname, 0, sizeof(sl->modname)); + namelen = strlen(name); + if (namelen > sizeof(sl->modname) - 1) + namelen = sizeof(sl->modname) - 1; + if (namelen) + memcpy(sl->modname, name, namelen); +} + +void SL_UpdateServerMapName(unsigned int ipaddr, unsigned short port, const char *name); +{ + int namelen; + slserver_t *sl; + sl = SL_FindServer(ipaddr, port); + if (sl == NULL) + return; + memset(sl->mapname, 0, sizeof(sl->mapname)); + namelen = strlen(name); + if (namelen > sizeof(sl->mapname) - 1) + namelen = sizeof(sl->mapname) - 1; + if (namelen) + memcpy(sl->mapname, name, namelen); +} + +void SL_UpdateServerPing(unsigned int ipaddr, unsigned short port, float ping); +{ + int i; + slserver_t *sl; + sl = SL_FindServer(ipaddr, port); + if (sl == NULL) + return; + i = ping * 1000.0; + sl->ping = bound(0, i, 9999); +} +*/ + double net_time; -- 2.39.2