update docs, cleanup memcardman comments and such
This commit is contained in:
@@ -9,6 +9,12 @@ Not all changes are documented, for various reasons.
|
|||||||
supported but exist anyways.)
|
supported but exist anyways.)
|
||||||
_____________________________________________________________________________
|
_____________________________________________________________________________
|
||||||
|
|
||||||
|
20100311
|
||||||
|
--------
|
||||||
|
* [Player.cpp] Don't add checkpoints to the combo if Autoplay is on.
|
||||||
|
* Re-add the ability to reload a theme's Lua scripts, this time using Ctrl+F2.
|
||||||
|
* Convert GrooveRadar base into an AutoActor. (Now it can use a Lua BGAnim.)
|
||||||
|
|
||||||
20100309
|
20100309
|
||||||
--------
|
--------
|
||||||
* [ScreenSelectMaster] Add GetSelectionIndex(pn) Lua binding. (You'll have to
|
* [ScreenSelectMaster] Add GetSelectionIndex(pn) Lua binding. (You'll have to
|
||||||
|
|||||||
+40
-3
@@ -8,8 +8,7 @@ That being said, the sm-ssc code style guidelines are as follows:
|
|||||||
1) Follow the current coding conventions set forth in the source code.
|
1) Follow the current coding conventions set forth in the source code.
|
||||||
This means use tabs. AJ prefers tabs have a width of 4. Visual Studio and web
|
This means use tabs. AJ prefers tabs have a width of 4. Visual Studio and web
|
||||||
browsers assume tabs to be 8 by default. :/
|
browsers assume tabs to be 8 by default. :/
|
||||||
Use of the tab character means you can define however the fuck wide you want it
|
Use of the tab character means you can define however wide you want it to be.
|
||||||
to be.
|
|
||||||
|
|
||||||
Use of the space character is allowed for complex alignment. There are many
|
Use of the space character is allowed for complex alignment. There are many
|
||||||
examples of this in the code.
|
examples of this in the code.
|
||||||
@@ -44,4 +43,42 @@ and Function in [], like so:
|
|||||||
LOG->Info( "[NetworkSyncManager::Listen] Initializing socket..." );
|
LOG->Info( "[NetworkSyncManager::Listen] Initializing socket..." );
|
||||||
You may not always need to do this, but it helps for clarity and sanity.
|
You may not always need to do this, but it helps for clarity and sanity.
|
||||||
|
|
||||||
4) There are no other rules (yet).
|
4) Comment style. (This is a preferred suggestion. You may choose to do whatever
|
||||||
|
you like, but it is recommended to follow this style when submitting code for
|
||||||
|
inclusion.)
|
||||||
|
// is preferred for one-liners
|
||||||
|
// and also blocks of text where the comment isn't too long.
|
||||||
|
// sometimes you'll find // comments longer than this thrown in there by AJ
|
||||||
|
/* instead of doing this.
|
||||||
|
* when making a new line in a long form comment, start like this line.
|
||||||
|
* and put the end where it fits. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* doing this (first line blank) is discouraged, but is allowed in certain places.
|
||||||
|
* Copyright notices use this style and should remain doing so; don't clean it up
|
||||||
|
* in that instance. All new copyright notices should follow this style as well,
|
||||||
|
* for consistency's sake.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* use of long comments for one line is VERY discouraged */
|
||||||
|
// usually, it will will get cleaned up into this style, but there are exceptions:
|
||||||
|
|
||||||
|
// exception #1: function arguments
|
||||||
|
void SomeFunction(size_t /*ACTUAL DATA TYPE*/)
|
||||||
|
// where you need to have it be /* */ or else it'll mess up.
|
||||||
|
|
||||||
|
// exception #2: #defines
|
||||||
|
#define /* you must use long form in defines, */ \
|
||||||
|
// otherwise it won't parse the newline correctly (this will cause an error) \
|
||||||
|
|
||||||
|
// exception #3: .h files
|
||||||
|
/* ScreenTypicalExample - this always shows up like this. It usually is always one line, even when it extends past column 80. This is acceptible; Most people don't write novels here like I just did. */
|
||||||
|
|
||||||
|
// on comment length:
|
||||||
|
/* typically total 80 characters is the preferred width per line, like this one.
|
||||||
|
* Sometimes, you can get away with sentences where a word or phrase hangs over the edge,
|
||||||
|
* especially if you can guess the context without needing to scroll.
|
||||||
|
* Pre-existing comments are usually trimmed to meet the 80-column width if they
|
||||||
|
* go way overboard. */
|
||||||
|
|
||||||
|
5) There are no other rules (yet).
|
||||||
+39
-38
@@ -54,19 +54,19 @@ Preference<RString> MemoryCardManager::m_sEditorMemoryCardOsMountPoint( "Editor
|
|||||||
|
|
||||||
const RString MEM_CARD_MOUNT_POINT[NUM_PLAYERS] =
|
const RString MEM_CARD_MOUNT_POINT[NUM_PLAYERS] =
|
||||||
{
|
{
|
||||||
/* @ is important; see RageFileManager LoadedDriver::GetPath */
|
// @ is important; see RageFileManager LoadedDriver::GetPath
|
||||||
"/@mc1/",
|
"/@mc1/",
|
||||||
"/@mc2/",
|
"/@mc2/",
|
||||||
};
|
};
|
||||||
|
|
||||||
static const RString MEM_CARD_MOUNT_POINT_INTERNAL[NUM_PLAYERS] =
|
static const RString MEM_CARD_MOUNT_POINT_INTERNAL[NUM_PLAYERS] =
|
||||||
{
|
{
|
||||||
/* @ is important; see RageFileManager LoadedDriver::GetPath */
|
// @ is important; see RageFileManager LoadedDriver::GetPath
|
||||||
"/@mc1int/",
|
"/@mc1int/",
|
||||||
"/@mc2int/",
|
"/@mc2int/",
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Only access the memory card driver in a timeout-safe thread. */
|
// Only access the memory card driver in a timeout-safe thread.
|
||||||
class ThreadedMemoryCardWorker: public RageWorkerThread
|
class ThreadedMemoryCardWorker: public RageWorkerThread
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -81,11 +81,11 @@ public:
|
|||||||
};
|
};
|
||||||
void SetMountThreadState( MountThreadState mts );
|
void SetMountThreadState( MountThreadState mts );
|
||||||
|
|
||||||
/* These functions may time out. */
|
// These functions may time out.
|
||||||
bool Mount( const UsbStorageDevice *pDevice );
|
bool Mount( const UsbStorageDevice *pDevice );
|
||||||
bool Unmount( const UsbStorageDevice *pDevice );
|
bool Unmount( const UsbStorageDevice *pDevice );
|
||||||
|
|
||||||
/* This function will not time out. */
|
// This function will not time out.
|
||||||
bool StorageDevicesChanged( vector<UsbStorageDevice> &aOut );
|
bool StorageDevicesChanged( vector<UsbStorageDevice> &aOut );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -163,10 +163,10 @@ void ThreadedMemoryCardWorker::SetMountThreadState( MountThreadState mts )
|
|||||||
{
|
{
|
||||||
/* If "pause", stop calling updates in the heartbeat. In principle, we should
|
/* If "pause", stop calling updates in the heartbeat. In principle, we should
|
||||||
* also not return from this function until the current heartbeat, if running,
|
* also not return from this function until the current heartbeat, if running,
|
||||||
* finishes. However, since we can't guarantee that it'll exit within the timeout,
|
* finishes. However, since we can't guarantee that it'll exit within the
|
||||||
* there's no point: we have to return when we time out, and in that case the
|
* timeout, there's no point: we have to return when we time out, and in that
|
||||||
* heartbeat will still be running. I don't know if the reasons for pausing
|
* case the heartbeat will still be running. I don't know if the reasons for
|
||||||
* really need us to wait, so don't. */
|
* pausing really need us to wait, so don't. */
|
||||||
m_MountThreadState = mts;
|
m_MountThreadState = mts;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -209,7 +209,7 @@ void ThreadedMemoryCardWorker::DoHeartbeat()
|
|||||||
if( m_MountThreadState == paused )
|
if( m_MountThreadState == paused )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* If true, detect and mount. If false, only detect. */
|
// If true, detect and mount. If false, only detect.
|
||||||
bool bMount = (m_MountThreadState == detect_and_mount);
|
bool bMount = (m_MountThreadState == detect_and_mount);
|
||||||
|
|
||||||
vector<UsbStorageDevice> aStorageDevices;
|
vector<UsbStorageDevice> aStorageDevices;
|
||||||
@@ -227,7 +227,7 @@ bool ThreadedMemoryCardWorker::Mount( const UsbStorageDevice *pDevice )
|
|||||||
{
|
{
|
||||||
ASSERT( TimeoutEnabled() );
|
ASSERT( TimeoutEnabled() );
|
||||||
|
|
||||||
/* If we're currently in a timed-out state, fail. */
|
// If we're currently in a timed-out state, fail.
|
||||||
if( IsTimedOut() )
|
if( IsTimedOut() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -242,7 +242,7 @@ bool ThreadedMemoryCardWorker::Unmount( const UsbStorageDevice *pDevice )
|
|||||||
{
|
{
|
||||||
ASSERT( TimeoutEnabled() );
|
ASSERT( TimeoutEnabled() );
|
||||||
|
|
||||||
/* If we're currently in a timed-out state, fail. */
|
// If we're currently in a timed-out state, fail.
|
||||||
if( IsTimedOut() )
|
if( IsTimedOut() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -321,7 +321,7 @@ void MemoryCardManager::Update()
|
|||||||
MESSAGEMAN->Broadcast( Message_StorageDevicesChanged );
|
MESSAGEMAN->Broadcast( Message_StorageDevicesChanged );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Assign cards from m_vStorageDevices to m_Device. */
|
// Assign cards from m_vStorageDevices to m_Device.
|
||||||
void MemoryCardManager::UpdateAssignments()
|
void MemoryCardManager::UpdateAssignments()
|
||||||
{
|
{
|
||||||
if( !g_bMemoryCardProfiles.Get() )
|
if( !g_bMemoryCardProfiles.Get() )
|
||||||
@@ -354,18 +354,18 @@ void MemoryCardManager::UpdateAssignments()
|
|||||||
UsbStorageDevice &assigned_device = m_Device[p];
|
UsbStorageDevice &assigned_device = m_Device[p];
|
||||||
if( !assigned_device.IsBlank() )
|
if( !assigned_device.IsBlank() )
|
||||||
{
|
{
|
||||||
/* The player has a card assigned. If it's been removed, clear it. */
|
// The player has a card assigned. If it's been removed, clear it.
|
||||||
vector<UsbStorageDevice>::iterator it = find( m_vStorageDevices.begin(), m_vStorageDevices.end(), assigned_device );
|
vector<UsbStorageDevice>::iterator it = find( m_vStorageDevices.begin(), m_vStorageDevices.end(), assigned_device );
|
||||||
if( it != m_vStorageDevices.end() )
|
if( it != m_vStorageDevices.end() )
|
||||||
{
|
{
|
||||||
/* The player has a card, and it's still plugged in. Update any changed
|
/* The player has a card, and it's still plugged in. Update any
|
||||||
* state, such as m_State. */
|
* changed state, such as m_State. */
|
||||||
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() );
|
||||||
assigned_device = *it;
|
assigned_device = *it;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The assigned card has been removed; clear it and re-search. */
|
// The assigned card has been removed; clear it and re-search.
|
||||||
LOG->Trace( "Player %i: disconnected bus %d port %d device %d path %s",
|
LOG->Trace( "Player %i: disconnected bus %d port %d device %d path %s",
|
||||||
p+1, assigned_device.iBus, assigned_device.iPort, assigned_device.iLevel, assigned_device.sOsMountDir.c_str() );
|
p+1, assigned_device.iBus, assigned_device.iPort, assigned_device.iLevel, assigned_device.sOsMountDir.c_str() );
|
||||||
assigned_device.MakeBlank();
|
assigned_device.MakeBlank();
|
||||||
@@ -406,7 +406,7 @@ void MemoryCardManager::UpdateAssignments()
|
|||||||
|
|
||||||
void MemoryCardManager::CheckStateChanges()
|
void MemoryCardManager::CheckStateChanges()
|
||||||
{
|
{
|
||||||
/* Deal with assignment changes. */
|
// Deal with assignment changes.
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
{
|
{
|
||||||
const UsbStorageDevice &new_device = m_Device[p];
|
const UsbStorageDevice &new_device = m_Device[p];
|
||||||
@@ -427,20 +427,21 @@ void MemoryCardManager::CheckStateChanges()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* We had a card inserted when we finalized. */
|
// We had a card inserted when we finalized.
|
||||||
if( new_device.m_State == UsbStorageDevice::STATE_NONE )
|
if( new_device.m_State == UsbStorageDevice::STATE_NONE )
|
||||||
state = MemoryCardState_Removed;
|
state = MemoryCardState_Removed;
|
||||||
if( new_device.m_State == UsbStorageDevice::STATE_READY )
|
if( new_device.m_State == UsbStorageDevice::STATE_READY )
|
||||||
{
|
{
|
||||||
if( m_FinalDevice[p].sSerial != new_device.sSerial )
|
if( m_FinalDevice[p].sSerial != new_device.sSerial )
|
||||||
{
|
{
|
||||||
/* A different card is inserted than we had when we finalized. */
|
// A different card is inserted than we had when we finalized.
|
||||||
state = MemoryCardState_Error;
|
state = MemoryCardState_Error;
|
||||||
sError = "Changed";
|
sError = "Changed";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise, the card is checking or has an error. Use the regular logic. */
|
// Otherwise, the card is checking or has an error.
|
||||||
|
// Use the regular logic.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -511,7 +512,7 @@ void MemoryCardManager::WaitForCheckingToComplete()
|
|||||||
bool bLogged = false;
|
bool bLogged = false;
|
||||||
while( !g_pWorker->IsTimedOut() )
|
while( !g_pWorker->IsTimedOut() )
|
||||||
{
|
{
|
||||||
/* Check for changes. */
|
// Check for changes.
|
||||||
Update();
|
Update();
|
||||||
|
|
||||||
bool bEitherPlayerIsChecking = false;
|
bool bEitherPlayerIsChecking = false;
|
||||||
@@ -521,8 +522,8 @@ void MemoryCardManager::WaitForCheckingToComplete()
|
|||||||
if( !bEitherPlayerIsChecking )
|
if( !bEitherPlayerIsChecking )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
/* Only if we need to, wait for something to happen. If we time out waiting for
|
/* Only if we need to, wait for something to happen. If we time out
|
||||||
* a heartbeat, give up. */
|
* waiting for a heartbeat, give up. */
|
||||||
if( !bLogged )
|
if( !bLogged )
|
||||||
{
|
{
|
||||||
bLogged = true;
|
bLogged = true;
|
||||||
@@ -550,7 +551,7 @@ void MemoryCardManager::LockCard( PlayerNumber pn )
|
|||||||
if( m_bCardLocked[pn] )
|
if( m_bCardLocked[pn] )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Set the final state. */
|
// Set the final state.
|
||||||
CheckStateChanges();
|
CheckStateChanges();
|
||||||
|
|
||||||
/* If the card in this player's slot is ready, then use it. If there is
|
/* If the card in this player's slot is ready, then use it. If there is
|
||||||
@@ -560,7 +561,7 @@ void MemoryCardManager::LockCard( PlayerNumber pn )
|
|||||||
else
|
else
|
||||||
m_FinalDevice[pn] = UsbStorageDevice();
|
m_FinalDevice[pn] = UsbStorageDevice();
|
||||||
|
|
||||||
/* Set this last, since it changes the behavior of CheckStateChanges. */
|
// Set this last, since it changes the behavior of CheckStateChanges.
|
||||||
m_bCardLocked[pn] = true;
|
m_bCardLocked[pn] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -570,11 +571,11 @@ void MemoryCardManager::UnlockCard( PlayerNumber pn )
|
|||||||
|
|
||||||
g_pWorker->SetMountThreadState( ThreadedMemoryCardWorker::detect_and_mount );
|
g_pWorker->SetMountThreadState( ThreadedMemoryCardWorker::detect_and_mount );
|
||||||
|
|
||||||
/* If a memory card was inserted too late last game, allow it now. */
|
// If a memory card was inserted too late last game, allow it now.
|
||||||
CheckStateChanges();
|
CheckStateChanges();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Called just before reading or writing to the memory card. Should block. */
|
// Called just before reading or writing to the memory card. Should block.
|
||||||
bool MemoryCardManager::MountCard( PlayerNumber pn, int iTimeout )
|
bool MemoryCardManager::MountCard( PlayerNumber pn, int iTimeout )
|
||||||
{
|
{
|
||||||
LOG->Trace( "MemoryCardManager::MountCard(%i)", pn );
|
LOG->Trace( "MemoryCardManager::MountCard(%i)", pn );
|
||||||
@@ -582,14 +583,14 @@ bool MemoryCardManager::MountCard( PlayerNumber pn, int iTimeout )
|
|||||||
return false;
|
return false;
|
||||||
ASSERT( !m_Device[pn].IsBlank() );
|
ASSERT( !m_Device[pn].IsBlank() );
|
||||||
|
|
||||||
/* Pause the mounting thread when we mount the first drive. */
|
// Pause the mounting thread when we mount the first drive.
|
||||||
bool bStartingMemoryCardAccess = true;
|
bool bStartingMemoryCardAccess = true;
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
if( m_bMounted[p] )
|
if( m_bMounted[p] )
|
||||||
bStartingMemoryCardAccess = false; /* already did */
|
bStartingMemoryCardAccess = false; // already did
|
||||||
if( bStartingMemoryCardAccess )
|
if( bStartingMemoryCardAccess )
|
||||||
{
|
{
|
||||||
/* We're starting to do stuff to the memory cards. */
|
// We're starting to do stuff to the memory cards.
|
||||||
this->PauseMountingThread( iTimeout );
|
this->PauseMountingThread( iTimeout );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,10 +612,10 @@ bool MemoryCardManager::MountCard( PlayerNumber pn, int iTimeout )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We don't want to unmount the timeout FS. Instead, just move the target. */
|
// We don't want to unmount the timeout FS. Instead, just move the target.
|
||||||
pDriver->Remount( m_Device[pn].sOsMountDir );
|
pDriver->Remount( m_Device[pn].sOsMountDir );
|
||||||
|
|
||||||
/* Flush mountpoints pointing to what we've mounted. */
|
// Flush mountpoints pointing to what we've mounted.
|
||||||
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT[pn] );
|
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT[pn] );
|
||||||
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT_INTERNAL[pn] );
|
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT_INTERNAL[pn] );
|
||||||
|
|
||||||
@@ -643,16 +644,16 @@ void MemoryCardManager::UnmountCard( PlayerNumber pn )
|
|||||||
if( !m_bMounted[pn] )
|
if( !m_bMounted[pn] )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* Leave our own filesystem drivers mounted. Unmount the kernel mount. */
|
// Leave our own filesystem drivers mounted. Unmount the kernel mount.
|
||||||
g_pWorker->Unmount( &m_Device[pn] );
|
g_pWorker->Unmount( &m_Device[pn] );
|
||||||
|
|
||||||
/* Flush mountpoints pointing to what we've unmounted. */
|
// Flush mountpoints pointing to what we've unmounted.
|
||||||
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT[pn] );
|
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT[pn] );
|
||||||
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT_INTERNAL[pn] );
|
FILEMAN->FlushDirCache( MEM_CARD_MOUNT_POINT_INTERNAL[pn] );
|
||||||
|
|
||||||
m_bMounted[pn] = false;
|
m_bMounted[pn] = false;
|
||||||
|
|
||||||
/* Unpause the mounting thread when we unmount the last drive. */
|
// Unpause the mounting thread when we unmount the last drive.
|
||||||
bool bNeedUnpause = true;
|
bool bNeedUnpause = true;
|
||||||
FOREACH_PlayerNumber( p )
|
FOREACH_PlayerNumber( p )
|
||||||
if( m_bMounted[p] )
|
if( m_bMounted[p] )
|
||||||
@@ -693,7 +694,7 @@ void MemoryCardManager::PauseMountingThread( int iTimeout )
|
|||||||
|
|
||||||
g_pWorker->SetMountThreadState( ThreadedMemoryCardWorker::paused );
|
g_pWorker->SetMountThreadState( ThreadedMemoryCardWorker::paused );
|
||||||
|
|
||||||
/* Start the timeout period. */
|
// Start the timeout period.
|
||||||
g_pWorker->SetTimeout( (float) iTimeout );
|
g_pWorker->SetTimeout( (float) iTimeout );
|
||||||
RageFileDriverTimeout::SetTimeout( (float) iTimeout );
|
RageFileDriverTimeout::SetTimeout( (float) iTimeout );
|
||||||
}
|
}
|
||||||
@@ -704,7 +705,7 @@ void MemoryCardManager::UnPauseMountingThread()
|
|||||||
|
|
||||||
g_pWorker->SetMountThreadState( ThreadedMemoryCardWorker::detect_and_mount );
|
g_pWorker->SetMountThreadState( ThreadedMemoryCardWorker::detect_and_mount );
|
||||||
|
|
||||||
/* End the timeout period. */
|
// End the timeout period.
|
||||||
g_pWorker->SetTimeout( -1 );
|
g_pWorker->SetTimeout( -1 );
|
||||||
RageFileDriverTimeout::SetTimeout( -1 );
|
RageFileDriverTimeout::SetTimeout( -1 );
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public:
|
|||||||
|
|
||||||
bool IsMounted( PlayerNumber pn ) const { return m_bMounted[pn]; }
|
bool IsMounted( PlayerNumber pn ) const { return m_bMounted[pn]; }
|
||||||
|
|
||||||
/* When paused, no changes in memory card state will be noticed until unpaused. */
|
// When paused, no changes in memory card state will be noticed until unpaused.
|
||||||
void PauseMountingThread( int iTimeout = 20 );
|
void PauseMountingThread( int iTimeout = 20 );
|
||||||
void UnPauseMountingThread();
|
void UnPauseMountingThread();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user