aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSmallJoker <mk939@ymail.com>2019-08-20 19:25:46 +0200
committerSmallJoker <mk939@ymail.com>2019-08-20 19:42:21 +0200
commitb8131c3415ee8811ab98b537c080d203d8bee774 (patch)
tree5d35cc4e4bd6028f465763ece0e810958412f898 /src
parentfb6f1fdcbe3ee2321cc33eb00f2c6da86744d00a (diff)
downloadminetest-b8131c3415ee8811ab98b537c080d203d8bee774.tar.gz
minetest-b8131c3415ee8811ab98b537c080d203d8bee774.tar.bz2
minetest-b8131c3415ee8811ab98b537c080d203d8bee774.zip
remove_detached_inventory: Fix segfault during mod load
Diffstat (limited to 'src')
-rw-r--r--src/server.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/server.cpp b/src/server.cpp
index 82c83e47d..871612e60 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -2571,6 +2571,9 @@ void Server::sendDetachedInventory(const std::string &name, session_t peer_id)
player_it->second.empty()) {
// OK. Send to everyone
} else {
+ if (!m_env)
+ return; // Mods are not done loading
+
RemotePlayer *p = m_env->getPlayer(player_it->second.c_str());
if (!p)
return; // Player is offline
@@ -3366,7 +3369,9 @@ Inventory* Server::createDetachedInventory(const std::string &name, const std::s
Inventory *inv = new Inventory(m_itemdef);
sanity_check(inv);
m_detached_inventories[name] = inv;
- m_detached_inventories_player[name] = player;
+ if (!player.empty())
+ m_detached_inventories_player[name] = player;
+
//TODO find a better way to do this
sendDetachedInventory(name,PEER_ID_INEXISTENT);
return inv;
@@ -3381,6 +3386,9 @@ bool Server::removeDetachedInventory(const std::string &name)
delete inv_it->second;
m_detached_inventories.erase(inv_it);
+ if (!m_env) // Mods are not done loading
+ return true;
+
const auto &player_it = m_detached_inventories_player.find(name);
if (player_it != m_detached_inventories_player.end()) {
RemotePlayer *player = m_env->getPlayer(player_it->second.c_str());