mirror of
https://github.com/minetest/minetest.git
synced 2025-01-30 03:30:22 +01:00
Fix get_server_status() segfault due to uninitialized m_env
Fixes #7857
This commit is contained in:
parent
b78698240c
commit
81d55338fa
@ -2903,32 +2903,38 @@ std::wstring Server::getStatusString()
|
|||||||
// Uptime
|
// Uptime
|
||||||
os << L", uptime=" << m_uptime.get();
|
os << L", uptime=" << m_uptime.get();
|
||||||
// Max lag estimate
|
// Max lag estimate
|
||||||
os<<L", max_lag="<<m_env->getMaxLagEstimate();
|
os << L", max_lag=" << (m_env ? m_env->getMaxLagEstimate() : 0);
|
||||||
|
|
||||||
// Information about clients
|
// Information about clients
|
||||||
bool first = true;
|
bool first = true;
|
||||||
os << L", clients={";
|
os << L", clients={";
|
||||||
|
if (m_env) {
|
||||||
std::vector<session_t> clients = m_clients.getClientIDs();
|
std::vector<session_t> clients = m_clients.getClientIDs();
|
||||||
for (session_t client_id : clients) {
|
for (session_t client_id : clients) {
|
||||||
// Get player
|
|
||||||
RemotePlayer *player = m_env->getPlayer(client_id);
|
RemotePlayer *player = m_env->getPlayer(client_id);
|
||||||
|
|
||||||
// Get name of player
|
// Get name of player
|
||||||
std::wstring name = L"unknown";
|
std::wstring name = L"unknown";
|
||||||
if (player)
|
if (player)
|
||||||
name = narrow_to_wide(player->getName());
|
name = narrow_to_wide(player->getName());
|
||||||
|
|
||||||
// Add name to information string
|
// Add name to information string
|
||||||
if (!first)
|
if (!first)
|
||||||
os << L", ";
|
os << L", ";
|
||||||
else
|
else
|
||||||
first = false;
|
first = false;
|
||||||
|
|
||||||
os << name;
|
os << name;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
os << L"}";
|
os << L"}";
|
||||||
|
|
||||||
if (!((ServerMap*)(&m_env->getMap()))->isSavingEnabled())
|
if (m_env && !((ServerMap*)(&m_env->getMap()))->isSavingEnabled())
|
||||||
os << std::endl << L"# Server: " << " WARNING: Map saving is disabled.";
|
os << std::endl << L"# Server: " << " WARNING: Map saving is disabled.";
|
||||||
|
|
||||||
if (!g_settings->get("motd").empty())
|
if (!g_settings->get("motd").empty())
|
||||||
os << std::endl << L"# Server: " << narrow_to_wide(g_settings->get("motd"));
|
os << std::endl << L"# Server: " << narrow_to_wide(g_settings->get("motd"));
|
||||||
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user