Beispiel #1
0
        public void Loaded(NetExecutorSnapper snapper, byte inputIndex)
        {
            Snapper    = snapper;
            InputIndex = inputIndex;

            if (snapper.Server.IsHost)
            {
                ServerInputs          = new T[2][];
                ServerInputTimestamps = new ushort[2][];
                ServerInputTickMS     = new float[2][];
                ServerInputStart      = new int[2];
                ServerInputCount      = new int[2];

                for (int i = 0; i < ServerInputs.Length; i++)
                {
                    ServerInputs[i]          = new T[32];
                    ServerInputTimestamps[i] = new ushort[32];
                    ServerInputTickMS[i]     = new float[32];
                }
            }
            else
            {
                ClientInputs          = new T[32];
                ClientInputTimestamps = new ushort[32];
                ClientInputTickMS     = new float[32];
            }
        }
Beispiel #2
0
        public void Loaded(NetExecutorSnapper snapper)
        {
            NetSnapper = snapper;
            Server     = NetSnapper.Server;

            // pass the loaded event to our logicians
            Logician.Loaded(snapper);
        }
Beispiel #3
0
        public SnapBasic2dEnvironment(int clientCount)
        {
            Tenv = TestEnvironment.AutoConnected(clientCount,
                                                 (serv) =>
            {
                NetExecutorSnapper netSnap = new NetExecutorSnapper();
                NetSnappers.Add(netSnap);
                serv.AddExecutor(netSnap);

                SnapInputManager <InputBasic2d, InputPackerBasic2d> input =
                    InputManagerBasic2d.Make();
                netSnap.AddInputManager(input);
                Inputs.Add(input);

                Snapper <NentBasic2d, NentStaticBasic2d, PackerBasic2d, PackInfoBasic2d> nent =
                    SnapperBasic2d.Make();
                netSnap.AddSnapper(nent);
                Nents.Add(nent);

                SimulatorBasic2d sim = new SimulatorBasic2d(input, nent, new AdvancerConfigBasic2d());
                netSnap.LoadSimulator(sim);
                Sims.Add(sim);
            });
        }
Beispiel #4
0
 // Register Commands
 public void Register(NetExecutorSnapper netSnapper, byte etype)
 {
     NetSnapper = netSnapper;
     EntityType = etype;
 }
Beispiel #5
0
        private void RepeatTestLogic(int clients, int amount, int runs)
        {
            SnapBasic2dEnvironment senv = new SnapBasic2dEnvironment(clients);

            senv.Activate();
            senv.FastTick();

            // have the server ghost some new entities
            List <byte> eids = new List <byte>();

            for (int i = 0; i < amount; i++)
            {
                senv.AddEntityFirst(new NentBasic2d()
                {
                    X    = 10f + i,
                    Y    = 5f + i,
                    XVel = 3f
                },
                                    new NentStaticBasic2d()
                {
                    Id1 = 0,
                    Id2 = 0
                }, out byte eid);

                eids.Add(eid);
            }

            ushort timeAdded = senv.NetSnappers[0].CurrentTime;

            senv.FastTick();

            ushort nextTimeChecked = 0;
            ushort timeChecked     = senv.NetSnappers[0].CurrentTime;
            Snapper <NentBasic2d, NentStaticBasic2d, PackerBasic2d, PackInfoBasic2d> checkNent =
                senv.Nents[0];

            for (int r = 0; r < runs; r++)
            {
                nextTimeChecked = senv.NetSnappers[0].CurrentTime;
                senv.FastTick(); // allow extra time to be sure the clients
                                 // have these timestamps

                // verify that the client has the entities
                for (int c = 1; c < senv.NetSnappers.Count; c++)
                {
                    NetExecutorSnapper ns = senv.NetSnappers[c];
                    Snapper <NentBasic2d, NentStaticBasic2d, PackerBasic2d, PackInfoBasic2d> nent = senv.Nents[c];

                    for (int i = 0; i < eids.Count; i++)
                    {
                        byte eid = eids[i];

                        // pull the entity from the source so we can compare
                        SnapHistory <NentBasic2d, NentStaticBasic2d> checkH = checkNent.GetFirstEntity(eid);
                        Assert.AreNotEqual(null, checkH);

                        // does this ent exist?
                        SnapHistory <NentBasic2d, NentStaticBasic2d> h = nent.GetFirstEntity(eid);
                        Assert.AreNotEqual(null, h);

                        // do we have snapshots for the latest timestamp?
                        int checkIndex = h.FindIndex(timeChecked);
                        Assert.IsTrue(checkIndex != -1);
                        int checkAgainstIndex = checkH.FindIndex(timeChecked);
                        Assert.IsTrue(checkAgainstIndex != -1);

                        // are the values in it correct?
                        Assert.AreEqual(checkH.Shots[checkAgainstIndex].X, h.Shots[checkIndex].X);
                        Assert.AreEqual(5f + i, h.Shots[checkIndex].Y);
                        Assert.AreEqual(3f, h.Shots[checkIndex].XVel);
                    }
                }

                timeChecked = nextTimeChecked;
            }
        }
Beispiel #6
0
 public void Loaded(NetExecutorSnapper snapper)
 {
     NetSnapper = snapper;
     Server = NetSnapper.Server;
 }