Beispiel #1
0
ExtFunc void InitUtil(void)
{
	if (initSeed)
		SRandom(initSeed);
	else
		SRandom(time(0));
	signal(SIGINT, CatchInt);
	ResetBaseTime();
}
Beispiel #2
0
BOOL KMailBox::DeleteMail(DWORD dwMailID)
{
    BOOL                   bResult      = false;
    KMailTable::iterator   it;

    it = m_MailTable.find(dwMailID);
    KGLOG_PROCESS_ERROR(it != m_MailTable.end());

    KMEMORY_FREE(it->second);

    m_MailTable.erase(it);

    ResetBaseTime();

    m_bSaved = false;

    bResult = true;
Exit0:
    return bResult;
}
Beispiel #3
0
int KMailBox::GetWithdrawMail(
    time_t nTimeNow, time_t nSurvivalTime, 
    std::vector<KMail*, KMemory::KAllocator<KMail*> >* pMailList
 )
{
    int     nResult = 0;
    KMail*  pMail   = NULL;

    assert(pMailList);
    assert(pMailList->size() == 0);

    for (KMailTable::iterator it = m_MailTable.begin(); it != m_MailTable.end(); NULL)
    {
        BOOL bReturn = false;

        pMail = it->second;
        assert(pMail);

        if (nTimeNow < pMail->nRecvTime + nSurvivalTime)
        {
            ++it;
            continue;
        }

        if (pMail->byType == eMailType_Player)
        {
            if (!pMail->bRead)
            {
                bReturn = true; //未读邮件需要退回
            }
            else if (pMail->nMoney > 0)
            {
                bReturn = true; // 有未取金钱的邮件需要退回
            }
            else
            {
                for (int i = 0; i < KMAIL_MAX_ITEM_COUNT; i++)
                {
                    if (pMail->ItemDesc[i].bAcquired == false)
                    {
                        bReturn = true; // 有未取道具的邮件需要退回 
                        break;
                    }
                }
            }
        }

        if (bReturn)
        {
            pMailList->push_back(pMail);
            nResult++;
        }
        else
        {
            KMEMORY_FREE(pMail); // 无需return的邮件,直接删除
        }

        m_bSaved = false;

        m_MailTable.erase(it++);
    }

    ResetBaseTime();

//Exit0:
    return nResult;
}