clean up formatting
This commit is contained in:
+142
-142
@@ -46,154 +46,154 @@ void MemoryCardManager::Update( float fDelta )
|
|||||||
|
|
||||||
// check for disconnects
|
// check for disconnects
|
||||||
FOREACH( UsbStorageDevice, vOld, old )
|
FOREACH( UsbStorageDevice, vOld, old )
|
||||||
{
|
{
|
||||||
bool bFoundMatch = false;
|
bool bFoundMatch = false;
|
||||||
FOREACH( UsbStorageDevice, vNew, newd )
|
FOREACH( UsbStorageDevice, vNew, newd )
|
||||||
{
|
|
||||||
if( old->IdsMatch(*newd) )
|
|
||||||
{
|
{
|
||||||
bFoundMatch = true;
|
if( old->IdsMatch(*newd) )
|
||||||
break;
|
{
|
||||||
|
bFoundMatch = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
if( !bFoundMatch )
|
||||||
if( !bFoundMatch )
|
{
|
||||||
{
|
LOG->Trace( "Disconnected bus %d port %d device %d path %s", old->iBus, old->iPort, old->iLevel, old->sOsMountDir.c_str() );
|
||||||
LOG->Trace( "Disconnected bus %d port %d device %d path %s", old->iBus, old->iPort, old->iLevel, old->sOsMountDir.c_str() );
|
vDisconnects.push_back( *old );
|
||||||
vDisconnects.push_back( *old );
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// check for connects
|
// check for connects
|
||||||
FOREACH( UsbStorageDevice, vNew, newd )
|
FOREACH( UsbStorageDevice, vNew, newd )
|
||||||
{
|
{
|
||||||
bool bFoundMatch = false;
|
bool bFoundMatch = false;
|
||||||
FOREACH( UsbStorageDevice, vOld, old )
|
FOREACH( UsbStorageDevice, vOld, old )
|
||||||
{
|
{
|
||||||
if( old->IdsMatch(*newd) )
|
if( old->IdsMatch(*newd) )
|
||||||
{
|
{
|
||||||
bFoundMatch = true;
|
bFoundMatch = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !bFoundMatch )
|
if( !bFoundMatch )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Connected bus %d port %d device %d path %s", newd->iBus, newd->iPort, newd->iLevel, newd->sOsMountDir.c_str() );
|
LOG->Trace( "Connected bus %d port %d device %d path %s", newd->iBus, newd->iPort, newd->iLevel, newd->sOsMountDir.c_str() );
|
||||||
vDisconnects.push_back( *newd );
|
vDisconnects.push_back( *newd );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// unassign cards that were disconnected
|
// unassign cards that were disconnected
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
{
|
{
|
||||||
UsbStorageDevice &assigned_device = m_Device[p];
|
UsbStorageDevice &assigned_device = m_Device[p];
|
||||||
if( assigned_device.IsBlank() ) // not assigned a card
|
if( assigned_device.IsBlank() ) // not assigned a card
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FOREACH( UsbStorageDevice, vDisconnects, disconnect )
|
FOREACH( UsbStorageDevice, vDisconnects, disconnect )
|
||||||
{
|
{
|
||||||
if( disconnect->IdsMatch(assigned_device) )
|
if( disconnect->IdsMatch(assigned_device) )
|
||||||
{
|
{
|
||||||
m_pDriver->Unmount(&assigned_device, MEM_CARD_MOUNT_POINT[p]);
|
m_pDriver->Unmount(&assigned_device, MEM_CARD_MOUNT_POINT[p]);
|
||||||
|
|
||||||
assigned_device.MakeBlank();
|
assigned_device.MakeBlank();
|
||||||
m_soundDisconnect.Play();
|
m_soundDisconnect.Play();
|
||||||
|
|
||||||
if( PROFILEMAN->ProfileWasLoadedFromMemoryCard(p) )
|
if( PROFILEMAN->ProfileWasLoadedFromMemoryCard(p) )
|
||||||
PROFILEMAN->UnloadProfile( p );
|
PROFILEMAN->UnloadProfile( p );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the status of already-assigned cards. It may contain updated info
|
// Update the status of already-assigned cards. It may contain updated info
|
||||||
// like WriteTest results and a new sName.
|
// like WriteTest results and a new sName.
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
{
|
{
|
||||||
UsbStorageDevice &assigned_device = m_Device[p];
|
UsbStorageDevice &assigned_device = m_Device[p];
|
||||||
if( assigned_device.IsBlank() ) // no card assigned to this player
|
if( assigned_device.IsBlank() ) // no card assigned to this player
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FOREACH( UsbStorageDevice, m_vStorageDevices, d )
|
FOREACH( UsbStorageDevice, m_vStorageDevices, d )
|
||||||
{
|
{
|
||||||
if( d->IdsMatch(assigned_device) )
|
if( d->IdsMatch(assigned_device) )
|
||||||
{
|
{
|
||||||
// play write test error sound if write test failed since we last checked
|
// play write test error sound if write test failed since we last checked
|
||||||
if( assigned_device.bNeedsWriteTest && !d->bNeedsWriteTest && !d->bWriteTestSucceeded )
|
if( assigned_device.bNeedsWriteTest && !d->bNeedsWriteTest && !d->bWriteTestSucceeded )
|
||||||
m_soundError.Play();
|
m_soundError.Play();
|
||||||
assigned_device = *d;
|
assigned_device = *d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// make a list of unassigned
|
// make a list of unassigned
|
||||||
vector<UsbStorageDevice> vUnassignedDevices = m_vStorageDevices; // copy
|
vector<UsbStorageDevice> vUnassignedDevices = m_vStorageDevices; // copy
|
||||||
|
|
||||||
// remove cards that are already assigned
|
// remove cards that are already assigned
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
{
|
{
|
||||||
UsbStorageDevice &assigned_device = m_Device[p];
|
UsbStorageDevice &assigned_device = m_Device[p];
|
||||||
if( assigned_device.IsBlank() ) // no card assigned to this player
|
if( assigned_device.IsBlank() ) // no card assigned to this player
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
FOREACH( UsbStorageDevice, vUnassignedDevices, d )
|
FOREACH( UsbStorageDevice, vUnassignedDevices, d )
|
||||||
{
|
{
|
||||||
if( d->IdsMatch(assigned_device) )
|
if( d->IdsMatch(assigned_device) )
|
||||||
{
|
{
|
||||||
vUnassignedDevices.erase( d );
|
vUnassignedDevices.erase( d );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// try to assign each device to a player
|
// try to assign each device to a player
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
{
|
{
|
||||||
LOG->Trace( "Looking for a card for Player %d", p+1 );
|
LOG->Trace( "Looking for a card for Player %d", p+1 );
|
||||||
|
|
||||||
UsbStorageDevice &assigned_device = m_Device[p];
|
UsbStorageDevice &assigned_device = m_Device[p];
|
||||||
if( !assigned_device.IsBlank() ) // they already have an assigned card
|
if( !assigned_device.IsBlank() ) // they already have an assigned card
|
||||||
{
|
{
|
||||||
LOG->Trace( "Player %d already has a card: '%s'", p+1, assigned_device.sOsMountDir.c_str() );
|
LOG->Trace( "Player %d already has a card: '%s'", p+1, assigned_device.sOsMountDir.c_str() );
|
||||||
continue; // skip
|
continue; // skip
|
||||||
}
|
}
|
||||||
|
|
||||||
FOREACH( UsbStorageDevice, vUnassignedDevices, d )
|
FOREACH( UsbStorageDevice, vUnassignedDevices, d )
|
||||||
{
|
{
|
||||||
// search for card dir match
|
// search for card dir match
|
||||||
if( !PREFSMAN->m_sMemoryCardOsMountPoint[p].empty() &&
|
if( !PREFSMAN->m_sMemoryCardOsMountPoint[p].empty() &&
|
||||||
d->sOsMountDir.CompareNoCase(PREFSMAN->m_sMemoryCardOsMountPoint[p]) )
|
d->sOsMountDir.CompareNoCase(PREFSMAN->m_sMemoryCardOsMountPoint[p]) )
|
||||||
continue; // not a match
|
continue; // not a match
|
||||||
|
|
||||||
// search for USB bus match
|
// search for USB bus match
|
||||||
if( PREFSMAN->m_iMemoryCardUsbBus[p] != -1 &&
|
if( PREFSMAN->m_iMemoryCardUsbBus[p] != -1 &&
|
||||||
PREFSMAN->m_iMemoryCardUsbBus[p] != d->iBus )
|
PREFSMAN->m_iMemoryCardUsbBus[p] != d->iBus )
|
||||||
continue; // not a match
|
continue; // not a match
|
||||||
|
|
||||||
if( PREFSMAN->m_iMemoryCardUsbPort[p] != -1 &&
|
if( PREFSMAN->m_iMemoryCardUsbPort[p] != -1 &&
|
||||||
PREFSMAN->m_iMemoryCardUsbPort[p] != d->iPort )
|
PREFSMAN->m_iMemoryCardUsbPort[p] != d->iPort )
|
||||||
continue; // not a match
|
continue; // not a match
|
||||||
|
|
||||||
if( PREFSMAN->m_iMemoryCardUsbLevel[p] != -1 &&
|
if( PREFSMAN->m_iMemoryCardUsbLevel[p] != -1 &&
|
||||||
PREFSMAN->m_iMemoryCardUsbLevel[p] != d->iLevel )
|
PREFSMAN->m_iMemoryCardUsbLevel[p] != d->iLevel )
|
||||||
continue; // not a match
|
continue; // not a match
|
||||||
|
|
||||||
LOG->Trace( "device match: iScsiIndex: %d, iBus: %d, iLevel: %d, iPort: %d, sOsMountDir: %s",
|
LOG->Trace( "device match: iScsiIndex: %d, iBus: %d, iLevel: %d, iPort: %d, sOsMountDir: %s",
|
||||||
d->iScsiIndex, d->iBus, d->iLevel, d->iPort, d->sOsMountDir.c_str() );
|
d->iScsiIndex, d->iBus, d->iLevel, d->iPort, d->sOsMountDir.c_str() );
|
||||||
|
|
||||||
assigned_device = *d; // save a copy
|
assigned_device = *d; // save a copy
|
||||||
vUnassignedDevices.erase( d ); // remove the device so we don't match it for another player
|
vUnassignedDevices.erase( d ); // remove the device so we don't match it for another player
|
||||||
m_bTooLate[p] = GAMESTATE->m_bPlayersFinalized; // the device is too late if inserted when cards were locked
|
m_bTooLate[p] = GAMESTATE->m_bPlayersFinalized; // the device is too late if inserted when cards were locked
|
||||||
|
|
||||||
// play sound
|
// play sound
|
||||||
if( m_bTooLate[p] )
|
if( m_bTooLate[p] )
|
||||||
m_soundTooLate.Play();
|
m_soundTooLate.Play();
|
||||||
else if( !d->bNeedsWriteTest && !d->bWriteTestSucceeded )
|
else if( !d->bNeedsWriteTest && !d->bWriteTestSucceeded )
|
||||||
m_soundError.Play();
|
m_soundError.Play();
|
||||||
else
|
else
|
||||||
m_soundReady.Play();
|
m_soundReady.Play();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SCREENMAN->RefreshCreditsMessages();
|
SCREENMAN->RefreshCreditsMessages();
|
||||||
}
|
}
|
||||||
@@ -201,7 +201,7 @@ void MemoryCardManager::Update( float fDelta )
|
|||||||
|
|
||||||
MemoryCardState MemoryCardManager::GetCardState( PlayerNumber pn )
|
MemoryCardState MemoryCardManager::GetCardState( PlayerNumber pn )
|
||||||
{
|
{
|
||||||
UsbStorageDevice &d = m_Device[pn];
|
UsbStorageDevice &d = m_Device[pn];
|
||||||
if( d.IsBlank() )
|
if( d.IsBlank() )
|
||||||
return MEMORY_CARD_STATE_NO_CARD;
|
return MEMORY_CARD_STATE_NO_CARD;
|
||||||
else if( m_bTooLate[pn] )
|
else if( m_bTooLate[pn] )
|
||||||
@@ -248,7 +248,7 @@ void MemoryCardManager::FlushAndReset()
|
|||||||
{
|
{
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
{
|
{
|
||||||
UsbStorageDevice &d = m_Device[p];
|
UsbStorageDevice &d = m_Device[p];
|
||||||
if( d.IsBlank() ) // no card assigned
|
if( d.IsBlank() ) // no card assigned
|
||||||
continue; // skip
|
continue; // skip
|
||||||
if( (!d.bNeedsWriteTest && !d.bWriteTestSucceeded) || m_bTooLate[p] )
|
if( (!d.bNeedsWriteTest && !d.bWriteTestSucceeded) || m_bTooLate[p] )
|
||||||
@@ -264,7 +264,7 @@ bool MemoryCardManager::PathIsMemCard( CString sDir ) const
|
|||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
if( !sDir.Left(MEM_CARD_MOUNT_POINT[p].size()).CompareNoCase( MEM_CARD_MOUNT_POINT[p] ) )
|
if( !sDir.Left(MEM_CARD_MOUNT_POINT[p].size()).CompareNoCase( MEM_CARD_MOUNT_POINT[p] ) )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CString MemoryCardManager::GetName( PlayerNumber pn ) const
|
CString MemoryCardManager::GetName( PlayerNumber pn ) const
|
||||||
@@ -282,7 +282,7 @@ void MemoryCardManager::UnPauseMountingThread()
|
|||||||
m_pDriver->SetMountThreadState(
|
m_pDriver->SetMountThreadState(
|
||||||
m_bCardsLocked ?
|
m_bCardsLocked ?
|
||||||
MemoryCardDriver::detect_and_dont_mount :
|
MemoryCardDriver::detect_and_dont_mount :
|
||||||
MemoryCardDriver::detect_and_mount );
|
MemoryCardDriver::detect_and_mount );
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsAnyPlayerUsingMemoryCard()
|
bool IsAnyPlayerUsingMemoryCard()
|
||||||
@@ -290,33 +290,33 @@ bool IsAnyPlayerUsingMemoryCard()
|
|||||||
FOREACH_HumanPlayer( pn )
|
FOREACH_HumanPlayer( pn )
|
||||||
if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY )
|
if( MEMCARDMAN->GetCardState(pn) == MEMORY_CARD_STATE_READY )
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "LuaFunctions.h"
|
#include "LuaFunctions.h"
|
||||||
LuaFunction_NoArgs( IsAnyPlayerUsingMemoryCard, IsAnyPlayerUsingMemoryCard() )
|
LuaFunction_NoArgs( IsAnyPlayerUsingMemoryCard, IsAnyPlayerUsingMemoryCard() )
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (c) 2003-2004 Chris Danford
|
* (c) 2003-2004 Chris Danford
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
* copy of this software and associated documentation files (the
|
* copy of this software and associated documentation files (the
|
||||||
* "Software"), to deal in the Software without restriction, including
|
* "Software"), to deal in the Software without restriction, including
|
||||||
* without limitation the rights to use, copy, modify, merge, publish,
|
* without limitation the rights to use, copy, modify, merge, publish,
|
||||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||||
* whom the Software is furnished to do so, provided that the above
|
* whom the Software is furnished to do so, provided that the above
|
||||||
* copyright notice(s) and this permission notice appear in all copies of
|
* copyright notice(s) and this permission notice appear in all copies of
|
||||||
* the Software and that both the above copyright notice(s) and this
|
* the Software and that both the above copyright notice(s) and this
|
||||||
* permission notice appear in supporting documentation.
|
* permission notice appear in supporting documentation.
|
||||||
*
|
*
|
||||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
* PERFORMANCE OF THIS SOFTWARE.
|
* PERFORMANCE OF THIS SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user