@ -68,25 +68,27 @@ static void NetworkTruncateString(char *name, const int max_width)
}
}
}
}
extern const char _openttd_revision [ ] ;
static void NetworkGameWindowWndProc ( Window * w , WindowEvent * e )
static void NetworkGameWindowWndProc ( Window * w , WindowEvent * e )
{
{
switch ( e - > event ) {
switch ( e - > event ) {
case WE_PAINT : {
case WE_PAINT : {
if ( _selected_item = = NULL )
w - > disabled_state = ( 1 < < 17 ) | ( 1 < < 18 ) ;
else if ( ! _selected_item - > online )
w - > disabled_state = ( 1 < < 17 ) ; // Server offline, join button disabled
else if ( _selected_item - > info . clients_on = = _selected_item - > info . clients_max )
w - > disabled_state = ( 1 < < 17 ) ; // Server full, join button disabled
# ifdef WITH_REV
else if ( strncmp ( _selected_item - > info . server_revision , _openttd_revision , NETWORK_REVISION_LENGTH - 1 ) ! = 0 ) {
if ( strncmp ( _selected_item - > info . server_revision , " norev000 " , sizeof ( _selected_item - > info . server_revision ) ) ! = 0 )
w - > disabled_state = ( 1 < < 17 ) ; // Revision mismatch, join button disabled
}
# endif
else
w - > disabled_state = 0 ;
w - > disabled_state = 0 ;
if ( _selected_item = = NULL ) {
SETBIT ( w - > disabled_state , 17 ) ; SETBIT ( w - > disabled_state , 18 ) ;
} else if ( ! _selected_item - > online ) {
SETBIT ( w - > disabled_state , 17 ) ; // Server offline, join button disabled
} else if ( _selected_item - > info . clients_on = = _selected_item - > info . clients_max ) {
SETBIT ( w - > disabled_state , 17 ) ; // Server full, join button disabled
// revisions don't match, check if server has no revision; then allow connection
} else if ( strncmp ( _selected_item - > info . server_revision , _openttd_revision , NETWORK_REVISION_LENGTH - 1 ) ! = 0 ) {
if ( strncmp ( _selected_item - > info . server_revision , NOREV_STRING , sizeof ( _selected_item - > info . server_revision ) ) ! = 0 )
SETBIT ( w - > disabled_state , 17 ) ; // Revision mismatch, join button disabled
}
SetDParam ( 0 , 0x00 ) ;
SetDParam ( 0 , 0x00 ) ;
SetDParam ( 2 , STR_NETWORK_LAN + _network_connection ) ;
SetDParam ( 2 , STR_NETWORK_LAN + _network_connection ) ;
DrawWindowWidgets ( w ) ;
DrawWindowWidgets ( w ) ;
@ -105,12 +107,8 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
char servername [ NETWORK_NAME_LENGTH ] ;
char servername [ NETWORK_NAME_LENGTH ] ;
const NetworkGameList * cur_item = _network_game_list ;
const NetworkGameList * cur_item = _network_game_list ;
while ( cur_item ! = NULL ) {
while ( cur_item ! = NULL ) {
# ifdef WITH_REV
bool compatible = ( strncmp ( cur_item - > info . server_revision , _openttd_revision , NETWORK_REVISION_LENGTH - 1 ) = = 0 ) ;
bool compatible = ( strncmp ( cur_item - > info . server_revision , _openttd_revision , NETWORK_REVISION_LENGTH - 1 ) = = 0 ) ;
# else
if ( strncmp ( cur_item - > info . server_revision , NOREV_STRING , sizeof ( cur_item - > info . server_revision ) ) = = 0 )
bool compatible = true ; // We have no idea if we are compatible...
# endif
if ( strncmp ( cur_item - > info . server_revision , " norev000 " , sizeof ( cur_item - > info . server_revision ) ) = = 0 )
compatible = true ;
compatible = true ;
if ( cur_item = = _selected_item )
if ( cur_item = = _selected_item )
@ -200,17 +198,15 @@ static void NetworkGameWindowWndProc(Window *w, WindowEvent *e)
y + = 2 ;
y + = 2 ;
# ifdef WITH_REV
if ( strncmp ( _selected_item - > info . server_revision , _openttd_revision , NETWORK_REVISION_LENGTH - 1 ) ! = 0 ) {
if ( strncmp ( _selected_item - > info . server_revision , _openttd_revision , NETWORK_REVISION_LENGTH - 1 ) ! = 0 ) {
if ( strncmp ( _selected_item - > info . server_revision , " norev000 " , sizeof ( _selected_item - > info . server_revision ) ) ! = 0 )
if ( strncmp ( _selected_item - > info . server_revision , NOREV_STRING , sizeof ( _selected_item - > info . server_revision ) ) ! = 0 )
DrawStringMultiCenter ( 360 , y , STR_NETWORK_VERSION_MISMATCH , 2 ) ; // server mismatch
DrawStringMultiCenter ( 360 , y , STR_NETWORK_VERSION_MISMATCH , 2 ) ; // server mismatch
} else
} else if ( _selected_item - > info . clients_on = = _selected_item - > info . clients_max ) {
# endif
if ( _selected_item - > info . clients_on = = _selected_item - > info . clients_max )
// Show: server full, when clients_on == clients_max
// Show: server full, when clients_on == clients_max
DrawStringMultiCenter ( 360 , y , STR_NETWORK_SERVER_FULL , 2 ) ; // server full
DrawStringMultiCenter ( 360 , y , STR_NETWORK_SERVER_FULL , 2 ) ; // server full
else if ( _selected_item - > info . use_password )
} else if ( _selected_item - > info . use_password )
DrawStringMultiCenter ( 360 , y , STR_NETWORK_PASSWORD , 2 ) ; // password warning
DrawStringMultiCenter ( 360 , y , STR_NETWORK_PASSWORD , 2 ) ; // password warning
y + = 10 ;
y + = 10 ;
}
}
} break ;
} break ;