Ejemplo n.º 1
0
User& IBattle::OnUserAdded( User& user )
{
	UserList::AddUser( user );
	UserBattleStatus& bs = user.BattleStatus();
	bs.spectator = false;
	bs.ready = false;
	bs.sync = SYNC_UNKNOWN;
	if ( !bs.IsBot() && IsFounderMe() && GetBattleType() == BT_Played ) {
		bs.team = GetFreeTeam( &user == &GetMe() );
		bs.ally = GetFreeAlly( &user == &GetMe() );
		bs.colour = GetFreeColour( user );
	}
	if ( IsFounderMe() && ( ( bs.pos.x < 0 ) || ( bs.pos.y < 0 ) ) ) {
		UserPosition& pos = bs.pos;
		pos = GetFreePosition();
		UserPositionChanged( user );
	}
	if ( !bs.spectator ) {
		PlayerJoinedAlly( bs.ally );
		PlayerJoinedTeam( bs.team );
	}
	if ( bs.spectator && IsFounderMe() ) m_opts.spectators++;
	if ( !bs.spectator && !bs.IsBot() ) {
		if ( bs.ready ) m_players_ready++;
		if ( bs.sync) m_players_sync++;
		if ( !bs.ready || !bs.sync ) m_ready_up_map[user.GetNick()] = time(0);
		if ( bs.ready && bs.sync ) m_players_ok++;
	}
	return user;
}
Ejemplo n.º 2
0
void Battle::OnRequestBattleStatus()
{
    UserBattleStatus& bs = m_serv.GetMe().BattleStatus();
    bs.team = GetFreeTeam( true );
    bs.ally = GetFreeAlly( true );
    bs.spectator = false;
    bs.colour = sett().GetBattleLastColour();
    // theres some highly annoying bug with color changes on player join/leave.
    if ( !bs.colour.IsOk() ) bs.colour = GetFreeColour( GetMe() );

    SendMyBattleStatus();
}
bool NoGuiSinglePlayerBattle::AddBot( const wxString& name, int ai_team_id, const wxString& side )
{
    int ai_id = GetAiIndex( name );
    if ( ai_id > -1 ) {
        UserBattleStatus bs;
        bs.owner = GetMe().GetNick();
        bs.aishortname = name;
        bs.aitype = ai_id;
        bs.team = ai_team_id;
        bs.ally = GetFreeAlly();
        bs.colour = GetNewColour();
        bs.side = GetSideIndex( side );
        //first arg is nick
        User& bot = OnBotAdded( name + _T("_") + TowxString( bs.team ), bs  );
        return true;
    }
    return false;
}