Пример #1
0
Файл: XE.cpp Проект: xahgo/tama
	ID GenerateID() 
	{ 
		DWORD idRand = 0;
		while( idRand == 0 )		// 0은 생성하지 못하도록
			idRand = xRand();
		return idRand; 
	}
Пример #2
0
void PostDeposit::operator ()( const SPC & lhs )	const
{	// 입찰금 우편 반환 함수자
	u_long idReceiver	= lhs->GetIdPlayer();
	CTElection* pElection	= static_cast<CTElection*>( CTLord::Instance()->GetElection() );

	// 후보자 순위에 따른 반환금 구하기
	float fRate		= pElection->GetRetRate( idReceiver );
	if( fRate == 0.0F )
		return;
	// 2008/10/31 - 정밀도 오류가 발생하여 수정 - 康
//	__int64 iDeposit	= lhs->GetDeposit() * fRate;
	__int64 iDeposit	= (__int64)( lhs->GetDeposit() / 100 * ( fRate * 100 ) );

	// 후보자의 순위에 따라 편지 내용을 작성
	CMail* pMail	= new CMail;
	pMail->m_tmCreate	= ::time_null();
	pMail->m_idSender	= 0;	//

	int nOrder	= pElection->GetOrder( idReceiver );

	if( nOrder < IElection::nMaxCandidates )
	{
		lstrcpy( pMail->m_szTitle, prj.GetText( TID_GAME_ELECTION_RETURN_DEPOSIT_MAIL_TITLE_02 ) );	// title
		sprintf( pMail->m_szText, prj.GetText( TID_GAME_ELECTION_RETURN_DEPOSIT_MAIL_TEXT_02 ),
			static_cast<__int64>( lhs->GetDeposit() ),
			nOrder + 1,
			static_cast<float>( fRate * 100.0F ),
			static_cast<__int64>( iDeposit ) );
	}
	else
	{
		lstrcpy( pMail->m_szTitle, prj.GetText( TID_GAME_ELECTION_RETURN_DEPOSIT_MAIL_TITLE_01 ) );	// title
		sprintf( pMail->m_szText, prj.GetText( TID_GAME_ELECTION_RETURN_DEPOSIT_MAIL_TEXT_01 ),
			static_cast<__int64>( lhs->GetDeposit() ),
			static_cast<float>( fRate * 100.0F ),
			static_cast<__int64>( iDeposit ) );

		if( !m_pQuery->Execute( "uspElectionLeaveOut %d, %d, %d", g_appInfo.dwSys, pElection->GetId(), idReceiver ) )
			Error( "couldn't execute uspElectionLeaveOut" );
	}
	
	// 반환금을 페린과 페냐로 분리하여 첨부
	int nPerin	= static_cast<int>( iDeposit / static_cast<__int64>(PERIN_VALUE ) );
	int nPenya	= static_cast<int>( iDeposit - static_cast<__int64>( PERIN_VALUE ) * static_cast<__int64>( nPerin ) );

	pMail->m_nGold	= nPenya;
	if( nPerin > 0 )
	{
		pMail->m_pItemElem	= new CItemElem;
		pMail->m_pItemElem->m_dwItemId	= II_SYS_SYS_SCR_PERIN;
		pMail->m_pItemElem->m_nItemNum	= static_cast<short>( nPerin );
		pMail->m_pItemElem->SetSerialNumber( xRand() );
	}

	// 우편 발송
	post::Post( idReceiver, pMail, m_pQuery );
}
    bool canInsertRoom( Level & level, vec4uint32 & newRoom, uint32_t & seed ) {
#ifdef FL_DEBUG
        log() << "Attempting room insert of " << newRoom << std::endl;
#endif

        vec2uint32 expandedRoomDimensions { newRoom.w + 2, newRoom.h + 2 };
        std::pair<bool, FreeEntryCache::FreeEntryIter> ce = freeEntrySelector_.findFreeEntryOfDimensions( freeEntryCache_,
                expandedRoomDimensions  );

        if( ce.first ) {
            FreeEntryCache::FreeEntryIter & fe( ce.second );
            const vec4uint32 & foundSegment( *(fe.entryListIter) );
#ifdef FL_DEBUG
            log() << "Found free entry: " << foundSegment << std::endl;
#endif

            // Choose a random x and y offset inside this segment based on how wide and high it is
            int32_t restrictedX( foundSegment.w - (expandedRoomDimensions.x ) );
            int32_t restrictedY( foundSegment.h - (expandedRoomDimensions.y ) );
#ifdef FL_DEBUG
            log() << "Restricted X/Y is " << restrictedX << " " << restrictedY << std::endl;
#endif
            uint32_t xRand( randGenerator_( seed ) );
            uint32_t yRand( randGenerator_( seed ) );
            uint32_t randXOffset( ( restrictedX > 0 ? ( xRand % restrictedX) : 0 ) );
            uint32_t randYOffset( ( restrictedY > 0 ? ( yRand % restrictedY) : 0 ) );
#ifdef FL_DEBUG
            log() << "Randoffsets are " << randXOffset << " " << randYOffset << std::endl;
#endif
            newRoom.x = foundSegment.x + randXOffset + 1;
            newRoom.y = foundSegment.y + randYOffset + 1;
#ifdef FL_DEBUG
            log() << "Room X and Y are " << newRoom.x << " " << newRoom.y << std::endl;
#endif

            freeEntryCache_.useFreeEntry( fe, newRoom );
//            vec4uint32 expandedRoom { newRoom.x - 1, newRoom.y - 1, newRoom.w + 2, newRoom.h + 2 };
            // We make the free space computations easier if we occlude an expanded room
            occlusionBuffer_.occludeWithBorder( newRoom );
#ifdef FL_DEBUG
            log() << "After free space use, occlusion buffer is now" << std::endl;
            occlusionBuffer_.debug();
#endif
            return true;
        }
        else {
#ifdef FL_DEBUG
            log() << "Unable to find free entry" << std::endl;
#endif
            return false;
        }
    }
Пример #4
0
void XPH::GetUUID( char *cOut, int len )
{
	char cBuff[48];
	char cBuff2[ 48 ];
	UINT rnd;
	rnd = xRand();
	sprintf_s( cBuff2, "%08x", rnd );
	strcpy_s( cBuff, cBuff2 );
	rnd = xRand();
	sprintf_s( cBuff2, "%08x", rnd );
	strcat_s( cBuff, cBuff2 );
	rnd = xRand();
	sprintf_s( cBuff2, "%08x", rnd );
	strcat_s( cBuff, cBuff2 );
	rnd = xRand();
	sprintf_s( cBuff2, "%08x", rnd );
	strcat_s( cBuff, cBuff2 );
	rnd = xRand();
	sprintf_s( cBuff2, "%08x", rnd );
	strcat_s( cBuff, cBuff2 );
	strcpy_s( cOut, len, cBuff );
}
Пример #5
0
void CTElection::PostItem( u_long idPlayer, PostItemStruct & pi )
{	// 우편을 통한 아이템 지급
	// 일반화 대상
	CMail* pMail	= new CMail;
	pMail->m_tmCreate	= ::time_null();
	pMail->m_idSender	= 0;	//
	sprintf( pMail->m_szTitle, prj.GetText( TID_GAME_ELECTION_SET_LORD_MAIL_TITLE ) );
	sprintf( pMail->m_szText, prj.GetText( TID_GAME_ELECTION_SET_LORD_MAIL_TEXT ) );
	pMail->m_pItemElem	= new CItemElem;
	pMail->m_pItemElem->m_dwItemId	= pi.nItem;
	pMail->m_pItemElem->m_nItemNum	= 1;
	pMail->m_pItemElem->m_dwKeepTime	= pi.dwKeepTime;
	pMail->m_pItemElem->SetSerialNumber( xRand() );
	CLController* pController	= m_pLord->GetController();
	post::Post( idPlayer, pMail, pController->GetQueryObject() );
}
Пример #6
0
void CCoupleHelper::PostItem( u_long idPlayer, const COUPLE_ITEM& ci, int nLevel )
{
	CMail* pMail	= new CMail;
	pMail->m_tmCreate	= ::time_null();
	pMail->m_idSender	= 0;	//
	sprintf( pMail->m_szTitle, prj.GetText( TID_GAME_COUPLE_ITEM_MAIL_TITLE ) );
	sprintf( pMail->m_szText, prj.GetText( TID_GAME_COUPLE_ITEM_MAIL_TEXT ), nLevel );
	pMail->m_pItemElem	= new CItemElem;
	pMail->m_pItemElem->m_dwItemId	= ci.nItem;
	pMail->m_pItemElem->m_nItemNum	= ci.nNum;
	pMail->m_pItemElem->m_dwKeepTime	=	0;
	if( ci.nLife > 0 )
		pMail->m_pItemElem->m_dwKeepTime	= ::time_null() + ci.nLife * 60;	// ci.nLife(단위: 분)
	pMail->m_pItemElem->m_byFlag	= static_cast<BYTE>( ci.nFlags );
	pMail->m_pItemElem->SetSerialNumber( xRand() );
	post::Post( idPlayer, pMail, m_pController->GetQueryObject() );
}