コード例 #1
0
// drawPlayerStats
//---------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------
void RankView::drawPlayerStats(Surface &dest)
{
    char statBuf[256];

    ObjectiveInterface::updatePlayerObjectiveCounts();

    std::vector<const PlayerState*> states;
    for(size_t i = 0; i < PlayerInterface::getMaxPlayers(); ++i) {
        PlayerState* state = PlayerInterface::getPlayerState(i);
        if(state->getStatus() != _player_state_active)
            continue;
        states.push_back(state);
    }

    switch(gameconfig->gametype) {
    case _gametype_objective:
        std::sort(states.begin(), states.end(), StatesSortByObjectives());
        break;
    case _gametype_timelimit:
    case _gametype_fraglimit:
        std::sort(states.begin(), states.end(), StatesSortByFrags());
        break;
    }

    unsigned int CHAR_YPIX = Surface::getFontHeight();
    unsigned int entryHeight = std::max(CHAR_YPIX, UNIT_FLAGS_SURFACE.getHeight()) + 2;
    iXY offset(2, 40);
    iXY flagOffset(162, 40 + (int(CHAR_YPIX - UNIT_FLAGS_SURFACE.getHeight()))/2);

    for(std::vector<const PlayerState*>::iterator i = states.begin();
            i != states.end(); ++i) {
        const PlayerState* state = *i;

        snprintf(statBuf, sizeof(statBuf),
                 "%-20s%10i%7i%6i%10i", state->getName().substr(0,20).c_str(),
                 state->getKills(), state->getLosses(), state->getTotal(),
                 state->getObjectivesHeld());
        dest.bltString(offset.x, offset.y, statBuf, state->getColor());
        UNIT_FLAGS_SURFACE.setFrame(state->getFlag());
        UNIT_FLAGS_SURFACE.blt( dest, flagOffset.x, flagOffset.y );

        offset.y += entryHeight;
        flagOffset.y += entryHeight;
    }

} // end RankView::drawPlayerStats
コード例 #2
0
void GameManager::netMessagePingRequest(const NetMessage* message)
{
    const SystemPingRequest *ping_request
        = (const SystemPingRequest*) message;

    if(ping_request->getClientPlayerIndex() >= PlayerInterface::getMaxPlayers())
    {
        LOGGER.warning("Invalid pingRequest message");
        return;
    }

    PlayerState * player;
    player = PlayerInterface::getPlayer( ping_request->getClientPlayerIndex() );

    SystemPingAcknowledge ping_ack;

    if ( player->getStatus() == _player_state_active
         && ping_request->getClientPlayerIndex() != MIN_PLAYER_ID
       )
    {
        SERVER->sendMessage(player->getID(), &ping_ack, sizeof(SystemPingAcknowledge));
    }
}
コード例 #3
0
// drawPlayerStats
//---------------------------------------------------------------------------
// Purpose:
//---------------------------------------------------------------------------
void RankView::drawPlayerStats( unsigned int flagHeight)
{
    char statBuf[256];

	states.clear();
	for(size_t i = 0; i < PlayerInterface::getMaxPlayers(); ++i)
	{
        PlayerState* state = PlayerInterface::getPlayer(i);
        if(state->getStatus() != _player_state_active)
        {
			continue;
		}
        states.push_back(state);
    }

    switch(gameconfig->gametype)
	{
        case _gametype_objective:
            std::sort(states.begin(), states.end(), StatesSortByObjectives());
            break;
        case _gametype_timelimit:
        case _gametype_fraglimit:
            std::sort(states.begin(), states.end(), StatesSortByFrags());
            break;
    }

    unsigned int CHAR_YPIX = Surface::getFontHeight();
    unsigned int entryHeight = std::max(CHAR_YPIX, flagHeight) + 2;
    iXY offset( 6*8, 40);
    iXY flagOffset(26, 40 + (int(CHAR_YPIX - flagHeight))/2);
    Surface * flag = 0;

    for(std::vector<const PlayerState*>::iterator i = states.begin();
            i != states.end(); ++i) {
        const PlayerState* state = *i;

        snprintf(statBuf, sizeof(statBuf),
                "%-20s%5i%7i%7i%10i", state->getName().substr(0,20).c_str(),
                state->getKills(), state->getLosses(), state->getTotal(),
                state->getObjectivesHeld());
        drawStringShadowed(offset.x, offset.y, statBuf, Color::white, Color::gray64);
        
        flag = ResourceManager::getFlag(state->getFlag());
        drawImage( *flag, flagOffset.x, flagOffset.y );
		if ( state->getID() != PlayerInterface::getLocalPlayerIndex() )
		{
			bool meWithHim = PlayerInterface::isSingleAllied(PlayerInterface::getLocalPlayerIndex(), state->getID());
			bool himWithMe = PlayerInterface::isSingleAllied(state->getID(), PlayerInterface::getLocalPlayerIndex());
			if ( meWithHim && himWithMe )
			{
				drawImage( allyImage, 4, flagOffset.y );
			}
			else if ( meWithHim )
			{
				drawImage( allyRequestImage, 4, flagOffset.y );
			}
			else if ( himWithMe )
			{
				drawImage( allyOtherImage, 4, flagOffset.y );
			}
			else
			{
				drawImage( noAllyImage, 4, flagOffset.y );
			}
		}
		
        offset.y += entryHeight;
        flagOffset.y += entryHeight;        
    }

} // end RankView::drawPlayerStats