Changeset - r214:315143c5d296
[Not reviewed]
master
0 1 0
signde - 20 years ago 2004-09-12 16:03:40
signde@openttd.org
(svn r215) -Feature: direct connect now allows selecting a port and a playername [ip/host]:[port]#[player]
1 file changed with 29 insertions and 3 deletions:
0 comments (0 inline, 0 general)
network_gui.c
Show inline comments
 
@@ -151,51 +151,77 @@ static void NetworkGameWindowWndProc(Win
 
		
 
		_network_game_count_last = _network_game_count;
 
		SetWindowDirty(w);
 

	
 
		break;
 

	
 
	case WE_MOUSELOOP:
 
		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);
 
			break;
 
		}
 
		break;
 

	
 
	case WE_ON_EDIT_TEXT: {
 
		const byte *b = e->edittext.str;
 
		if (*b != 0)
 
			NetworkCoreConnectGame(b, _network_server_port);
 
		byte *b = e->edittext.str;
 
		if (*b != 0) {
 
			byte * ip = NULL;
 
			byte * port = NULL;
 
			byte * player = NULL;
 
			byte c;
 
			uint16 rport;
 

	
 
			rport = _network_server_port;
 
			c = 0;
 
			ip = b;
 
			
 
			while (b[c] != 0) {
 
				if (((char)b[c]) == '#') {
 
					player = &b[c+1];
 
					b[c] = 0;
 
					}
 
				if (((char)b[c]) == ':') {
 
					port = &b[c+1];
 
					b[c] = 0;
 
					}
 
				c++;
 
				}
 

	
 
			if (player!=NULL) _network_playas = atoi(player);
 
			if (port!=NULL) rport = atoi(port);
 

	
 
			NetworkCoreConnectGame(b, rport);
 
		}
 
	} break;
 

	
 
	case WE_TICK: {
 
		if (_network_game_count_last != _network_game_count)
 
			SetWindowDirty(w);
 
	} break;
 

	
 
	}
 
}
 

	
 
static const Widget _network_game_window_widgets[] = {
 
{   WWT_CLOSEBOX,   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_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_IMGBTN,   BGC,   250,   394,    42,    53, 0x0,													STR_NETWORK_ENTER_NAME_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},
 

	
0 comments (0 inline, 0 general)