Beispiel #1
0
        public void Register(string mountName, IFileSystem fileSystem)
        {
            var accessor = new FileSystemAccessor(mountName, fileSystem, this);

            MountTable.Mount(accessor).ThrowIfFailure();

            accessor.IsAccessLogEnabled = IsEnabledAccessLog();
        }
Beispiel #2
0
        internal void EnableFileSystemAccessorAccessLog(U8Span mountName)
        {
            if (MountTable.Find(mountName.ToString(), out FileSystemAccessor accessor).IsFailure())
            {
                throw new LibHacException("abort");
            }

            accessor.IsAccessLogEnabled = true;
        }
Beispiel #3
0
        internal bool IsEnabledFileSystemAccessorAccessLog(string mountName)
        {
            if (MountTable.Find(mountName, out FileSystemAccessor accessor).IsFailure())
            {
                return(true);
            }

            return(accessor.IsAccessLogEnabled);
        }
Beispiel #4
0
        public static void Initialize()
        {
            nextPlayerGuid = CharacterTable.getNextGuid();
            nextPlayerGuid++;
            nextItemGuid = InventoryItemTable.getNextGuid();
            nextItemGuid++;
            nextGuildId = GuildTable.getNextGuid();
            nextGuildId++;
            nextMountId = MountTable.getNextGuid();
            nextMountId++;
            nextSpeakingId = SpeakingTable.getNextGuid();
            nextSpeakingId++;
            SpellTable.Load();
            ExpFloorTable.Load();
            MonsterTable.Load();
            ItemTemplateTable.Load();
            ItemTemplateTable.LoadItemActions();
            ItemSetTable.Load();
            DropTable.Load();
            TitleTable.Load();
            IObjectTemplateTable.Load();
            AreaTable.Load();
            AreaSubTable.Load();
            MapTable.Load();
            MapTable.LoadActions();
            CellActionTable.Load();
            MobGroupFixTable.Load();
            BreedTable.Load();
            NpcTemplateTable.Load();
            NpcTemplateTable.LoadPlaces();
            NpcQuestionTable.Load();
            NpcReplyTable.Load();
            ShopNpcTable.Initialize();
            GuildTable.Load();
            CharactersGuildTable.Load();
            TaxCollectorTable.Load();
            PrismeTable.Load();
            BidHouseTable.Load();
            BidHouseTable.LoadItems();
            MountParkTable.Load();
            StaticMountTable.Load();
            MountTable.Load();//TODO Dynamic load of Character mount
            ZaapTable.Load();
            ZaapiTable.Load();

            var Timer = new System.Timers.Timer(1000 * 60 * 25);

            Timer.Elapsed += delegate(object sender, ElapsedEventArgs e)
            {
                Save();
            };
            Timer.Start();
        }
Beispiel #5
0
        public int getTotalPod()
        {
            //int pod = 1000;
            int ability = 0;

            if (Ability.Contains(2))
            {
                ability = 20 * Level;
            }
            return(10 * Level + (100 * MountTable.getGeneration(Color) + ability));
            //return pod;
        }
Beispiel #6
0
 public Mount(int color)
 {
     ID           = DatabaseCache.nextMountId++;
     Color        = color;
     Level        = 1;
     Exp          = 0;
     Name         = "SansNom";
     Fatigue      = 0;
     Energy       = getMaxEnergie();
     Reproduction = 0;
     Maturite     = getMaxMatu();
     Serenite     = 0;
     myStats      = StaticMountTable.getMountStats(Color, Level);
     Ancestres    = ",,,,,,,,,,,,,";
     MountTable.Add(this);
     itemList = "";
 }
Beispiel #7
0
        public void Unmount(string mountName)
        {
            MountTable.Find(mountName, out FileSystemAccessor fileSystem).ThrowIfFailure();

            if (IsEnabledAccessLog() && fileSystem.IsAccessLogEnabled)
            {
                TimeSpan startTime = Time.GetCurrent();
                MountTable.Unmount(mountName);
                TimeSpan endTime = Time.GetCurrent();

                OutputAccessLog(startTime, endTime, $", name: \"{mountName}\"");
            }
            else
            {
                MountTable.Unmount(mountName);
            }
        }
Beispiel #8
0
        internal Result FindFileSystem(ReadOnlySpan <char> path, out FileSystemAccessor fileSystem, out ReadOnlySpan <char> subPath)
        {
            fileSystem = default;

            Result result = GetMountName(path, out ReadOnlySpan <char> mountName, out subPath);

            if (result.IsFailure())
            {
                return(result);
            }

            result = MountTable.Find(mountName.ToString(), out fileSystem);
            if (result.IsFailure())
            {
                return(result);
            }

            return(Result.Success);
        }
Beispiel #9
0
        private static void MountDescriptionRequest(WorldClient Client, string Packet)
        {
            int DDid = -1;

            try
            {
                DDid = int.Parse(Regex.Split(Packet.Substring(2), ("\\|"))[0]);
                //on ignore le temps?
            }
            catch (Exception e)
            {
            }
            if (DDid == -1)
            {
                return;
            }
            Mount DD = MountTable.getMount(DDid);

            if (DD == null)
            {
                return;
            }
            Client.Send(new MountDescriptionMessage(DD));
        }
Beispiel #10
0
        public Result Commit(U8Span mountName)
        {
            Result rc = MountTable.Find(mountName.ToString(), out FileSystemAccessor fileSystem);

            if (rc.IsFailure())
            {
                return(rc);
            }

            if (IsEnabledAccessLog() && fileSystem.IsAccessLogEnabled)
            {
                TimeSpan startTime = Time.GetCurrent();
                rc = fileSystem.Commit();
                TimeSpan endTime = Time.GetCurrent();

                OutputAccessLog(rc, startTime, endTime, $", name: \"{mountName.ToString()}\"");
            }
            else
            {
                rc = fileSystem.Commit();
            }

            return(rc);
        }
Beispiel #11
0
        private static void ProcessExchangeMountParkRequest(WorldClient Client, string Packet)
        {
            MountPark MP = Client.Character.inMountPark;

            if (MP != null)
            {
                char c = Packet[2];
                Packet = Packet.Substring(3);
                int guid = -1;
                try
                {
                    guid = int.Parse(Packet);
                }
                catch (Exception e)
                {
                };
                switch (c)
                {
                case 'C':    //Parcho => Etable (Stocker)
                    if (guid == -1 || !Client.Character.InventoryCache.hasItemGuid(guid))
                    {
                        return;
                    }
                    InventoryItemModel obj = Client.Character.InventoryCache.GetItem(guid);

                    //on prend la DD demandée
                    int   DDid = -1;
                    Mount DD   = null;
                    if (obj.GetStats().HasEffect(EffectEnum.MountOwner))
                    {
                        DDid = obj.GetStats().GetEffect(EffectEnum.MountOwner).Items;
                        DD   = MountTable.getMount(DDid);
                    }
                    //FIXME mettre return au if pour ne pas créer des nouvelles dindes
                    if (DD == null)
                    {
                        int color = StaticMountTable.getMountColorByParchoTemplate(obj.TemplateID);
                        if (color < 1)
                        {
                            return;
                        }
                        DD = new Mount(color);
                    }
                    DD.Intialize();

                    //On enleve l'Item du Monde et du Perso
                    Client.Character.InventoryCache.remove(guid);
                    InventoryItemTable.removeItem(guid);
                    //on ajoute la dinde a l'étable
                    Client.Account.Data.Mounts.Add(DD.ID, DD);
                    Client.Account.Data.Save();

                    //On envoie les Packet
                    Client.Send(new ObjectRemoveMessage(obj.ID));
                    Client.Send(new ExchangeEndMessage('+', DD.parse()));
                    break;

                case 'c':    //Etable => Parcho(Echanger)
                    Mount DD1 = MountTable.getMount(guid);
                    //S'il n'a pas la dinde
                    if (!Client.Account.Data.Mounts.ContainsKey(DD1.ID) || DD1 == null)
                    {
                        return;
                    }
                    //on retire la dinde de l'étable
                    Client.Account.Data.Mounts.Remove(DD1.ID);

                    GenericStats Stat = new GenericStats();
                    Stat.AddItem(EffectEnum.MountOwner, DD1.ID);
                    Stat.AddSpecialEffect(EffectEnum.MountOwnerName, Client.Character.Name);
                    Stat.AddSpecialEffect(EffectEnum.MountName, DD1.Name);

                    var item = InventoryItemTable.TryCreateItem(StaticMountTable.getMountScroll(DD1.get_color()).ID, Client.Character, 1, -1, Stat.ToItemStats());

                    Client.Send(new ExchangeEndMessage('-', DD1.ID + ""));
                    Stat = null;
                    break;

                case 'g':    //Equiper
                    Mount DD3 = MountTable.getMount(guid);
                    //S'il n'a pas la dinde
                    if (DD3 == null || !Client.Account.Data.Mounts.ContainsKey(DD3.ID) || Client.Character.Mount != null)
                    {
                        return;
                    }
                    DD3.Intialize();
                    Client.Account.Data.Mounts.Remove(DD3.ID);
                    Client.Account.Data.Save();
                    Client.Character.Mount = DD3;

                    //Packets
                    Client.Send(new CharacterRideEventMessage("+", DD3));
                    Client.Send(new ExchangeEndMessage('-', DD3.ID + ""));
                    Client.Send(new CharacterMountXpGive(Client.Character.MountXPGive));
                    break;

                case 'p':    //Equipé => Stocker
                    //Si c'est la dinde équipé
                    if (Client.Character.Mount != null ? Client.Character.Mount.ID == guid : false)
                    {
                        //Si le perso est sur la monture on le fait descendre
                        if (Client.Character.isOnMount())
                        {
                            Client.Character.toogleOnMount();
                        }
                        //Si ca n'a pas réussie, on s'arrete là (Items dans le sac ?)
                        if (Client.Character.isOnMount())
                        {
                            return;
                        }

                        Mount DD2 = Client.Character.Mount;
                        DD2.Intialize();
                        Client.Account.Data.Mounts.Add(DD2.ID, DD2);
                        Client.Account.Data.Save();
                        Client.Character.Mount = null;

                        //Packets
                        Client.Send(new ExchangeEndMessage('+', DD2.parse()));
                        Client.Send(new CharacterRideEventMessage("-", null));
                        Client.Send(new CharacterMountXpGive(Client.Character.MountXPGive));
                    }
                    else    //Sinon...
                    {
                    }
                    break;
                }
            }
            else
            {
                Client.Send(new BasicNoOperationMessage());
                return;
            }
        }
Beispiel #12
0
        public override bool MoveItem(Network.WorldClient Client, Database.Models.InventoryItemModel Item, ushort Quantity, bool Add = false)
        {
            if (Add)
            {
                if (Quantity > Item.Quantity)
                {
                    Quantity = (ushort)Item.Quantity;
                }

                InventoryItemModel ObjectEqualize = getSimilarItem(Item);
                int    newQua = Item.Quantity - Quantity;
                String str;

                if (ObjectEqualize == null)
                {
                    if (newQua <= 0)
                    {
                        Client.Character.InventoryCache.RemoveItem(Item);
                        Mount.Items.Add(Item);
                        str = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                        Client.Send(new ObjectRemoveMessage(Item.ID));
                    }
                    else
                    {
                        Client.Character.InventoryCache.UpdateObjectquantity(Item, newQua);
                        ObjectEqualize = InventoryItemTable.TryCreateItem(Item.TemplateID, Mount, Quantity, Stats: Item.Effects);
                        str            = "O+" + ObjectEqualize.ID + "|" + ObjectEqualize.Quantity + "|" + ObjectEqualize.TemplateID + "|" + ObjectEqualize.GetStats().ToItemStats();
                    }
                }
                else if (newQua <= 0)
                {
                    Client.Character.InventoryCache.RemoveItem(Item);
                    ObjectEqualize.Quantity += Item.Quantity;
                    InventoryItemTable.removeItem(Item.ID);
                    str = "O+" + ObjectEqualize.ID + "|" + ObjectEqualize.Quantity + "|" + ObjectEqualize.TemplateID + "|" + ObjectEqualize.GetStats().ToItemStats();
                    Client.Send(new ObjectRemoveMessage(Item.ID));
                    InventoryItemTable.Update(ObjectEqualize);
                }
                else
                {
                    Client.Character.InventoryCache.UpdateObjectquantity(Item, newQua);
                    ObjectEqualize.Quantity += Quantity;
                    str = "O+" + ObjectEqualize.ID + "|" + ObjectEqualize.Quantity + "|" + ObjectEqualize.TemplateID + "|" + ObjectEqualize.GetStats().ToItemStats();
                    InventoryItemTable.Update(ObjectEqualize);
                }
                Client.Send(new BankUpdateMessage(str));
                Client.Send(new InventoryWeightMessage(0, 2000)); // TODO PODS
                Client.Send(new MountActualPodMessage(Mount));
                MountTable.Update(Mount);
            }
            else
            {
                if (!Mount.Items.Contains(Item))
                {
                    return(false);
                }
                InventoryItemModel ObjectEqualize = Client.Character.InventoryCache.getSimilarInventoryItem(Item);
                int    newQua = Item.Quantity - Quantity;
                String str;

                if (ObjectEqualize == null)
                {
                    if (newQua <= 0)
                    {
                        Mount.Items.Remove(Item);
                        if (Client.Character.InventoryCache.TryMergeItem(Item.TemplateID, Item.GetStats().ToItemStats(), Item.Slot, Item.Quantity))
                        {
                            InventoryItemTable.removeItem(Item.ID);
                        }
                        else
                        {
                            Client.Character.InventoryCache.Add(Item);
                        }
                        str = "O-" + Item.ID;
                    }
                    else
                    {
                        ObjectEqualize = InventoryItemTable.TryCreateItem(Item.TemplateID, Client.Character, Quantity, Stats: Item.Effects);
                        Item.Quantity  = newQua;
                        str            = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    }
                }
                else if (newQua <= 0)
                {
                    Mount.Items.Remove(Item);
                    ObjectEqualize.Quantity += Item.Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    InventoryItemTable.removeItem(Item.ID);
                    str = "O-" + Item.ID;
                    InventoryItemTable.Update(ObjectEqualize);
                }
                else
                {
                    Item.Quantity            = newQua;
                    ObjectEqualize.Quantity += Quantity;
                    Client.Send(new ObjectQuantityMessage(ObjectEqualize.ID, ObjectEqualize.Quantity));
                    str = "O+" + Item.ID + "|" + Item.Quantity + "|" + Item.TemplateID + "|" + Item.GetStats().ToItemStats();
                    InventoryItemTable.Update(ObjectEqualize);
                }
                Client.Send(new BankUpdateMessage(str));
                Client.Send(new InventoryWeightMessage(0, 2000)); // TODO PODS
                Client.Send(new MountActualPodMessage(Mount));
                MountTable.Update(Mount);
            }
            return(true);
        }
Beispiel #13
0
 public void Initialize(FileSystemClient fsClient)
 {
     MountTable = new MountTable(fsClient);
 }
Beispiel #14
0
        private void Initialize()
        {
            this.myStats = new GenericStats(this);
            for (int i = 1; i < 16; i++)
            {
                var Item = this.InventoryCache.GetItemInSlot((ItemSlotEnum)i);

                if (Item != null)
                {
                    this.myStats.Merge(Item.GetStats());
                    this.Life += Item.GetStats().GetTotal(EffectEnum.AddVitalite);
                }
            }
            if (this.ZaapString != null)
            {
                foreach (String str in ZaapString.Split(','))
                {
                    short zaap;
                    if (!short.TryParse(str, out zaap))
                    {
                        continue;
                    }
                    try
                    {
                        Zaaps.Add(zaap);
                    }
                    catch (Exception e)
                    {
                        Logger.Error(e);
                    }
                }
            }
            else
            {
                if (Settings.AppSettings.GetBoolElement("World.AllZaap"))
                {
                    foreach (short map in ZaapTable.Cache.Keys)
                    {
                        this.Zaaps.Add(map);
                    }
                }
            }

            if (this.MountID != -1)
            {
                Mount = MountTable.getMount(this.MountID);
                if (Mount != null)
                {
                    Mount.Intialize();
                }
            }

            if (this.SpellString == null || this.SpellString == "")
            {
                this.mySpells = SpellBook.GenerateForBreed((ClassEnum)this.Classe);
                for (int i = 1; i < Client.GetCharacter().Level; i++)
                {
                    this.mySpells.GenerateLevelUpSpell((ClassEnum)Client.GetCharacter().Classe, i);
                }
                Client.Send(new BasicNoOperationMessage());
                Client.Send(new SpellsListMessage(Client.Character));
            }
            else
            {
                this.mySpells = SpellBook.FromDatabase(this.SpellString);
            }

            if (LifePer <= 0)
            {
                LifePer = 1;
            }

            Life = (MaxLife * LifePer / 100);
            if (Life == 0)
            {
                Life = 1;
            }
            _exPdv = Life;

            this.myInitialized = true;
        }
Beispiel #15
0
 public static void Update(Player character)
 {
     try
     {
         MySqlCommand Command = new MySqlCommand()
         {
             Connection  = DatabaseManager.RealmProvider.getConnection(),
             CommandText = "UPDATE characters SET owner = @owner,name = @name,level = @level,color1 = @color1,color2 = @color2,color3 = @color3,look = @look,sexe = @sexe,classe = @class,map = @map,cell = @CellId,restriction = @res,experience = @experience,kamas = @kamas,capital = @capital,spellboost = @spellboost,lifeper = @lifeper,energy = @energy,ap = @ap,mp = @mp,vitality = @vitality,wisdom = @wisdom,strength = @strength,intell = @intell,agility = @agility,chance = @chance,alignement = @align,honor = @h,deshonor = @ds, stuff= @stuff, spells = @spells, savepos = @spos, zaaps = @za, mount = @mount, mountxpgive = @mxp, wornitem = @witem, seeAlign = @hw, title = @ti, cote = @cote WHERE guid = @guid",
         };
         Command.Prepare();
         Command.Parameters.AddWithValue("@guid", character.ID);
         Command.Parameters.AddWithValue("@owner", character.Owner);
         Command.Parameters.AddWithValue("@name", character.Name);
         Command.Parameters.AddWithValue("@level", character.Level);
         Command.Parameters.AddWithValue("@color1", character.Color1);
         Command.Parameters.AddWithValue("@color2", character.Color2);
         Command.Parameters.AddWithValue("@color3", character.Color3);
         Command.Parameters.AddWithValue("@look", character.Look);
         Command.Parameters.AddWithValue("@sexe", character.Sexe);
         Command.Parameters.AddWithValue("@class", character.Classe);
         Command.Parameters.AddWithValue("@map", character.Map);
         Command.Parameters.AddWithValue("@CellId", character.CellId);
         Command.Parameters.AddWithValue("@res", character.Restriction);
         Command.Parameters.AddWithValue("@experience", character.Experience);
         Command.Parameters.AddWithValue("@kamas", character.Kamas);
         Command.Parameters.AddWithValue("@capital", character.CaractPoint);
         Command.Parameters.AddWithValue("@spellboost", character.SpellPoint);
         Command.Parameters.AddWithValue("@energy", character.Energy);
         Command.Parameters.AddWithValue("@lifeper", character.GetPDVper());
         Command.Parameters.AddWithValue("@ap", character.AP);
         Command.Parameters.AddWithValue("@mp", character.MP);
         Command.Parameters.AddWithValue("@vitality", character.Vitality);
         Command.Parameters.AddWithValue("@wisdom", character.Wisdom);
         Command.Parameters.AddWithValue("@strength", character.Strength);
         Command.Parameters.AddWithValue("@intell", character.Strength);
         Command.Parameters.AddWithValue("@agility", character.Agility);
         Command.Parameters.AddWithValue("@chance", character.Chance);
         Command.Parameters.AddWithValue("@align", character.Alignement);
         Command.Parameters.AddWithValue("@h", character.Honor);
         Command.Parameters.AddWithValue("@ds", character.Deshonor);
         Command.Parameters.AddWithValue("@stuff", character.parseItemsToDB());
         Command.Parameters.AddWithValue("@spells", character.GetSpellBook().ToDatabase());
         Command.Parameters.AddWithValue("@spos", character.SavePos);
         Command.Parameters.AddWithValue("@za", character.parseZaaps());
         Command.Parameters.AddWithValue("@mount", character.Mount != null ? character.Mount.ID : -1);
         Command.Parameters.AddWithValue("@mxp", character.MountXPGive);
         Command.Parameters.AddWithValue("@hw", character.showWings ? 1 : 0);
         Command.Parameters.AddWithValue("@ti", character.Title);
         Command.Parameters.AddWithValue("@cote", character.Cote);
         if (character.InventoryCache == null)
         {
             Command.Parameters.AddWithValue("@witem", ",,,,");
         }
         else
         {
             Command.Parameters.AddWithValue("@witem", character.InventoryCache.SerializeAsDisplayEquipment());
         }
         DatabaseManager.RealmProvider.ExecuteQuery(Command);
         if (character.InventoryCache != null)
         {
             InventoryItemTable.Update(character.InventoryCache);
         }
         if (character.getCharacterGuild() != null)
         {
             CharactersGuildTable.Add(character.getCharacterGuild());
         }
         if (character.Mount != null)
         {
             MountTable.Update(character.Mount);
         }
     }
     catch (System.InvalidOperationException e1)
     {
         DatabaseManager.RealmProvider.Restart();
         Update(character);
     }
     catch (Exception e)
     {
         Logger.Error(e.ToString());
     }
 }
Beispiel #16
0
 public void Initialize()
 {
     if (myInitialized)
     {
         return;
     }
     try
     {
         BHI = new Dictionary <int, List <BidHouseItem> >();
         if (!BidHouseTable.BHITEMS.ContainsKey(this.Guid))
         {
             BidHouseTable.BHITEMS.Add(Guid, new Dictionary <int, List <BidHouseItem> >());
         }
         BHI = BidHouseTable.BHITEMS[Guid];
         foreach (String s in Friends.Split(';'))
         {
             if (String.IsNullOrEmpty(s))
             {
                 continue;
             }
             FriendsList.Add(Convert.ToInt32(s.Split('|')[0]), s.Split('|')[1]);
         }
         foreach (String s in Ennemys.Split(';'))
         {
             if (String.IsNullOrEmpty(s))
             {
                 continue;
             }
             EnnemyList.Add(Convert.ToInt32(s.Split('|')[0]), s.Split('|')[1]);
         }
         foreach (String s in Bank.Split(';'))
         {
             if (String.IsNullOrEmpty(s))
             {
                 continue;
             }
             long id;
             if (!long.TryParse(s, out id))
             {
                 continue;
             }
             InventoryItemModel obj = InventoryItemTable.getItem(id);
             if (obj != null)
             {
                 bankItems.Add(id, obj);
             }
             else
             {
                 obj = InventoryItemTable.Load(id);
                 if (obj != null)
                 {
                     bankItems.Add(id, obj);
                 }
             }
         }
         foreach (String s in Stables.Split(';'))
         {
             if (String.IsNullOrEmpty(s))
             {
                 continue;
             }
             int id;
             if (!int.TryParse(s, out id))
             {
                 continue;
             }
             Mount DD = MountTable.getMount(id);
             if (DD != null)
             {
                 Mounts.Add(id, DD);
             }
         }
     }
     catch (Exception e)
     {
         Logger.Error(e);
     }
     myInitialized = true;
 }