diff options
Diffstat (limited to 'src/net_query.c')
-rw-r--r-- | src/net_query.c | 74 |
1 files changed, 53 insertions, 21 deletions
diff --git a/src/net_query.c b/src/net_query.c index 475fa98f..80b5b1bc 100644 --- a/src/net_query.c +++ b/src/net_query.c @@ -22,8 +22,10 @@ // Querying servers to find their current status. // +#include <stdio.h> #include <stdarg.h> #include <stdlib.h> +#include <string.h> #include "i_system.h" #include "i_timer.h" @@ -79,9 +81,8 @@ typedef struct boolean printed; } query_target_t; -// Transmit a query packet - static boolean registered_with_master = false; +static boolean got_master_response = false; static net_context_t *query_context; static query_target_t *targets; @@ -156,9 +157,24 @@ void NET_Query_MasterResponse(net_packet_t *packet) printf("Failed to register with master server at %s\n", MASTER_SERVER_ADDRESS); } + + got_master_response = true; } } +boolean NET_Query_CheckAddedToMaster(boolean *result) +{ + // Got response from master yet? + + if (!got_master_response) + { + return false; + } + + *result = registered_with_master; + return true; +} + // Send a query to the master server. static void NET_Query_SendMasterQuery(net_addr_t *addr) @@ -532,10 +548,14 @@ static void NET_Query_QueryLoop(net_query_callback_t callback, void *user_data) void NET_Query_Init(void) { - query_context = NET_NewContext(); - NET_AddModule(query_context, &net_sdl_module); - net_sdl_module.InitClient(); + if (query_context == NULL) + { + query_context = NET_NewContext(); + NET_AddModule(query_context, &net_sdl_module); + net_sdl_module.InitClient(); + } + free(targets); targets = NULL; num_targets = 0; @@ -646,23 +666,35 @@ static void formatted_printf(int wide, char *s, ...) static char *GameDescription(GameMode_t mode, GameMission_t mission) { - switch (mode) - { - case shareware: - return "shareware"; - case registered: - return "registered"; - case retail: - return "ultimate"; - case commercial: - if (mission == doom2) - return "doom2"; - else if (mission == pack_tnt) - return "tnt"; - else if (mission == pack_plut) - return "plutonia"; + switch (mission) + { + case doom: + if (mode == shareware) + return "swdoom"; + else if (mode == registered) + return "regdoom"; + else if (mode == retail) + return "ultdoom"; + else + return "doom"; + case doom2: + return "doom2"; + case pack_tnt: + return "tnt"; + case pack_plut: + return "plutonia"; + case pack_chex: + return "chex"; + case pack_hacx: + return "hacx"; + case heretic: + return "heretic"; + case hexen: + return "hexen"; + case strife: + return "strife"; default: - return "unknown"; + return "?"; } } |