本文整理汇总了C++中CAccount::SetChanged方法的典型用法代码示例。如果您正苦于以下问题:C++ CAccount::SetChanged方法的具体用法?C++ CAccount::SetChanged怎么用?C++ CAccount::SetChanged使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CAccount
的用法示例。
在下文中一共展示了CAccount::SetChanged方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Load
bool CAccountManager::Load( void )
{
//Create a registry result
CRegistryResult result;
//Select all our required information from the accounts database
m_pDatabaseManager->QueryWithResultf ( m_hDbConnection, &result, "SELECT id,name,password,ip,serial,httppass from accounts" );
//Initialize all our variables
m_iAccounts = 0;
bool bNeedsVacuum = false;
CElapsedTime activityTimer;
bool bOutputFeedback = false;
for ( CRegistryResultIterator iter = result->begin() ; iter != result->end() ; ++iter )
{
const CRegistryResultRow& row = *iter;
//Fill User ID, Name & Password (Required data)
int iUserID = static_cast < int > ( row[0].nVal );
SString strName = (const char *)row[1].pVal;
SString strPassword = (const char *)row[2].pVal;
SString strIP = (const char *)row[3].pVal;
SString strSerial = (const char *)row[4].pVal;
SString strHttpPassAppend = (const char *)row[5].pVal;
// Check for overlong names and incorrect escapement
bool bRemoveAccount = false;
bool bChanged = false;
if ( strName.length () > 64 )
{
// Try to repair name
if ( strName.length () <= 256 )
{
strName = strName.Replace ( "\"\"", "\"", true ).substr ( 0, 64 );
bChanged = true;
}
// If name gone doolally or account with this name already exists, remove account
if ( strName.length () > 256 || Get ( strName ) )
{
bNeedsVacuum = true;
bRemoveAccount = true;
CLogger::LogPrintf ( "Removed duplicate or damaged account for %s\n", strName.substr ( 0, 64 ).c_str() );
}
}
// Check for disallowed account names
if ( strName == "*****" || strName == CONSOLE_ACCOUNT_NAME )
bRemoveAccount = true;
// Do account remove if required
if ( bRemoveAccount )
{
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM accounts WHERE id=?", SQLITE_INTEGER, iUserID );
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM userdata WHERE userid=?", SQLITE_INTEGER, iUserID );
m_pDatabaseManager->Execf ( m_hDbConnection, "DELETE FROM serialusage WHERE userid=?", SQLITE_INTEGER, iUserID );
continue;
}
//Create a new account with the specified information
CAccount* pAccount = g_pGame->GetAccountManager ()->AddPlayerAccount ( strName, strPassword, iUserID, strIP, strSerial, strHttpPassAppend );
if ( bChanged )
pAccount->SetChanged ( bChanged );
m_iAccounts = std::max ( m_iAccounts, iUserID );
// Feedback for the user
if ( activityTimer.Get() > 5000 )
{
activityTimer.Reset();
bOutputFeedback = true;
CLogger::LogPrintf ( "Reading accounts %d/%d\n", m_List.size(), result->nRows );
}
}
if ( bOutputFeedback )
CLogger::LogPrintf ( "Reading accounts done.\n");
if ( bNeedsVacuum )
m_pDatabaseManager->Execf ( m_hDbConnection, "VACUUM" );
// Save any upgraded accounts
{
CElapsedTime activityTimer;
bool bOutputFeedback = false;
uint uiSaveCount = 0;
for ( CMappedAccountList::const_iterator iter = m_List.begin () ; iter != m_List.end () ; iter++ )
{
CAccount* pAccount = *iter;
if ( pAccount->IsRegistered () && pAccount->HasChanged () && !pAccount->IsConsoleAccount () )
{
uiSaveCount++;
Save ( pAccount, false );
// Feedback for the user
if ( activityTimer.Get() > 5000 )
{
activityTimer.Reset();
bOutputFeedback = true;
CLogger::LogPrintf ( "Saving upgraded accounts %d\n", uiSaveCount );
}
}
}
if ( uiSaveCount > 100 )
//.........这里部分代码省略.........