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

Function handleJoinServer

src/clientbase/playing.cpp:1077–1146  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1075
1076
1077void handleJoinServer(void* msg) {
1078 // FIXME: MsgJoinServer notes ...
1079 // - fix whatever is broken
1080 // - add notifications
1081 // - add an AutoJoinAccess.txt file to decided
1082 // if confirmation queries or required
1083
1084 std::string addr;
1085 int32_t port;
1086 int16_t team;
1087 std::string referrer;
1088 std::string message;
1089
1090 msg = nboUnpackStdString(msg, addr);
1091 msg = nboUnpackInt32(msg, port);
1092 msg = nboUnpackInt16(msg, team);
1093 msg = nboUnpackStdString(msg, referrer);
1094 msg = nboUnpackStdString(msg, message);
1095
1096 if (addr.empty()) {
1097 return;
1098 }
1099 if ((port < 0) || (port > 65535)) {
1100 return;
1101 }
1102
1103 if (!BZDB.isTrue("autoJoin")) {
1104 addMessage(NULL,
1105 TextUtils::format("ignored autoJoin to %s:%i", addr.c_str(), port)
1106 );
1107 return;
1108 }
1109
1110 autoJoinAccessList.reload();
1111 std::vector<std::string> nameAndIp;
1112 nameAndIp.push_back(addr);
1113//FIXME nameAndIp.push_back(serverAddress.getDotNotation());
1114 if (!autoJoinAccessList.authorized(nameAndIp)) {
1115 showError("Auto Join Denied Locally");
1116 std::string warn = ColorStrings[WhiteColor];
1117 warn += "NOTE: ";
1118 warn += ColorStrings[GreyColor];
1119 warn += "auto joining is controlled by ";
1120 warn += ColorStrings[YellowColor];
1121 warn += autoJoinAccessList.getFileName();
1122 addMessage(NULL, warn);
1123 return;
1124 }
1125
1126 StartupInfo& info = startupInfo;
1127
1128 strncpy(info.serverName, addr.c_str(), ServerNameLen - 1);
1129 info.serverName[ServerNameLen - 1] = 0;
1130
1131 strncpy(info.referrer, referrer.c_str(), ReferrerLen - 1);
1132 info.referrer[ReferrerLen - 1] = 0;
1133
1134 info.serverPort = port;

Callers 1

handleServerMessageFunction · 0.85

Calls 15

nboUnpackStdStringFunction · 0.85
nboUnpackInt32Function · 0.85
nboUnpackInt16Function · 0.85
addMessageFunction · 0.85
debugfFunction · 0.85
isTrueMethod · 0.80
c_strMethod · 0.80
authorizedMethod · 0.80
formatFunction · 0.50
showErrorFunction · 0.50
joinGameFunction · 0.50
emptyMethod · 0.45

Tested by

no test coverage detected