예제 #1
0
        private List <MsgGroups> MergeQueries(List <List <MsgGroups> > sqResults, int windowSize)
        {
            var        result   = new List <MsgGroups>();
            int        _size    = sqResults.Count();
            List <int> curIndex = new List <int>();

            for (int i = 0; i < _size; i++)
            {
                curIndex.Add(0);
            }

            while (true)
            {
                bool can_end = true;

                var curAccomadtion = new List <MsgGroups>();

                for (int i = 0; i < _size; i++)
                {
                    var elem = sqResults[i][curIndex[i]];
                    curAccomadtion.Add(elem);
                }

                if (isCorrectAccomodation(curAccomadtion, windowSize))
                {
                    var current = new MsgGroups();
                    foreach (var group in curAccomadtion)
                    {
                        current.AddRange(group);
                    }

                    result.Add(current);
                }

                for (int i = _size - 1; i >= 0; i--)
                {
                    if (curIndex[i] < sqResults[i].Count - 1)
                    {
                        can_end = false;
                        curIndex[i]++;
                        for (int j = i + 1; j < _size; j++)
                        {
                            curIndex[j] = 0;
                        }

                        break;
                    }
                }


                if (can_end)
                {
                    break;
                }
            }


            return(result);
        }
예제 #2
0
        public override object VisitRestrictions([NotNull] ChatParser.RestrictionsContext context)
        {
            var rList = new MsgGroups();

            foreach (var r in context.restriction())
            {
                var newList = (List <int>)VisitRestriction(r);
                newList.Sort();
                rList.Add(newList);
            }

            return(rList);
        }
예제 #3
0
        private List <MsgGroups> OnlyRestrictionsToList(MsgGroups rList)
        {
            var result = new List <MsgGroups>();

            foreach (var r in rList)
            {
                result.Add(new MsgGroups {
                    r
                });
            }

            return(result);
        }
예제 #4
0
        private MsgGroups MergeRestrictions(MsgGroups rList, int windowSize)
        {
            int _size  = rList.Count;
            var result = new MsgGroups();

            if (_size == 1)
            {
                foreach (var r in rList[0])
                {
                    result.Add(new List <int> {
                        r
                    });
                }

                return(result);
            }


            for (int fstInd = 0; fstInd < rList[0].Count; fstInd++)
            {
                int        curPos  = rList[0][fstInd];
                int        fstPos  = rList[0][fstInd];
                List <int> curMsgs = new List <int> {
                    curPos
                };
                for (int i = 1; i < _size; i++)
                {
                    foreach (var _id in rList[i])
                    {
                        if (_id <= curPos)
                        {
                            continue;
                        }

                        if (_id - fstPos <= windowSize)
                        {
                            curMsgs.Add(_id);
                            curPos = _id;
                            break;
                        }
                    }
                }

                if (curMsgs.Count == _size)
                {
                    result.Add(curMsgs);
                }
            }

            return(result);
        }
예제 #5
0
        private static NetDeliveryMethod GetMethod(MsgGroups group)
        {
            switch (group)
            {
            case MsgGroups.Entity:
                return(NetDeliveryMethod.Unreliable);

            case MsgGroups.Core:
            case MsgGroups.String:
            case MsgGroups.Command:
                return(NetDeliveryMethod.ReliableUnordered);

            default:
                throw new ArgumentOutOfRangeException(nameof(group), group, null);
            }
        }
예제 #6
0
 /// <summary>
 /// Constructs an instance of the NetMessage.
 /// </summary>
 /// <param name="name">String identifier of the message type.</param>
 /// <param name="group">The group this message type belongs to.</param>
 protected NetMessage(string name, MsgGroups group)
 {
     MsgName  = name;
     MsgGroup = group;
 }
예제 #7
0
 /// <summary>
 /// Constructs an instance of the NetMessage.
 /// </summary>
 /// <param name="name">String identifier of the message type.</param>
 /// <param name="group">The group this message type belongs to.</param>
 /// <param name="id">Legacy enum ID for this message.</param>
 internal NetMessage(string name, MsgGroups group, NetMessages id)
 {
     MsgName  = name;
     MsgGroup = group;
     MsgId    = id;
 }
예제 #8
0
 /// <summary>
 /// Constructs an instance of the NetMessage.
 /// </summary>
 /// <param name="name">String identifier of the message type.</param>
 /// <param name="group">The group this message type belongs to.</param>
 internal NetMessage(string name, MsgGroups group)
 {
     MsgName  = name;
     MsgGroup = group;
 }