fix the Fix get_server_status() segfault due to uninitialized m_env

* Related to [#7857](https://github.com/minetest/minetest/issues/7857)
  due to uninitialized m_env , so rest of the diff was not necesary
* ajust commit 13ad926546def65f01b5941ebb21493278189bea that was
  incorrectly backported, due t_session variable type from mt 5.X
This commit is contained in:
mckaygerhard 2023-01-06 12:56:50 -04:00
parent 3206cb8f0f
commit 68acdf12b4

View File

@ -3024,25 +3024,24 @@ std::wstring Server::getStatusString()
bool first = true;
os << L", clients={";
if (m_env) {
std::vector<session_t> clients = m_clients.getClientIDs();
for (session_t client_id : clients) {
RemotePlayer *player = m_env->getPlayer(client_id);
std::vector<u16> clients = m_clients.getClientIDs();
for (std::vector<u16>::iterator i = clients.begin(); i != clients.end(); ++i) {
// Get player
RemotePlayer *player = m_env->getPlayer(*i);
// Get name of player
std::wstring name = L"unknown";
if (player)
if (player != NULL)
name = narrow_to_wide(player->getName());
// Add name to information string
if (!first)
if(!first)
os << L", ";
else
first = false;
os << name;
}
}
}
os << L"}";
if (m_env && !((ServerMap*)(&m_env->getMap()))->isSavingEnabled())
if (m_env && !((ServerMap*)(&m_env->getMap()))->isSavingEnabled())
os << std::endl << L"# Server: " << " WARNING: Map saving is disabled.";
if (!g_settings->get("motd").empty())
os << std::endl << L"# Server: " << narrow_to_wide(g_settings->get("motd"));