コード例 #1
0
NetGameClient::NetGameClient()
: server_id(0), join_req_time(0)
{
	Print("Constructing NetGameClient\n");

	NetHost me;
	Text    server_name;
	WORD    port = 11101;

	NetClientConfig* ncc = NetClientConfig::GetInstance();
	if (ncc) {
		NetServerInfo* info = ncc->GetSelectedServer();

		if (info) {
			server_name = info->hostname;
			port        = info->gameport;
		}
	}

	if (server_name.length() && port > 0) {
		Print("  '%s' is a client of '%s'\n", me.Name(), server_name);
		link = new(__FILE__,__LINE__) NetLink;
		server_id = link->AddPeer(NetAddr(server_name, port));
		SendJoinRequest();
	}
	else if (port == 0) {
		Print("  '%s' invalid game port number %d\n", me.Name(), port);
	}
	else {
		Print("  '%s' is a client without a server\n", me.Name());
	}
}
コード例 #2
0
NetLobbyClient::NetLobbyClient()
: NetLobby(false), server_id(0), host(false), exit_code(0), temporary(false)
{
    NetHost me;
    Text    server_name;
    WORD    port = 11101;

    ping_req_time = 0;
    chat_req_time = 0;
    user_req_time = 0;
    camp_req_time = 0;
    unit_req_time = 0;
    mods_req_time = 0;

    NetClientConfig* ncc = NetClientConfig::GetInstance();
    if (ncc) {
        NetServerInfo* info = ncc->GetSelectedServer();

        if (info) {
            server_name = info->hostname;
            addr        = info->addr;
            port        = info->port;
            gamepass    = info->password;
        }
    }

    if (server_name.length() && port > 0) {
        Print("  '%s' is a client of '%s'\n", me.Name(), server_name.data());
        link = new(__FILE__,__LINE__) NetLink;
        server_id = link->AddPeer(NetAddr(server_name, port));
    }
    else if (port == 0) {
        Print("  '%s' invalid lobby port number %d\n", me.Name(), port);
    }
    else {
        Print("  '%s' is a client without a server\n", me.Name());
    }
}