Skip to content

Commit

Permalink
Send auto-kick messages as system messages
Browse files Browse the repository at this point in the history
  • Loading branch information
past-due committed Jun 27, 2024
1 parent be0e48a commit 8ce7354
Showing 1 changed file with 3 additions and 9 deletions.
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

0 comments on commit 8ce7354

Please sign in to comment.