implement coin settling
This commit is contained in:
@@ -1248,8 +1248,28 @@ CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature,
|
||||
return sFileName;
|
||||
}
|
||||
|
||||
void InsertCoin( int iNum )
|
||||
static Preference<float> g_iCoinSettleTime( "CoinSettleTime", 0.03f );
|
||||
|
||||
void InsertCoin( int iNum, const RageTimer *pTime )
|
||||
{
|
||||
if( pTime != NULL )
|
||||
{
|
||||
/* If a time is supplied for the button press, don't allow coin inserts
|
||||
* in very rapid succession, to be sure one insert signal isn't counted
|
||||
* as two coins. Use pTime, and never the current time, or we'll drop
|
||||
* coins if multiple coins are inserted during a screen load. */
|
||||
static RageTimer LastCoin( RageZeroTimer );
|
||||
|
||||
float fAgo = *pTime - LastCoin;
|
||||
if( !LastCoin.IsZero() && fAgo < g_iCoinSettleTime.Get() )
|
||||
{
|
||||
LOG->Trace("Ignored coin input (%f since last accepted)", fAgo );
|
||||
return;
|
||||
}
|
||||
|
||||
LastCoin = *pTime;
|
||||
}
|
||||
|
||||
GAMESTATE->m_iCoins += iNum;
|
||||
LOG->Trace("%i coins inserted, %i needed to play", GAMESTATE->m_iCoins, PREFSMAN->m_iCoinsPerCredit.Get() );
|
||||
BOOKKEEPER->CoinInserted();
|
||||
@@ -1294,7 +1314,7 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam
|
||||
LOG->Trace( "Ignored coin insertion (editing)" );
|
||||
break;
|
||||
}
|
||||
InsertCoin();
|
||||
InsertCoin( 1, &DeviceI.ts );
|
||||
return false; // Attract need to know because they go to TitleMenu on > 1 credit
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define STEPMANIA_H
|
||||
|
||||
class Game;
|
||||
class RageTimer;
|
||||
|
||||
#ifdef _XBOX
|
||||
void __cdecl main();
|
||||
@@ -19,7 +20,7 @@ void FocusChanged( bool bHasFocus );
|
||||
// If successful, return filename of screenshot in sDir, else return ""
|
||||
CString SaveScreenshot( CString sDir, bool bSaveCompressed, bool bMakeSignature, int iIndex = -1 );
|
||||
|
||||
void InsertCoin( int iNum = 1 );
|
||||
void InsertCoin( int iNum = 1, const RageTimer *pTime = NULL );
|
||||
void InsertCredit();
|
||||
|
||||
extern int g_argc;
|
||||
|
||||
Reference in New Issue
Block a user