Skip to content

Commit 6cf6368

Browse files
committed
Fix crash when opening map settings
In one instance a NULL-check for the `lua` pointer was missing as the call should have been through a function. Fixes #1701
1 parent 5d1edef commit 6cf6368

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

libs/s25main/desktops/dskGameLobby.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ dskGameLobby::dskGameLobby(ServerType serverType, std::shared_ptr<GameLobby> gam
235235
// Karte laden, um Kartenvorschau anzuzeigen
236236
if(!gameLobby_->isSavegame())
237237
{
238-
bool isMapPreviewEnabled = !lua || lua->IsMapPreviewEnabled();
238+
const bool isMapPreviewEnabled = !lua || lua->IsMapPreviewEnabled();
239239
if(!isMapPreviewEnabled)
240240
{
241241
AddTextDeepening(70, DrawPoint(560, 40), Extent(220, 220), TextureColor::Grey, _("No preview"), LargeFont,
@@ -685,13 +685,16 @@ void dskGameLobby::Msg_ButtonClick(const unsigned ctrl_id)
685685
else
686686
{
687687
std::unique_ptr<iwAddons> w;
688-
if(allowAddonChange && lua->IsChangeAllowed("addonsAll"))
688+
if(!allowAddonChange)
689+
w = std::make_unique<iwAddons>(gameLobby_->getSettings(), this, AddonChangeAllowed::None);
690+
else if(IsChangeAllowed("addonsAll"))
689691
w = std::make_unique<iwAddons>(gameLobby_->getSettings(), this, AddonChangeAllowed::All);
690-
else if(allowAddonChange)
692+
else
693+
{
694+
RTTR_Assert(lua); // Otherwise all changes would be allowed
691695
w = std::make_unique<iwAddons>(gameLobby_->getSettings(), this, AddonChangeAllowed::WhitelistOnly,
692696
lua->GetAllowedAddons());
693-
else
694-
w = std::make_unique<iwAddons>(gameLobby_->getSettings(), this, AddonChangeAllowed::None);
697+
}
695698
WINDOWMANAGER.Show(std::move(w));
696699
}
697700
}
@@ -960,7 +963,6 @@ void dskGameLobby::SetPlayerReady(unsigned char player, bool ready)
960963

961964
void dskGameLobby::CI_NewPlayer(const unsigned playerId)
962965
{
963-
// Spielername setzen
964966
UpdatePlayerRow(playerId);
965967

966968
if(lua && gameLobby_->isHost())
@@ -976,7 +978,6 @@ void dskGameLobby::CI_PlayerLeft(const unsigned playerId)
976978

977979
void dskGameLobby::CI_GameLoading(std::shared_ptr<Game> game)
978980
{
979-
// Desktop wechseln
980981
WINDOWMANAGER.Switch(std::make_unique<dskGameLoader>(std::move(game)));
981982
}
982983

0 commit comments

Comments
 (0)