summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/net_gui.c54
-rw-r--r--src/net_query.c18
-rw-r--r--src/net_query.h1
3 files changed, 71 insertions, 2 deletions
diff --git a/src/net_gui.c b/src/net_gui.c
index d8c584b7..a79df735 100644
--- a/src/net_gui.c
+++ b/src/net_gui.c
@@ -37,6 +37,7 @@
#include "net_client.h"
#include "net_gui.h"
+#include "net_query.h"
#include "net_server.h"
#include "textscreen.h"
@@ -46,6 +47,7 @@ static int old_max_players;
static txt_label_t *player_labels[NET_MAXPLAYERS];
static txt_label_t *ip_labels[NET_MAXPLAYERS];
static txt_label_t *drone_label;
+static txt_label_t *master_msg_label;
static boolean had_warning;
static void EscapePressed(TXT_UNCAST_ARG(widget), void *unused)
@@ -73,6 +75,8 @@ static void OpenWaitDialog(void)
TXT_SignalConnect(cancel, "pressed", EscapePressed, NULL);
TXT_SetWindowAction(window, TXT_HORIZ_LEFT, cancel);
+ TXT_SetWindowPosition(window, TXT_HORIZ_CENTER, TXT_VERT_BOTTOM,
+ TXT_SCREEN_W / 2, TXT_SCREEN_H - 9);
old_max_players = 0;
}
@@ -182,6 +186,55 @@ static void UpdateGUI(void)
TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, startgame);
}
+static void BuildMasterStatusWindow(void)
+{
+ txt_window_t *master_window;
+
+ master_window = TXT_NewWindow(NULL);
+ master_msg_label = TXT_NewLabel("");
+ TXT_AddWidget(master_window, master_msg_label);
+
+ // This window is here purely for information, so it should be
+ // in the background.
+
+ TXT_LowerWindow(master_window);
+ TXT_SetWindowPosition(master_window, TXT_HORIZ_CENTER, TXT_VERT_CENTER,
+ TXT_SCREEN_W / 2, TXT_SCREEN_H - 4);
+ TXT_SetWindowAction(master_window, TXT_HORIZ_LEFT, NULL);
+ TXT_SetWindowAction(master_window, TXT_HORIZ_CENTER, NULL);
+ TXT_SetWindowAction(master_window, TXT_HORIZ_RIGHT, NULL);
+}
+
+static void CheckMasterStatus(void)
+{
+ boolean added;
+
+ if (!NET_Query_CheckAddedToMaster(&added))
+ {
+ return;
+ }
+
+ if (master_msg_label == NULL)
+ {
+ BuildMasterStatusWindow();
+ }
+
+ if (added)
+ {
+ TXT_SetLabel(master_msg_label,
+ "Your server is now registered with the global master server.\n"
+ "Other players can find your server online.");
+ }
+ else
+ {
+ TXT_SetLabel(master_msg_label,
+ "Failed to register with the master server. Your server is not\n"
+ "publicly accessible. You may need to reconfigure your Internet\n"
+ "router to add a port forward for UDP port 2342. Look up\n"
+ "information on port forwarding online.");
+ }
+}
+
static void PrintSHA1Digest(char *s, byte *digest)
{
unsigned int i;
@@ -307,6 +360,7 @@ void NET_WaitForLaunch(void)
{
UpdateGUI();
CheckSHA1Sums();
+ CheckMasterStatus();
TXT_DispatchEvents();
TXT_DrawDesktop();
diff --git a/src/net_query.c b/src/net_query.c
index 392ee022..80b5b1bc 100644
--- a/src/net_query.c
+++ b/src/net_query.c
@@ -81,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;
@@ -158,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)
diff --git a/src/net_query.h b/src/net_query.h
index 5a30bd0d..d98f5da5 100644
--- a/src/net_query.h
+++ b/src/net_query.h
@@ -44,6 +44,7 @@ extern int NET_Query_Poll(net_query_callback_t callback, void *user_data);
extern net_addr_t *NET_Query_ResolveMaster(net_context_t *context);
extern void NET_Query_AddToMaster(net_addr_t *master_addr);
+extern boolean NET_Query_CheckAddedToMaster(boolean *result);
extern void NET_Query_MasterResponse(net_packet_t *packet);
#endif /* #ifndef NET_QUERY_H */