From 2779eb792a04667958feab9b433c1c82392c0bc3 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Wed, 14 Feb 2024 21:07:57 +0100 Subject: 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. --- src/net/tmwa/playerhandler.cpp | 5 +++-- 1 file 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; } -- cgit v1.2.3-70-g09d2