(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 ;)
pull/155/head
truelight 20 years ago
parent 093540e9b5
commit 2f6a26ab2d

@ -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..

@ -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);

@ -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;

@ -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;

@ -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);
}

@ -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;

Loading…
Cancel
Save