Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Send auto-kick messages as system messages #3932

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/multiplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,6 @@ void startMultiplayerGame();
#define LAG_CHECK_INTERVAL 1000
const std::chrono::milliseconds LagCheckInterval(LAG_CHECK_INTERVAL);

static void sendTextMessage(const char* msg)
{
auto message = InGameChatMessage(selectedPlayer, msg);
message.send();
}

void autoLagKickRoutine()
{
if (!bMultiPlayer || !NetPlay.bComms || !NetPlay.isHost)
Expand Down Expand Up @@ -221,20 +215,20 @@ void autoLagKickRoutine()
if (ingame.LagCounter[i] >= LagAutoKickSeconds) {
std::string msg = astringf("Auto-kicking player %" PRIu32 " (\"%s\") because of ping issues. (Timeout: %u seconds)", i, getPlayerName(i), LagAutoKickSeconds);
debug(LOG_INFO, "%s", msg.c_str());
sendTextMessage(msg.c_str());
sendInGameSystemMessage(msg.c_str());
wz_command_interface_output("WZEVENT: lag-kick: %u %s\n", i, NetPlay.players[i].IPtextAddress);
kickPlayer(i, "Your connection was too laggy.", ERROR_CONNECTION, false);
ingame.LagCounter[i] = 0;
}
else if (ingame.LagCounter[i] >= (LagAutoKickSeconds - 3)) {
std::string msg = astringf("Auto-kicking player %" PRIu32 " (\"%s\") in %u seconds.", i, getPlayerName(i), (LagAutoKickSeconds - ingame.LagCounter[i]));
debug(LOG_INFO, "%s", msg.c_str());
sendTextMessage(msg.c_str());
sendInGameSystemMessage(msg.c_str());
}
else if (ingame.LagCounter[i] % 15 == 0) { // every 15 seconds
std::string msg = astringf("Auto-kicking player %" PRIu32 " (\"%s\") in %u seconds.", i, getPlayerName(i), (LagAutoKickSeconds - ingame.LagCounter[i]));
debug(LOG_INFO, "%s", msg.c_str());
sendTextMessage(msg.c_str());
sendInGameSystemMessage(msg.c_str());
}
}
}
Expand Down
Loading