MCPcopy Create free account
hub / github.com/dhewm/dhewm3 / ConnectToServer

Method ConnectToServer

neo/framework/async/AsyncClient.cpp:183–218  ·  view source on GitHub ↗

================== idAsyncClient::ConnectToServer ================== */

Source from the content-addressed store, hash-verified

181==================
182*/
183void idAsyncClient::ConnectToServer( const netadr_t adr ) {
184 // shutdown any current game. that includes network disconnect
185 session->Stop();
186
187 if ( !InitPort() ) {
188 return;
189 }
190
191 if ( cvarSystem->GetCVarBool( "net_serverDedicated" ) ) {
192 common->Printf( "Can't connect to a server as dedicated\n" );
193 return;
194 }
195
196 // trash any currently pending packets
197 ClearPendingPackets();
198
199 serverAddress = adr;
200
201 // clear the client state
202 Clear();
203
204 // get a pseudo random client id, but don't use the id which is reserved for connectionless packets
205 clientId = Sys_Milliseconds() & CONNECTIONLESS_MESSAGE_ID_MASK;
206
207 // calculate a checksum on some of the essential data used
208 clientDataChecksum = declManager->GetChecksum();
209
210 // start challenging the server
211 clientState = CS_CHALLENGING;
212
213 active = true;
214
215 guiNetMenu = uiManager->FindGui( "guis/netmenu.gui", true, false, true );
216 guiNetMenu->SetStateString( "status", va( common->GetLanguageDict()->GetString( "#str_06749" ), Sys_NetAdrToString( adr ) ) );
217 session->SetGUI( guiNetMenu, HandleGuiCommand );
218}
219
220/*
221==================

Callers 1

Connect_fMethod · 0.80

Calls 15

ClearFunction · 0.85
Sys_MillisecondsFunction · 0.85
vaFunction · 0.85
GetCVarBoolMethod · 0.80
GetChecksumMethod · 0.80
FindGuiMethod · 0.80
SetStateStringMethod · 0.80
SetGUIMethod · 0.80
Sys_NetAdrToStringFunction · 0.50
Sys_StringToNetAdrFunction · 0.50
StopMethod · 0.45
PrintfMethod · 0.45

Tested by

no test coverage detected