From 56cd5fb9613aa42d7f47a0c7f752e8d69bdc3564 Mon Sep 17 00:00:00 2001 From: Kyzentun Date: Wed, 12 Feb 2014 15:08:54 -0700 Subject: [PATCH] GetCreditsRequiredToPlayStyle didn't check the coin mode. --- src/GameCommand.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/GameCommand.cpp b/src/GameCommand.cpp index 4c589aaf8e..d2fc35a7bc 100644 --- a/src/GameCommand.cpp +++ b/src/GameCommand.cpp @@ -442,6 +442,15 @@ int GetNumCreditsPaid() int GetCreditsRequiredToPlayStyle( const Style *style ) { + // GameState::GetCoinsNeededToJoin returns 0 if the coin mode isn't + // CoinMode_Pay, which means the theme can't make sure that there are + // enough credits available. GameCommand::IsPlayable will cause a crash + // if there aren't enough credits. So we have to check the coin mode here + // and return 0 if the player doesn't have to pay. + if( GAMESTATE->GetCoinMode() != CoinMode_Pay ) + { + return 0; + } if( GAMESTATE->GetPremium() == Premium_2PlayersFor1Credit ) return 1;