MCPcopy Create free account
hub / github.com/assaultcube/AC / connectserv_

Function connectserv_

source/src/client.cpp:56–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56void connectserv_(const char *servername, int serverport = 0, const char *password = NULL, int role = CR_DEFAULT)
57{
58 if(serverport <= 0) serverport = CUBE_DEFAULT_SERVER_PORT;
59 if(watchingdemo) enddemoplayback();
60
61 if(connpeer)
62 {
63 conoutf("aborting connection attempt");
64 abortconnect();
65 }
66 connectrole = role;
67 copystring(clientpassword, password ? password : "");
68 ENetAddress address;
69 address.port = serverport;
70
71 if(servername)
72 {
73 addserver(servername, serverport, 0);
74 conoutf("\f2attempting to %sconnect to \f5%s\f4:%d\f2", role==CR_DEFAULT?"":"\f8admin\f2", servername, serverport);
75 if(!resolverwait(servername, &address))
76 {
77 conoutf("\f2could \f3not resolve\f2 server \f5%s\f2", servername);
78 clientpassword[0] = '\0';
79 connectrole = CR_DEFAULT;
80 return;
81 }
82 }
83 else
84 {
85 conoutf("\f2attempting to connect over \f1LAN\f2");
86 address.host = ENET_HOST_BROADCAST;
87 }
88
89 if(!clienthost)
90 clienthost = enet_host_create(NULL, 2, 3, 0, 0);
91
92 if(clienthost)
93 {
94 connpeer = enet_host_connect(clienthost, &address, 3, 0);
95 enet_host_flush(clienthost);
96 connmillis = totalmillis;
97 connattempts = 0;
98 if(!m_mp(gamemode)) gamemode = GMODE_TEAMDEATHMATCH;
99 }
100 else
101 {
102 conoutf("\f2could \f3not connect\f2 to server");
103 clientpassword[0] = '\0';
104 connectrole = CR_DEFAULT;
105 }
106}
107
108void connectserv(char *servername, int *serverport, char *password)
109{

Callers 6

connectservFunction · 0.85
connectadminFunction · 0.85
lanconnectFunction · 0.85
modconnectservFunction · 0.85
modconnectadminFunction · 0.85
modlanconnectFunction · 0.85

Calls 9

enddemoplaybackFunction · 0.85
abortconnectFunction · 0.85
copystringFunction · 0.85
addserverFunction · 0.85
enet_host_createFunction · 0.85
enet_host_connectFunction · 0.85
enet_host_flushFunction · 0.85
conoutfFunction · 0.70
resolverwaitFunction · 0.70

Tested by

no test coverage detected