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; }
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(); }
wxColour IBattle::GetNewColour() const { return GetFreeColour(); }
wxColour IBattle::GetFreeColour( User &for_whom ) const { return GetFreeColour( &for_whom ); }