summaryrefslogtreecommitdiff
path: root/network_gui.c
diff options
context:
space:
mode:
authordominik <dominik@openttd.org>2004-08-22 10:23:37 +0000
committerdominik <dominik@openttd.org>2004-08-22 10:23:37 +0000
commit0bd907e88df535a11483b5bdcb5763a5fce0cbf5 (patch)
treeba05804e536e0dfe9e8f04ff59eca4cecbea04e5 /network_gui.c
parentb2340212c393d2488b8554dccafb9ab56e00dee5 (diff)
downloadopenttd-0bd907e88df535a11483b5bdcb5763a5fce0cbf5.tar.xz
(svn r106) New network core (by sign_de)
Features: * network core is dynamicly loaded when needed (-n isn't needed anymore) for easy switching between single and multiplayer. But commandline shortcuts are still enabled: -n = autodetect network server -n [ip] = connect to the server * udp now uses 2 different ports - you can run 1 server and serveral clients on one pc - the clients udp-socket gets unloaded when the network game starts - the servers udp-sockets remains online to allow the network gui to detect itself * new gameinfo structure this struct is available for every online/lan game * dynamic NetworkGameList
Diffstat (limited to 'network_gui.c')
-rw-r--r--network_gui.c46
1 files changed, 14 insertions, 32 deletions
diff --git a/network_gui.c b/network_gui.c
index 008067e4d..75f65d89b 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -21,16 +21,6 @@ void ShowQueryString(StringID str, StringID caption, int maxlen, int maxwidth, b
static byte _selected_field;
char *direct_ip = NULL;
-
-void ConnectToServer(byte* b)
-{
- _networking = true;
-
- NetworkInitialize(b);
- DEBUG(misc, 1) ("Connecting to %s %d\n", b, _network_port);
- NetworkConnect(b, _network_port);
-}
-
static const StringID _connection_types_dropdown[] = {
STR_NETWORK_LAN,
STR_NETWORK_INTERNET,
@@ -65,7 +55,15 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
case 0: // close X
case 15: // cancel button
DeleteWindowById(WC_NETWORK_WINDOW, 0);
+ NetworkLobbyShutdown();
break;
+ case 3: // find server automaticaly
+ {
+ byte *b = "auto";
+ NetworkCoreConnectGame(b,_network_server_port);
+ }
+ break;
+
case 4: // connect via direct ip
{
StringID str;
@@ -111,7 +109,7 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
byte *b = e->edittext.str;
if (*b == 0)
return;
- ConnectToServer(b);
+ NetworkCoreConnectGame(b,_network_server_port);
} break;
}
@@ -159,6 +157,8 @@ void ShowNetworkGameWindow()
{
Window *w;
DeleteWindowById(WC_NETWORK_WINDOW, 0);
+
+ NetworkLobbyInit();
w = AllocateWindowDesc(&_network_game_window_desc);
strcpy(_edit_str_buf, "Your name");
@@ -168,24 +168,9 @@ void ShowNetworkGameWindow()
WP(w,querystr_d).maxlen = MAX_QUERYSTR_LEN;
WP(w,querystr_d).maxwidth = 240;
WP(w,querystr_d).buf = _edit_str_buf;
-
-
- ShowErrorMessage(-1, TEMP_STRING_NO_NETWORK, 0, 0);
-}
-
-
-void StartServer()
-{
- _networking = true;
- NetworkInitialize(NULL);
- DEBUG(misc, 1) ("Listening on port %d\n", _network_port);
- NetworkListen(_network_port);
- _networking_server = true;
- DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME);
+ // ShowErrorMessage(-1, TEMP_STRING_NO_NETWORK, 0, 0);
}
-
-
static const StringID _players_dropdown[] = {
STR_NETWORK_2_PLAYERS,
STR_NETWORK_3_PLAYERS,
@@ -232,8 +217,9 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
ShowDropDownMenu(w, _players_dropdown, _opt_mod_ptr->currency, e->click.widget, 0);
return;
case 9: // start game
- StartServer();
+ NetworkCoreStartGame();
ShowNetworkLobbyWindow();
+ DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME);
break;
}
@@ -308,10 +294,6 @@ static void ShowNetworkStartServerWindow()
WP(w,querystr_d).buf = _edit_str_buf;
}
-
-
-
-
static void NetworkLobbyWindowWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {