summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2004-12-15 21:13:52 +0000
committertruelight <truelight@openttd.org>2004-12-15 21:13:52 +0000
commit2f6a26ab2d8b8781dc78063f54e0102e5191c63a (patch)
tree7dad5cae0e7fb3089a2b3e52a45d1b9e3a90e1f0
parent093540e9b5d5f0d271c218c0ea9b70fd1f7de7b4 (diff)
downloadopenttd-2f6a26ab2d8b8781dc78063f54e0102e5191c63a.tar.xz
(svn r1108) -Fix: [Network] Fixed problem around slow clients:
They joined, they got the map, but it took some time before the new player was created. In this time a player could do stuff, causing a player-id-mismatch, and the player was kicked out. Now a player get's a nice GUI which says: registering.. When that is gone, the player is joined and can play safely. Tnx to Moriarty for bugging me with this bug ;)
-rw-r--r--lang/english.txt1
-rw-r--r--main_gui.c17
-rw-r--r--network.h1
-rw-r--r--network_client.c3
-rw-r--r--network_gui.c9
-rw-r--r--players.c7
6 files changed, 30 insertions, 8 deletions
diff --git a/lang/english.txt b/lang/english.txt
index c2bbe2fe3..5cccf71fa 100644
--- a/lang/english.txt
+++ b/lang/english.txt
@@ -1303,6 +1303,7 @@ STR_NETWORK_CONNECTING_2 :{BLACK}(2/6) Authorising..
STR_NETWORK_CONNECTING_3 :{BLACK}(3/6) Waiting..
STR_NETWORK_CONNECTING_4 :{BLACK}(4/6) Downloading map..
STR_NETWORK_CONNECTING_5 :{BLACK}(5/6) Processing data..
+STR_NETWORK_CONNECTING_6 :{BLACK}(6/6) Registering..
STR_NETWORK_CONNECTING_SPECIAL_1 :{BLACK}Fetching game info..
STR_NETWORK_CONNECTING_SPECIAL_2 :{BLACK}Fetching company info..
diff --git a/main_gui.c b/main_gui.c
index ce5f3cb1e..765ef1935 100644
--- a/main_gui.c
+++ b/main_gui.c
@@ -2229,7 +2229,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
DrawSprite(SPR_OTTD_T, off_x + 34, 50);
DrawSprite(SPR_OTTD_T, off_x + 65, 50);
DrawSprite(SPR_OTTD_D, off_x + 96, 50);
-
+
/*
DrawSprite(SPR_OTTD_R, off_x + 119, 50);
DrawSprite(SPR_OTTD_A, off_x + 148, 50);
@@ -2323,8 +2323,8 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
ShowBuildRailToolbar(_last_built_railtype, 4);
break;
- case 'L':
- ShowTerraformToolbar();
+ case 'L':
+ ShowTerraformToolbar();
break;
case 'X':
@@ -2332,9 +2332,9 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
MarkWholeScreenDirty();
break;
- case WKC_BACKQUOTE:
- IConsoleSwitch();
- e->keypress.cont=false;
+ case WKC_BACKQUOTE:
+ IConsoleSwitch();
+ e->keypress.cont=false;
break;
#ifdef ENABLE_NETWORK
@@ -2356,6 +2356,7 @@ static void MainWindowWndProc(Window *w, WindowEvent *e) {
void ShowSelectGameWindow();
+extern void ShowJoinStatusWindowAfterJoin();
void SetupColorsAndInitialWindow()
{
@@ -2405,6 +2406,10 @@ void SetupColorsAndInitialWindow()
WP(w,def_d).data_1 = -1280;
+ /* Bring joining GUI to front till the client is really joined */
+ if (_networking && !_network_server)
+ ShowJoinStatusWindowAfterJoin();
+
break;
case GM_EDITOR:
w = AllocateWindow(0, 0, width, height, MainWindowWndProc, 0, NULL);
diff --git a/network.h b/network.h
index ae7135498..086b42a8a 100644
--- a/network.h
+++ b/network.h
@@ -109,6 +109,7 @@ typedef enum {
NETWORK_JOIN_STATUS_WAITING,
NETWORK_JOIN_STATUS_DOWNLOADING,
NETWORK_JOIN_STATUS_PROCESSING,
+ NETWORK_JOIN_STATUS_REGISTERING,
NETWORK_JOIN_STATUS_GETTING_COMPANY_INFO,
} NetworkJoinStatus;
diff --git a/network_client.c b/network_client.c
index ab87aae7d..c0e69ca5b 100644
--- a/network_client.c
+++ b/network_client.c
@@ -487,8 +487,6 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
}
_opt_mod_ptr = &_opt;
- DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
-
// Say we received the map and loaded it correctly!
SEND_COMMAND(PACKET_CLIENT_MAP_OK)();
@@ -498,6 +496,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_MAP)
if (_network_playas == OWNER_SPECTATOR) {
// The client wants to be a spectator..
_local_player = OWNER_SPECTATOR;
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
} else {
// send a command to make a new player
_local_player = 0;
diff --git a/network_gui.c b/network_gui.c
index 8257e8db0..e3bb1e85e 100644
--- a/network_gui.c
+++ b/network_gui.c
@@ -1271,6 +1271,15 @@ void ShowJoinStatusWindow()
AllocateWindowDesc(&_network_join_status_window_desc);
}
+void ShowJoinStatusWindowAfterJoin()
+{
+ /* This is a special instant of ShowJoinStatusWindow, because
+ it is opened after the map is loaded, but the client maybe is not
+ done registering itself to the server */
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+ _network_join_status = NETWORK_JOIN_STATUS_REGISTERING;
+ AllocateWindowDesc(&_network_join_status_window_desc);
+}
diff --git a/players.c b/players.c
index 039654df3..603d1ead7 100644
--- a/players.c
+++ b/players.c
@@ -643,6 +643,13 @@ int32 CmdPlayerCtrl(int x, int y, uint32 flags, uint32 p1, uint32 p2)
switch(p1 & 0xff) {
case 0: // make new player
p = DoStartupNewPlayer(false);
+
+#ifdef ENABLE_NETWORK
+ if (_networking && !_network_server && _local_player == OWNER_SPECTATOR)
+ /* In case we are a client joining a server... */
+ DeleteWindowById(WC_NETWORK_STATUS_WINDOW, 0);
+#endif /* ENABLE_NETWORK */
+
if (p != NULL) {
if (_local_player == OWNER_SPECTATOR) {
_local_player = p->index;