public void StopGame(byte reason)
        {
            if (Node == null) return;

            for (int i = 0; i < Pets.Count; i++)
            {
                MonsterObject pet = Pets[i];

                if (pet.Info.AI == 64)//IntelligentCreature
                {
                    //dont save Creatures they will miss alot of AI-Info when they get spawned on login
                    UnSummonIntelligentCreature(((IntelligentCreatureObject)pet).petType, false);
                    continue;
                }

                pet.Master = null;

                if (!pet.Dead)
                {
                    try
                    {
                        Info.Pets.Add(new PetInfo(pet) { Time = Envir.Time });
                        pet.CurrentMap.RemoveObject(pet);
                        pet.Despawn();
                    }
                    catch
                    {
                        SMain.EnqueueDebugging(Name + " Pet logout was null on logout : " + pet != null ? pet.Name : "" + " " + pet.CurrentMap != null ? pet.CurrentMap.Info.FileName : "");
                    }
                }
            }
            Pets.Clear();
            //reset cast times to zero - in the future this should be saved and passed back to the client
            //cast time should remove the server time on logout, then add it back on login - this should make it only count down when in game
            //ignore if less than zero already
            //client should then add the existing client time to its value - this should keep the count down in sync with the new time
            for (int i = 0; i < Info.Magics.Count; i++)
            {
                Info.Magics[i].CastTime = 0;
            }

            if (MyGuild != null) MyGuild.PlayerLogged(this, false);
            Envir.Players.Remove(this);
            CurrentMap.RemoveObject(this);
            Despawn();

            if (GroupMembers != null)
            {
                GroupMembers.Remove(this);
                RemoveGroupBuff();

                if (GroupMembers.Count > 1)
                {
                    Packet p = new S.DeleteMember { Name = Name };

                    for (int i = 0; i < GroupMembers.Count; i++)
                        GroupMembers[i].Enqueue(p);
                }
                else
                {
                    GroupMembers[0].Enqueue(new S.DeleteGroup());
                    GroupMembers[0].GroupMembers = null;
                }
                GroupMembers = null;
            }

            for (int i = 0; i < Buffs.Count; i++)
            {
                Buff buff = Buffs[i];
                if (buff.Infinite) continue;
                if (buff.Type == BuffType.Curse) continue;

                buff.Caster = null;
                if (!buff.Paused) buff.ExpireTime -= Envir.Time;

                Info.Buffs.Add(buff);
            }
            Buffs.Clear();

            TradeCancel();
            RefineCancel();
            LogoutRelationship();
            LogoutMentor();

            string logReason = LogOutReason(reason);

            SMain.Enqueue(logReason);

            Fishing = false;

            Info.LastIP = Connection.IPAddress;
            Info.LastDate = Envir.Now;

            Report.Disconnected(logReason);
            Report.ForceSave();

            CleanUp();
        }
        public void DelMember(string name)
        {
            if (GroupMembers == null)
            {
                ReceiveChat("You are not in a group.", ChatType.System);
                return;
            }
            if (GroupMembers[0] != this)
            {
                ReceiveChat("You are not the group leader.", ChatType.System);
                return;
            }

            PlayerObject player = null;

            for (int i = 0; i < GroupMembers.Count; i++)
            {
                if (String.Compare(GroupMembers[i].Name, name, StringComparison.OrdinalIgnoreCase) != 0) continue;
                player = GroupMembers[i];
                break;
            }


            if (player == null)
            {
                ReceiveChat(name + " is not in your group.", ChatType.System);
                return;
            }

            player.RemoveGroupBuff();

            GroupMembers.Remove(player);
            player.Enqueue(new S.DeleteGroup());

            if (GroupMembers.Count > 1)
            {
                Packet p = new S.DeleteMember { Name = player.Name };

                for (int i = 0; i < GroupMembers.Count; i++)
                    GroupMembers[i].Enqueue(p);
            }
            else
            {
                GroupMembers[0].Enqueue(new S.DeleteGroup());
                GroupMembers[0].GroupMembers = null;
            }
            player.GroupMembers = null;
        }
        public void SwitchGroup(bool allow)
        {
            Enqueue(new S.SwitchGroup { AllowGroup = allow });

            if (AllowGroup == allow) return;
            AllowGroup = allow;

            if (AllowGroup || GroupMembers == null) return;

            RemoveGroupBuff();

            GroupMembers.Remove(this);
            Enqueue(new S.DeleteGroup());

            if (GroupMembers.Count > 1)
            {
                Packet p = new S.DeleteMember { Name = Name };

                for (int i = 0; i < GroupMembers.Count; i++)
                    GroupMembers[i].Enqueue(p);
            }
            else
            {
                GroupMembers[0].Enqueue(new S.DeleteGroup());
                GroupMembers[0].GroupMembers = null;
            }
            GroupMembers = null;
        }
Exemple #4
0
        public void StopGame()
        {
            if (Node == null) return;

            for (int i = 0; i < Pets.Count; i++)
            {
                MonsterObject pet = Pets[i];
                pet.Master = null;

                if (!pet.Dead)
                {
                    Info.Pets.Add(new PetInfo(pet));
                    pet.CurrentMap.RemoveObject(pet);
                    pet.Despawn();
                }
            }

            Pets.Clear();
            if (MyGuild != null) MyGuild.PlayerLogged(this, false);
            Envir.Players.Remove(this);
            CurrentMap.RemoveObject(this);
            Despawn();

            if (GroupMembers != null)
            {
                GroupMembers.Remove(this);

                if (GroupMembers.Count > 1)
                {
                    Packet p = new S.DeleteMember { Name = Name };

                    for (int i = 0; i < GroupMembers.Count; i++)
                        GroupMembers[i].Enqueue(p);
                }
                else
                {
                    GroupMembers[0].Enqueue(new S.DeleteGroup());
                    GroupMembers[0].GroupMembers = null;
                }
                GroupMembers = null;
            }

            SMain.Enqueue(string.Format("{0} Has logged out.", Name));

            Info.LastIP = Connection.IPAddress;
            Info.LastDate = Envir.Now;

            CleanUp();
        }
Exemple #5
0
        public void StopGame(byte reason)
        {
            if (Node == null) return;

            for (int i = 0; i < Pets.Count; i++)
            {
                MonsterObject pet = Pets[i];

                if (pet.Info.AI == 64)//IntelligentCreature
                {
                    //dont save Creatures they will miss alot of AI-Info when they get spawned on login
                    UnSummonIntelligentCreature(((IntelligentCreatureObject)Pets[i]).petType, false);
                    continue;
                }

                pet.Master = null;

                if (!pet.Dead)
                {
                    Info.Pets.Add(new PetInfo(pet) { Time = Envir.Time });
                    pet.CurrentMap.RemoveObject(pet);
                    pet.Despawn();
                }
            }
            Pets.Clear();

            for (int i = 0; i < Buffs.Count; i++ )
            {
                Buff buff = Buffs[i];
                if (buff.Infinite) continue;
                if (buff.Type == BuffType.Curse) continue;

                buff.Caster = null;
                buff.ExpireTime -= Envir.Time;

                Info.Buffs.Add(buff);
            }
            Buffs.Clear();

            if (MyGuild != null) MyGuild.PlayerLogged(this, false);
            Envir.Players.Remove(this);
            CurrentMap.RemoveObject(this);
            Despawn();

            if (GroupMembers != null)
            {
                GroupMembers.Remove(this);

                if (GroupMembers.Count > 1)
                {
                    Packet p = new S.DeleteMember { Name = Name };

                    for (int i = 0; i < GroupMembers.Count; i++)
                        GroupMembers[i].Enqueue(p);
                }
                else
                {
                    GroupMembers[0].Enqueue(new S.DeleteGroup());
                    GroupMembers[0].GroupMembers = null;
                }
                GroupMembers = null;
            }

            TradeCancel();

            string logReason = LogOutReason(reason);

            SMain.Enqueue(logReason);

            Fishing = false;

            Info.LastIP = Connection.IPAddress;
            Info.LastDate = Envir.Now;

            Report.Disconnected(logReason);
            Report.ForceSave();

            CleanUp();
        }
Exemple #6
0
 private static void DeleteMember(S.DeleteMember p) => gameManager.DeleteMemberFromGroup(p.Name);