Ejemplo n.º 1
0
 public Vote(VoteEvent myVoteEvent, Voter v, int uid)
 {
     this.v = v;
     this.c = myVoteEvent.GetCandidateByUid(uid);
     if (this.c == null)
     {
         Log myLog = new Log("The Candidate is null");
         LogStore.LogList.Add(myLog);
     }
 }
        public IGameEvent ReadGameEvent(IBitStream stream, bool useOld = false)
        {
            uint eventId = 0;
            int  v3      = 127;//adjust value depending on game, 127 is for bf2 and bf2142
            int  v4      = 0;

            do
            {
                ++v4;
            }while (v3 > (1 << v4) - 1);//if the event amount defined above is 127 then the result will be 7, meaning we read 7 bits and those 7 bits are the event id
            eventId = stream.ReadBits((uint)v4);
            IGameEvent eventInstance;

            if (!useOld)
            {
                eventInstance = Config.EventRegistry.Trigger(eventId, stream);//dont use in development
            }
            else
            #region old
            {
                if (eventId == 1)
                {
                    eventInstance = new ChallengeEvent().DeSerialize(stream);
                }
                else if (eventId == 2)
                {
                    eventInstance = new ChallengeResponseEvent().DeSerialize(stream);
                }
                else if (eventId == 3)
                {
                    eventInstance = new ConnectionTypeEvent().DeSerialize(stream);
                }
                else if (eventId == 4)
                {
                    eventInstance = new DataBlockEvent().DeSerialize(stream);
                }
                else if (eventId == 5)
                {
                    eventInstance = new CreatePlayerEvent().DeSerialize(stream);
                }
                else if (eventId == 6)
                {
                    eventInstance = new CreateObjectEvent().DeSerialize(stream);
                }
                else if (eventId == 8)
                {
                    eventInstance = new DestroyObjectEvent().DeSerialize(stream);
                }
                else if (eventId == 11)
                {
                    eventInstance = new PostRemoteEvent().DeSerialize(stream);
                }
                else if (eventId == 16)
                {
                    eventInstance = new StringBlockEvent().DeSerialize(stream);
                }
                else if (eventId == 31)
                {
                    eventInstance = new CreateKitEvent().DeSerialize(stream);
                }
                else if (eventId == 35) //voip event
                {
                    stream.ReadBits(9); //just read so we can skip
                    eventInstance = null;
                }
                else if (eventId == 39)
                {
                    eventInstance = new VoteEvent().DeSerialize(stream);
                }
                else if (eventId == 42)
                {
                    eventInstance = new UnlockEvent().DeSerialize(stream);
                }
                else if (eventId == 46)
                {
                    eventInstance = new ContentCheckEvent().DeSerialize(stream);
                }
                else if (eventId == 50)
                {
                    eventInstance = null;
                }
                else if (eventId == 54)    //voip event, we dont care
                {
                    stream.ReadBits(0x10); //just read so we can skip
                    eventInstance = null;
                }
                else if (eventId == 56)
                {
                    eventInstance = new BeginRoundEvent().DeSerialize(stream);
                }
                else if (eventId == 57)
                {
                    eventInstance = new CreateSpawnGroupEvent().DeSerialize(stream);
                }
                else
                {
                    eventInstance = null;
                }
            }
            #endregion
            return(eventInstance);
        }