summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--intro_gui.c5
-rw-r--r--lang/english.txt26
-rw-r--r--misc_gui.c1
-rw-r--r--network.c90
-rw-r--r--network_gui.c170
-rw-r--r--ttd.c4
-rw-r--r--variables.h1
7 files changed, 175 insertions, 122 deletions
diff --git a/intro_gui.c b/intro_gui.c
index f53ab4145..f1e546763 100644
--- a/intro_gui.c
+++ b/intro_gui.c
@@ -61,7 +61,10 @@ static void SelectGameWndProc(Window *w, WindowEvent *e) {
case 7:
if (!_network_available) {
ShowErrorMessage(-1,STR_NETWORK_ERR_NOTAVAILABLE, 0, 0);
- } else ShowNetworkGameWindow();
+ } else {
+ ShowNetworkGameWindow();
+ ShowErrorMessage(-1, TEMP_STRING_NO_NETWORK, 0, 0);
+ }
break;
case 8: ShowGameOptions(); break;
case 9: ShowGameDifficulty(); break;
diff --git a/lang/english.txt b/lang/english.txt
index 9df37dee2..0dd4a4289 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1169,7 +1169,7 @@ TEMP_AI_ACTIVATED :{WHITE}Warning: this new AI is still alpha! Currently, o
############ network gui strings
-TEMP_STRING_NO_NETWORK :{WHITE}Network interface is not working yet!
+TEMP_STRING_NO_NETWORK :{WHITE}Network interface is not fully working yet!{}Some options work, but others like lobby, etc. don't. Just so you know.
STR_NETWORK_MULTIPLAYER :{WHITE}Multiplayer
@@ -1187,8 +1187,8 @@ STR_NETWORK_ENTER_NAME_TIP :{BLACK}This is the name other players will identi
STR_NETWORK_SELECT_CONNECTION :{BLACK}Select connection type:
STR_NETWORK_CONNECTION_TYPE_TIP :{BLACK}Chose between an internet game or a local area nework game
STR_NETWORK_COMBO1 :{BLACK}{SKIP}{SKIP}{STRING}
-STR_NETWORK_LAN :{BLACK}LAN
-STR_NETWORK_INTERNET :{BLACK}Internet
+STR_NETWORK_LAN :LAN
+STR_NETWORK_INTERNET :Internet
STR_NETWORK_GAME_NAME :{BLACK}Name
STR_NETWORK_GAME_NAME_TIP :{BLACK}Name of the game
@@ -1213,15 +1213,16 @@ STR_NETWORK_SELECT_MAP_TIP :{BLACK}Which map do you want to play?
STR_NETWORK_NUMBER_OF_PLAYERS :{BLACK}Number of players:
STR_NETWORK_NUMBER_OF_PLAYERS_TIP :{BLACK}Chose a maximum number of players. Not all slots need to be filled.
STR_NETWORK_COMBO2 :{BLACK}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{SKIP}{STRING}
-STR_NETWORK_2_PLAYERS :{BLACK}2 players
-STR_NETWORK_3_PLAYERS :{BLACK}3 players
-STR_NETWORK_4_PLAYERS :{BLACK}4 players
-STR_NETWORK_5_PLAYERS :{BLACK}5 players
-STR_NETWORK_6_PLAYERS :{BLACK}6 players
-STR_NETWORK_7_PLAYERS :{BLACK}7 players
-STR_NETWORK_8_PLAYERS :{BLACK}8 players
+STR_NETWORK_2_PLAYERS :2 players
+STR_NETWORK_3_PLAYERS :3 players
+STR_NETWORK_4_PLAYERS :4 players
+STR_NETWORK_5_PLAYERS :5 players
+STR_NETWORK_6_PLAYERS :6 players
+STR_NETWORK_7_PLAYERS :7 players
+STR_NETWORK_8_PLAYERS :8 players
STR_NETWORK_START_GAME :{BLACK}Start Game
-
+STR_NETWORK_LOAD_GAME :{BLACK}Load Game
+STR_NETWORK_LOAD_SCENARIO :{BLACK}Load Scenario
STR_NETWORK_GAME_LOBBY :{WHITE}Multiplayer game lobby
@@ -1238,6 +1239,9 @@ STR_NETWORK_READY :{BLACK}Ready
STR_NETWORK_ERR_NOTAVAILABLE :{WHITE} No network devices found or compiled without ENABLE_NETWORK
STR_NETWORK_ERR_NOSERVER :{WHITE} Could not find any network game
STR_NETWORK_ERR_NOCONNECTION :{WHITE} The server didn't answer the request
+STR_NETWORK_ERR_DESYNC :{WHITE} Network-Game synchronization failed.
+STR_NETWORK_ERR_LOSTCONNECTION :{WHITE} Network-Game connection lost.
+STR_NETWORK_ERR_SAVEGAMEERROR :{WHITE} Could not load server-savegame.
############ end network gui strings
diff --git a/misc_gui.c b/misc_gui.c
index 1796305c3..a47b3edf4 100644
--- a/misc_gui.c
+++ b/misc_gui.c
@@ -457,6 +457,7 @@ static void ErrmsgWndProc(Window *w, WindowEvent *e)
TileHighlightData *thd = _thd_ptr;
TileIndex tile = thd->redsq;
thd->redsq = 0;
+ _switch_mode_errorstr = INVALID_STRING_ID;
if (tile != 0)
MarkTileDirtyByTile(tile);
break;
diff --git a/network.c b/network.c
index b75b0c6f2..cbb102f6e 100644
--- a/network.c
+++ b/network.c
@@ -221,17 +221,17 @@ static size_t _transmit_file_size;
static FILE *_recv_file;
typedef struct NetworkGameInfo {
- char server_name[40]; // name of the game
- char server_revision[8]; // server game version
- byte server_lang; // langid
- byte players_max; // max players allowed on server
- byte players_on; // current count of players on server
- uint16 game_date; // current date
- char game_password[10]; // should fit ... 14 chars
- char map_name[40]; // map which is played ["random" for a randomized map]
- uint map_width; // map width / 8
- uint map_height; // map height / 8
- byte map_set; // graphical set
+ char server_name[40]; // name of the game
+ char server_revision[8]; // server game version
+ byte server_lang; // langid
+ byte players_max; // max players allowed on server
+ byte players_on; // current count of players on server
+ uint16 game_date; // current date
+ char game_password[10]; // should fit ... 10 chars
+ char map_name[40]; // map which is played ["random" for a randomized map]
+ uint map_width; // map width / 8
+ uint map_height; // map height / 8
+ byte map_set; // graphical set
} NetworkGameInfo;
typedef struct NetworkGameList {
@@ -279,6 +279,36 @@ snooze(milliseconds*1000);
//////////////////////////////////////////////////////////////////////
// ****************************** //
+// * Network Error Handlers * //
+// ****************************** //
+
+static void NetworkHandleSaveGameError() {
+ _networking_sync = false;
+ _networking_queuing = true;
+ _switch_mode = SM_MENU;
+ _switch_mode_errorstr = STR_NETWORK_ERR_SAVEGAMEERROR;
+}
+
+static void NetworkHandleConnectionLost() {
+ _networking_sync = false;
+ _networking_queuing = true;
+ _switch_mode = SM_MENU;
+ _switch_mode_errorstr = STR_NETWORK_ERR_LOSTCONNECTION;
+}
+static void NetworkHandleDeSync() {
+ printf("fatal error: network sync error at frame %i\n",_frame_counter);
+ {
+ int i;
+ for (i=15; i>=0; i--) printf("frame %i: [0]=%i, [1]=%i\n",_frame_counter-(i+1),_my_seed_list[i][0],_my_seed_list[i][1]);
+ for (i=0; i<8; i++) printf("frame %i: [0]=%i, [1]=%i\n",_frame_counter+i,_future_seed[i].seed[0],_future_seed[i].seed[1]);
+ }
+ _networking_sync = false;
+ _networking_queuing = true;
+ _switch_mode = SM_MENU;
+ _switch_mode_errorstr = STR_NETWORK_ERR_DESYNC;
+}
+
+// ****************************** //
// * TCP Packets and Handlers * //
// ****************************** //
@@ -326,8 +356,7 @@ void NetworkProcessCommands()
while (_num_future_seed) {
assert(_future_seed[0].frame >= _frame_counter);
if (_future_seed[0].frame != _frame_counter) break;
- if (_future_seed[0].seed[0] != _sync_seed_1 ||_future_seed[0].seed[1] != _sync_seed_2)
- error("!network sync error");
+ if (_future_seed[0].seed[0] != _sync_seed_1 ||_future_seed[0].seed[1] != _sync_seed_2) NetworkHandleDeSync();
memcpy_overlapping(_future_seed, _future_seed + 1, --_num_future_seed * sizeof(FutureSeeds));
}
}
@@ -494,8 +523,7 @@ static void HandleSyncPacket(SyncPacket *sp)
// we are ahead of the server check if the seed is in our list.
if (_frame_counter_srv + 16 > _frame_counter) {
// the random seed exists in our array check it.
- if (s1 != _my_seed_list[_frame_counter_srv & 0xF][0] || s2 != _my_seed_list[_frame_counter_srv & 0xF][1])
- error("!network is desynched\n");
+ if (s1 != _my_seed_list[_frame_counter_srv & 0xF][0] || s2 != _my_seed_list[_frame_counter_srv & 0xF][1]) NetworkHandleDeSync();
}
} else {
// the server's frame has not been executed yet. store the server's seed in a list.
@@ -537,17 +565,14 @@ static void HandleFilePacket(FilePacketHdr *fp)
// attempt loading the game.
_game_mode = GM_NORMAL;
- if (SaveOrLoad("networkc.tmp", SL_LOAD) != SL_OK) error("network load failed");
-
+ if (SaveOrLoad("networkc.tmp", SL_LOAD) != SL_OK) {
+ NetworkCoreDisconnect();
+ NetworkHandleSaveGameError();
+ return;
+ }
// sync to server.
_networking_queuing = false;
NetworkStartSync(false);
-/*
- _networking_sync = true;
- _frame_counter = 0; // start executing at frame 0.
- _sync_seed_1 = _sync_seed_2 = 0;
- _num_future_seed = 0;
- memset(_my_seed_list, 0, sizeof(_my_seed_list)); */
if (_network_playas == 0) {
// send a command to make a new player
@@ -977,7 +1002,7 @@ void NetworkReceive()
#else
n = WaitSelect(FD_SETSIZE, &read_fd, &write_fd, NULL, &tv, NULL);
#endif
- if (n == -1) error("select failed");
+ if (n == -1) NetworkHandleConnectionLost();
// accept clients..
if (_networking_server && FD_ISSET(_listensocket, &read_fd))
@@ -1258,7 +1283,7 @@ void NetworkUDPBroadCast(bool client, struct UDPPacket packet) {
bcptr[3]=255;
out_addr.sin_addr.s_addr = bcaddr;
res=sendto(udp,(char *) &packet,sizeof(packet),0,(struct sockaddr *) &out_addr,sizeof(out_addr));
- if (res==-1) error("udp: broadcast error: %i",GET_LAST_ERROR());
+ if (res==-1) DEBUG(misc,1)("udp: broadcast error: %i",GET_LAST_ERROR());
i++;
}
@@ -1446,22 +1471,27 @@ bool NetworkCoreConnectGame(byte* b, unsigned short port)
if (strcmp((char *) b,"auto")==0) {
// do autodetect
NetworkUDPSearchGame(&b, &port);
- }
+ }
if (port==0) {
// autodetection failed
if (_networking_override) NetworkLobbyShutdown();
ShowErrorMessage(-1, STR_NETWORK_ERR_NOSERVER, 0, 0);
+ _switch_mode_errorstr = STR_NETWORK_ERR_NOSERVER;
return false;
- }
+ }
+
NetworkInitialize();
_networking = NetworkConnect(b, port);
if (_networking) {
NetworkLobbyShutdown();
- } else {
- if (_networking_override) NetworkLobbyShutdown();
+ } else {
+ if (_networking_override)
+ NetworkLobbyShutdown();
+
ShowErrorMessage(-1, STR_NETWORK_ERR_NOCONNECTION,0,0);
- }
+ _switch_mode_errorstr = STR_NETWORK_ERR_NOCONNECTION;
+ }
return _networking;
}
diff --git a/network_gui.c b/network_gui.c
index 75f65d89b..a4ad826bd 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -27,13 +27,23 @@ static const StringID _connection_types_dropdown[] = {
INVALID_STRING_ID
};
+/* Should be _network_game->players_max but since network is not yet really done
+* we'll just use some dummy here
+* network.c -->> static NetworkGameInfo _network_game;
+*/
+static byte _players_max;
+/* Should be ??????????? (something) but since network is not yet really done
+* we'll just use some dummy here
+*/
+static byte _network_connection;
+
static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
SET_DPARAM16(0, 0x00);
- SET_DPARAM16(2, STR_NETWORK_LAN + _opt_mod_ptr->road_side);
+ SET_DPARAM16(2, STR_NETWORK_LAN + _network_connection);
DrawWindowWidgets(w);
DrawEditBox(w, 6);
@@ -45,27 +55,20 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
DrawString(238, 82, STR_NETWORK_PLAYERS, 2);
DrawString(288, 82, STR_NETWORK_MAP_SIZE, 2);
- break;
- }
+ } break;
case WE_CLICK:
_selected_field = e->click.widget;
switch(e->click.widget) {
-
- case 0: // close X
- case 15: // cancel button
+ case 0: case 15: /* Close 'X' | Cancel button */
DeleteWindowById(WC_NETWORK_WINDOW, 0);
NetworkLobbyShutdown();
break;
- case 3: // find server automaticaly
- {
+ case 3: { /* Find server automaticaly */
byte *b = "auto";
- NetworkCoreConnectGame(b,_network_server_port);
- }
- break;
-
- case 4: // connect via direct ip
- {
+ NetworkCoreConnectGame(b, _network_server_port);
+ } break;
+ case 4: { /* Connect via direct ip */
StringID str;
str = AllocateName((byte*)_decode_parameters, 0);
@@ -77,27 +80,32 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
w->window_class,
w->window_number);
DeleteName(str);
- }
- break;
-
- case 5: // start server
+ } break;
+ case 5: /* Start server */
ShowNetworkStartServerWindow();
break;
-
- case 8:
- ShowDropDownMenu(w, _connection_types_dropdown, _opt_mod_ptr->currency, e->click.widget, 0);
+ case 7: case 8: /* Connection type */
+ ShowDropDownMenu(w, _connection_types_dropdown, _network_connection, 8, 0); // do it for widget 8
return;
}
+ break;
+
+ case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
+ _network_connection = e->dropdown.index;
+
+ SetWindowDirty(w);
+ break;
case WE_MOUSELOOP:
- if(_selected_field != 6)
- break;
- HandleEditBox(w, 6);
+ if (_selected_field == 6)
+ HandleEditBox(w, 6);
+
break;
case WE_KEYPRESS:
if(_selected_field != 6)
break;
+
switch (HandleEditBoxKey(w, 6, e)) {
case 1:
HandleButtonClick(w, 9);
@@ -116,32 +124,31 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
}
static const Widget _network_game_window_widgets[] = {
-{ WWT_PUSHTXTBTN, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
-{ WWT_CAPTION, BGC, 10, 399, 0, 13, STR_NETWORK_MULTIPLAYER},
-{ WWT_IMGBTN, BGC, 0, 399, 14, 199, 0x0},
-
-{ WWT_PUSHTXTBTN, BTC, 20, 130, 22, 33, STR_NETWORK_FIND_SERVER, STR_NETWORK_FIND_SERVER_TIP},
-{ WWT_PUSHTXTBTN, BTC, 145, 255, 22, 33, STR_NETWORK_DIRECT_CONNECT, STR_NETWORK_DIRECT_CONNECT_TIP},
-{ WWT_PUSHTXTBTN, BTC, 270, 380, 22, 33, STR_NETWORK_START_SERVER, STR_NETWORK_START_SERVER_TIP},
+{ WWT_PUSHTXTBTN, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW},
+{ WWT_CAPTION, BGC, 10, 399, 0, 13, STR_NETWORK_MULTIPLAYER, STR_NULL},
+{ WWT_IMGBTN, BGC, 0, 399, 14, 199, 0x0, STR_NULL},
-{ WWT_IMGBTN, BGC, 250, 394, 42, 53, 0x0, STR_NETWORK_ENTER_NAME_TIP},
+{ WWT_PUSHTXTBTN, BTC, 20, 130, 22, 33, STR_NETWORK_FIND_SERVER, STR_NETWORK_FIND_SERVER_TIP},
+{ WWT_PUSHTXTBTN, BTC, 145, 255, 22, 33, STR_NETWORK_DIRECT_CONNECT, STR_NETWORK_DIRECT_CONNECT_TIP},
+{ WWT_PUSHTXTBTN, BTC, 270, 380, 22, 33, STR_NETWORK_START_SERVER, STR_NETWORK_START_SERVER_TIP},
-{ WWT_6, BGC, 250, 393, 62, 73, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TYPE_TIP},
-{ WWT_CLOSEBOX, BGC, 382, 392, 63, 72, STR_0225, STR_NETWORK_CONNECTION_TYPE_TIP},
+{ WWT_IMGBTN, BGC, 250, 394, 42, 53, 0x0, STR_NETWORK_ENTER_NAME_TIP},
-{ WWT_SCROLLBAR, BGC, 382, 392, 81, 175, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{ WWT_6, BGC, 250, 393, 62, 73, STR_NETWORK_COMBO1, STR_NETWORK_CONNECTION_TYPE_TIP},
+{ WWT_CLOSEBOX, BGC, 382, 392, 63, 72, STR_0225, STR_NETWORK_CONNECTION_TYPE_TIP},
-{ WWT_IMGBTN, BTC, 10, 231, 81, 92, 0x0, STR_NETWORK_GAME_NAME_TIP },
-{ WWT_IMGBTN, BTC, 232, 281, 81, 92, 0x0, STR_NETWORK_PLAYERS_TIP },
-{ WWT_IMGBTN, BTC, 282, 331, 81, 92, 0x0, STR_NETWORK_MAP_SIZE_TIP },
-{ WWT_IMGBTN, BTC, 332, 381, 81, 92, 0x0, STR_NETWORK_INFO_ICONS_TIP },
+{ WWT_SCROLLBAR, BGC, 382, 392, 81, 175, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{ WWT_MATRIX, BGC, 10, 381, 93, 175, 0x601, STR_NETWORK_CLICK_GAME_TO_SELECT},
+{ WWT_IMGBTN, BTC, 10, 231, 81, 92, 0x0, STR_NETWORK_GAME_NAME_TIP },
+{ WWT_IMGBTN, BTC, 232, 281, 81, 92, 0x0, STR_NETWORK_PLAYERS_TIP },
+{ WWT_IMGBTN, BTC, 282, 331, 81, 92, 0x0, STR_NETWORK_MAP_SIZE_TIP },
+{ WWT_IMGBTN, BTC, 332, 381, 81, 92, 0x0, STR_NETWORK_INFO_ICONS_TIP },
-{ WWT_PUSHTXTBTN, BTC, 145, 255, 180, 191, STR_012E_CANCEL, STR_NULL},
-{ WWT_PUSHTXTBTN, BTC, 270, 392, 180, 191, STR_NETWORK_JOIN_GAME, STR_NULL},
+{ WWT_MATRIX, BGC, 10, 381, 93, 175, 0x601, STR_NETWORK_CLICK_GAME_TO_SELECT},
-{ WWT_LAST},
+{ WWT_PUSHTXTBTN, BTC, 145, 255, 180, 191, STR_012E_CANCEL, STR_NULL},
+{ WWT_PUSHTXTBTN, BTC, 270, 392, 180, 191, STR_NETWORK_JOIN_GAME, STR_NULL},
+{ WWT_LAST},
};
static const WindowDesc _network_game_window_desc = {
@@ -168,7 +175,6 @@ 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);
}
static const StringID _players_dropdown[] = {
@@ -182,13 +188,12 @@ static const StringID _players_dropdown[] = {
INVALID_STRING_ID
};
-
static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
{
switch(e->event) {
case WE_PAINT: {
- SET_DPARAM16(7, STR_NETWORK_2_PLAYERS + _opt_mod_ptr->road_side);
+ SET_DPARAM16(7, STR_NETWORK_2_PLAYERS + _players_max);
DrawWindowWidgets(w);
GfxFillRect(11, 63, 237, 168, 0xD7);
@@ -202,39 +207,45 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
DrawString(10, 43, STR_NETWORK_SELECT_MAP, 2);
DrawString(260, 63, STR_NETWORK_NUMBER_OF_PLAYERS, 2);
- break;
- }
+ } break;
case WE_CLICK:
_selected_field = e->click.widget;
switch(e->click.widget) {
-
- case 0: // close X
- case 10: // cancel button
+ case 0: case 12: /* Close 'X' | Cancel button */
ShowNetworkGameWindow();
break;
- case 8:
- ShowDropDownMenu(w, _players_dropdown, _opt_mod_ptr->currency, e->click.widget, 0);
+ case 7: case 8: /* Number of Players */
+ ShowDropDownMenu(w, _players_dropdown, _players_max, 8, 0); // do it for widget 8
return;
- case 9: // start game
+ case 9: /* Start game */
NetworkCoreStartGame();
- ShowNetworkLobbyWindow();
+ //ShowNetworkLobbyWindow();
DoCommandP(0, 0, 0, NULL, CMD_START_NEW_GAME);
break;
- }
-
- case WE_MOUSELOOP:
- if(_selected_field == 3)
- {
- HandleEditBox(w, 3);
+ case 10: /* Load game */
+ NetworkCoreStartGame();
+ //ShowNetworkLobbyWindow();
+ ShowSaveLoadDialog(SLD_LOAD_GAME);
break;
- }
- if(_selected_field == 4)
- {
- HandleEditBox(w, 4);
+ case 11: /* Load scenario */
+ NetworkCoreStartGame();
+ //ShowNetworkLobbyWindow();
+ ShowSaveLoadDialog(SLD_LOAD_SCENARIO);;
break;
}
-
+ break;
+
+ case WE_DROPDOWN_SELECT: /* we have selected a dropdown item in the list */
+ _players_max = e->dropdown.index;
+
+ SetWindowDirty(w);
+ break;
+
+ case WE_MOUSELOOP:
+ if(_selected_field == 3 || _selected_field == 4)
+ HandleEditBox(w, _selected_field);
+
break;
case WE_KEYPRESS:
@@ -251,22 +262,23 @@ static void NetworkStartServerWindowWndProc(Window *w, WindowEvent *e)
}
static const Widget _network_start_server_window_widgets[] = {
-{ WWT_PUSHTXTBTN, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
-{ WWT_CAPTION, BGC, 10, 399, 0, 13, STR_NETWORK_START_GAME_WINDOW },
-{ WWT_IMGBTN, BGC, 0, 399, 14, 199, 0x0},
-
-{ WWT_IMGBTN, BGC, 80, 190, 22, 33, 0x0, STR_NETWORK_NEW_GAME_NAME_TIP},
-{ WWT_IMGBTN, BGC, 280, 390, 22, 33, 0x0, STR_NETWORK_PASSWORD_TIP},
+{ WWT_CLOSEBOX, BGC, 0, 10, 0, 13, STR_00C5, STR_018B_CLOSE_WINDOW },
+{ WWT_CAPTION, BGC, 10, 399, 0, 13, STR_NETWORK_START_GAME_WINDOW, STR_NULL},
+{ WWT_IMGBTN, BGC, 0, 399, 14, 199, 0x0, STR_NULL},
-{ WWT_IMGBTN, BGC, 10, 240, 62, 170, 0x0, STR_NETWORK_SELECT_MAP_TIP},
-{ WWT_SCROLLBAR, BGC, 241, 251, 62, 170, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
+{ WWT_IMGBTN, BGC, 80, 190, 22, 33, 0x0, STR_NETWORK_NEW_GAME_NAME_TIP},
+{ WWT_IMGBTN, BGC, 280, 390, 22, 33, 0x0, STR_NETWORK_PASSWORD_TIP},
-{ WWT_6, BGC, 260, 390, 81, 92, STR_NETWORK_COMBO2, STR_NETWORK_NUMBER_OF_PLAYERS_TIP},
-{ WWT_CLOSEBOX, BGC, 378, 388, 82, 91, STR_0225, STR_NETWORK_NUMBER_OF_PLAYERS_TIP},
+{ WWT_IMGBTN, BGC, 10, 240, 62, 170, 0x0, STR_NETWORK_SELECT_MAP_TIP},
+{ WWT_SCROLLBAR, BGC, 241, 251, 62, 170, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
-{ WWT_PUSHTXTBTN, BTC, 80, 180, 180, 191, STR_NETWORK_START_GAME, STR_NULL},
-{ WWT_PUSHTXTBTN, BTC, 220, 320, 180, 191, STR_012E_CANCEL, STR_NULL},
+{ WWT_6, BGC, 260, 390, 81, 92, STR_NETWORK_COMBO2, STR_NETWORK_NUMBER_OF_PLAYERS_TIP},
+{ WWT_CLOSEBOX, BGC, 379, 389, 82, 91, STR_0225, STR_NETWORK_NUMBER_OF_PLAYERS_TIP},
+{ WWT_PUSHTXTBTN, BTC, 10, 100, 180, 191, STR_NETWORK_START_GAME, STR_NULL},
+{ WWT_PUSHTXTBTN, BTC, 110, 200, 180, 191, STR_NETWORK_LOAD_GAME, STR_NULL},
+{ WWT_PUSHTXTBTN, BTC, 210, 300, 180, 191, STR_NETWORK_LOAD_SCENARIO, STR_NULL},
+{ WWT_PUSHTXTBTN, BTC, 310, 390, 180, 191, STR_012E_CANCEL, STR_NULL},
{ WWT_LAST},
};
@@ -278,7 +290,6 @@ static const WindowDesc _network_start_server_window_desc = {
NetworkStartServerWindowWndProc,
};
-
static void ShowNetworkStartServerWindow()
{
Window *w;
@@ -286,7 +297,6 @@ static void ShowNetworkStartServerWindow()
w = AllocateWindowDesc(&_network_start_server_window_desc);
strcpy(_edit_str_buf, "");
-
WP(w,querystr_d).caret = 1;
WP(w,querystr_d).maxlen = MAX_QUERYSTR_LEN;
diff --git a/ttd.c b/ttd.c
index dfca2556a..99b9d3474 100644
--- a/ttd.c
+++ b/ttd.c
@@ -489,6 +489,7 @@ int ttd_main(int argc, char* argv[])
_game_mode = GM_MENU;
_switch_mode = SM_MENU;
+ _switch_mode_errorstr = INVALID_STRING_ID;
MyGetOptInit(&mgo, argc-1, argv+1, "m:s:v:hn::l:eit:d::r:g::G:cp:");
while ((i = MyGetOpt(&mgo)) != -1) {
@@ -860,6 +861,9 @@ normal_load:
MarkWholeScreenDirty();
break;
}
+
+ if (_switch_mode_errorstr!=INVALID_STRING_ID)
+ ShowErrorMessage(INVALID_STRING_ID,_switch_mode_errorstr,0,0);
_in_state_game_loop = false;
}
diff --git a/variables.h b/variables.h
index 7a6d33814..d4f3c91b3 100644
--- a/variables.h
+++ b/variables.h
@@ -282,6 +282,7 @@ typedef struct {
// Used when switching from the intro menu.
VARDEF byte _switch_mode;
+VARDEF StringID _switch_mode_errorstr;
VARDEF bool _exit_game;
VARDEF SmallFiosItem _file_to_saveload;
VARDEF byte _make_screenshot;