当前位置: 首页>>代码示例>>C++>>正文


C++ CAccount类代码示例

本文整理汇总了C++中CAccount的典型用法代码示例。如果您正苦于以下问题:C++ CAccount类的具体用法?C++ CAccount怎么用?C++ CAccount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CAccount类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ReadAccount

bool CWalletDB::ReadAccount(const string& strAccount, CAccount& account)
{
    account.SetNull();
    return Read(make_pair(string("acc"), strAccount), account);
}
开发者ID:OrthoCoin,项目名称:orthocoin,代码行数:5,代码来源:walletdb.cpp

示例2: executeTask

void CSchedule::executeTask(CTask * paramTask)
{
	string sendString;
	char sendBuffer[1000];
	
	CModificationInformation * modificationInformation;
	CAccount * account;
	
	int i;
	
	switch(paramTask->type)
	{
		case 1:
			if (!paramTask->correctPassword)
			{
				sendString = "02524fThe password is wrong.";
				strcpy(sendBuffer, sendString.c_str());
				sendCommand(paramTask->socketFd, sendBuffer, 28);
				
				break;
			}
			
			modificationInformation = paramTask->modificationInformation;
			
			if (modificationInformation->nrOfExpectedDescriptionLines != modificationInformation->nrOfReceivedDescriptionLines)
			{
				sendString = "05024fCould not receive all lines of the description.";
				strcpy(sendBuffer, sendString.c_str());
				sendCommand(paramTask->socketFd, sendBuffer, 53);
				
				break;
			}
			
			account = getAccountFromId(paramTask->id);
			
			if (((i = getIdFromName(modificationInformation->firstName)) > 0) && (i != modificationInformation->id))
			{
				sendString = "04924fAn account with the first Name already exists.";
				strcpy(sendBuffer, sendString.c_str());
				sendCommand(paramTask->socketFd, sendBuffer, 52);
				
				break;
			}
			
			if (((i = getIdFromName(modificationInformation->secondName)) > 0) && (i != modificationInformation->id))
			{
				sendString = "05024fAn account with the second Name already exists.";
				strcpy(sendBuffer, sendString.c_str());
				sendCommand(paramTask->socketFd, sendBuffer, 53);
				
				break;
			}
			
			if (((i = getIdFromName(modificationInformation->thirdName)) > 0) && (i != modificationInformation->id))
			{
				sendString = "04924fAn account with the third Name already exists.";
				strcpy(sendBuffer, sendString.c_str());
				sendCommand(paramTask->socketFd, sendBuffer, 52);
				
				break;
			}
			
			account->setFirstName(modificationInformation->firstName);
			account->setSecondName(modificationInformation->secondName);
			account->setThirdName(modificationInformation->thirdName);
			account->setPrivateNrOfEvaluatedTtrsGames(modificationInformation->privateNrOfEvaluatedTtrsGames);
			account->setDescription(modificationInformation->description);
			
			sendString = "00324s";
			strcpy(sendBuffer, sendString.c_str());
			sendCommand(paramTask->socketFd, sendBuffer, 6);
			
			// Protocol Send-Syntax:	24:{s,f}ErrorMessage
			
			saveToFile(pathToFileToSaveTo);
			
			cout << "Modified account:" << endl;
			account->printDetails();
			
			break;
			
		case 2:
			if (!paramTask->correctPassword)
			{
				sendString = "02529fThe password is wrong.";
				strcpy(sendBuffer, sendString.c_str());
				sendCommand(paramTask->socketFd, sendBuffer, 28);
				
				break;
			}
			
			account = getAccountFromId(paramTask->id);
			
			account->setPassword(paramTask->string1);
			
			sendString = "00329s";
			strcpy(sendBuffer, sendString.c_str());
			sendCommand(paramTask->socketFd, sendBuffer, 6);
			
			// Protocol Send-Syntax:	29:{s,f}ErrorMessage
//.........这里部分代码省略.........
开发者ID:TiriliPiitPiit,项目名称:Rating-Server,代码行数:101,代码来源:Schedule.cpp

示例3: password

bool CAccountManager::LogIn(CClient* pClient, CClient* pEchoClient, const char* szAccountName, const char* szPassword)
{
    // Is he already logged in?
    if (pClient->IsRegistered())
    {
        if (pEchoClient)
            pEchoClient->SendEcho("login: You are already logged in");
        return false;
    }

    if (pClient->GetClientType() != CClient::CLIENT_PLAYER)
    {
        if (pEchoClient)
            pEchoClient->SendEcho("login: Only players can log in");
        return false;
    }

    // Get the players details
    CPlayer* pPlayer = static_cast<CPlayer*>(pClient);
    SString  strPlayerName = pPlayer->GetNick();
    SString  strPlayerIP = pPlayer->GetSourceIP();
    SString  strPlayerSerial = pPlayer->GetSerial();

    if (m_AccountProtect.IsFlooding(strPlayerIP.c_str()))
    {
        if (pEchoClient)
            pEchoClient->SendEcho(SString("login: Account locked", szAccountName).c_str());
        CLogger::AuthPrintf("LOGIN: Ignoring %s trying to log in as '%s' (IP: %s  Serial: %s)\n", strPlayerName.c_str(), szAccountName, strPlayerIP.c_str(),
                            strPlayerSerial.c_str());
        return false;
    }

    // Grab the account on his nick if any
    CAccount* pAccount = g_pGame->GetAccountManager()->Get(szAccountName);
    if (!pAccount)
    {
        if (pEchoClient)
            pEchoClient->SendEcho(SString("login: No known account for '%s'", szAccountName).c_str());
        CLogger::AuthPrintf("LOGIN: %s tried to log in as '%s' (Unknown account) (IP: %s  Serial: %s)\n", strPlayerName.c_str(), szAccountName,
                            strPlayerIP.c_str(), strPlayerSerial.c_str());
        return false;
    }

    if (pAccount->GetClient())
    {
        if (pEchoClient)
            pEchoClient->SendEcho(SString("login: Account for '%s' is already in use", szAccountName).c_str());
        return false;
    }
    if (!IsValidPassword(szPassword) || !pAccount->IsPassword(szPassword))
    {
        if (pEchoClient)
            pEchoClient->SendEcho(SString("login: Invalid password for account '%s'", szAccountName).c_str());
        CLogger::AuthPrintf("LOGIN: %s tried to log in as '%s' with an invalid password (IP: %s  Serial: %s)\n", strPlayerName.c_str(), szAccountName,
                            strPlayerIP.c_str(), strPlayerSerial.c_str());
        m_AccountProtect.AddConnect(strPlayerIP.c_str());
        return false;
    }

    // Check serial authorization
    if (IsAuthorizedSerialRequired(pAccount))
    {
        pAccount->AddSerialForAuthorization(strPlayerSerial, strPlayerIP);
        if (!pAccount->IsSerialAuthorized(strPlayerSerial))
        {
            if (pEchoClient)
                pEchoClient->SendEcho(
                    SString("login: Serial pending authorization for account '%s' - See https:"
                            "//mtasa.com/authserial",
                            szAccountName));
            CLogger::AuthPrintf("LOGIN: %s tried to log in as '%s' with an unauthorized serial (IP: %s  Serial: %s)\n", *strPlayerName, szAccountName,
                                *strPlayerIP, *strPlayerSerial);
            CLogger::AuthPrintf(
                "LOGIN: See https:"
                "//mtasa.com/authserial\n");
            return false;
        }
    }

    // Log him in
    CAccount* pCurrentAccount = pClient->GetAccount();
    pClient->SetAccount(pAccount);
    pAccount->SetClient(pClient);

    // Call the onPlayerLogin script event
    CLuaArguments Arguments;
    Arguments.PushAccount(pCurrentAccount);
    Arguments.PushAccount(pAccount);
    Arguments.PushBoolean(false);            // was bAutoLogin
    if (!pPlayer->CallEvent("onPlayerLogin", Arguments))
    {
        // DENIED!
        pClient->SetAccount(pCurrentAccount);
        pAccount->SetClient(NULL);
        return false;
    }

    // Success is here
    pAccount->OnLoginSuccess(strPlayerSerial, strPlayerIP);

//.........这里部分代码省略.........
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:101,代码来源:CAccountManager.cpp

示例4: ReadAccount

bool WalletBatch::ReadAccount(const std::string& strAccount, CAccount& account)
{
    account.SetNull();
    return m_batch.Read(std::make_pair(std::string("acc"), strAccount), account);
}
开发者ID:MentalCollatz,项目名称:DigiByteProject,代码行数:5,代码来源:walletdb.cpp

示例5: 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)
//.........这里部分代码省略.........
开发者ID:Audifire,项目名称:mtasa-blue,代码行数:101,代码来源:CAccountManager.cpp


注:本文中的CAccount类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。