Beispiel #1
0
void ClientVoteMgr::HandleVoteStart(ILTMessage_Read* pMsg)
{
	m_CurrentVote.m_nVoteID = pMsg->Readuint8();
	VoteType eVoteType = (VoteType)pMsg->ReadBits( FNumBitsExclusive<kNumVoteTypes>::k_nValue );
	m_CurrentVote.m_eVoteType = eVoteType;
	m_CurrentVote.m_nCallerID = pMsg->Readuint32();
	m_CurrentVote.m_nTargetID = pMsg->Readuint32();
	m_CurrentVote.m_nVotesNeeded = pMsg->Readuint8();
	m_VoteTimer.Start(pMsg->Readdouble());

	m_CurrentVote.m_nYesVotes = 1; //count the person who called the vote

	uint32 nLocalID = 0;
	g_pLTClient->GetLocalClientID (&nLocalID);

	//if I'm the one who called the vote, I've already voted yes
	m_bHasVoted = (nLocalID == m_CurrentVote.m_nCallerID);

	wchar_t wszMsg[256] = L"";
	wchar_t wszTxt[256] = L"";
	CClientInfoMgr *pCIMgr = g_pGameClientShell->GetInterfaceMgr( )->GetClientInfoMgr();
	if (!pCIMgr)
	{
		LTERROR("ClientInfoMgr not available");
		return;
	}

	switch(eVoteType)
	{
	case eVote_Kick:
		m_sTargetName = pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID);

		FormatString("Vote_StartKick",wszMsg,LTARRAYSIZE(wszMsg),pCIMgr->GetPlayerName(m_CurrentVote.m_nCallerID),pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID));
		FormatString("Vote_Kick",wszTxt,LTARRAYSIZE(wszTxt),pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID));

		break;
	case eVote_TeamKick:
		m_sTargetName = pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID);

		FormatString("Vote_StartTeamKick",wszMsg,LTARRAYSIZE(wszMsg),pCIMgr->GetPlayerName(m_CurrentVote.m_nCallerID),pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID));
		FormatString("Vote_TeamKick",wszTxt,LTARRAYSIZE(wszTxt),pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID));

		break;
	case eVote_Ban:
		m_sTargetName = pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID);

		FormatString("Vote_StartBan",wszMsg,LTARRAYSIZE(wszMsg),pCIMgr->GetPlayerName(m_CurrentVote.m_nCallerID),pCIMgr->GetPlayerName(m_CurrentVote.m_nTargetID));
		FormatString("Vote_Ban",wszTxt,LTARRAYSIZE(wszTxt),m_sTargetName.c_str());

		break;
	case eVote_NextRound:
		m_sTargetName = L"";

		FormatString("Vote_StartNextRound",wszMsg,LTARRAYSIZE(wszMsg),pCIMgr->GetPlayerName(m_CurrentVote.m_nCallerID));
		FormatString("Vote_NextRound",wszTxt,LTARRAYSIZE(wszTxt));

		break;
	case eVote_NextMap:
		m_sTargetName = L"";

		FormatString("Vote_StartNextMap",wszMsg,LTARRAYSIZE(wszMsg),pCIMgr->GetPlayerName(m_CurrentVote.m_nCallerID));
		FormatString("Vote_NextMap",wszTxt,LTARRAYSIZE(wszTxt));

		break;
	case eVote_SelectMap:
		m_sTargetName = g_pMissionMgr->GetMapList()[m_CurrentVote.m_nTargetID].c_str();

		FormatString("Vote_StartSelectMap",wszMsg,LTARRAYSIZE(wszMsg),pCIMgr->GetPlayerName(m_CurrentVote.m_nCallerID),m_sTargetName.c_str());
		FormatString("Vote_SelectMap",wszTxt,LTARRAYSIZE(wszTxt),m_sTargetName.c_str());

		break;
	}

	g_pGameMsgs->AddMessage(wszMsg);
	g_pTransmission->Show(wszMsg);
	m_sVoteString = wszTxt;

	g_pHUDMgr->QueueUpdate(kHUDVote);

}
Beispiel #2
0
void CTriggerFX::CheckPlayersWithinTrigger()
{
	if( m_cs.bLocked )
		return;

	// Get a list of all the characters...

	CSpecialFXList *pList = g_pGameClientShell->GetSFXMgr()->GetFXList( SFX_CHARACTER_ID );
	if( !pList )
		return;

	int nListSize = pList->GetSize();
	int nNumChars = pList->GetNumItems();
	int nNumFoundChars = 0;
	int nNumPlayersFound = 0;
	uint32 dwLocalId = 0;

	g_pLTClient->GetLocalClientID( &dwLocalId );

	LTVector vTrigPos, vPlayerPos, vPlayerDims, vPlayerMin, vPlayerMax;
	g_pLTClient->GetObjectPos( m_hServerObject, &vTrigPos );

	// Setup the triggers box...
	
	LTVector vTrigMin = vTrigPos - m_cs.vDims;
	LTVector vTrigMax = vTrigPos + m_cs.vDims;

	bool bLocalPlayerIn = false;
	
	// Initialize our containers to zero.  Don't call clear, since we'll be using
	// these vectors every frame and most likely they will have the same
	// number of elements across multiple frames.
	m_lstPlayersNotInTrigger.resize( 0 );
	m_lstNewPlayersInTrigger.resize( 0 );

	for( int i = 0; i < nListSize; ++i )
	{
		// Try not to go through the entire list...

		if( nNumFoundChars == nNumChars )
			break;

		if( (*pList)[i] )
		{
			CCharacterFX *pChar = (CCharacterFX*)(*pList)[i];
			if( !pChar )
				continue;

			// Found another char..
			++nNumFoundChars;

			if( pChar->m_cs.bIsPlayer && pChar->m_cs.nClientID != ( uint8 )-1 )
			{
				++nNumPlayersFound;
				
				HOBJECT hPlayer = pChar->GetServerObj();

				g_pLTClient->GetObjectPos( hPlayer, &vPlayerPos );
				g_pPhysicsLT->GetObjectDims( hPlayer, &vPlayerDims );

				vPlayerMin = vPlayerPos - vPlayerDims;
				vPlayerMax = vPlayerPos + vPlayerDims;

				// Check the current list of players in the trigger for this player...
					
				CharFXList::iterator iter;
				for( iter = m_lstCurPlayersInTrigger.begin(); iter != m_lstCurPlayersInTrigger.end(); ++iter )
				{
					if( pChar == (*iter) )
						break;
				}

				// Check if we are within the height of the trigger...

				bool bWithinHeight = false;
				if( vPlayerMax.y > vTrigMin.y && vPlayerMin.y < vTrigMax.y )
					bWithinHeight = true;

				if( bWithinHeight && BoxesIntersect( vTrigMin, vTrigMax, vPlayerMin, vPlayerMax ) && !pChar->IsPlayerDead())
				{
					if( dwLocalId == pChar->m_cs.nClientID )
						bLocalPlayerIn = true;

					// If it wasn't in the list add it...

					if( iter == m_lstCurPlayersInTrigger.end() )
					{
						m_lstCurPlayersInTrigger.push_back( pChar );
						m_lstNewPlayersInTrigger.push_back( pChar );
					}

				}
				else
				{
					if( iter != m_lstCurPlayersInTrigger.end() )
						m_lstCurPlayersInTrigger.erase( iter );

					m_lstPlayersNotInTrigger.push_back( pChar );
				}
			}
		}
	}

	wchar_t wszBuffer[256];

	if( (m_lstNewPlayersInTrigger.size() > 0) && (nNumPlayersFound > 1) )
	{
		CClientInfoMgr *pInfoMgr = g_pInterfaceMgr->GetClientInfoMgr();
		if( !pInfoMgr )
			return;

		if( bLocalPlayerIn )
		{
			// Display a general transmission and messages for each player you are waiting for...

			int nPlayersNotInTrig = m_lstPlayersNotInTrigger.size();

			if( m_cs.nPlayerInsideID != (uint32)-1 )
			{
				g_pTransmission->Show( StringIDFromIndex(m_cs.nPlayerInsideID) );
			}
			else if( nPlayersNotInTrig > 1 )
			{
				//sTransmission.Format( "You are waiting for %i players.", nPlayersNotInTrig );
				FormatString( "IDS_EXIT_PLAYER_WAITING", wszBuffer, LTARRAYSIZE(wszBuffer), nPlayersNotInTrig );
				g_pTransmission->Show( wszBuffer );
			}
			else
			{
				//sTransmission.Format( "You are waiting for 1 player." );
				FormatString( "IDS_EXIT_PLAYER_WAITING_1", wszBuffer, LTARRAYSIZE(wszBuffer) );
				g_pTransmission->Show( wszBuffer );
			}		
			
			
			CharFXList::iterator iter;
			for( iter = m_lstPlayersNotInTrigger.begin(); iter != m_lstPlayersNotInTrigger.end(); ++iter )
			{
				//sMessage.Format( "You are waiting for %s.", pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID ));
				FormatString( "IDS_EXIT_PLAYER_WAITING_NAME", wszBuffer, LTARRAYSIZE(wszBuffer), pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID) );
				g_pGameMsgs->AddMessage( wszBuffer );
			}
		}
		else
		{
			// Display a general transmission and messages for each player waiting for you...

			int nPlayersInTrig = m_lstCurPlayersInTrigger.size();
			
			if( m_cs.nPlayerOutsideID != (uint32)-1 )
			{
				g_pTransmission->Show( LoadString(m_cs.nPlayerOutsideID) );
			}
			else if( nPlayersInTrig > 1 )
			{
//				sTransmission.Format( "%i players are waiting for you",nPlayersInTrig  );
				FormatString( "IDS_EXIT_WAITING", wszBuffer, LTARRAYSIZE(wszBuffer), nPlayersInTrig );
				g_pTransmission->Show( wszBuffer );
			}
			else
			{
//				sTransmission.Format( "1 player is waiting for you." );
				FormatString( "IDS_EXIT_WAITING_1", wszBuffer, LTARRAYSIZE(wszBuffer) );
				g_pTransmission->Show( wszBuffer );
			}
			

			CharFXList::iterator iter;
			for( iter = m_lstCurPlayersInTrigger.begin(); iter != m_lstCurPlayersInTrigger.end(); ++iter )
			{
				FormatString( "IDS_EXIT_WAITING_NAME", wszBuffer, LTARRAYSIZE(wszBuffer), pInfoMgr->GetPlayerName( (*iter)->m_cs.nClientID) );
				g_pGameMsgs->AddMessage( wszBuffer );	
			}
		}
	}
}