Allow telling client the banned reason for the future

This commit is contained in:
Benau
2019-03-09 15:56:34 +08:00
parent 4c2fe75cb4
commit 809e15031c
2 changed files with 15 additions and 2 deletions

View File

@@ -836,9 +836,19 @@ void ClientLobby::connectionRefused(Event* event)
_("Connection refused: Server is busy."));
break;
case RR_BANNED:
STKHost::get()->setErrorMessage(
_("Connection refused: You are banned from the server."));
{
core::stringw msg =
_("Connection refused: You are banned from the server.");
core::stringw reason;
data.decodeStringW(&reason);
if (!reason.empty())
{
msg += L"\n";
msg += reason;
}
STKHost::get()->setErrorMessage(msg);
break;
}
case RR_INCORRECT_PASSWORD:
STKHost::get()->setErrorMessage(
_("Connection refused: Server password is incorrect."));

View File

@@ -2116,6 +2116,9 @@ void ServerLobby::connectionRequested(Event* event)
NetworkString *message = getNetworkString(2);
message->setSynchronous(true);
message->addUInt8(LE_CONNECTION_REFUSED).addUInt8(RR_BANNED);
// For future we can say the reason here
// and use encodeString instead
message->addUInt8(0);
peer->cleanPlayerProfiles();
peer->sendPacket(message, true/*reliable*/, false/*encrypted*/);
peer->reset();