Ejemplo n.º 1
0
 private MatchMaker(int dummy)
 {
     mutex             = new object();
     state             = State.NotQueued;
     match_player_decl = new MatchDecl();
     match_mode        = MatchMode.Skirmish; //Garbage
     aren_type         = Arena.None;         //Atleast an invalid value
     team_size         = TeamSize.One;       //Garbage
     arena             = null;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// If the return key == <see cref="State.AwaitingAccept"/> then the return value is the match finder used for queueing up.
        /// </summary>
        /// <returns></returns>
        public State AwaitingAccept(MatchDecl match)
        {
            State old;

            if (try_change_state(State.AwaitingAccept, State.Queued, out old))
            {
                match_player_decl = match;
                return(State.AwaitingAccept);
            }
            return(old);
        }
Ejemplo n.º 3
0
        protected bool PopQueueForPlayers(List <Player> left, List <Player> right)
        {
            var match_decl = new MatchDecl(left, right);

            foreach (var player in left.Concat(right))
            {
                if (!player.online)
                {
                    cancel_queue(left, right);
                    return(false);
                }
                var player_res = player.match_maker.AwaitingAccept(match_decl);

                switch (player_res)
                {
                case MatchMaker.State.AwaitingAccept:
                    break;     //Success

                default:
                    cancel_queue(left, right);
                    return(false);
                }
            }

            var ev = new QueueStateMsg
            {
                Authenticated = true,
                CurrentState  = QueueState.QueuePopped
            };

            foreach (var player in left.Concat(right))
            {
                player.stream_match_maker.Enqueue(ev);
            }

            return(true);
        }