예제 #1
0
// 加入一封邮件,并将加入结果的在数据池中的索引返回,如果加入失败,则返回 -1
INT CMailPool::AddMail( const MAIL* pMail )
{
	if ( pMail == NULL )
	{
		Assert( pMail == NULL );
		return -1;
	}

	ENUM_RELATION eCampType = CalcRelationType( pMail->m_Camp, 
		CObjectManager::GetMe()->GetMySelf()->GetCampData()->m_nCampID,
		CGameProcedure::s_pCampDataMgr );

	if( eCampType != RELATION_FRIEND )
	{
		return -1;
	}

	SMail* pSMail = new SMail;

	pSMail->m_uFlag = pMail->m_uFlag;

	struct tm* ttm;
	ttm = localtime( &(pMail->m_uCreateTime) );
	if ( ttm != NULL )
	{
		strftime(pSMail->m_szCreateTime, sizeof(pSMail->m_szCreateTime), "%a %y/%m/%d %H:%M:%S", ttm );
	}

	pSMail->m_SourGUID = pMail->m_GUID;
	strncpy( pSMail->m_szSourName, pMail->m_szSourName, pMail->m_SourSize );
	pSMail->m_nPortrait = pMail->m_nPortrait;
	strncpy( pSMail->m_szDestName, pMail->m_szDestName, pMail->m_DestSize );
	strncpy( pSMail->m_szContex, pMail->m_szContex, pMail->m_ContexSize );

	pSMail->m_Camp = pMail->m_Camp;

	m_MailPool.push_back( pSMail );

	return ((INT)(m_MailPool.size() - 1));
}
예제 #2
0
ENUM_RELATION CGameInterface::GetCampType( CObject *pObj_A, CObject *pObj_B )
{
	if ( pObj_A == NULL || pObj_B == NULL )
	{
		return RELATION_ENEMY;
	}

	if ( pObj_A == pObj_B )
	{
		return RELATION_FRIEND;
	}

	ObjID_t idOwner_A, idOwner_B, idA, idB;
	idA			= pObj_A->GetServerID();
	idB			= pObj_B->GetServerID();
	idOwner_A	= pObj_A->GetOwnerID();
	idOwner_B	= pObj_B->GetOwnerID();
	if ( idOwner_A != INVALID_ID || idOwner_B != INVALID_ID )
	{
		if ( idOwner_A == idOwner_B
			|| idOwner_A == idB
			|| idOwner_B == idA )
		{
			return RELATION_FRIEND;
		}
	}

	//const _CAMP_DATA *pCamp_A, *pCamp_B;
	//BOOL bHuman_A, bHuman_B;
	//const CampAndStandDataMgr_T *pCampMgr;

	//pCamp_A		= pObj_A->GetCampData();
	//pCamp_B		= pObj_B->GetCampData();
	//bHuman_A	= g_theKernel.IsKindOf( pObj_A->GetClass(), GETCLASS(CObject_PlayerMySelf));
	//bHuman_B	= g_theKernel.IsKindOf( pObj_B->GetClass(), GETCLASS(CObject_PlayerMySelf));
	//pCampMgr	= CGameProcedure::s_pCampDataMgr;

	return CalcRelationType( pObj_A->GetCampData()->m_nCampID, pObj_B->GetCampData()->m_nCampID, CGameProcedure::s_pCampDataMgr );
}