Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 2 additions & 0 deletions config.lua.dist
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ expFromPlayersLevelRange = 75
-- Connection Config
-- NOTE: maxPlayers set to 0 means no limit
-- NOTE: allowWalkthrough is only applicable to players
-- NOTE: statusCountMaxPlayersPerIp allows you to only count up to X players per IP in status response (0 = disabled)
ip = "127.0.0.1"
bindOnlyGlobalAddress = false
loginProtocolPort = 7171
Expand All @@ -31,6 +32,7 @@ allowClones = false
allowWalkthrough = true
serverName = "Forgotten"
statusTimeout = 5000
statusCountMaxPlayersPerIp = 0
replaceKickOnLogin = true
maxPacketsPerSecond = 25

Expand Down
1 change: 1 addition & 0 deletions src/configmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ bool ConfigManager::load()
integer[PROTECTION_LEVEL] = getGlobalNumber(L, "protectionLevel", 1);
integer[DEATH_LOSE_PERCENT] = getGlobalNumber(L, "deathLosePercent", -1);
integer[STATUSQUERY_TIMEOUT] = getGlobalNumber(L, "statusTimeout", 5000);
integer[STATUS_COUNT_MAX_PLAYERS_PER_IP] = getGlobalNumber(L, "statusCountMaxPlayersPerIp", 0);
integer[FRAG_TIME] = getGlobalNumber(L, "timeToDecreaseFrags", 24 * 60 * 60);
integer[WHITE_SKULL_TIME] = getGlobalNumber(L, "whiteSkullTime", 15 * 60);
integer[STAIRHOP_DELAY] = getGlobalNumber(L, "stairJumpExhaustion", 2000);
Expand Down
19 changes: 19 additions & 0 deletions src/protocolstatus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "configmanager.h"
#include "game.h"
#include "outputmessage.h"
#include <ranges>

extern ConfigManager g_config;
extern Game g_game;
Expand Down Expand Up @@ -101,6 +102,24 @@ void ProtocolStatus::sendStatusString()
owner.append_attribute("email") = g_config.getString(ConfigManager::OWNER_EMAIL).c_str();

pugi::xml_node players = tsqp.append_child("players");

uint32_t reportableOnlinePlayerCount = 0;
uint32_t maxPlayersPerIp = getNumber(ConfigManager::STATUS_COUNT_MAX_PLAYERS_PER_IP);
if (maxPlayersPerIp > 0) {
std::map<Connection::Address, uint32_t> playersPerIp;
for (const auto& it : g_game.getPlayers()) {
if (!it.second->getIP().is_unspecified()) {
++playersPerIp[it.second->getIP()];
}
}

for (auto& p : playersPerIp | std::views::values) {
Comment thread
DSpeichert marked this conversation as resolved.
Outdated
reportableOnlinePlayerCount += std::min(p, maxPlayersPerIp);
}
} else {
reportableOnlinePlayerCount = g_game.getPlayersOnline();
}

players.append_attribute("online") = std::to_string(g_game.getPlayersOnline()).c_str();
players.append_attribute("max") = std::to_string(g_config.getNumber(ConfigManager::MAX_PLAYERS)).c_str();
players.append_attribute("peak") = std::to_string(g_game.getPlayersRecord()).c_str();
Expand Down
Loading