From 6ccbbb4f6f4b1d2b95ee1649251c8f18714287e8 Mon Sep 17 00:00:00 2001 From: Dan Guzek Date: Mon, 1 Sep 2014 20:03:45 -0400 Subject: [PATCH] update InsertCoin and InsertCredit functions These should now agree with kyzentun's suggestions. --- src/GameState.cpp | 8 ++++++-- src/StepMania.cpp | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/GameState.cpp b/src/GameState.cpp index a316a2e3e0..b75952fe33 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -2592,8 +2592,12 @@ public: static int AddStageToPlayer( T* p, lua_State *L ) { p->AddStageToPlayer(Enum::Check(L, 1)); return 0; } static int InsertCoin( T* p, lua_State *L ) { - int numCoins = lua_tointeger(L, 1); - StepMania::InsertCoin(numCoins, false); + int numCoins = IArg(1); + if (GAMESTATE->m_iCoins + numCoins >= 0) + StepMania::InsertCoin(numCoins, false); + else + luaL_error( L, "Credits may not be negative." ); + } static int InsertCredit( T* p, lua_State *L ) { diff --git a/src/StepMania.cpp b/src/StepMania.cpp index 5271066b47..f0494f7dcc 100644 --- a/src/StepMania.cpp +++ b/src/StepMania.cpp @@ -1252,7 +1252,7 @@ void StepMania::InsertCoin( int iNum, bool bCountInBookkeeping ) LOG->Trace("%i coins inserted, %i needed to play", GAMESTATE->m_iCoins.Get(), PREFSMAN->m_iCoinsPerCredit.Get() ); - // If inserting coins, play the appropriate sound; if deducting coins, don't. + // If inserting coins, play an appropriate sound; if deducting coins, don't play anything. if (iNum > 0) { if( iNumCoinsOld != GAMESTATE->m_iCoins )