public void LoadWeather()
        {
            //Wrap our function inside a catcher
            try
            {
                //NOTE: Must be defined per zone and random information

                //Load info from ini for now
                Ini ini = new Ini();
                ini = new CLFramework.Ini(Environment.CurrentDirectory + @"\Settings\Settings.ini");
                string Enabled = ini.GetValue("Custom", "WeatherEnabled", "true").ToString();
                string Type    = ini.GetValue("Custom", "WeatherType", "1").ToString();
                string Info    = ini.GetValue("Custom", "WeatherInfo", "10").ToString();

                //If the user has defined to enable custom weather type
                if (Enabled == "1")
                {
                    //We send the information they chosen
                    client.Send(Packet.Weather(Convert.ToByte(Type), Convert.ToInt32(Info)));
                }
                //If disabled
                else
                {
                    //Send static weather
                    client.Send(Packet.Weather(0, 1));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        void CharacterCreate()
        {
            //Start wrapper for catching errors
            try
            {
                //Check the amount of characters created (If 4 then we return). Todo: Check if any message shows up.
                if (DB.GetRowsCount("SELECT * FROM character WHERE account='" + Player.AccountName + "'") == 4)
                    return;
                //Open our packet reader
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                byte tocheck = Reader.Byte();
                string name = Reader.Text();
                int model = Reader.Int32();
                byte volume = Reader.Byte();
                int[] Item = new int[4];
                Item[0] = Reader.Int32();
                Item[1] = Reader.Int32();
                Item[2] = Reader.Int32();
                Item[3] = Reader.Int32();
                Reader.Close();
                //Check player name
                #region Check Name
                //Check the character name before creation
                if (CharacterCheck(name))
                {
                    //If bad send informational packet
                    client.Send(Packet.CharacterName(4));
                    //Finally return.
                    return;
                }
                //Set and disable special characters
                if (name.Contains("[")) return;
                else if (name.Contains("GM")) return;
                else if (name.Contains("]")) return;
                else if (name.Contains("-")) return;
                #endregion
                //Begin creation for EU characters
                #region European characters
                //Check by model type to see what race we have.
                if (model >= 14715 && model <= 14745)
                {
                    //Insert the basic information into the database
                    DB.query("INSERT INTO character (account, name, chartype, volume, xsect, ysect, xpos, zpos, ypos, savearea,GuideData) VALUES ('" + Player.AccountName + "','" + name + "', '" + model + "', '" + volume + "','79','105','387','1000','1279','20','0000000000000000')");
                    //Insert reverse scroll data into the database
                    DB.query("INSERT INTO character_rev (charname, revxsec, revysec, revx, revy, revz) VALUES ('" + name + "','79','105','1000','22','83')");
                    //Set definition for the character id information
                    Player.CreatingCharID = Convert.ToInt32(DB.GetData("Select * from character Where name='" + name + "'", "id"));
                    //Set default information (TODO: Check if all chars have same base).
                    double MagDef = 3;
                    double PhyDef = 6;
                    double Parry = 11;
                    double Hit = 11;
                    double MinPhyA = 6;
                    double MaxPhyA = 9;
                    double MinMagA = 6;
                    double MaxMagA = 10;

                    //Open new framework ini reading
                    Ini ini;
                    //Open settings information for start items
                    ini = new Ini(Environment.CurrentDirectory + @"\Settings\Settings.ini");
                    //5 Items max for starting characters
                    string Item1 = ini.GetValue("European.Start", "Item1", "").ToString();
                    string Item2 = ini.GetValue("European.Start", "Item2", "").ToString();
                    string Item3 = ini.GetValue("European.Start", "Item3", "").ToString();
                    string Item4 = ini.GetValue("European.Start", "Item4", "").ToString();
                    string Item5 = ini.GetValue("European.Start", "Item5", "").ToString();
                    //The amount related information
                    string Amount1 = ini.GetValue("European.Start", "Amount1", "").ToString();
                    string Amount2 = ini.GetValue("European.Start", "Amount2", "").ToString();
                    string Amount3 = ini.GetValue("European.Start", "Amount3", "").ToString();
                    string Amount4 = ini.GetValue("European.Start", "Amount4", "").ToString();
                    string Amount5 = ini.GetValue("European.Start", "Amount5", "").ToString();
                    //Add the custom items
                    try
                    {
                        AddItem(Convert.ToInt32(Item1), Convert.ToByte(Amount1), 13, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item2), Convert.ToByte(Amount2), 14, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item3), Convert.ToByte(Amount3), 15, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item4), Convert.ToByte(Amount4), 16, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item5), Convert.ToByte(Amount5), 17, Player.CreatingCharID, 0);
                    }
                    catch (Exception)
                    {
                    }
                    //Add the base items
                    AddItem(Item[0], 0, 1, Player.CreatingCharID, 0);
                    AddItem(Item[1], 0, 4, Player.CreatingCharID, 0);
                    AddItem(Item[2], 0, 5, Player.CreatingCharID, 0);
                    AddItem(Item[3], 0, 6, Player.CreatingCharID, 0);
                    //Set mag defense
                    MagDef += ObjData.Manager.ItemBase[Item[0]].Defans.MinMagDef;
                    MagDef += ObjData.Manager.ItemBase[Item[1]].Defans.MinMagDef;
                    MagDef += ObjData.Manager.ItemBase[Item[2]].Defans.MinMagDef;
                    //Set phy defence
                    PhyDef += ObjData.Manager.ItemBase[Item[0]].Defans.MinPhyDef;
                    PhyDef += ObjData.Manager.ItemBase[Item[1]].Defans.MinPhyDef;
                    PhyDef += ObjData.Manager.ItemBase[Item[2]].Defans.MinPhyDef;
                    //Set parry information
                    Parry += ObjData.Manager.ItemBase[Item[0]].Defans.Parry;
                    Parry += ObjData.Manager.ItemBase[Item[1]].Defans.Parry;
                    Parry += ObjData.Manager.ItemBase[Item[2]].Defans.Parry;
                    //Set hit ratio
                    Hit += ObjData.Manager.ItemBase[Item[3]].Attack.MinAttackRating;
                    //Set phy attack
                    MinPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LPhyAttack;
                    MaxPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HPhyAttack;
                    //Set mag attack
                    MinMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LMagAttack;
                    MaxMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HMagAttack;
                    //If the 3rd item is a sword or a dark staff
                    if (Item[3] == 10730 || Item[3] == 10734)
                    {
                        //Add the mag def information
                        MagDef += ObjData.Manager.ItemBase[251].Defans.MinMagDef;
                        //Add the phy def information
                        PhyDef += ObjData.Manager.ItemBase[251].Defans.MinPhyDef;
                        //Add parry ration
                        Parry += ObjData.Manager.ItemBase[251].Defans.Parry;
                        //Add shield item
                        AddItem(10738, 0, 7, Player.CreatingCharID, 0);
                    }
                    //If the 3rd item is a crossbow
                    if (Item[3] == 10733)
                    {
                        //We add our base bolts 250
                        AddItem(10376, 250, 7, Player.CreatingCharID, 0);
                    }
                    //Update database information for stats
                    DB.query("update character set min_phyatk='" + (int)Math.Round(MinPhyA) +
                            "', max_phyatk='" + Math.Round(MaxPhyA) +
                            "', min_magatk='" + Math.Round(MinMagA) +
                            "', max_magatk='" + Math.Round(MaxMagA) +
                            "', phydef='" + Math.Round(PhyDef) +
                            "', magdef='" + Math.Round(PhyDef) +
                            "', parry='" + Math.Round(Parry) +
                            "', hit='" + Math.Round(Hit) +
                            "' where name='" + name + "'");
                    //Add base mastery's for europe characters
                    AddMastery(513, Player.CreatingCharID); //Warrior
                    AddMastery(515, Player.CreatingCharID); //Rogue
                    AddMastery(514, Player.CreatingCharID); //Wizard
                    AddMastery(516, Player.CreatingCharID); //Warlock
                    AddMastery(517, Player.CreatingCharID); //Bard
                    AddMastery(518, Player.CreatingCharID); //Cleric
                    client.Send(Packet.ScreenSuccess(1));
                #endregion
                }
                //If the character model is an chinese character
                else
                {
                #region Chinese characters
                    DB.query("INSERT INTO character (account, name, chartype, volume,GuideData) VALUES ('" + Player.AccountName + "','" + name + "', '" + model + "', '" + volume + "','0000000000000000')");
                    DB.query("INSERT INTO character_rev (charname, revxsec, revysec, revx, revy, revz) VALUES ('" + name + "','168','79','911','1083','-32')");
                    Player.CreatingCharID = Convert.ToInt32(DB.GetData("Select * from character Where name='" + name + "'", "id"));

                    #region Item
                    double MagDef = 3;
                    double PhyDef = 6;
                    double Parry = 11;
                    double Hit = 11;
                    double MinPhyA = 6;
                    double MaxPhyA = 9;
                    double MinMagA = 6;
                    double MaxMagA = 10;

                    CLFramework.Ini ini;
                    ini = new CLFramework.Ini(Environment.CurrentDirectory + @"\Settings\Settings.ini");

                    string Item1 = ini.GetValue("Chinese.Start", "Item1", "").ToString();
                    string Item2 = ini.GetValue("Chinese.Start", "Item2", "").ToString();
                    string Item3 = ini.GetValue("Chinese.Start", "Item3", "").ToString();
                    string Item4 = ini.GetValue("Chinese.Start", "Item4", "").ToString();
                    string Item5 = ini.GetValue("Chinese.Start", "Item5", "").ToString();

                    string Amount1 = ini.GetValue("Chinese.Start", "Amount1", "").ToString();
                    string Amount2 = ini.GetValue("Chinese.Start", "Amount2", "").ToString();
                    string Amount3 = ini.GetValue("Chinese.Start", "Amount3", "").ToString();
                    string Amount4 = ini.GetValue("Chinese.Start", "Amount4", "").ToString();
                    string Amount5 = ini.GetValue("Chinese.Start", "Amount5", "").ToString();

                    try
                    {
                        AddItem(Convert.ToInt32(Item1), Convert.ToByte(Amount1), 13, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item2), Convert.ToByte(Amount2), 14, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item3), Convert.ToByte(Amount3), 15, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item4), Convert.ToByte(Amount4), 16, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item5), Convert.ToByte(Amount5), 17, Player.CreatingCharID, 0);
                    }
                    catch (Exception)
                    {

                    }

                    AddItem(Item[0], 0, 1, Player.CreatingCharID, 0);
                    AddItem(Item[1], 0, 4, Player.CreatingCharID, 0);
                    AddItem(Item[2], 0, 5, Player.CreatingCharID, 0);
                    AddItem(Item[3], 0, 6, Player.CreatingCharID, 0);

                    MagDef += ObjData.Manager.ItemBase[Item[0]].Defans.MinMagDef;
                    MagDef += ObjData.Manager.ItemBase[Item[1]].Defans.MinMagDef;
                    MagDef += ObjData.Manager.ItemBase[Item[2]].Defans.MinMagDef;
                    PhyDef += ObjData.Manager.ItemBase[Item[0]].Defans.MinPhyDef;
                    PhyDef += ObjData.Manager.ItemBase[Item[1]].Defans.MinPhyDef;
                    PhyDef += ObjData.Manager.ItemBase[Item[2]].Defans.MinPhyDef;
                    Parry += ObjData.Manager.ItemBase[Item[0]].Defans.Parry;
                    Parry += ObjData.Manager.ItemBase[Item[1]].Defans.Parry;
                    Parry += ObjData.Manager.ItemBase[Item[2]].Defans.Parry;
                    Hit += ObjData.Manager.ItemBase[Item[3]].Attack.MinAttackRating;
                    MinPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LPhyAttack;
                    MaxPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HPhyAttack;
                    MinMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LMagAttack;
                    MaxMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HMagAttack;

                    if (Item[3] == 3632 || Item[3] == 3633)
                    {
                        MagDef += ObjData.Manager.ItemBase[251].Defans.MinMagDef;
                        PhyDef += ObjData.Manager.ItemBase[251].Defans.MinPhyDef;
                        Parry += ObjData.Manager.ItemBase[251].Defans.Parry;
                        AddItem(251, 0, 7, Player.CreatingCharID, 0);
                    }
                    if (Item[3] == 3636)
                    {
                        AddItem(62, 250, 7, Player.CreatingCharID, 0);
                    }
                    #endregion

                    DB.query("update character set min_phyatk='" + (int)Math.Round(MinPhyA) +
                            "', max_phyatk='" + Math.Round(MaxPhyA) +
                            "', min_magatk='" + Math.Round(MinMagA) +
                            "', max_magatk='" + Math.Round(MaxMagA) +
                            "', phydef='" + Math.Round(PhyDef) +
                            "', magdef='" + Math.Round(PhyDef) +
                            "', parry='" + Math.Round(Parry) +
                            "', hit='" + Math.Round(Hit) +
                            "' where name='" + name + "'");

                    AddMastery(257, Player.CreatingCharID); //blade
                    AddMastery(258, Player.CreatingCharID); //heuksal
                    AddMastery(259, Player.CreatingCharID); //bow
                    AddMastery(273, Player.CreatingCharID); //cold
                    AddMastery(274, Player.CreatingCharID); //light
                    AddMastery(275, Player.CreatingCharID); //fire
                    AddMastery(276, Player.CreatingCharID); //force
                    client.Send(Packet.ScreenSuccess(1));
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
 public Ini(Ini ini)
     : base(ini)
 {
 }
Example #4
0
        void CharacterCreate()
        {
            //Start wrapper for catching errors
            try
            {
                //Check the amount of characters created (If 4 then we return). Todo: Check if any message shows up.
                if (DB.GetRowsCount("SELECT * FROM character WHERE account='" + Player.AccountName + "'") == 4)
                {
                    return;
                }
                //Open our packet reader
                PacketReader Reader  = new PacketReader(PacketInformation.buffer);
                byte         tocheck = Reader.Byte();
                string       name    = Reader.Text();
                int          model   = Reader.Int32();
                byte         volume  = Reader.Byte();
                int[]        Item    = new int[4];
                Item[0] = Reader.Int32();
                Item[1] = Reader.Int32();
                Item[2] = Reader.Int32();
                Item[3] = Reader.Int32();
                Reader.Close();
                //Check player name
                #region Check Name
                //Check the character name before creation
                if (CharacterCheck(name))
                {
                    //If bad send informational packet
                    client.Send(Packet.CharacterName(4));
                    //Finally return.
                    return;
                }
                //Set and disable special characters
                if (name.Contains("["))
                {
                    return;
                }
                else if (name.Contains("GM"))
                {
                    return;
                }
                else if (name.Contains("]"))
                {
                    return;
                }
                else if (name.Contains("-"))
                {
                    return;
                }
                #endregion
                //Begin creation for EU characters
                #region European characters
                //Check by model type to see what race we have.
                if (model >= 14715 && model <= 14745)
                {
                    //Insert the basic information into the database
                    DB.query("INSERT INTO character (account, name, chartype, volume, xsect, ysect, xpos, zpos, ypos, savearea,GuideData) VALUES ('" + Player.AccountName + "','" + name + "', '" + model + "', '" + volume + "','79','105','387','1000','1279','20','0000000000000000')");
                    //Insert reverse scroll data into the database
                    DB.query("INSERT INTO character_rev (charname, revxsec, revysec, revx, revy, revz) VALUES ('" + name + "','79','105','1000','22','83')");
                    //Set definition for the character id information
                    Player.CreatingCharID = Convert.ToInt32(DB.GetData("Select * from character Where name='" + name + "'", "id"));
                    //Set default information (TODO: Check if all chars have same base).
                    double MagDef  = 3;
                    double PhyDef  = 6;
                    double Parry   = 11;
                    double Hit     = 11;
                    double MinPhyA = 6;
                    double MaxPhyA = 9;
                    double MinMagA = 6;
                    double MaxMagA = 10;

                    //Open new framework ini reading
                    Ini ini;
                    //Open settings information for start items
                    ini = new Ini(Environment.CurrentDirectory + @"\Settings\Settings.ini");
                    //5 Items max for starting characters
                    string Item1 = ini.GetValue("European.Start", "Item1", "").ToString();
                    string Item2 = ini.GetValue("European.Start", "Item2", "").ToString();
                    string Item3 = ini.GetValue("European.Start", "Item3", "").ToString();
                    string Item4 = ini.GetValue("European.Start", "Item4", "").ToString();
                    string Item5 = ini.GetValue("European.Start", "Item5", "").ToString();
                    //The amount related information
                    string Amount1 = ini.GetValue("European.Start", "Amount1", "").ToString();
                    string Amount2 = ini.GetValue("European.Start", "Amount2", "").ToString();
                    string Amount3 = ini.GetValue("European.Start", "Amount3", "").ToString();
                    string Amount4 = ini.GetValue("European.Start", "Amount4", "").ToString();
                    string Amount5 = ini.GetValue("European.Start", "Amount5", "").ToString();
                    //Add the custom items
                    try
                    {
                        AddItem(Convert.ToInt32(Item1), Convert.ToByte(Amount1), 13, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item2), Convert.ToByte(Amount2), 14, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item3), Convert.ToByte(Amount3), 15, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item4), Convert.ToByte(Amount4), 16, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item5), Convert.ToByte(Amount5), 17, Player.CreatingCharID, 0);
                    }
                    catch (Exception)
                    {
                    }
                    //Add the base items
                    AddItem(Item[0], 0, 1, Player.CreatingCharID, 0);
                    AddItem(Item[1], 0, 4, Player.CreatingCharID, 0);
                    AddItem(Item[2], 0, 5, Player.CreatingCharID, 0);
                    AddItem(Item[3], 0, 6, Player.CreatingCharID, 0);
                    //Set mag defense
                    MagDef += ObjData.Manager.ItemBase[Item[0]].Defans.MinMagDef;
                    MagDef += ObjData.Manager.ItemBase[Item[1]].Defans.MinMagDef;
                    MagDef += ObjData.Manager.ItemBase[Item[2]].Defans.MinMagDef;
                    //Set phy defence
                    PhyDef += ObjData.Manager.ItemBase[Item[0]].Defans.MinPhyDef;
                    PhyDef += ObjData.Manager.ItemBase[Item[1]].Defans.MinPhyDef;
                    PhyDef += ObjData.Manager.ItemBase[Item[2]].Defans.MinPhyDef;
                    //Set parry information
                    Parry += ObjData.Manager.ItemBase[Item[0]].Defans.Parry;
                    Parry += ObjData.Manager.ItemBase[Item[1]].Defans.Parry;
                    Parry += ObjData.Manager.ItemBase[Item[2]].Defans.Parry;
                    //Set hit ratio
                    Hit += ObjData.Manager.ItemBase[Item[3]].Attack.MinAttackRating;
                    //Set phy attack
                    MinPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LPhyAttack;
                    MaxPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HPhyAttack;
                    //Set mag attack
                    MinMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LMagAttack;
                    MaxMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HMagAttack;
                    //If the 3rd item is a sword or a dark staff
                    if (Item[3] == 10730 || Item[3] == 10734)
                    {
                        //Add the mag def information
                        MagDef += ObjData.Manager.ItemBase[251].Defans.MinMagDef;
                        //Add the phy def information
                        PhyDef += ObjData.Manager.ItemBase[251].Defans.MinPhyDef;
                        //Add parry ration
                        Parry += ObjData.Manager.ItemBase[251].Defans.Parry;
                        //Add shield item
                        AddItem(10738, 0, 7, Player.CreatingCharID, 0);
                    }
                    //If the 3rd item is a crossbow
                    if (Item[3] == 10733)
                    {
                        //We add our base bolts 250
                        AddItem(10376, 250, 7, Player.CreatingCharID, 0);
                    }
                    //Update database information for stats
                    DB.query("update character set min_phyatk='" + (int)Math.Round(MinPhyA) +
                             "', max_phyatk='" + Math.Round(MaxPhyA) +
                             "', min_magatk='" + Math.Round(MinMagA) +
                             "', max_magatk='" + Math.Round(MaxMagA) +
                             "', phydef='" + Math.Round(PhyDef) +
                             "', magdef='" + Math.Round(PhyDef) +
                             "', parry='" + Math.Round(Parry) +
                             "', hit='" + Math.Round(Hit) +
                             "' where name='" + name + "'");
                    //Add base mastery's for europe characters
                    AddMastery(513, Player.CreatingCharID); //Warrior
                    AddMastery(515, Player.CreatingCharID); //Rogue
                    AddMastery(514, Player.CreatingCharID); //Wizard
                    AddMastery(516, Player.CreatingCharID); //Warlock
                    AddMastery(517, Player.CreatingCharID); //Bard
                    AddMastery(518, Player.CreatingCharID); //Cleric
                    client.Send(Packet.ScreenSuccess(1));
                    #endregion
                }
                //If the character model is an chinese character
                else
                {
                    #region Chinese characters
                    DB.query("INSERT INTO character (account, name, chartype, volume,GuideData) VALUES ('" + Player.AccountName + "','" + name + "', '" + model + "', '" + volume + "','0000000000000000')");
                    DB.query("INSERT INTO character_rev (charname, revxsec, revysec, revx, revy, revz) VALUES ('" + name + "','168','79','911','1083','-32')");
                    Player.CreatingCharID = Convert.ToInt32(DB.GetData("Select * from character Where name='" + name + "'", "id"));

                    #region Item
                    double MagDef  = 3;
                    double PhyDef  = 6;
                    double Parry   = 11;
                    double Hit     = 11;
                    double MinPhyA = 6;
                    double MaxPhyA = 9;
                    double MinMagA = 6;
                    double MaxMagA = 10;

                    CLFramework.Ini ini;
                    ini = new CLFramework.Ini(Environment.CurrentDirectory + @"\Settings\Settings.ini");

                    string Item1 = ini.GetValue("Chinese.Start", "Item1", "").ToString();
                    string Item2 = ini.GetValue("Chinese.Start", "Item2", "").ToString();
                    string Item3 = ini.GetValue("Chinese.Start", "Item3", "").ToString();
                    string Item4 = ini.GetValue("Chinese.Start", "Item4", "").ToString();
                    string Item5 = ini.GetValue("Chinese.Start", "Item5", "").ToString();

                    string Amount1 = ini.GetValue("Chinese.Start", "Amount1", "").ToString();
                    string Amount2 = ini.GetValue("Chinese.Start", "Amount2", "").ToString();
                    string Amount3 = ini.GetValue("Chinese.Start", "Amount3", "").ToString();
                    string Amount4 = ini.GetValue("Chinese.Start", "Amount4", "").ToString();
                    string Amount5 = ini.GetValue("Chinese.Start", "Amount5", "").ToString();

                    try
                    {
                        AddItem(Convert.ToInt32(Item1), Convert.ToByte(Amount1), 13, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item2), Convert.ToByte(Amount2), 14, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item3), Convert.ToByte(Amount3), 15, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item4), Convert.ToByte(Amount4), 16, Player.CreatingCharID, 0);
                        AddItem(Convert.ToInt32(Item5), Convert.ToByte(Amount5), 17, Player.CreatingCharID, 0);
                    }
                    catch (Exception)
                    {
                    }

                    AddItem(Item[0], 0, 1, Player.CreatingCharID, 0);
                    AddItem(Item[1], 0, 4, Player.CreatingCharID, 0);
                    AddItem(Item[2], 0, 5, Player.CreatingCharID, 0);
                    AddItem(Item[3], 0, 6, Player.CreatingCharID, 0);

                    MagDef  += ObjData.Manager.ItemBase[Item[0]].Defans.MinMagDef;
                    MagDef  += ObjData.Manager.ItemBase[Item[1]].Defans.MinMagDef;
                    MagDef  += ObjData.Manager.ItemBase[Item[2]].Defans.MinMagDef;
                    PhyDef  += ObjData.Manager.ItemBase[Item[0]].Defans.MinPhyDef;
                    PhyDef  += ObjData.Manager.ItemBase[Item[1]].Defans.MinPhyDef;
                    PhyDef  += ObjData.Manager.ItemBase[Item[2]].Defans.MinPhyDef;
                    Parry   += ObjData.Manager.ItemBase[Item[0]].Defans.Parry;
                    Parry   += ObjData.Manager.ItemBase[Item[1]].Defans.Parry;
                    Parry   += ObjData.Manager.ItemBase[Item[2]].Defans.Parry;
                    Hit     += ObjData.Manager.ItemBase[Item[3]].Attack.MinAttackRating;
                    MinPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LPhyAttack;
                    MaxPhyA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HPhyAttack;
                    MinMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_LMagAttack;
                    MaxMagA += ObjData.Manager.ItemBase[Item[3]].Attack.Min_HMagAttack;

                    if (Item[3] == 3632 || Item[3] == 3633)
                    {
                        MagDef += ObjData.Manager.ItemBase[251].Defans.MinMagDef;
                        PhyDef += ObjData.Manager.ItemBase[251].Defans.MinPhyDef;
                        Parry  += ObjData.Manager.ItemBase[251].Defans.Parry;
                        AddItem(251, 0, 7, Player.CreatingCharID, 0);
                    }
                    if (Item[3] == 3636)
                    {
                        AddItem(62, 250, 7, Player.CreatingCharID, 0);
                    }
                    #endregion

                    DB.query("update character set min_phyatk='" + (int)Math.Round(MinPhyA) +
                             "', max_phyatk='" + Math.Round(MaxPhyA) +
                             "', min_magatk='" + Math.Round(MinMagA) +
                             "', max_magatk='" + Math.Round(MaxMagA) +
                             "', phydef='" + Math.Round(PhyDef) +
                             "', magdef='" + Math.Round(PhyDef) +
                             "', parry='" + Math.Round(Parry) +
                             "', hit='" + Math.Round(Hit) +
                             "' where name='" + name + "'");

                    AddMastery(257, Player.CreatingCharID); //blade
                    AddMastery(258, Player.CreatingCharID); //heuksal
                    AddMastery(259, Player.CreatingCharID); //bow
                    AddMastery(273, Player.CreatingCharID); //cold
                    AddMastery(274, Player.CreatingCharID); //light
                    AddMastery(275, Player.CreatingCharID); //fire
                    AddMastery(276, Player.CreatingCharID); //force
                    client.Send(Packet.ScreenSuccess(1));
                    #endregion
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
 public static void Load()
 {
     #region Folder Check
     if (
         !File.Exists(Environment.CurrentDirectory + @"\Config\LoginServer.ini") &&
         !File.Exists(Environment.CurrentDirectory + @"\Config\IPCServer.ini") &&
         !File.Exists(Environment.CurrentDirectory + @"\Config\GameServer.ini") &&
         !File.Exists(Environment.CurrentDirectory + @"\News")
         )
     {
         Console.ForegroundColor = ConsoleColor.Red;
         Console.WriteLine("Could not find System Files:\n{0} OR \n{1} OR \n{2} OR \nNews Folder", @"\Config\LoginServer.ini", @"\Config\IPCServer.ini", @"\Config\GameServer.ini");
         System.Threading.Thread.Sleep(5000);
         Environment.Exit(0);
     }
     else
     {
         Ini settings;
     #endregion
         #region Login Server
         settings = new Ini(Environment.CurrentDirectory + @"\Config\LoginServer.ini");
         Serverdef.Loginserver_PORT = Convert.ToInt32(settings.GetValue("LS_Information", "Port", 15779));
         Serverdef.Loginserver_IP = settings.GetValue("LS_Information", "Ipadress", "").ToString();
         Serverdef.SilkroadClientVersion = settings.GetValue("LS_Information", "Version",0);
         Serverdef.SilkroadClientLocale = (byte)settings.GetValue("LS_Information", "Locale",0);
         settings = null;
         #endregion
         #region IPC Server
         settings = new Ini(Environment.CurrentDirectory + @"\Config\IPCServer.ini");
         Serverdef.IPCPort = Convert.ToUInt16(settings.GetValue("IPC_Information", "Port", 15779));
         Serverdef.IPCIP = settings.GetValue("IPC_Information", "Ipadress", "").ToString();
         settings = null;
         #endregion
         #region Game Server
         settings = new Ini(Environment.CurrentDirectory + @"\Config\GameServer.ini");
         string[] server_list = null;
         server_list = settings.GetEntryNames("SERVERS");
         if (server_list != null && server_list.Length > 0)
         {
             foreach (string sectname in server_list)
             {
                 string selectedserver = settings.GetValue("SERVERS", sectname, "");
                 Serverdef.ServerDetails Serverinformation = new Serverdef.ServerDetails();
                 Serverinformation.id = Convert.ToUInt16(settings.GetValue(selectedserver, "id", 0));
                 Serverinformation.ip = settings.GetValue(selectedserver, "ip", "");
                 Serverinformation.name = settings.GetValue(selectedserver, "name", selectedserver);
                 Serverinformation.port = Convert.ToUInt16(settings.GetValue(selectedserver, "port", 15780));
                 Serverinformation.ipcport = Convert.ToUInt16(settings.GetValue(selectedserver, "ipcport", 15780));
                 Serverinformation.code = settings.GetValue(selectedserver, "code", "");
                	if (Serverinformation.ip == "" || Serverinformation.port == 0 || Serverinformation.id == 0 || Serverinformation.ipcport == 0 || Serverdef.Serverlist.ContainsKey(Serverinformation.id))
                 {
                     Console.WriteLine("Error " + selectedserver + " in " + @"\Config\GameServer.ini" + ": field missing or id already in use!");
                     Serverinformation = null;
                 }
                 else
                 {
                     Console.WriteLine("Added {0} To the serverlist", Serverinformation.name);
                 }
                 Serverdef.Serverlist.Add(Serverinformation.id, Serverinformation);
             }
         }
         server_list = null;
         settings = null;
         Console.WriteLine(Serverdef.TextDivider);
         #endregion
         #region NEWS
         int news_count = 0;
         string[] fileEntries = Directory.GetFiles(Environment.CurrentDirectory + @"\News", @"????-??-??.*");
         if (fileEntries.Length > 0)
         {
             Array.Sort(fileEntries);
             Array.Reverse(fileEntries);
             foreach (string fName in fileEntries)
             {
                 if (news_count < 10)
                 {
                     DateTime aDate;
                     if (DateTime.TryParse(Path.GetFileNameWithoutExtension(fName), out aDate))
                     {
                         using (StreamReader aFile = new StreamReader(fName))
                         {
                             string line = aFile.ReadLine();
                             if (line != null)
                             {
                                 string line2 = aFile.ReadToEnd();
                                 if (line2 != null)
                                 {
                                     Serverdef.NewsList Item = new Serverdef.NewsList();
                                     Item.Title = line;
                                     Item.Article = line2;
                                     Item.Day = (short)aDate.Day;
                                     Item.Month = (short)aDate.Month;
                                     Item.Year = (short)aDate.Year;
                                     Serverdef.News_List.Add(Item);
                                     news_count++;
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     Console.WriteLine("Please remove old news, only 10 are loaded!");
                 }
                 Console.WriteLine("Loaded {0} News Articles\n", news_count);
                 Console.WriteLine(Serverdef.TextDivider);
             }
         }
         else
         {
             Console.WriteLine("There is no news to be loaded\n");
         }
         #endregion
     }
 }
        public void LoadWeather()
        {
            //Wrap our function inside a catcher
            try
            {
                //NOTE: Must be defined per zone and random information

                //Load info from ini for now
                Ini ini = new Ini();
                ini = new CLFramework.Ini(Environment.CurrentDirectory + @"\Settings\Settings.ini");
                string Enabled = ini.GetValue("Custom", "WeatherEnabled", "true").ToString();
                string Type = ini.GetValue("Custom", "WeatherType", "1").ToString();
                string Info = ini.GetValue("Custom", "WeatherInfo", "10").ToString();

                //If the user has defined to enable custom weather type
                if (Enabled == "1")
                {
                    //We send the information they chosen
                    client.Send(Packet.Weather(Convert.ToByte(Type), Convert.ToInt32(Info)));
                }
                //If disabled
                else
                {
                    //Send static weather
                    client.Send(Packet.Weather(0, 1));
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }
        }
        public static bool LoadServers(string serverFile, ushort defaultPort)
        {
            try
            {
                if (File.Exists(Environment.CurrentDirectory + @"\Settings\" + serverFile))
                {
                    Ini ini = new Ini(Environment.CurrentDirectory + @"\Settings\" + serverFile);
                    string[] sList = null;
                    sList = ini.GetEntryNames("SERVERS");
                    if (sList != null && sList.Length > 0)
                    {

                        foreach (string sectname in sList)
                        {
                            string sName = ini.GetValue("SERVERS", sectname, "");
                            SrevoServerInfo SServerInfo = new SrevoServerInfo();
                            SServerInfo.id = Convert.ToUInt16(ini.GetValue(sName, "id", 0));
                            SServerInfo.ip = ini.GetValue(sName, "ip", "");
                            SServerInfo.ipcport = Convert.ToUInt16(ini.GetValue(sName, "ipcport", defaultPort));
                            SServerInfo.code = ini.GetValue(sName, "code", "");
                            if (SServerInfo.ip == "" || SServerInfo.id == 0 || SServerInfo.ipcport == 0 || LSList.ContainsKey(SServerInfo.id))
                            {
                                Log.Exception(string.Format("IPC: Error on Server \"{0}\" in {1}: Mandatory field missing or id already in use!", sName, serverFile));
                                SServerInfo = null;
                            }
                            else
                            {
                                LSList.Add(SServerInfo.id, SServerInfo);
                            }
                        }
                    }
                    if (LSList.Count > 0)
                    {
                        Console.WriteLine("");
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("------------------------------------[SERVER]------------------------------------");
                        string defServer = "Server";
                        if (LSList.Count > 1) defServer = "Servers";
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("                          Added:");
                        Console.ForegroundColor = ConsoleColor.White;
                        Console.Write(" {0} ", LSList.Count());
                        Console.ForegroundColor = ConsoleColor.Green;
                        Console.Write("{0} to the list", defServer);
                        Console.WriteLine();
                        return true;
                    }
                    else
                    {
                        Log.Exception("[IPC] Info: No LoginServers configured, using a default local LoginServer.");
                        return false;
                    }
                    sList = null;
                    ini = null;
                }
                else
                {
                    return false;
                }
            }
            catch (Exception ex)
            {
                Log.Exception(ex);

            }
            return false;
        }
        static void Main(string[] args)
        {
            Ini ini;
            string sqlConnect = @"Data Source=(local)\SQLEXPRESS;Initial Catalog=silk;Integrated Security=True;MultipleActiveResultSets=True;";
            string sIpIPC = "";
            string sIpServer = "";
            ushort iPortIPC = 15780;
            ushort iPortServer = 15780;
            ushort iPortCmd = 10101;
            if (File.Exists("./Settings/Settings.ini"))
            {
                //Load our ini file
                ini = new Ini(Environment.CurrentDirectory + @"\Settings\Settings.ini");
                //Read line below given value.
                sqlConnect = ini.GetValue("Database", "connectionstring", @"Data Source=(local)\SQLEXPRESS;Initial Catalog=silk;Integrated Security=True;MultipleActiveResultSets=True;").ToString();
                //Load our rates.
                Helpers.Settings.Rate.Gold = Convert.ToByte(ini.GetValue("Rates", "Goldrate", 1));
                Helpers.Settings.Rate.Item = Convert.ToByte(ini.GetValue("Rates", "Droprate", 1));
                Helpers.Settings.Rate.Experience = Convert.ToByte(ini.GetValue("Rates", "XPrate", 1));
                Helpers.Settings.Rate.SkillPoint = Convert.ToByte(ini.GetValue("Rates", "SPrate", 1));
                Helpers.Settings.Rate.ItemSox = Convert.ToByte(ini.GetValue("Rates", "Sealrate", 1));
                Helpers.Settings.Rate.Elixir = Convert.ToByte(ini.GetValue("Rates", "Elixirsrate", 1));
                Helpers.Settings.Rate.Alchemy = Convert.ToByte(ini.GetValue("Rates", "Alchemyrate", 1));
                Helpers.Settings.Rate.ETC = Convert.ToByte(ini.GetValue("Rates", "ETCrate", 1));
                Helpers.Settings.Rate.MonsterSpawn = Convert.ToByte(ini.GetValue("Rates", "Spawnrate", 1));
                iPortIPC = Convert.ToUInt16(ini.GetValue("IPC", "port", 15780));
                sIpIPC = ini.GetValue("IPC", "ip", "");
                iPortServer = Convert.ToUInt16(ini.GetValue("Server", "port", 15780));
                sIpServer = ini.GetValue("Server", "ip", "");
                iPortCmd = Convert.ToUInt16(ini.GetValue("CMD", "port", 10101));
                Helpers.Manager.maxSlots = Convert.ToInt32(ini.GetValue("Server", "MaxSlots", 100));
            }
            else
            {
                Log.Exception("Settings Error");
            }
            DB.Connection(sqlConnect);
            // create servers
            try
            {
                net = new Server();

                net.OnConnect += new Server.dConnect(_OnClientConnect);

                Helpers.Manager.ServerStartedTime = DateTime.Now;

                SRClient.OnReceiveData += new SRClient.dReceive(_OnReceiveData);
                SRClient.OnDisconnect += new SRClient.dDisconnect(_OnClientDisconnect);

                #region IPC Server StartUp
                Helpers.Manager.IPC = new Servers.IPCServer();
                Helpers.Manager.IPC.OnReceive += new Servers.IPCServer.dOnReceive(_OnIPC);
                Helpers.Settings.LoadServers("LoginServers.ini", 15779);
                #endregion

            }
            catch (Exception ex)
            {
                Log.Exception(ex);
            }

            #region Check Directories
            string cur_path = Environment.CurrentDirectory + @"\PlayerData\";
            Directory.CreateDirectory(cur_path + "HotKey");
            Directory.CreateDirectory(cur_path + "AutoPotion");
            Directory.CreateDirectory(cur_path + "Log");
            cur_path = null;
            #endregion
            FileDB.Load();
            //Update serverlist info
            Helpers.Manager.clients.update += new EventHandler(Brain.ServerMgr.UpdateServerInfo);
            Helpers.Manager.IPC.Start(sIpIPC, iPortIPC);
            net.Start(sIpServer, iPortServer);
            Brain.ServerMgr.UpdateServerInfo();
            // main loop
            lastPromote = DateTime.Now;
            Console.ReadLine();
            Brain.ServerMgr.UpdateServerInfo(0);
        }