From 0330569537b66a3405df8630e98c6311160cadaa Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 22 Oct 2023 17:49:52 +0300 Subject: [PATCH] engine: client: remove master server queries from NetAPI, they are never used by mods --- engine/client/cl_game.c | 37 +++++-------------------- engine/client/cl_main.c | 60 ++--------------------------------------- engine/client/client.h | 9 ------- 3 files changed, 8 insertions(+), 98 deletions(-) diff --git a/engine/client/cl_game.c b/engine/client/cl_game.c index afc229b7..4563c04e 100644 --- a/engine/client/cl_game.c +++ b/engine/client/cl_game.c @@ -3336,6 +3336,9 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags, if( remote_address->type != NA_IPX && remote_address->type != NA_BROADCAST_IPX ) return; // IPX no longer support + if( request == NETAPI_REQUEST_SERVERLIST ) + return; // no support for server list requests + // find a free request for( i = 0; i < MAX_REQUESTS; i++ ) { @@ -3372,28 +3375,9 @@ static void GAME_EXPORT NetAPI_SendRequest( int context, int request, int flags, nr->resp.remote_address = *remote_address; nr->flags = flags; - if( request == NETAPI_REQUEST_SERVERLIST ) - { - char fullquery[512]; - size_t len; - - len = CL_BuildMasterServerScanRequest( fullquery, sizeof( fullquery ), false ); - - // make sure that port is specified - if( !nr->resp.remote_address.port ) - nr->resp.remote_address.port = MSG_BigShort( PORT_MASTER ); - - // grab the list from the master server - NET_SendPacket( NS_CLIENT, len, fullquery, nr->resp.remote_address ); - clgame.request_type = NET_REQUEST_CLIENT; - clgame.master_request = nr; // holds the master request unitl the master acking - } - else - { - // local servers request - Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request ); - Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req ); - } + // local servers request + Q_snprintf( req, sizeof( req ), "netinfo %i %i %i", PROTOCOL_VERSION, context, request ); + Netchan_OutOfBandPrint( NS_CLIENT, nr->resp.remote_address, "%s", req ); } /* @@ -3421,13 +3405,6 @@ static void GAME_EXPORT NetAPI_CancelRequest( int context ) nr->pfnFunc( &nr->resp ); } - if( clgame.net_requests[i].resp.type == NETAPI_REQUEST_SERVERLIST && &clgame.net_requests[i] == clgame.master_request ) - { - if( clgame.request_type == NET_REQUEST_CLIENT ) - clgame.request_type = NET_REQUEST_CANCEL; - clgame.master_request = NULL; - } - memset( &clgame.net_requests[i], 0, sizeof( net_request_t )); break; } @@ -3456,8 +3433,6 @@ void GAME_EXPORT NetAPI_CancelAllRequests( void ) } memset( clgame.net_requests, 0, sizeof( clgame.net_requests )); - clgame.request_type = NET_REQUEST_CANCEL; - clgame.master_request = NULL; } /* diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index df78338c..f8265846 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1617,14 +1617,6 @@ void CL_InternetServers_f( void ) cls.internetservers_wait = NET_SendToMasters( NS_CLIENT, len, fullquery ); cls.internetservers_pending = true; - - if( !cls.internetservers_wait ) - { - // now we clearing the vgui request - if( clgame.master_request != NULL ) - memset( clgame.master_request, 0, sizeof( net_request_t )); - clgame.request_type = NET_REQUEST_GAMEUI; - } } /* @@ -2161,58 +2153,10 @@ void CL_ConnectionlessPacket( netadr_t from, sizebuf_t *msg ) // list is ends here if( !servadr.port ) - { - if( clgame.request_type == NET_REQUEST_CLIENT && clgame.master_request != NULL ) - { - net_request_t *nr = clgame.master_request; - net_adrlist_t *list, **prev; - - // setup the answer - nr->resp.remote_address = from; - nr->resp.error = NET_SUCCESS; - nr->resp.ping = host.realtime - nr->timesend; - - if( nr->timeout <= host.realtime ) - SetBits( nr->resp.error, NET_ERROR_TIMEOUT ); - - Con_Printf( "serverlist call: %s\n", NET_AdrToString( from )); - nr->pfnFunc( &nr->resp ); - - // throw the list, now it will be stored in user area - prev = (net_adrlist_t**)&nr->resp.response; - - while( 1 ) - { - list = *prev; - if( !list ) break; - - // throw out any variables the game created - *prev = list->next; - Mem_Free( list ); - } - memset( nr, 0, sizeof( *nr )); // done - clgame.request_type = NET_REQUEST_CANCEL; - clgame.master_request = NULL; - } break; - } - if( clgame.request_type == NET_REQUEST_CLIENT && clgame.master_request != NULL ) - { - net_request_t *nr = clgame.master_request; - net_adrlist_t *list; - - // adding addresses into list - list = Z_Malloc( sizeof( *list )); - list->remote_address = servadr; - list->next = nr->resp.response; - nr->resp.response = list; - } - else if( clgame.request_type == NET_REQUEST_GAMEUI ) - { - NET_Config( true, false ); // allow remote - Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION ); - } + NET_Config( true, false ); // allow remote + Netchan_OutOfBandPrint( NS_CLIENT, servadr, "info %i", PROTOCOL_VERSION ); } if( cls.internetservers_pending ) diff --git a/engine/client/client.h b/engine/client/client.h index f607189e..8b98642e 100644 --- a/engine/client/client.h +++ b/engine/client/client.h @@ -423,13 +423,6 @@ typedef struct float applied_angle; } screen_shake_t; -typedef enum -{ - NET_REQUEST_CANCEL = 0, // request was cancelled for some reasons - NET_REQUEST_GAMEUI, // called from GameUI - NET_REQUEST_CLIENT, // called from Client -} net_request_type_t; - typedef struct { net_response_t resp; @@ -491,9 +484,7 @@ typedef struct client_textmessage_t *titles; // title messages, not network messages int numTitles; - net_request_type_t request_type; // filter the requests net_request_t net_requests[MAX_REQUESTS]; // no reason to keep more - net_request_t *master_request; // queued master request efrag_t *free_efrags; // linked efrags cl_entity_t viewent; // viewmodel