diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-14 21:07:57 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-02-14 21:08:51 +0100 |
commit | 2779eb792a04667958feab9b433c1c82392c0bc3 (patch) | |
tree | 18566c7aad65a4ac5010da10616d5943ea33a120 /src | |
parent | 92a6fd04d44bcd405641d7297a0167e2d5aba26f (diff) | |
download | mana-2779eb792a04667958feab9b433c1c82392c0bc3.tar.gz mana-2779eb792a04667958feab9b433c1c82392c0bc3.tar.bz2 mana-2779eb792a04667958feab9b433c1c82392c0bc3.tar.xz mana-2779eb792a04667958feab9b433c1c82392c0bc3.zip |
Avoid crash when receiving SMSG_MAP_MASK without Game instance
It happened to me a few times. Needs checking whether we could instead
make sure we always have a Game instance when receiving this message,
because this way a map mask might get ignored.
Or maybe the map mask just needs to be stored elsewhere.
Diffstat (limited to 'src')
-rw-r--r-- | src/net/tmwa/playerhandler.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/net/tmwa/playerhandler.cpp b/src/net/tmwa/playerhandler.cpp index f704576e..9c1a7135 100644 --- a/src/net/tmwa/playerhandler.cpp +++ b/src/net/tmwa/playerhandler.cpp @@ -516,8 +516,9 @@ void PlayerHandler::handleMessage(MessageIn &msg) { const int mask = msg.readInt32(); msg.readInt32(); // unused - if (Map *map = Game::instance()->getCurrentMap()) - map->setMask(mask); + if (auto game = Game::instance()) + if (Map *map = game->getCurrentMap()) + map->setMask(mask); } break; } |