From ef8b2c81a2d25c92dde622e451787cb1e0dca142 Mon Sep 17 00:00:00 2001 From: havoc Date: Sun, 14 Jan 2007 09:56:30 +0000 Subject: [PATCH] patch from div0 that adds a special "extResponse " type of packet that can be returned to menu qc as a string (to query current version of Nexuiz or anything else of that nature, requires special servers that return such packets, the packets are sent using the "packet" command which already existed from qw support) git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6689 d7cf8633-e32d-0410-b094-e92efae38249 --- mvm_cmds.c | 21 ++++++++++++++++++++- netconn.c | 13 +++++++++++++ netconn.h | 5 +++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/mvm_cmds.c b/mvm_cmds.c index 19f3ced7..12c0af5b 100644 --- a/mvm_cmds.c +++ b/mvm_cmds.c @@ -782,6 +782,24 @@ void VM_M_WriteEntity (void) MSG_WriteShort (VM_WriteDest(), PRVM_G_EDICTNUM(OFS_PARM0)); } +//string(void) getextresponse = #624; // returns the next extResponse packet that was sent to this client +void VM_M_getextresponse (void) +{ + VM_SAFEPARMCOUNT(0,VM_argv); + + if (net_extresponse_count <= 0) + { + PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(NULL); + } + else + { + int first; + --net_extresponse_count; + first = (net_extresponse_last + NET_EXTRESPONSE_MAX - net_extresponse_count) % NET_EXTRESPONSE_MAX; + PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(net_extresponse[first]); + } +} + prvm_builtin_t vm_m_builtins[] = { 0, // to be consistent with the old vm // common builtings (mostly) @@ -946,7 +964,8 @@ prvm_builtin_t vm_m_builtins[] = { VM_M_refreshserverlist, VM_M_getserverlistnumber, VM_M_getserverlistindexforkey, - VM_M_addwantedserverlistkey // 623 + VM_M_addwantedserverlistkey, // 623 + VM_M_getextresponse }; const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t); diff --git a/netconn.c b/netconn.c index 598199be..02f6b5a9 100755 --- a/netconn.c +++ b/netconn.c @@ -126,6 +126,10 @@ cvar_t sv_netport = {0, "port", "26000", "server port for players to connect to" cvar_t net_address = {0, "net_address", "0.0.0.0", "network address to open ports on"}; //cvar_t net_netaddress_ipv6 = {0, "net_address_ipv6", "[0:0:0:0:0:0:0:0]", "network address to open ipv6 ports on"}; +char net_extresponse[NET_EXTRESPONSE_MAX][1400]; +int net_extresponse_count = 0; +int net_extresponse_last = 0; + // ServerList interface serverlist_mask_t serverlist_andmasks[SERVERLIST_ANDMASKCOUNT]; serverlist_mask_t serverlist_ormasks[SERVERLIST_ORMASKCOUNT]; @@ -1343,6 +1347,15 @@ static int NetConn_ClientParsePacket(lhnetsocket_t *mysocket, unsigned char *dat serverlist_querywaittime = realtime + 3; return true; } + if (!strncmp(string, "extResponse ", 12)) + { + ++net_extresponse_count; + if(net_extresponse_count > NET_EXTRESPONSE_MAX) + net_extresponse_count = NET_EXTRESPONSE_MAX; + net_extresponse_last = (net_extresponse_last + 1) % NET_EXTRESPONSE_MAX; + dpsnprintf(net_extresponse[net_extresponse_last], sizeof(net_extresponse[net_extresponse_last]), "%s %s", addressstring2, string + 12); + return true; + } if (!strncmp(string, "ping", 4)) { if (developer.integer >= 10) diff --git a/netconn.h b/netconn.h index bbd1b88e..f158e359 100755 --- a/netconn.h +++ b/netconn.h @@ -37,6 +37,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define NET_PROTOCOL_VERSION 3 +#define NET_EXTRESPONSE_MAX 16 // This is the network info/connection protocol. It is used to find Quake // servers, get info about them, and connect to them. Once connected, the @@ -311,6 +312,10 @@ extern qboolean serverlist_consoleoutput; // //============================================================================ +extern char net_extresponse[NET_EXTRESPONSE_MAX][1400]; +extern int net_extresponse_count; +extern int net_extresponse_last; + extern double masterquerytime; extern int masterquerycount; extern int masterreplycount; -- 2.39.2