MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / joinInternetGame

Function joinInternetGame

src/clientbase/playing.cpp:263–366  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261
262
263void joinInternetGame(const struct in_addr* inAddress) {
264 // get server address
265 Address serverAddress(*inAddress);
266 if (serverAddress.isAny()) {
267 showError("Server not found");
268 return;
269 }
270
271 // check for a local server block
272 serverAccessList.reload();
273 std::vector<std::string> nameAndIp;
274 nameAndIp.push_back(startupInfo.serverName);
275 nameAndIp.push_back(serverAddress.getDotNotation());
276 if (!serverAccessList.authorized(nameAndIp)) {
277 showError("Server Access Denied Locally");
278 std::string msg = ColorStrings[WhiteColor];
279 msg += "NOTE: ";
280 msg += ColorStrings[GreyColor];
281 msg += "server access is controlled by ";
282 msg += ColorStrings[YellowColor];
283 msg += serverAccessList.getFileName();
284 addMessage(NULL, msg);
285 return;
286 }
287 // open server
288 ServerLink* _serverLink =
289 new ServerLink(startupInfo.serverName,
290 serverAddress,
291 startupInfo.serverPort);
292
293 serverLink = _serverLink;
294
295 serverLink->sendVarRequest();
296
297 // assume everything's okay for now
298 serverDied = false;
299 serverError = false;
300
301 if (!serverLink) {
302 showError("Memory error");
303 return;
304 }
305
306 // check server
307 if (serverLink->getState() != ServerLink::Okay) {
308 switch (serverLink->getState()) {
309 case ServerLink::BadVersion: {
310 std::string msg = "Incompatible server version ";
311 msg += serverLink->getVersion();
312 showError(msg.c_str());
313 break;
314 }
315 case ServerLink::Refused: {
316 // you got banned
317 const std::string& rejmsg = serverLink->getRejectionMessage();
318
319 // add to the HUD
320 std::string msg = ColorStrings[RedColor];

Callers 2

playingLoopFunction · 0.85
playingLoopFunction · 0.85

Calls 15

addMessageFunction · 0.85
sendFlagNegotiationFunction · 0.85
isAnyMethod · 0.80
getDotNotationMethod · 0.80
authorizedMethod · 0.80
sendVarRequestMethod · 0.80
getVersionMethod · 0.80
c_strMethod · 0.80
sendUDPlinkRequestMethod · 0.80
showErrorFunction · 0.50
formatFunction · 0.50
reloadMethod · 0.45

Tested by

no test coverage detected