Exemplo n.º 1
0
        void DoLocationChecks()
        {
            while (true)
            {
                Thread.Sleep(3);
                Player[] players = PlayerInfo.Online.Items;
                for (int i = 0; i < players.Length; i++)
                {
                    try {
                        Player p = players[i];

                        if (p.frozen)
                        {
                            p.SendPos(0xFF, p.pos[0], p.pos[1], p.pos[2], p.rot[0], p.rot[1]); continue;
                        }
                        else if (p.following != "")
                        {
                            Player who = PlayerInfo.FindExact(p.following);
                            if (who == null || who.level != p.level)
                            {
                                p.following = "";
                                if (!p.canBuild)
                                {
                                    p.canBuild = true;
                                }
                                if (who != null && who.possess == p.name)
                                {
                                    who.possess = "";
                                }
                                continue;
                            }

                            if (p.canBuild)
                            {
                                p.SendPos(0xFF, who.pos[0], (ushort)(who.pos[1] - 16), who.pos[2], who.rot[0], who.rot[1]);
                            }
                            else
                            {
                                p.SendPos(0xFF, who.pos[0], who.pos[1], who.pos[2], who.rot[0], who.rot[1]);
                            }
                        }
                        else if (p.possess != "")
                        {
                            Player who = PlayerInfo.Find(p.possess);
                            if (who == null || who.level != p.level)
                            {
                                p.possess = "";
                            }
                        }

                        ushort x = (ushort)(p.pos[0] / 32);
                        ushort y = (ushort)(p.pos[1] / 32);
                        ushort z = (ushort)(p.pos[2] / 32);

                        if (p.level.Death)
                        {
                            p.CheckSurvival(x, y, z);
                        }
                        p.CheckBlock(x, y, z);
                        p.oldIndex = p.level.PosToInt(x, y, z);
                    } catch (Exception e) {
                        Server.ErrorLog(e);
                    }
                }
            }
        }