示例#1
0
        public void LoadInfo(bool clear = false)
        {
            if (clear)
            {
                ClearInfo();
            }

            if (!Directory.Exists(Settings.NPCPath))
            {
                return;
            }

            string fileName = Path.Combine(Settings.NPCPath, Info.FileName + ".txt");

            if (File.Exists(fileName))
            {
                List <string> lines = File.ReadAllLines(fileName).ToList();

                lines = ParseInsert(lines);

                if (Info.IsDefault)
                {
                    ParseDefault(lines);
                }
                else
                {
                    ParseScript(lines);
                }
            }
            else
            {
                SMain.Enqueue(string.Format("File Not Found: {0}, NPC: {1}", Info.FileName, Info.Name));
            }
        }
示例#2
0
        public void ParseBuffReward(List <BuffReward> list, string line)
        {
            if (line.Length < 3)
            {
                return;
            }

            string[] split = line.Split(' ');


            if (!Enum.TryParse(split[0], out BuffType buff))
            {
                SMain.Enqueue("wrong buff " + split[0]);
                return;
            }
            int.TryParse(split[1], out int count);
            long.TryParse(split[2], out long time);

            BuffReward br = new BuffReward()
            {
                buff   = buff,
                amount = count,
                time   = time,
            };

            list.Add(br);
        }
示例#3
0
        public void LoadInfo(bool clear = false)
        {
            if (clear)
            {
                ClearInfo();
            }

            if (!Directory.Exists(Settings.QuestPath))
            {
                return;
            }

            string fileName = Path.Combine(Settings.QuestPath, FileName + ".txt");

            if (File.Exists(fileName))
            {
                List <string> lines = File.ReadAllLines(fileName).ToList();

                ParseFile(lines);
            }
            else
            {
                SMain.Enqueue(string.Format("File Not Found: {0}, Quest: {1}", fileName, Name));
            }
        }
示例#4
0
        private bool OpenConnection()
        {
            try
            {
                string server   = Settings.ServerIP;
                string uid      = Settings.Uid;
                string password = Settings.Pwd;
                string connectionString;
                connectionString = "SERVER=" + server + ";" + "UID=" + uid + ";" + "PASSWORD="******"; convert zero datetime=True";
                connection       = new MySqlConnection(connectionString);
                connection.Open();
                return(true);
            }
            catch (MySqlException ex)
            {
                switch (ex.Number)
                {
                case 0:
                    SMain.Enqueue("Cannot connect to server.");
                    break;

                case 1045:
                    SMain.Enqueue("Invalid username/password");
                    break;

                default:
                    SMain.Enqueue(ex);
                    break;
                }
                return(false);
            }
        }
示例#5
0
        private void ClientVersion(C.ClientVersion p)
        {
            if (Stage != GameStage.None)
            {
                return;
            }

            if (Settings.CheckVersion)
            {
                if (!Functions.CompareBytes(Settings.VersionHash, p.VersionHash))
                {
                    Disconnecting = true;

                    List <byte> data = new List <byte>();

                    data.AddRange(new S.ClientVersion {
                        Result = 0
                    }.GetPacketBytes());

                    BeginSend(data);
                    SoftDisconnect(10);
                    SMain.Enqueue(SessionID + ", Disconnnected - Wrong Client Version.");
                    return;
                }
            }
            Enqueue(new S.ClientVersion {
                Result = 1
            });
            Stage = GameStage.Login;
        }
示例#6
0
        public void LoadDrops()
        {
            try
            {
                Drops.Clear();
                var pathArray = Directory.GetFiles(Settings.DropPath, Name + ".txt", SearchOption.AllDirectories);

                string path = string.Empty;
                if (pathArray.Length > 0)
                {
                    path = pathArray[0];
                }

                if (!File.Exists(path))
                {
                    return;
                }

                string[] lines = File.ReadAllLines(path);

                for (int i = 0; i < lines.Length; i++)
                {
                    if (lines[i].StartsWith(";") || string.IsNullOrWhiteSpace(lines[i]))
                    {
                        continue;
                    }

                    DropInfo drop = DropInfo.FromLine(lines[i], Name);
                    if (drop == null)
                    {
                        SMain.Enqueue(string.Format("Could not load Drop: {0}, Line {1}", Name, lines[i]));
                        continue;
                    }

                    Drops.Add(drop);
                }

                Drops.Sort((drop1, drop2) =>
                {
                    if (drop1.Gold > 0 && drop2.Gold == 0)
                    {
                        return(1);
                    }
                    if (drop1.Gold == 0 && drop2.Gold > 0)
                    {
                        return(-1);
                    }
                    if (drop1.Gold > 0 && drop2.Gold > 0)
                    {
                        return(drop1.Gold > drop2.Gold ? 1 : -1);
                    }

                    return(drop1.Item.Type.CompareTo(drop2.Item.Type));
                });
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#7
0
        public void LoadDrops()
        {
            Drops.Clear();
            string path = Path.Combine(Settings.DropPath, Name + ".txt");

            if (!File.Exists(path))
            {
                string[] contents = new[]
                {
                    ";Pots + Other", string.Empty, string.Empty,
                    ";Weapons", string.Empty, string.Empty,
                    ";Armour", string.Empty, string.Empty,
                    ";Helmets", string.Empty, string.Empty,
                    ";Necklace", string.Empty, string.Empty,
                    ";Bracelets", string.Empty, string.Empty,
                    ";Rings", string.Empty, string.Empty,
                    ";Shoes", string.Empty, string.Empty,
                    ";Belts", string.Empty, string.Empty,
                    ";Stone",
                };

                File.WriteAllLines(path, contents);


                return;
            }

            string[] lines = File.ReadAllLines(path);

            for (int i = 0; i < lines.Length; i++)
            {
                if (lines[i].StartsWith(";") || string.IsNullOrWhiteSpace(lines[i]))
                {
                    continue;
                }

                DropInfo drop = DropInfo.FromLine(lines[i]);
                if (drop == null)
                {
                    SMain.Enqueue(string.Format("Could not load Drop: {0}, Line {1}", Name, lines[i]));
                    continue;
                }

                Drops.Add(drop);
            }

            Drops.Sort((drop1, drop2) =>
            {
                if (drop1.Gold > 0 && drop2.Gold == 0)
                {
                    return(1);
                }
                if (drop1.Gold == 0 && drop2.Gold > 0)
                {
                    return(-1);
                }

                return(drop1.Item.Type.CompareTo(drop2.Item.Type));
            });
        }
示例#8
0
        public static void SaveNPCInfoDB(NPCInfo InfoNPCList)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();
                string sqlCommand;
                string query = "SELECT COUNT(*) FROM  " + Settings.DBServer + ".npcinfo WHERE IndexID = " + InfoNPCList.Index;
                using (var cmd = new MySqlCommand(query, connection))
                {
                    int count = Convert.ToInt32(cmd.ExecuteScalar());

                    if (count == 0)
                    {
                        sqlCommand = "INSERT INTO  " + Settings.DBServer + ".npcinfo (MapIndex, IndexID, FileName, Name, Location_X, Location_Y, Rate, Image, HourStart, MinuteStart, HourEnd, MinuteEnd, TimeVisible, IsDefault, MinLev, MaxLev, DayofWeek, ClassRequired, Conquest, FlagNeeded) VALUES (@MapIndex, @IndexID, @FileName, @Name, @Location_X, @Location_Y, @Rate, @Image, @HourStart, @MinuteStart, @HourEnd, @MinuteEnd, @TimeVisible, @IsDefault, @MinLev, @MaxLev, @DayofWeek, @ClassRequired, @Conquest, @FlagNeeded)";
                    }
                    else
                    {
                        sqlCommand = "UPDATE  " + Settings.DBServer + ".npcinfo SET MapIndex = @MapIndex, FileName = @FileName, IndexID = @IndexID, Name = @Name, Location_X = @Location_X, Location_Y = @Location_Y, Rate = @Rate, Image = @Image,  HourStart = @HourStart, MinuteStart = @MinuteStart, HourEnd = @HourEnd, MinuteEnd = @MinuteEnd, TimeVisible = @TimeVisible, IsDefault = @IsDefault, MinLev = @MinLev, MaxLev = @MaxLev,  DayofWeek = @DayofWeek, ClassRequired = @ClassRequired, Conquest = @Conquest, FlagNeeded = @FlagNeeded WHERE IndexID = " + InfoNPCList.Index;
                    }
                }

                using (var command = new MySqlCommand(sqlCommand, connection))
                {
                    command.Parameters.AddWithValue("@MapIndex", InfoNPCList.MapIndex);
                    command.Parameters.AddWithValue("@FileName", InfoNPCList.FileName);
                    command.Parameters.AddWithValue("@IndexID", InfoNPCList.Index);
                    command.Parameters.AddWithValue("@Name", InfoNPCList.Name);
                    command.Parameters.AddWithValue("@Location_X", InfoNPCList.Location.X);
                    command.Parameters.AddWithValue("@Location_Y", InfoNPCList.Location.Y);
                    command.Parameters.AddWithValue("@Rate", InfoNPCList.Rate);
                    command.Parameters.AddWithValue("@Image", InfoNPCList.Image);
                    command.Parameters.AddWithValue("@HourStart", InfoNPCList.HourStart);
                    command.Parameters.AddWithValue("@MinuteStart", InfoNPCList.MinuteStart);
                    command.Parameters.AddWithValue("@HourEnd", InfoNPCList.HourEnd);
                    command.Parameters.AddWithValue("@MinuteEnd", InfoNPCList.MinuteEnd);
                    command.Parameters.AddWithValue("@TimeVisible", InfoNPCList.TimeVisible);
                    command.Parameters.AddWithValue("@IsDefault", InfoNPCList.IsDefault);
                    command.Parameters.AddWithValue("@MinLev", InfoNPCList.MinLev);
                    command.Parameters.AddWithValue("@MaxLev", InfoNPCList.MaxLev);
                    command.Parameters.AddWithValue("@DayofWeek", InfoNPCList.DayofWeek);
                    command.Parameters.AddWithValue("@ClassRequired", InfoNPCList.ClassRequired);
                    command.Parameters.AddWithValue("@Conquest", InfoNPCList.Conquest);
                    command.Parameters.AddWithValue("@FlagNeeded", InfoNPCList.FlagNeeded);

                    command.ExecuteNonQuery();
                    command.Dispose();
                }

                connection.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#9
0
        public static void SaveMagicInfoDB(MagicInfo info)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();
                string sqlCommand;
                string queryy = "SELECT COUNT(*) FROM " + Settings.DBServer + ".magicinfo WHERE Spell = '" + Convert.ToInt32(info.Spell) + "'";

                using (var cmdd = new MySqlCommand(queryy, connection))
                {
                    int countt = Convert.ToInt32(cmdd.ExecuteScalar());
                    if (countt == 0)
                    {
                        sqlCommand = "INSERT INTO  " + Settings.DBServer + ".magicinfo (Name, Spell, BaseCost, LevelCost, Icon, Level1,Level2, Level3, Need1, Need2, Need3, DelayBase, DelayReduction, PowerBase, PowerBonus, MPowerBase, MPowerBonus, MultiplierBase, MultiplierBonus, Range_) VALUES (@Name, @Spell, @BaseCost, @LevelCost, @Icon, @Level1, @Level2, @Level3, @Need1, @Need2, @Need3, @DelayBase, @DelayReduction, @PowerBase, @PowerBonus, @MPowerBase, @MPowerBonus,@MultiplierBase, @MultiplierBonus, @Range_)";
                    }
                    else
                    {
                        sqlCommand = "UPDATE  " + Settings.DBServer + ".magicinfo SET Spell = @Spell, BaseCost = @BaseCost, LevelCost = @LevelCost, Icon = @Icon, Level1 = @Level1, Level2 = @Level2, Level3 = @Level3, Need1 = @Need1, Need2 = @Need2, Need3 = @Need3, DelayBase = @DelayBase, DelayReduction = @DelayReduction, PowerBase = @PowerBase, PowerBonus = @PowerBonus, MPowerBase = @MPowerBase, MPowerBonus = @MPowerBonus, MultiplierBase = @MultiplierBase, MultiplierBonus = @MultiplierBonus, Range_ = @Range_, Name = @Name WHERE Spell = '" + Convert.ToInt32(info.Spell) + "'";
                    }

                    using (var Update = new MySqlCommand(sqlCommand, connection))
                    {
                        Update.Parameters.AddWithValue("@Need2", info.Need2);
                        Update.Parameters.AddWithValue("@Name", info.Name);
                        Update.Parameters.AddWithValue("@Level2", info.Level2);
                        Update.Parameters.AddWithValue("@Need3", info.Need3);
                        Update.Parameters.AddWithValue("@Need1", info.Need1);
                        Update.Parameters.AddWithValue("@Range_", info.Range);
                        Update.Parameters.AddWithValue("@DelayReduction", info.DelayReduction);
                        Update.Parameters.AddWithValue("@MultiplierBonus", info.MultiplierBonus);
                        Update.Parameters.AddWithValue("@PowerBonus", info.PowerBonus);
                        Update.Parameters.AddWithValue("@MultiplierBase", info.MultiplierBase);
                        Update.Parameters.AddWithValue("@PowerBase", info.PowerBase);
                        Update.Parameters.AddWithValue("@MPowerBase", info.MPowerBase);
                        Update.Parameters.AddWithValue("@MPowerBonus", info.MPowerBonus);
                        Update.Parameters.AddWithValue("@Spell", info.Spell);
                        Update.Parameters.AddWithValue("@BaseCost", info.BaseCost);
                        Update.Parameters.AddWithValue("@DelayBase", info.DelayBase);
                        Update.Parameters.AddWithValue("@LevelCost", info.LevelCost);
                        Update.Parameters.AddWithValue("@Level3", info.Level3);
                        Update.Parameters.AddWithValue("@Level1", info.Level1);
                        Update.Parameters.AddWithValue("@Icon", info.Icon);

                        Update.ExecuteNonQuery();
                        Update.Dispose();
                    }
                }

                connection.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#10
0
 public static void End()
 {
     SMain.Enqueue(String.Join("MapInfo Import Report:", errors.Count > 0 ? "" : "No Errors"));
     foreach (String error in errors)
     {
         SMain.Enqueue(error);
     }
 }
示例#11
0
        public static void SaveQuestDB(QuestInfo info)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();
                string sqlCommand;
                string query = "SELECT COUNT(*) FROM  " + Settings.DBServer + ".questinfo WHERE IndexID=" + info.Index;
                using (var cmd = new MySqlCommand(query, connection))
                {
                    int count = Convert.ToInt32(cmd.ExecuteScalar());

                    if (count == 0)
                    {
                        sqlCommand = "INSERT INTO  " + Settings.DBServer + ".questinfo (IndexID, Name, Group_, FileName, RequiredMinLevel, RequiredMaxLevel, RequiredQuest, RequiredClass, Type, GotoMessage, KillMessage, ItemMessage, FlagMessage) VALUES (@IndexID, @Name, @Group_, @FileName, @RequiredMinLevel, @RequiredMaxLevel, @RequiredQuest, @RequiredClass, @Type, @GotoMessage, @KillMessage, @ItemMessage, @FlagMessage)";
                    }

                    else
                    {
                        sqlCommand = "UPDATE  " + Settings.DBServer + ".questinfo SET IndexID = @IndexID, Name = @Name, Group_ = @Group_, FileName = @FileName, RequiredMinLevel = @RequiredMinLevel, RequiredMaxLevel = @RequiredMaxLevel, RequiredQuest = @RequiredQuest, RequiredClass = @RequiredClass,Type = @Type, GotoMessage = @GotoMessage, KillMessage = @KillMessage, ItemMessage = @ItemMessage, FlagMessage = @FlagMessage  WHERE IndexID = " + info.Index + "";
                    }
                }

                using (var command = new MySqlCommand(sqlCommand, connection))
                {
                    command.Parameters.AddWithValue("@IndexID", info.Index);
                    command.Parameters.AddWithValue("@Name", info.Name);
                    command.Parameters.AddWithValue("@Group_", info.Group);
                    command.Parameters.AddWithValue("@FileName", info.FileName);
                    command.Parameters.AddWithValue("@RequiredMinLevel", info.RequiredMinLevel);
                    command.Parameters.AddWithValue("@RequiredMaxLevel", info.RequiredMaxLevel);
                    command.Parameters.AddWithValue("@RequiredQuest", info.RequiredQuest);
                    command.Parameters.AddWithValue("@RequiredClass", info.RequiredClass);
                    command.Parameters.AddWithValue("@Type", info.Type);
                    command.Parameters.AddWithValue("@GotoMessage", info.GotoMessage);
                    command.Parameters.AddWithValue("@KillMessage", info.KillMessage);
                    command.Parameters.AddWithValue("@ItemMessage", info.ItemMessage);
                    command.Parameters.AddWithValue("@FlagMessage", info.FlagMessage);
                    command.ExecuteNonQuery();
                    command.Dispose();
                }

                connection.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#12
0
 private bool CloseConnection()
 {
     try
     {
         connection.Close();
         return(true);
     }
     catch (MySqlException ex)
     {
         SMain.Enqueue(ex);
         return(false);
     }
 }
示例#13
0
        public RecipeInfo(string name)
        {
            ItemInfo itemInfo = SMain.Envir.GetItemInfo(name);

            if (itemInfo == null)
            {
                SMain.Enqueue(string.Format("Could not find Item: {0}", name));
                return;
            }

            Item = SMain.Envir.CreateShopItem(itemInfo);

            LoadIngredients(name);
        }
示例#14
0
        public void SaveProgressAccountsDB(List <AccountInfo> AccountListDB)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();

                for (int i = 0; i < AccountListDB.Count; i++)
                {
                    string sqlCommand = "INSERT INTO  " + Settings.DBAccount + ".account (AccountID, Password, UserName, BirthDate, SecretQuestion, SecretAnswer, EMailAddress, CreationIP, CreationDate, Banned, BanReason, ExpiryDate, WrongPasswordCount, LastIP, LastDate, Gold, Credit, AdminAccount) VALUES (@AccountID, @Password, @UserName, @BirthDate, @SecretQuestion, @SecretAnswer, @EMailAddress, @CreationIP, @CreationDate, @Banned, @BanReason, @ExpiryDate, @WrongPasswordCount, @LastIP, @LastDate, @Gold, @Credit, @AdminAccount)";


                    using (var command = new MySqlCommand(sqlCommand, connection))
                    {
                        command.Parameters.AddWithValue("@AccountID", AccountListDB[i].AccountID);
                        command.Parameters.AddWithValue("@Password", AccountListDB[i].Password);
                        command.Parameters.AddWithValue("@UserName", AccountListDB[i].UserName);
                        command.Parameters.AddWithValue("@BirthDate", AccountListDB[i].BirthDate);
                        command.Parameters.AddWithValue("@SecretQuestion", AccountListDB[i].SecretQuestion);
                        command.Parameters.AddWithValue("@SecretAnswer", AccountListDB[i].SecretAnswer);
                        command.Parameters.AddWithValue("@EMailAddress", AccountListDB[i].EMailAddress);
                        command.Parameters.AddWithValue("@CreationIP", AccountListDB[i].CreationIP);
                        command.Parameters.AddWithValue("@CreationDate", AccountListDB[i].CreationDate);
                        command.Parameters.AddWithValue("@Banned", AccountListDB[i].Banned);
                        command.Parameters.AddWithValue("@BanReason", AccountListDB[i].BanReason);
                        command.Parameters.AddWithValue("@ExpiryDate", AccountListDB[i].ExpiryDate);
                        command.Parameters.AddWithValue("@WrongPasswordCount", AccountListDB[i].WrongPasswordCount);
                        command.Parameters.AddWithValue("@LastIP", AccountListDB[i].LastIP);
                        command.Parameters.AddWithValue("@LastDate", AccountListDB[i].LastDate);
                        command.Parameters.AddWithValue("@Gold", AccountListDB[i].Gold);
                        command.Parameters.AddWithValue("@Credit", AccountListDB[i].Credit);
                        command.Parameters.AddWithValue("@AdminAccount", AccountListDB[i].AdminAccount);

                        command.ExecuteNonQuery();
                        command.Dispose();
                    }
                }

                connection.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#15
0
        private void ParseGoods(IList <string> lines)
        {
            for (int i = 0; i < lines.Count; i++)
            {
                if (!lines[i].ToUpper().StartsWith(TradeKey))
                {
                    continue;
                }

                while (++i < lines.Count)
                {
                    if (lines[i].StartsWith("["))
                    {
                        return;
                    }
                    if (String.IsNullOrEmpty(lines[i]))
                    {
                        continue;
                    }

                    var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    ItemInfo info = SMain.Envir.GetItemInfo(data[0]);
                    if (info == null)
                    {
                        continue;
                    }
                    UserItem goods = new UserItem(info)
                    {
                        CurrentDura = info.Durability, MaxDura = info.Durability
                    };
                    if (goods == null || Goods.Contains(goods))
                    {
                        SMain.Enqueue(string.Format("Could not find Item: {0}, File: {1}", lines[i], Info.FileName));
                        continue;
                    }
                    uint count = 1;
                    if (data.Length == 2)
                    {
                        uint.TryParse(data[1], out count);
                    }
                    goods.Count    = count;
                    goods.UniqueID = (ulong)i;

                    Goods.Add(goods);
                }
            }
        }
示例#16
0
        public Buff(MySqlDataReader readerBuff)
        {
            Type       = (BuffType)Convert.ToByte(readerBuff["Type"]);
            Caster     = null;
            Visible    = Convert.ToBoolean(readerBuff["Visible"]);
            ObjectID   = Convert.ToUInt32(readerBuff["ObjectID"]);
            ExpireTime = Convert.ToInt64(readerBuff["ExpireTime"]);
            Infinite   = Convert.ToBoolean(readerBuff["Infinite"]);

            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();

                MySqlCommand instruccion = connection.CreateCommand();

                // int Position = Convert.ToInt32(readerBuff["Position"]);

                instruccion.CommandText = "SELECT Value FROM " + Settings.DBAccount + ".buff_value WHERE ChName = '" + readerBuff["ChName"].ToString() + "' And Type = '" + readerBuff["Type"].ToString() + "' ORDER BY Position";

                MySqlDataReader readerValue = instruccion.ExecuteReader();

                List <int> cant = new List <int>();

                while (readerValue.Read())
                {
                    cant.Add(Convert.ToInt32(readerValue["Value"]));
                }

                if (readerValue.HasRows)
                {
                    Values = new int[cant.Count];
                    Values = cant.ToArray();
                }

                readerValue.Dispose();
                connection.Close();
            }

            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#17
0
        public void LoadEliteDrops()
        {
            try
            {
                EliteDrops.Clear();
                var pathArray = Directory.GetFiles(Settings.DropPath + @".\Elites\", Name + ".txt", SearchOption.TopDirectoryOnly);

                string path = string.Empty;
                if (pathArray.Length > 0)
                {
                    path = pathArray[0];
                }

                if (!File.Exists(path))
                {
                    //  Create a dummy/empty

                    return;
                }

                string[] lines = File.ReadAllLines(path);

                for (int i = 0; i < lines.Length; i++)
                {
                    if (lines[i].StartsWith(";") || string.IsNullOrWhiteSpace(lines[i]))
                    {
                        continue;
                    }

                    EliteDropInfo drop = EliteDropInfo.FromLine(lines[i], Name);
                    if (drop == null)
                    {
                        SMain.Enqueue(string.Format("Could not load Drop: {0}, Line {1}", Name, lines[i]));
                        continue;
                    }

                    EliteDrops.Add(drop);
                }
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#18
0
        public void SaveProgressMagicDB(List <AccountInfo> AccountListDB)
        {
            try
            {
                MySqlConnection connectionMagics = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connectionMagics.ConnectionString = connectionString;
                connectionMagics.Open();

                for (int i = 0; i < AccountListDB.Count; i++)
                {
                    string sqlMagics;

                    for (int c = 0; c < AccountListDB[i].Characters.Count; c++)
                    {
                        for (int mm = 0; mm < AccountListDB[i].Characters[c].Magics.Count; mm++)
                        {
                            sqlMagics = "INSERT INTO  " + Settings.DBAccount + ".magics (Spell, ChName, Level, Key_, Experience, IsTempSpell, CastTime) VALUES (@Spell, @ChName, @Level, @Key_, @Experience, @IsTempSpell, @CastTime)";

                            using (var command = new MySqlCommand(sqlMagics, connectionMagics))
                            {
                                command.Parameters.AddWithValue("@Spell", AccountListDB[i].Characters[c].Magics[mm].Spell);
                                command.Parameters.AddWithValue("@ChName", AccountListDB[i].Characters[c].Name);
                                command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Magics[mm].Level);
                                command.Parameters.AddWithValue("@Key_", AccountListDB[i].Characters[c].Magics[mm].Key);
                                command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Magics[mm].Experience);
                                command.Parameters.AddWithValue("@IsTempSpell", AccountListDB[i].Characters[c].Magics[mm].IsTempSpell);
                                command.Parameters.AddWithValue("@CastTime", AccountListDB[i].Characters[c].Magics[mm].CastTime);
                                command.ExecuteNonQuery();
                                command.Dispose();
                            }
                        }
                    }
                }
                connectionMagics.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#19
0
        public MirConnection(int sessionID, TcpClient client)
        {
            SessionID = sessionID;
            IPAddress = client.Client.RemoteEndPoint.ToString().Split(':')[0];


            SMain.Enqueue(IPAddress + ", Connected.");

            _client         = client;
            _client.NoDelay = true;

            TimeConnected = SMain.Envir.Time;
            TimeOutTime   = TimeConnected + Settings.TimeOut;


            _receiveList = new ConcurrentQueue <Packet>();
            _sendList    = new Queue <Packet>(new[] { new S.Connected() });
            _retryList   = new Queue <Packet>();

            Connected = true;
            BeginReceive();
        }
示例#20
0
        private void LoadIngredients(string recipe)
        {
            List <string> lines = File.ReadAllLines(Settings.RecipePath + recipe + ".txt").ToList();

            Ingredients = new List <UserItem>();

            for (int i = 0; i < lines.Count; i++)
            {
                if (String.IsNullOrEmpty(lines[i]))
                {
                    continue;
                }

                var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                ItemInfo info = SMain.Envir.GetItemInfo(data[0]);

                if (info == null)
                {
                    SMain.Enqueue(string.Format("Could not find Item: {0}, Recipe: {1}", lines[i], recipe));
                    continue;
                }

                uint count = 1;
                if (data.Length == 2)
                {
                    uint.TryParse(data[1], out count);
                }

                UserItem ingredient = SMain.Envir.CreateShopItem(info);

                ingredient.Count = count > info.StackSize ? info.StackSize : count;

                Ingredients.Add(ingredient);
            }
        }
示例#21
0
        private List <string> ParseInsert(List <string> lines)
        {
            List <string> newLines = new List <string>();

            for (int i = 0; i < lines.Count; i++)
            {
                if (!lines[i].ToUpper().StartsWith("#INSERT"))
                {
                    continue;
                }

                string[] split = lines[i].Split(' ');

                if (split.Length < 2)
                {
                    continue;
                }

                string path = Path.Combine(Settings.EnvirPath, split[1].Substring(1, split[1].Length - 2));

                if (!File.Exists(path))
                {
                    SMain.Enqueue(string.Format("File Not Found: {0}, NPC: {1}", path, Info.Name));
                }
                else
                {
                    newLines = File.ReadAllLines(path).ToList();
                }

                lines.AddRange(newLines);
            }

            lines.RemoveAll(str => str.ToUpper().StartsWith("#INSERT"));

            return(lines);
        }
示例#22
0
        public static void SaveMonsterDB(MonsterInfo info)
        {
            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();

                string sqlMonsterExists = "SELECT Count(*) FROM " + Settings.DBServer + ".monsterinfo where IndexID = '" + info.Index + "'";
                string sqlCommand;

                if (Envir.ConnectADB.Count(sqlMonsterExists) > 0)
                {
                    sqlCommand = "UPDATE  " + Settings.DBServer + ".monsterinfo SET IndexID = @IndexID, AI = @AI, Accuracy = @Accuracy, Agility = @Agility, AttackSpeed = @AttackSpeed, CanPush = @CanPush, CanTame = @CanTame, Effect = @Effect, Experience = @Experience, HP = @HP, Image = @Image, Level = @Level, Light = @Light, MaxAC = @MaxAC, MaxDC = @MaxDC, MaxMAC = @MaxMAC, MaxMC = @MaxMC, MaxSC = @MaxSC, MinAC = @MinAC, MinDC = @MinDC, MinMAC = @MinMAC, MinMC = @MinMC, MinSC = @MinSC, MoveSpeed = @MoveSpeed, Name = @Name, ViewRange = @ViewRange, AutoRev_ = @AutoRev_, CoolEye_ = @CoolEye_, Undead_ = @Undead_ where IndexID = " + info.Index;
                }
                else
                {
                    sqlCommand = "INSERT INTO  " + Settings.DBServer + ".monsterinfo (IndexID, AI, Accuracy, Agility, AttackSpeed, CanPush, CanTame,Effect, Experience, HP, Image, Level, Light, MaxAC, MaxDC, MaxMAC, MaxMC, MaxSC, MinAC, MinDC, MinMAC, MinMC, MinSC, MoveSpeed, Name, ViewRange, AutoRev_, CoolEye_, Undead_ ) VALUES (@IndexID, @AI, @Accuracy, @Agility, @AttackSpeed, @CanPush, @CanTame, @Effect, @Experience, @HP, @Image, @Level, @Light, @MaxAC, @MaxDC, @MaxMAC, @MaxMC, @MaxSC, @MinAC, @MinDC, @MinMAC, @MinMC, @MinSC, @MoveSpeed, @Name, @ViewRange ,@AutoRev_, @CoolEye_, @Undead_)";
                }

                using (var command = new MySqlCommand(sqlCommand, connection))
                {
                    command.Parameters.AddWithValue("@IndexID", info.Index);
                    command.Parameters.AddWithValue("@Name", info.Name);
                    command.Parameters.AddWithValue("@Image", info.Image);
                    command.Parameters.AddWithValue("@AI", info.AI);
                    command.Parameters.AddWithValue("@Effect", info.Effect);
                    command.Parameters.AddWithValue("@Level", info.Level);
                    command.Parameters.AddWithValue("@ViewRange", info.ViewRange);
                    command.Parameters.AddWithValue("@HP", info.HP);
                    command.Parameters.AddWithValue("@MinAC", info.MinAC);
                    command.Parameters.AddWithValue("@MaxAC", info.MaxAC);
                    command.Parameters.AddWithValue("@MinMAC", info.MinMAC);
                    command.Parameters.AddWithValue("@MaxMAC", info.MaxMAC);
                    command.Parameters.AddWithValue("@MinDC", info.MinDC);
                    command.Parameters.AddWithValue("@MaxDC", info.MaxDC);
                    command.Parameters.AddWithValue("@MinMC", info.MinMC);
                    command.Parameters.AddWithValue("@MaxMC", info.MaxMC);
                    command.Parameters.AddWithValue("@MinSC", info.MinSC);
                    command.Parameters.AddWithValue("@MaxSC", info.MaxSC);
                    command.Parameters.AddWithValue("@Accuracy", info.Accuracy);
                    command.Parameters.AddWithValue("@Agility", info.Agility);
                    command.Parameters.AddWithValue("@Light", info.Light);
                    command.Parameters.AddWithValue("@AttackSpeed", info.AttackSpeed);
                    command.Parameters.AddWithValue("@MoveSpeed", info.MoveSpeed);
                    command.Parameters.AddWithValue("@Experience", info.Experience);
                    command.Parameters.AddWithValue("@CanTame", info.CanTame);
                    command.Parameters.AddWithValue("@CanPush", info.CanPush);
                    command.Parameters.AddWithValue("@AutoRev_", info.AutoRev);
                    command.Parameters.AddWithValue("@CoolEye_", info.CoolEye);
                    command.Parameters.AddWithValue("@Undead_", info.Undead);
                    command.ExecuteNonQuery();
                    command.Dispose();
                }

                connection.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#23
0
        public void SQLError(MySqlException ex)
        {
            switch (ex.ErrorCode)
            {
            case 0:
                SMain.Enqueue(string.Format("Cannot connect to MySQL Database :\tIP : {0}\tPort : {1}\tDatabase : {2}", Settings.SQL_IP, Settings.SQL_PORT, Settings.SQL_DBName));
                break;

            case 1045:
                SMain.Enqueue(string.Format("Login failure for MySQL Database, check details!"));
                break;

            case 1053:
                SMain.Enqueue(string.Format("MySQL Server is shutting down.."));
                break;

            case 1054:
                SMain.Enqueue(string.Format("MySQL Column not found in table."));
                break;

            case 1055:
                SMain.Enqueue(string.Format("MySQL Item isn't in GROUP BY."));
                break;

            case 1056:
                SMain.Enqueue(string.Format("MySQL Cannot GROUP BY on table."));
                break;

            case 1059:
                SMain.Enqueue(string.Format("MySQL Identifier name is too long."));
                break;

            case 1060:
                SMain.Enqueue(string.Format("MySQL Column duplicate in statement."));
                break;

            case 1061:
                SMain.Enqueue(string.Format("MySQL Key Name duplicate in statement."));
                break;

            case 1062:
                SMain.Enqueue(string.Format("MySQL Duplicate entry for key in statement."));
                break;

            case 1063:
                SMain.Enqueue(string.Format("MySQL Incorrect column specifier."));
                break;

            case 1065:
                SMain.Enqueue(string.Format("MySQL Empty Query."));
                break;

            case 1077:
                SMain.Enqueue(string.Format("MySQL Shutting down.."));
                break;

            case 1078:
                SMain.Enqueue(string.Format("MySQL Aborting : Reason receive Signal."));
                break;

            case 1079:
                SMain.Enqueue(string.Format("MySQL Shutdown complete."));
                break;

            case 1102:
                SMain.Enqueue(string.Format("MySQL Incorrect database name."));
                break;

            case 1105:
                SMain.Enqueue("MySQL Unknown Error.");
                break;

            case 1146:
                SMain.Enqueue(string.Format("Table does not exist on MySQL Database."));
                break;

            default:
                SMain.Enqueue(string.Format("MySQL insert characterinfo data error : {0}", ex.ToString()));
                break;
            }
        }
示例#24
0
        private void LoadIngredients(string recipe)
        {
            List <string> lines = File.ReadAllLines(Settings.RecipePath + recipe + ".txt").ToList();

            Ingredients = new List <UserItem>();

            var mode = "ingredients";

            for (int i = 0; i < lines.Count; i++)
            {
                if (String.IsNullOrEmpty(lines[i]))
                {
                    continue;
                }

                var data1 = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                ItemInfo info1 = SMain.Envir.GetItemInfo(data1[0]);

                if (info1 == null)
                {
                    mode = lines[i].Substring(1, lines[i].Length - 2).ToLower();
                    continue;
                }

                switch (mode)
                {
                case "ingredients":
                {
                    var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    ItemInfo info = SMain.Envir.GetItemInfo(data[0]);

                    if (info == null)
                    {
                        SMain.Enqueue(string.Format("Could not find Item: {0}, Recipe: {1}", lines[i], recipe));
                        continue;
                    }

                    uint count = 1;
                    if (data.Length == 2)
                    {
                        uint.TryParse(data[1], out count);
                    }

                    UserItem ingredient = SMain.Envir.CreateShopItem(info);

                    ingredient.Count = count > info.StackSize ? info.StackSize : count;

                    Ingredients.Add(ingredient);
                }
                break;

                case "criteria":
                {
                    var data = lines[i].Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);

                    if (data.Length < 2)
                    {
                        continue;
                    }

                    try
                    {
                        switch (data[0].ToLower())
                        {
                        case "level":
                            RequiredLevel = ushort.Parse(data[1]);
                            break;

                        case "class":
                            RequiredClass.Add((MirClass)byte.Parse(data[1]));
                            break;

                        case "gender":
                            RequiredGender = (MirGender)byte.Parse(data[1]);
                            break;

                        case "flag":
                            RequiredFlag.Add(int.Parse(data[1]));
                            break;

                        case "quest":
                            RequiredQuest.Add(int.Parse(data[1]));
                            break;
                        }
                    }
                    catch
                    {
                        SMain.Enqueue(string.Format("Could not parse option: {0}, Value: {1}", data[0], data[1]));
                        continue;
                    }
                }
                break;
                }
            }
        }
示例#25
0
        public void SaveProgressDB(List <AccountInfo> AccountListDB)
        {
            var timer = Stopwatch.StartNew();

            try
            {
                MySqlConnection connectioninfo = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connectioninfo.ConnectionString = connectionString;
                connectioninfo.Open();

                for (int iii = 0; iii < 1; iii++)
                {
                    for (int i = 0; i < AccountListDB.Count; i++)
                    {
                        string sqlAccount = "UPDATE  " + Settings.DBAccount + ".account SET Gold = @Gold, Credit = @Credit WHERE AccountID = '" + AccountListDB[i].AccountID + "'";

                        using (var command = new MySqlCommand(sqlAccount, connectioninfo))
                        {
                            command.Parameters.AddWithValue("@Gold", AccountListDB[i].Gold);
                            command.Parameters.AddWithValue("@Credit", AccountListDB[i].Credit);

                            command.ExecuteNonQuery();
                            command.Dispose();
                        }

                        for (int c = 0; c < AccountListDB[i].Characters.Count; c++)
                        {
                            string sqlCharacterinfo = "UPDATE  " + Settings.DBAccount + ".characterinfo SET Level = @Level, CurrentMapIndex = @CurrentMapIndex, CurrentLocation_X = @CurrentLocation_X, CurrentLocation_Y = @CurrentLocation_Y, Direction = @Direction, BindMapIndex = @BindMapIndex, BindLocation_X = @BindLocation_X, BindLocation_Y = @BindLocation_Y, Experience = @Experience, MentorExp = @MentorExp, PKPoints = @PKPoints WHERE AccountID = '" + AccountListDB[i].AccountID + "' AND IndexID = '" + AccountListDB[i].Characters[c].Index + "'";

                            using (var command = new MySqlCommand(sqlCharacterinfo, connectioninfo))
                            {
                                command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Level);
                                command.Parameters.AddWithValue("@CurrentMapIndex", AccountListDB[i].Characters[c].CurrentMapIndex);
                                command.Parameters.AddWithValue("@CurrentLocation_X", AccountListDB[i].Characters[c].CurrentLocation.X);
                                command.Parameters.AddWithValue("@CurrentLocation_Y", AccountListDB[i].Characters[c].CurrentLocation.Y);
                                command.Parameters.AddWithValue("@Direction", AccountListDB[i].Characters[c].Direction);
                                command.Parameters.AddWithValue("@BindMapIndex", AccountListDB[i].Characters[c].BindMapIndex);
                                command.Parameters.AddWithValue("@BindLocation_X", AccountListDB[i].Characters[c].BindLocation.X);
                                command.Parameters.AddWithValue("@BindLocation_Y", AccountListDB[i].Characters[c].BindLocation.Y);
                                command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Experience);
                                command.Parameters.AddWithValue("@MentorExp", AccountListDB[i].Characters[c].MentorExp);
                                command.Parameters.AddWithValue("@PKPoints", AccountListDB[i].Characters[c].PKPoints);

                                command.ExecuteNonQuery();
                                command.Dispose();
                            }

                            for (int mm = 0; mm < AccountListDB[i].Characters[c].Magics.Count; mm++)
                            {
                                if (AccountListDB[i].Characters[c].Magics[mm].Level < 3 || AccountListDB[i].Characters[c].Magics[mm].Spell == Spell.Fury || AccountListDB[i].Characters[c].Magics[mm].Spell == Spell.ImmortalSkin || AccountListDB[i].Characters[c].Magics[mm].Spell == Spell.SwiftFeet)
                                {
                                    int IdSpell = Convert.ToInt32(AccountListDB[i].Characters[c].Magics[mm].Spell);

                                    string sqlMagics = "UPDATE  " + Settings.DBAccount + ".magics SET Level = @Level, Experience = @Experience, Key_ = @Key_ WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' And Spell = '" + IdSpell + "' ";

                                    using (var command = new MySqlCommand(sqlMagics, connectioninfo))
                                    {
                                        command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Magics[mm].Level);
                                        command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Magics[mm].Experience);
                                        command.Parameters.AddWithValue("@Key_", AccountListDB[i].Characters[c].Magics[mm].Key);

                                        command.ExecuteNonQuery();
                                        command.Dispose();
                                    }
                                }
                            }

                            for (int ee = 0; ee < AccountListDB[i].Characters[c].Equipment.Length; ee++)
                            {
                                if (AccountListDB[i].Characters[c].Equipment[ee] == null)
                                {
                                    continue;
                                }

                                string sqlEquipment = "UPDATE  " + Settings.DBAccount + ".inventory SET CurrentDura = @CurrentDura, MaxDura = @MaxDura, Count = @Count, Cursed = @Cursed, ExpireInfo = @ExpireInfo  WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' AND UniqueID = '" + AccountListDB[i].Characters[c].Equipment[ee].UniqueID + "'";

                                using (var command = new MySqlCommand(sqlEquipment, connectioninfo))
                                {
                                    command.Parameters.AddWithValue("@CurrentDura", AccountListDB[i].Characters[c].Equipment[ee].CurrentDura);
                                    command.Parameters.AddWithValue("@MaxDura", AccountListDB[i].Characters[c].Equipment[ee].MaxDura);
                                    command.Parameters.AddWithValue("@Count", AccountListDB[i].Characters[c].Equipment[ee].Count);
                                    command.Parameters.AddWithValue("@Cursed", AccountListDB[i].Characters[c].Equipment[ee].Cursed);
                                    command.Parameters.AddWithValue("@ExpireInfo", AccountListDB[i].Characters[c].Equipment[ee].ExpiryDate);

                                    command.ExecuteNonQuery();
                                    command.Dispose();
                                }

                                if (AccountListDB[i].Characters[c].Equipment[ee].IsAttached)
                                {
                                    for (int sl = 0; sl < AccountListDB[i].Characters[c].Equipment[ee].Slots.Length; sl++)
                                    {
                                        if (AccountListDB[i].Characters[c].Equipment[ee].Slots[sl] == null)
                                        {
                                            continue;
                                        }

                                        string sqlEquipmentSlot = "UPDATE  " + Settings.DBAccount + ".inventory SET CurrentDura = @CurrentDura, MaxDura = @MaxDura, Count = @Count, Cursed = @Cursed, ExpireInfo = @ExpireInfo  WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' AND UniqueID = '" + AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].UniqueID + "'";

                                        using (var command = new MySqlCommand(sqlEquipmentSlot, connectioninfo))
                                        {
                                            command.Parameters.AddWithValue("@CurrentDura", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].CurrentDura);
                                            command.Parameters.AddWithValue("@MaxDura", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].MaxDura);
                                            command.Parameters.AddWithValue("@Count", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].Count);
                                            command.Parameters.AddWithValue("@Cursed", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].Cursed);
                                            command.Parameters.AddWithValue("@ExpireInfo", AccountListDB[i].Characters[c].Equipment[ee].Slots[sl].ExpiryDate);

                                            command.ExecuteNonQuery();
                                            command.Dispose();
                                        }
                                    }
                                }
                            }

                            for (int mm = 0; mm < AccountListDB[i].Characters[c].Buffs.Count; mm++)
                            {
                                if (AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.Drop || AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.Exp || AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.General || AccountListDB[i].Characters[c].Buffs[mm].Type == BuffType.Transform)
                                {
                                    int typeBuff = Convert.ToInt32(AccountListDB[i].Characters[c].Buffs[mm].Type);

                                    string sqlbuff = "UPDATE  " + Settings.DBAccount + ".buff SET ExpireTime = @ExpireTime WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "' AND Type = '" + typeBuff + "'";

                                    using (var command = new MySqlCommand(sqlbuff, connectioninfo))
                                    {
                                        command.Parameters.AddWithValue("@ExpireTime", AccountListDB[i].Characters[c].Buffs[mm].ExpireTime);
                                        command.ExecuteNonQuery();
                                        command.Dispose();
                                    }
                                }
                            }

                            for (int it = 0; it < AccountListDB[i].Characters[c].IntelligentCreatures.Count; it++)
                            {
                                string sqlIntelligentCreatures = "UPDATE " + Settings.DBAccount + ".intelligentcreatures SET ExpireTime = @ExpireTime, BlackstoneTime = @BlackstoneTime, MaintainFoodTime = @MaintainFoodTime, CustomName = @CustomName WHERE ChName = '" + AccountListDB[i].Characters[c].Name + "'  And PetType = '" + Convert.ToInt32(AccountListDB[i].Characters[c].IntelligentCreatures[it].PetType) + "'";

                                using (var command = new MySqlCommand(sqlIntelligentCreatures, connectioninfo))
                                {
                                    command.Parameters.AddWithValue("@ExpireTime", AccountListDB[i].Characters[c].IntelligentCreatures[it].ExpireTime);
                                    command.Parameters.AddWithValue("@BlackstoneTime", AccountListDB[i].Characters[c].IntelligentCreatures[it].BlackstoneTime);
                                    command.Parameters.AddWithValue("@MaintainFoodTime", AccountListDB[i].Characters[c].IntelligentCreatures[it].MaintainFoodTime);

                                    command.Parameters.AddWithValue("@CustomName", AccountListDB[i].Characters[c].IntelligentCreatures[it].CustomName);

                                    command.ExecuteNonQuery();
                                    command.Dispose();
                                }
                            }
                        }
                    }
                }
                connectioninfo.Close();
                AccountListDB.Clear();
            }

            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }

            SMain.Enqueue(string.Format("Saved, Elapsed para int.Parse: {0}", timer.Elapsed));
        }
示例#26
0
        public bool Load()
        {
            try
            {
                MonsterInfo info = Envir.GetMonsterInfo(Info.MonsterName);
                if (info == null)
                {
                    SMain.Enqueue("Failed to load Dragon (bad monster name): " + Info.MonsterName);
                    return(false);
                }
                LinkedMonster = MonsterObject.GetMonster(info);

                Map map = SMain.Envir.GetMapByNameAndInstance(Info.MapFileName);
                if (map == null)
                {
                    SMain.Enqueue("Failed to load Dragon (bad map name): " + Info.MapFileName);
                    return(false);
                }

                if (Info.Location.X > map.Width || Info.Location.Y > map.Height)
                {
                    SMain.Enqueue("Failed to load Dragon (bad map XY): " + Info.MapFileName);
                    return(false);
                }

                if (LinkedMonster.Spawn(map, Info.Location))
                {
                    if (LinkedMonster is EvilMir)
                    {
                        EvilMir mob = (EvilMir)LinkedMonster;
                        if (mob != null)
                        {
                            mob.DragonLink = true;
                        }
                    }
                    MonsterInfo bodyinfo = Envir.GetMonsterInfo(Info.BodyName);
                    if (bodyinfo != null)
                    {
                        MonsterObject bodymob;
                        Point         spawnlocation = Point.Empty;
                        for (int i = 0; i <= BodyLocations.Length - 1; i++)
                        {
                            bodymob       = MonsterObject.GetMonster(bodyinfo);
                            spawnlocation = new Point(LinkedMonster.CurrentLocation.X + BodyLocations[i].X, LinkedMonster.CurrentLocation.Y + BodyLocations[i].Y);
                            if (bodymob != null)
                            {
                                bodymob.Spawn(LinkedMonster.CurrentMap, spawnlocation);
                            }
                        }
                    }

                    DropArea = new Rectangle(Info.DropAreaTop.X, Info.DropAreaTop.Y, Info.DropAreaBottom.X - Info.DropAreaTop.X, Info.DropAreaBottom.Y - Info.DropAreaTop.Y);
                    Loaded   = true;
                    return(true);
                }
            }
            catch (Exception ex)
            {
                SMain.Enqueue(ex);
            }

            SMain.Enqueue("Failed to load Dragon");
            return(false);
        }
示例#27
0
        public AuctionInfo(MySqlDataReader readerAuctionsDB)
        {
            AuctionID  = Convert.ToUInt64(readerAuctionsDB["AuctionID"]);
            NameSeller = Convert.ToString(readerAuctionsDB["NameSeller"]);

            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();

                MySqlCommand instruccion = connection.CreateCommand();

                instruccion.CommandText = "SELECT * FROM " + Settings.DBAccount + ".auctionsitems WHERE AuctionID = '" + AuctionID + "'";

                MySqlDataReader readerAuctions = instruccion.ExecuteReader();

                while (readerAuctions.Read())
                {
                    UserItem AddItem = new UserItem(readerAuctions);

                    if (SMain.Envir.BindItem(AddItem))
                    {
                        Item = AddItem;
                    }
                }

                readerAuctions.Dispose();
                if (Item != null)
                {
                    if (Item.IsAwake)
                    {
                        MySqlCommand instruccionAwake = connection.CreateCommand();

                        instruccionAwake.CommandText = "SELECT * FROM " + Settings.DBAccount + ".awake WHERE UniqueID = '" + Item.UniqueID + "' ORDER BY Position";

                        MySqlDataReader readerAwakeDB = instruccionAwake.ExecuteReader();

                        Item.Awake      = new Awake();
                        Item.Awake.type = (AwakeType)Convert.ToInt32(Item.AwakeType);

                        while (readerAwakeDB.Read())
                        {
                            Item.Awake.listAwake.Add(Convert.ToByte(readerAwakeDB["Value"]));
                        }

                        readerAwakeDB.Dispose();
                    }
                    if (Item.IsAttached)
                    {
                        MySqlCommand instruccionAttached = connection.CreateCommand();

                        instruccionAttached.CommandText = "SELECT * FROM " + Settings.DBAccount + ".auctionsitems WHERE Attached = '" + Item.UniqueID + "' ORDER BY Position";

                        MySqlDataReader readerAttachedDB = instruccionAttached.ExecuteReader();

                        Item.Awake      = new Awake();
                        Item.Awake.type = (AwakeType)Convert.ToInt32(Item.AwakeType);

                        while (readerAttachedDB.Read())
                        {
                            Item.Awake.listAwake.Add(Convert.ToByte(readerAttachedDB["Value"]));
                        }

                        readerAttachedDB.Dispose();
                    }
                }
                connection.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }



            ConsignmentDate = readerAuctionsDB.GetDateTime(readerAuctionsDB.GetOrdinal("ConsignmentDate"));
            Price           = Convert.ToUInt32(readerAuctionsDB["Price"]);

            CharacterIndex = Convert.ToInt32(readerAuctionsDB["CharacterIndex"]);

            Expired = Convert.ToBoolean(readerAuctionsDB["Expired"]);
            Sold    = Convert.ToBoolean(readerAuctionsDB["Sold"]);
        }
示例#28
0
        public void SaveProgressCharacterinfoDB(List <AccountInfo> AccountListDB)
        {
            try
            {
                MySqlConnection connectionCharacterinfo = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connectionCharacterinfo.ConnectionString = connectionString;
                connectionCharacterinfo.Open();

                for (int i = 0; i < AccountListDB.Count; i++)
                {
                    string sqlCharacterinfo;

                    for (int c = 0; c < AccountListDB[i].Characters.Count; c++)
                    {
                        string query_Characters = "SELECT COUNT(*) FROM  " + Settings.DBAccount + ".characterinfo WHERE AccountID = '" + AccountListDB[i].AccountID + "' AND IndexID = '" + AccountListDB[i].Characters[c].Index + "'";
                        using (var cmd = new MySqlCommand(query_Characters, connectionCharacterinfo))
                        {
                            int count = Convert.ToInt32(cmd.ExecuteScalar());

                            if (count == 0)
                            {
                                sqlCharacterinfo = "INSERT INTO  " + Settings.DBAccount + ".characterinfo (IndexID, AccountID, Name, Level, Class, Gender, Hair, CreationIP, CreationDate, Banned, HP, MP, BanReason, ExpiryDate, LastIP, LastDate, Deleted, DeleteDate, Married, MarriedDate, Mentor, MentorDate, isMentor, MentorExp, CurrentMapIndex, CurrentLocation_X, CurrentLocation_Y, Direction, BindMapIndex, BindLocation_X, BindLocation_Y, Experience, AMode, PMode, PKPoints, Thrusting, HalfMoon, CrossHalfMoon, DoubleSlash, MentalState, AllowGroup, AllowTrade, PearlCount, CollectTime, GuildIndex) VALUES (@IndexID, @AccountID, @Name, @Level, @Class, @Gender, @Hair, @CreationIP, @CreationDate, @Banned, @HP, @MP, @BanReason, @ExpiryDate, @LastIP, @LastDate, @Deleted, @DeleteDate, @Married, @MarriedDate, @Mentor, @MentorDate, @isMentor, @MentorExp, @CurrentMapIndex, @CurrentLocation_X, @CurrentLocation_Y, @Direction, @BindMapIndex, @BindLocation_X, @BindLocation_Y, @Experience, @AMode, @PMode, @PKPoints, @Thrusting, @HalfMoon, @CrossHalfMoon, @DoubleSlash, @MentalState, @AllowGroup, @AllowTrade, @PearlCount, @CollectTime, @GuildIndex)";
                            }

                            else
                            {
                                sqlCharacterinfo = "UPDATE  " + Settings.DBAccount + ".characterinfo SET AccountID = @AccountID, Name = @Name, Level = @Level, Class = @Class, Gender = @Gender, Hair = @Hair, CreationIP = @CreationIP, CreationDate = @CreationDate, Banned = @Banned, HP = @HP, MP = @MP, BanReason = @BanReason, ExpiryDate = @ExpiryDate, LastIP = @LastIP, LastDate = @LastDate, Deleted = @Deleted, DeleteDate = @DeleteDate, Married = @Married, MarriedDate = @MarriedDate, Mentor = @Mentor, MentorDate = @MentorDate, isMentor = @isMentor, MentorExp = @MentorExp, CurrentMapIndex = @CurrentMapIndex, CurrentLocation_X = @CurrentLocation_X, CurrentLocation_Y = @CurrentLocation_Y, Direction = @Direction, BindMapIndex = @BindMapIndex, BindLocation_X = @BindLocation_X, BindLocation_Y = @BindLocation_Y, Experience = @Experience, AMode = @AMode, PMode = @PMode, PKPoints = @PKPoints, Thrusting = @Thrusting, HalfMoon = @HalfMoon, CrossHalfMoon = @CrossHalfMoon, DoubleSlash = @DoubleSlash, MentalState = @MentalState, AllowGroup = @AllowGroup, AllowTrade = @AllowTrade, PearlCount = @PearlCount, CollectTime = @CollectTime,  GuildIndex = @GuildIndex WHERE AccountID = '" + AccountListDB[i].AccountID + "' AND IndexID = '" + AccountListDB[i].Characters[c].Index + "'";
                            }
                        }

                        using (var command = new MySqlCommand(sqlCharacterinfo, connectionCharacterinfo))
                        {
                            command.Parameters.AddWithValue("@IndexID", AccountListDB[i].Characters[c].Index);
                            command.Parameters.AddWithValue("@AccountID", AccountListDB[i].AccountID);
                            command.Parameters.AddWithValue("@Name", AccountListDB[i].Characters[c].Name);
                            command.Parameters.AddWithValue("@Level", AccountListDB[i].Characters[c].Level);
                            command.Parameters.AddWithValue("@Class", AccountListDB[i].Characters[c].Class);
                            command.Parameters.AddWithValue("@Gender", AccountListDB[i].Characters[c].Gender);
                            command.Parameters.AddWithValue("@Hair", AccountListDB[i].Characters[c].Hair);

                            command.Parameters.AddWithValue("@CreationIP", AccountListDB[i].Characters[c].CreationIP);
                            command.Parameters.AddWithValue("@CreationDate", AccountListDB[i].Characters[c].CreationDate);
                            command.Parameters.AddWithValue("@Banned", AccountListDB[i].Characters[c].Banned);
                            command.Parameters.AddWithValue("@BanReason", AccountListDB[i].Characters[c].BanReason);

                            command.Parameters.AddWithValue("@ExpiryDate", AccountListDB[i].Characters[c].ExpiryDate);

                            command.Parameters.AddWithValue("@LastIP", AccountListDB[i].Characters[c].LastIP);
                            command.Parameters.AddWithValue("@LastDate", AccountListDB[i].Characters[c].LastDate);
                            command.Parameters.AddWithValue("@Deleted", AccountListDB[i].Characters[c].Deleted);
                            command.Parameters.AddWithValue("@DeleteDate", AccountListDB[i].Characters[c].DeleteDate);
                            command.Parameters.AddWithValue("@CurrentMapIndex", AccountListDB[i].Characters[c].CurrentMapIndex);
                            command.Parameters.AddWithValue("@CurrentLocation_X", AccountListDB[i].Characters[c].CurrentLocation.X);
                            command.Parameters.AddWithValue("@CurrentLocation_Y", AccountListDB[i].Characters[c].CurrentLocation.Y);
                            command.Parameters.AddWithValue("@Direction", AccountListDB[i].Characters[c].Direction);
                            command.Parameters.AddWithValue("@BindMapIndex", AccountListDB[i].Characters[c].BindMapIndex);
                            command.Parameters.AddWithValue("@BindLocation_X", AccountListDB[i].Characters[c].BindLocation.X);
                            command.Parameters.AddWithValue("@BindLocation_Y", AccountListDB[i].Characters[c].BindLocation.Y);
                            command.Parameters.AddWithValue("@HP", AccountListDB[i].Characters[c].HP);
                            command.Parameters.AddWithValue("@MP", AccountListDB[i].Characters[c].MP);

                            command.Parameters.AddWithValue("@Experience", AccountListDB[i].Characters[c].Experience);
                            command.Parameters.AddWithValue("@AMode", AccountListDB[i].Characters[c].AMode);
                            command.Parameters.AddWithValue("@PMode", AccountListDB[i].Characters[c].PMode);
                            command.Parameters.AddWithValue("@PKPoints", AccountListDB[i].Characters[c].PKPoints);
                            command.Parameters.AddWithValue("@Thrusting", AccountListDB[i].Characters[c].Thrusting);
                            command.Parameters.AddWithValue("@HalfMoon", AccountListDB[i].Characters[c].HalfMoon);
                            command.Parameters.AddWithValue("@CrossHalfMoon", AccountListDB[i].Characters[c].CrossHalfMoon);
                            command.Parameters.AddWithValue("@DoubleSlash", AccountListDB[i].Characters[c].DoubleSlash);
                            command.Parameters.AddWithValue("@MentalState", AccountListDB[i].Characters[c].MentalState);
                            command.Parameters.AddWithValue("@AllowGroup", AccountListDB[i].Characters[c].AllowGroup);
                            command.Parameters.AddWithValue("@AllowTrade", AccountListDB[i].Characters[c].AllowTrade);
                            command.Parameters.AddWithValue("@Married", AccountListDB[i].Characters[c].Married);
                            command.Parameters.AddWithValue("@MarriedDate", AccountListDB[i].Characters[c].MarriedDate);
                            command.Parameters.AddWithValue("@Mentor", AccountListDB[i].Characters[c].Mentor);
                            command.Parameters.AddWithValue("@MentorDate", AccountListDB[i].Characters[c].MentorDate);
                            command.Parameters.AddWithValue("@isMentor", AccountListDB[i].Characters[c].isMentor);
                            command.Parameters.AddWithValue("@MentorExp", AccountListDB[i].Characters[c].MentorExp);
                            command.Parameters.AddWithValue("@PearlCount", AccountListDB[i].Characters[c].PearlCount);
                            command.Parameters.AddWithValue("@CollectTime", AccountListDB[i].Characters[c].CollectTime);
                            command.Parameters.AddWithValue("@GuildIndex", AccountListDB[i].Characters[c].GuildIndex);

                            command.ExecuteNonQuery();
                            command.Dispose();
                        }
                    }
                }
                connectionCharacterinfo.Close();
            }
            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#29
0
        public QuestProgressInfo(MySqlDataReader readerQuestProgressDB, string Name)
        {
            Index = Convert.ToInt32(readerQuestProgressDB["IndexID"]);
            Info  = SMain.Envir.QuestInfoList.FirstOrDefault(e => e.Index == Index);

            // StartDateTime = DateTime.Now;
            //  EndDateTime = DateTime.MaxValue;

            EndDateTime   = readerQuestProgressDB.GetDateTime(readerQuestProgressDB.GetOrdinal("EndDateTime"));
            StartDateTime = readerQuestProgressDB.GetDateTime(readerQuestProgressDB.GetOrdinal("StartDateTime"));

            try
            {
                MySqlConnection connection = new MySqlConnection(); //star conection
                String          connectionString;
                connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                connection.ConnectionString = connectionString;
                connection.Open();

                MySqlCommand instruccionKillTask = connection.CreateCommand();

                instruccionKillTask.CommandText = "SELECT * FROM " + Settings.DBAccount + ".killtaskcount WHERE ChName = '" + Name + "' and IndexID = '" + Index + "' ORDER BY IndexID, Position";

                MySqlDataReader readerKillTask = instruccionKillTask.ExecuteReader();


                while (readerKillTask.Read())
                {
                    int position = Convert.ToInt32(readerKillTask["Position"]);
                    int value    = Convert.ToInt32(readerKillTask["Value"]);

                    KillTaskCount.Add(value);
                }

                readerKillTask.Dispose();


                MySqlCommand instruccionItemTask = connection.CreateCommand();

                instruccionItemTask.CommandText = "SELECT * FROM " + Settings.DBAccount + ".itemtaskcount WHERE ChName = '" + Name + "' and IndexID = '" + Index + "' ORDER BY IndexID, Position";

                MySqlDataReader readerItemTask = instruccionItemTask.ExecuteReader();


                while (readerItemTask.Read())
                {
                    int  position = Convert.ToInt32(readerItemTask["Position"]);
                    long value    = Convert.ToInt64(readerItemTask["Value"]);

                    ItemTaskCount.Add(value);
                }

                readerItemTask.Dispose();

                MySqlCommand instruccionFlagTask = connection.CreateCommand();

                instruccionFlagTask.CommandText = "SELECT * FROM " + Settings.DBAccount + ".flagtaskset WHERE ChName = '" + Name + "' and IndexID = '" + Index + "' ORDER BY IndexID, Position";

                MySqlDataReader readerFlagTask = instruccionFlagTask.ExecuteReader();


                while (readerFlagTask.Read())
                {
                    int  position = Convert.ToInt32(readerFlagTask["Position"]);
                    bool value    = Convert.ToBoolean(readerFlagTask["value"]);

                    FlagTaskSet.Add(value);
                }

                readerFlagTask.Dispose();

                connection.Close();
            }

            catch (MySqlException ex)
            {
                SMain.Enqueue(ex);
            }
        }
示例#30
0
        public MailInfo(MySqlDataReader readerMail)
        {
            MailID         = Convert.ToUInt32(readerMail["MailID"]);
            Sender         = readerMail["Sender"].ToString();
            RecipientIndex = Convert.ToInt32(readerMail["RecipientIndex"]);
            Message        = readerMail["Message"].ToString();
            Gold           = Convert.ToUInt32(readerMail["Gold"]);
            ItemCount      = Convert.ToInt32(readerMail["ItemCount"]);
            if (ItemCount > 0)
            {
                try
                {
                    MySqlConnection connection = new MySqlConnection(); //star conection
                    String          connectionString;
                    connectionString            = "Server=" + Settings.ServerIP + "; Uid=" + Settings.Uid + "; Pwd=" + Settings.Pwd + "; convert zero datetime=True";
                    connection.ConnectionString = connectionString;
                    connection.Open();

                    MySqlCommand instruccion = connection.CreateCommand();

                    instruccion.CommandText = "SELECT * FROM " + Settings.DBAccount + ".mailitems WHERE MailID = '" + MailID + "'";

                    MySqlDataReader readerAuctions = instruccion.ExecuteReader();

                    while (readerAuctions.Read())
                    {
                        UserItem AddItem = new UserItem(readerAuctions);

                        if (SMain.Envir.BindItem(AddItem))
                        {
                            Items.Add(AddItem);
                        }
                    }

                    readerAuctions.Dispose();

                    for (int i = 0; i < Items.Count; i++)
                    {
                        if (Items[i].IsAwake)
                        {
                            MySqlCommand instruccionAwake = connection.CreateCommand();

                            instruccionAwake.CommandText = "SELECT * FROM " + Settings.DBAccount + ".mailitems WHERE UniqueID = '" + Items[i].UniqueID + "' ORDER BY Position";

                            MySqlDataReader readerAwakeDB = instruccionAwake.ExecuteReader();

                            Items[i].Awake      = new Awake();
                            Items[i].Awake.type = (AwakeType)Convert.ToInt32(Items[i].AwakeType);

                            while (readerAwakeDB.Read())
                            {
                                Items[i].Awake.listAwake.Add(Convert.ToByte(readerAwakeDB["Value"]));
                            }

                            readerAwakeDB.Dispose();
                        }
                        if (Items[i].IsAttached)
                        {
                            MySqlCommand instruccionAttached = connection.CreateCommand();

                            instruccionAttached.CommandText = "SELECT * FROM " + Settings.DBAccount + ".mailitems WHERE Attached = '" + Items[i].UniqueID + "' ORDER BY Position";

                            MySqlDataReader readerAttachedDB = instruccionAttached.ExecuteReader();

                            Items[i].Awake      = new Awake();
                            Items[i].Awake.type = (AwakeType)Convert.ToInt32(Items[i].AwakeType);

                            while (readerAttachedDB.Read())
                            {
                                Items[i].Awake.listAwake.Add(Convert.ToByte(readerAttachedDB["Value"]));
                            }

                            readerAttachedDB.Dispose();
                        }
                    }
                    connection.Close();
                }
                catch (MySqlException ex)
                {
                    SMain.Enqueue(ex);
                }
            }


            DateSent   = readerMail.GetDateTime(readerMail.GetOrdinal("DateSent"));
            DateOpened = readerMail.GetDateTime(readerMail.GetOrdinal("DateOpened"));

            Locked    = Convert.ToBoolean(readerMail["Locked"]);
            Collected = Convert.ToBoolean(readerMail["Collected"]);
            CanReply  = Convert.ToBoolean(readerMail["CanReply"]);
        }