From c5c69ec1421c3447a89651e707c564e24e16efe0 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 21 Dec 2005 03:49:34 +0000 Subject: [PATCH] simplify --- stepmania/src/ScreenServiceAction.cpp | 37 ++++++++++++++------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/stepmania/src/ScreenServiceAction.cpp b/stepmania/src/ScreenServiceAction.cpp index 3d9653362a..f2226ba444 100644 --- a/stepmania/src/ScreenServiceAction.cpp +++ b/stepmania/src/ScreenServiceAction.cpp @@ -258,9 +258,8 @@ static CString TransferStatsMemoryCardToMachine() return "Stats transferred to machine."; } -static CString CopyEditsMachineToMemoryCard() +static PlayerNumber GetFirstReadyMemoryCard() { - bool bTriedToCopy = false; FOREACH_PlayerNumber( pn ) { if( MEMCARDMAN->GetCardState(pn) != MemoryCardState_Ready ) @@ -268,8 +267,21 @@ static CString CopyEditsMachineToMemoryCard() if( !MEMCARDMAN->IsMounted(pn) ) MEMCARDMAN->MountCard(pn); + return pn; + } - bTriedToCopy = true; + return PLAYER_INVALID; +} + +static CString CopyEditsMachineToMemoryCard() +{ + PlayerNumber pn = GetFirstReadyMemoryCard(); + if( pn == PLAYER_INVALID ) + return "Edits not copied - No memory cards ready."; + + { + if( !MEMCARDMAN->IsMounted(pn) ) + MEMCARDMAN->MountCard(pn); int iNumAttempted = 0; int iNumSuccessful = 0; @@ -313,12 +325,8 @@ static CString CopyEditsMachineToMemoryCard() // TODO: Make string themable return ssprintf("Copied to P%d card:\n%d/%d copies OK (%d overwritten).",pn+1,iNumSuccessful,iNumAttempted,iNumOverwritten); - break; } - if( !bTriedToCopy ) - return "Edits not copied - No memory cards ready."; - MEMCARDMAN->FlushAndReset(); return "Edits copied to machine."; @@ -326,17 +334,14 @@ static CString CopyEditsMachineToMemoryCard() static CString CopyEditsMemoryCardToMachine() { - bool bTriedToCopy = false; - FOREACH_PlayerNumber( pn ) - { - if( MEMCARDMAN->GetCardState(pn) != MemoryCardState_Ready ) - continue; // skip + PlayerNumber pn = GetFirstReadyMemoryCard(); + if( pn == PLAYER_INVALID ) + return "Edits not copied - No memory cards ready."; + { if( !MEMCARDMAN->IsMounted(pn) ) MEMCARDMAN->MountCard(pn); - bTriedToCopy = true; - int iNumAttempted = 0; int iNumSuccessful = 0; int iNumOverwritten = 0; @@ -383,12 +388,8 @@ static CString CopyEditsMemoryCardToMachine() // TODO: Make themeable return ssprintf("Copied from P%d card:\n%d/%d copies OK (%d overwritten).",pn+1,iNumSuccessful,iNumAttempted,iNumOverwritten); - break; } - if( !bTriedToCopy ) - return "Edits not copied - No memory cards ready."; - MEMCARDMAN->FlushAndReset(); return "Edits copied to memory card.";