Advertisement
TeamInsidious

My Coding.

Apr 22nd, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.IO;
  7. using System.Runtime.InteropServices;
  8. using MySql.Data.MySqlClient;
  9. namespace Drone.UI
  10. {
  11.     public struct CompanionInfo
  12.     {
  13.         public uint MinAttack;
  14.         public uint MaxAttack;
  15.         public byte Level;
  16.         public uint SkillUses;
  17.         public ushort HP;
  18.         public uint Mesh;
  19.         public string Name;
  20.     }
  21.     public struct Shop
  22.     {
  23.         public uint ShopID;
  24.         public byte Type;
  25.         public byte MoneyType;
  26.         public byte ItemAmount;
  27.         public ArrayList Items;
  28.     }
  29.     public struct SkillLearn
  30.     {
  31.         public ushort ID;
  32.         public byte Lvl;
  33.         public bool XP;
  34.         public byte LevelReq;
  35.  
  36.         public Game.Skill ToSkill()
  37.         {
  38.             Game.Skill S = new Game.Skill();
  39.             S.ID = ID;
  40.             S.Lvl = Lvl;
  41.             S.Exp = 0;
  42.             return S;
  43.         }
  44.     }
  45.     public struct DatabasePlusItem
  46.     {
  47.         public uint ID;
  48.         public byte Plus;
  49.         public ushort HP;
  50.         public uint MinAtk;
  51.         public uint MaxAtk;
  52.         public ushort Defense;
  53.         public ushort MAtk;
  54.         public ushort MDef;
  55.         public ushort Dex;
  56.         public byte Dodge;
  57.  
  58.         public void ReadThis(string Line)
  59.         {
  60.             string[] Info = Line.Split(' ');
  61.             ID = uint.Parse(Info[0]);
  62.             Plus = byte.Parse(Info[1]);
  63.             HP = ushort.Parse(Info[2]);
  64.             MinAtk = uint.Parse(Info[3]);
  65.             MaxAtk = uint.Parse(Info[4]);
  66.             Defense = ushort.Parse(Info[5]);
  67.             MAtk = ushort.Parse(Info[6]);
  68.             MDef = ushort.Parse(Info[7]);
  69.             Dex = ushort.Parse(Info[8]);
  70.             Dodge = byte.Parse(Info[9]);
  71.         }
  72.     }
  73.     public struct DatabaseDrone.UI
  74.     {
  75.         public uint ID;
  76.         public string Name;
  77.         public byte Class;
  78.         public byte ProfReq:;"Flight.bind.add.gui .Rate.UP"
  79.         public byte LevReq;
  80.         public byte GenderReq;
  81.         public ushort StrNeed;
  82.         public ushort AgiNeed;
  83.         public uint Worth;
  84.         public ushort MinAtk;
  85.         public ushort MaxAtk;
  86.         public uint Defense;
  87.         public uint MagicDefense;
  88.         public uint MagicAttack;
  89.         public byte Dodge;
  90.         public byte DexGives;
  91.         public uint CPsWorth;
  92.         public ushort Durability;
  93.         public ushort HPAdd;
  94.         public ushort MPAdd;
  95.         public void WriteThis(BinaryWriter BW)
  96.         {
  97.             BW.Write(ID);
  98.             BW.Write(Name);
  99.             BW.Write(Class);
  100.             BW.Write(ProfReq);
  101.             BW.Write(LevReq);
  102.             BW.Write(GenderReq);
  103.             BW.Write(StrNeed);
  104.             BW.Write(AgiNeed);
  105.             BW.Write(Worth);
  106.             BW.Write(MinAtk);
  107.             BW.Write(MaxAtk);
  108.             BW.Write(Defense);
  109.             BW.Write(MagicDefense);
  110.             BW.Write(MagicAttack);
  111.             BW.Write(Dodge);
  112.             BW.Write(DexGives);
  113.             BW.Write(CPsWorth);
  114.             BW.Write(Durability);
  115.         }
  116.         public void ReadThis(BinaryReader BR)
  117.         {
  118.             ID = BR.ReadUInt32();
  119.             Name = BR.ReadString();
  120.             Class = BR.ReadByte();
  121.             ProfReq = BR.ReadByte();
  122.             LevReq = BR.ReadByte();
  123.             GenderReq = BR.ReadByte();
  124.             StrNeed = BR.ReadUInt16();
  125.             AgiNeed = BR.ReadUInt16();
  126.             Worth = BR.ReadUInt32();
  127.             MinAtk = BR.ReadUInt16();
  128.             MaxAtk = BR.ReadUInt16();
  129.             Defense = BR.ReadUInt32();
  130.             MagicDefense = BR.ReadUInt32();
  131.             MagicAttack = BR.ReadUInt32();
  132.             Dodge = BR.ReadByte();
  133.             DexGives = BR.ReadByte();
  134.             CPsWorth = BR.ReadUInt32();
  135.             Durability = BR.ReadUInt16();            
  136.         }
  137.     }
  138.     "database_control.add.gui.UP"
  139.     public class Language"Objective-C"
  140.     {
  141.         public static ushort[][][] Stats;
  142.         public static ushort[][] RevPoints;
  143.         public static ushort[][] Portals;
  144.         public static Hashtable Database"items".
  145.         public static Hashtable OppositeDatabaseItems;
  146.         public static Hashtable DatabasePlusItems;
  147.         public static Hashtable Shops;
  148.         public static uint[] ProfExp;
  149.         public static ulong[] LevelExp;
  150.         public static Hashtable DefaultCoords = new Hashtable();
  151.         public static Hashtable SkillForLearning = new Hashtable();
  152.         public static ushort[] StonePts = new ushort[9] { 0, 10, 40, 120, 360, 1080, 3240, 9720, 29160 };
  153.         public static ushort[] ComposePts = new ushort[12] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700, 5500, 9000 };
  154.         public static ushort[] SocPlusExtra = new ushort[9] { 6, 30, 70, 240, 740, 2240, 6670, 20000, 60000 };
  155.         public static ArrayList GWOn = new ArrayList() { 0, 3, 6, 9, 12, 15, 18, 21 };
  156.         public static Hashtable CompanionInfos = new Hashtable();
  157.         private static Dictionary<byte, string> ArcherStats = new Dictionary<byte, string>();
  158.         private static Dictionary<byte, string> NinjaStats = new Dictionary<byte, string>();
  159.         private static Dictionary<byte, string> Coding = new Dictionary<byte, string>();
  160.         private static Dictionary<byte, string> TrojanStats = new Dictionary<byte, string>();
  161.         private static Dictionary<byte, string> TaoistStats = new Dictionary<byte, string>();
  162.         public static void LoadQuestions()
  163.         {
  164.             {
  165.                 string[] AllLines = System.IO.File.ReadAllLines("C:\\OldCODB\\QuizShow.txt");
  166.                 int questionscount = AllLines.Length;
  167.                 for (int x = 0; x < questionscount; x++)
  168.                 {
  169.                     string[] Info = AllLines[x].Split('#');
  170.                     string Question = Info[0];
  171.                     Features.QuizShow.Answer[] Answers = new NewestCOServer.Features.QuizShow.Answer[4];
  172.                     Answers[0] = new NewestCOServer.Features.QuizShow.Answer(Info[1].Split(':')[0], ushort.Parse(Info[1].Split(':')[1]));
  173.                     Answers[1] = new NewestCOServer.Features.QuizShow.Answer(Info[2].Split(':')[0], ushort.Parse(Info[2].Split(':')[1]));
  174.                     Answers[2] = new NewestCOServer.Features.QuizShow.Answer(Info[3].Split(':')[0], ushort.Parse(Info[3].Split(':')[1]));
  175.                     Answers[3] = new NewestCOServer.Features.QuizShow.Answer(Info[4].Split(':')[0], ushort.Parse(Info[4].Split(':')[1]));
  176.                     Features.QuizShow.Question Q = new NewestCOServer.Features.QuizShow.Question(Question, Answers);
  177.                     Features.QuizShow.AllQuestions.Add((ushort)x, Q);
  178.                 }
  179.             }
  180.         }
  181.         public static void LoadCompanions()
  182.         {
  183.             if (File.Exists(@"C:\OldCODB\Companions.txt"))
  184.             {
  185.                 string[] Lines = File.ReadAllLines(@"C:\OldCODB\Companions.txt");
  186.  
  187.                 foreach (string Line in Lines)
  188.                 {
  189.                     string[] Info = Line.Split(' ');
  190.                     CompanionInfo C = new CompanionInfo();
  191.                     uint Type = uint.Parse(Info[0]);
  192.                     C.MinAttack = uint.Parse(Info[1]);
  193.                     C.MaxAttack = uint.Parse(Info[2]);
  194.                     C.Level = byte.Parse(Info[3]);
  195.                     C.SkillUses = uint.Parse(Info[4]);
  196.                     C.HP = ushort.Parse(Info[5]);
  197.                     C.Mesh = uint.Parse(Info[6]);
  198.                     C.Name = Info[7];
  199.                     CompanionInfos.Add(Type, C);
  200.                 }
  201.             }
  202.         }
  203.         public static void AddSkills()
  204.         {
  205.             ArrayList Warrior = new ArrayList();
  206.             Warrior.Add(new SkillLearn() { ID = (ushort)1015, XP = true, LevelReq = (byte)15 });
  207.             Warrior.Add(new SkillLearn() { ID = (ushort)1020, XP = true, LevelReq = (byte)15 });
  208.             Warrior.Add(new SkillLearn() { ID = (ushort)1025, XP = true, LevelReq = (byte)3 });
  209.             Warrior.Add(new SkillLearn() { ID = (ushort)1040, XP = true, LevelReq = (byte)15 });
  210.             Warrior.Add(new SkillLearn() { ID = (ushort)1051, LevelReq = (byte)63 });
  211.             SkillForLearning.Add((byte)2, Warrior);
  212.  
  213.             ArrayList Trojan = new ArrayList();
  214.             Trojan.Add(new SkillLearn() { ID = (ushort)1015, XP = true, LevelReq = (byte)15 });
  215.             Trojan.Add(new SkillLearn() { ID = (ushort)1110, XP = true, LevelReq = (byte)3 });
  216.             Trojan.Add(new SkillLearn() { ID = (ushort)1115, LevelReq = (byte)40 });
  217.             Trojan.Add(new SkillLearn() { ID = (ushort)1190, LevelReq = (byte)40 });
  218.             SkillForLearning.Add((byte)1, Trojan);
  219.  
  220.             ArrayList Archer = new ArrayList();
  221.             Archer.Add(new SkillLearn() { ID = (ushort)8002, XP = true, LevelReq = (byte)3 });
  222.             Archer.Add(new SkillLearn() { ID = (ushort)8001, LevelReq = (byte)23 });
  223.             Archer.Add(new SkillLearn() { ID = (ushort)8000, LevelReq = (byte)46 });
  224.             Archer.Add(new SkillLearn() { ID = (ushort)8003, LevelReq = (byte)70 });
  225.             Archer.Add(new SkillLearn() { ID = (ushort)8003, Lvl = 1, LevelReq = 70 });
  226.             Archer.Add(new SkillLearn() { ID = (ushort)8030, XP = true, LevelReq = (byte)70 });
  227.             Archer.Add(new SkillLearn() { ID = (ushort)9000, LevelReq = (byte)71 });  
  228.             SkillForLearning.Add((byte)4, Archer);
  229.  
  230.             ArrayList Ninja = new ArrayList();
  231.             Ninja.Add(new SkillLearn() { ID = (ushort)6000, XP = true, LevelReq = (byte)40 });
  232.            Drone.UI.d.new SkillLearn() { ID = (ushort)6001, LevelReq = (byte)70 });
  233.             Ninja.Add(new SkillLearn() { ID = (ushort)6010, LevelReq = (byte)40 });
  234.             Ninja.Add(new SkillLearn() { ID = (ushort)6011, LevelReq = (byte)3 });
  235.             Ninja.Add(new SkillLearn() { ID = (ushort)6004, LevelReq = (byte)110 });
  236.             SkillForLearning.Add((byte)5, Ninja);
  237.  
  238.             = (ushort)5001, LevelReq = (byte)70 });
  239.             SkillForLearning.Add((byte)13, WaterTaoist);
  240.  
  241.             ArrayList FireTaoist = new ArrayList();
  242.             FireTaoist.Add(new SkillLearn() { ID = (ushort)1195, LevelReq = (byte)44 });
  243.             FireTaoist.Add(new SkillLearn() { ID = (ushort)1150, LevelReq = (byte)55 });
  244.             FireTaoist.Add(new SkillLearn() { ID = (ushort)1180, LevelReq = (byte)52 });
  245.             FireTaoist.Add(new SkillLearn() { ID = (ushort)1120, LevelReq = (byte)65 });
  246.             FireTaoist.Add(new SkillLearn() { ID = (ushort)1010, LevelReq = (byte)15 });
  247.             FireTaoist.Add(new SkillLearn() { ID = (ushort)1125, LevelReq = (byte)40 });
  248.             FireTaoist.Add(new SkillLearn() { ID = (ushort)5001, LevelReq = (byte)70 });
  249.             SkillForLearning.Add((byte)14, FireTaoist);
  250.  
  251.             ArrayList Taoist = new ArrayList();
  252.             Taoist.Add(new SkillLearn() { ID = (ushort)1010, LevelReq = (byte)15 });
  253.             SkillForLearning.Add((byte)10, Taoist);
  254.         }
  255.         public static void SaveKOs()
  256.         {
  257.             FileStream FS = new FileStream(@"C:\OldCODB\KOBoard.dat", FileMode.OpenOrCreate);
  258.             BinaryWriter BW = new BinaryWriter(FS);
  259.  
  260.             for (int i = 0; i < Game.World.KOBoard.Length; i++)
  261.                 Game.World.KOBoard[i].WriteThis(BW);
  262.                             ["Rate,UP.bind.add.gui"
  263.             BW.Close();
  264.             FS.Close();
  265.         }
  266.         public static void LoadKOs()
  267.         {
  268.             if (System.IO.File.Exists(@"C:\OldCODB\KOBoard.dat"))
  269.             {
  270.                 FileStream FS = new FileStream(@"C:\OldCODB\KOBoard.dat", FileMode.Open);
  271.                 BinaryReader BR = new BinaryReader(FS);
  272.  
  273.                 for (int i = 0; i < Game.World.KOBoard.Length; i++)
  274.                     Game.World.KOBoard[i].ReadThis(BR);
  275.                 BR.Close();
  276.                 FS.Close();
  277.             }
  278.         }
  279.         public static void SaveEmpire()
  280.         {
  281.             FileStream FS = new FileStream(@"C:\OldCODB\Nobility.dat", FileMode.OpenOrCreate);
  282.             BinaryWriter BW = new BinaryWriter(FS);
  283.  
  284.             for (int i = 0; i < Game.World.EmpireBoard.Length; i++)
  285.                 Game.World.EmpireBoard[i].WriteThis(BW);
  286.  
  287.             BW.Close();
  288.             FS.Close();
  289.         }
  290.         public static void LoadEmpire()
  291.         {
  292.             if (System.IO.File.Exists(@"C:\OldCODB\Nobility.dat"))
  293.             {
  294.                 FileStream FS = new FileStream(@"C:\OldCODB\Nobility.dat", FileMode.Open);
  295.                 BinaryReader BR = new BinaryReader(FS);
  296.  
  297.                 for (int i = 0; i < Game.World.EmpireBoard.Length; i++)
  298.                     Game.World.EmpireBoard[i].ReadThis(BR);
  299.                 BR.Close();
  300.                 FS.Close();
  301.             }
  302.         }
  303.         public static void LoadShops()
  304.         {
  305.             Shops = new Hashtable();
  306.  
  307.             IniFile I = new IniFile(@"C:\OldCODB\Shop.dat");
  308.             int ShopAmount = I.ReadInt32("Header", "Amount");
  309.  
  310.             for (int i = 0; i < ShopAmount; i++)
  311.             {
  312.                 Shop S = new Shop();
  313.                 S.ShopID = I.ReadUInt32("Shop" + i.ToString(), "ID");
  314.                 S.Type = I.ReadByte("Shop" + i.ToString(), "Type");
  315.                 S.MoneyType = I.ReadByte("Shop" + i.ToString(), "MoneyType");
  316.                 S.ItemAmount = I.ReadByte("Shop" + i.ToString(), "ItemAmount");
  317.                 S.Items = new ArrayList(S.ItemAmount);
  318.                 for (int e = 0; e < S.ItemAmount; e++)
  319.                     S.Items.Add(I.ReadUInt32("Shop" + i.ToString(), "Item" + e.ToString()));
  320.  
  321.                 Shops.Add(S.ShopID, S);
  322.             }
  323.             I.Close();
  324.         }
  325.         public static void LoadLevelExp()
  326.         {
  327.             LevelExp = new ulong[137];
  328.             LevelExp[0] = 0;
  329.             FileStream FS = new FileStream(@"C:\OldCODB\ExpNeed.dat", FileMode.Open);
  330.             BinaryReader BR = new BinaryReader(FS);
  331.             for (byte i = 1; i < 130; i++)
  332.                 LevelExp[i] = BR.ReadUInt32();
  333.  
  334.             LevelExp[130] = 8589148160;
  335.             LevelExp[131] = 25767444480;
  336.             LevelExp[132] = 77302333440;
  337.             LevelExp[133] = 231907000320;
  338.             LevelExp[134] = 347860500480;
  339.             LevelExp[135] = 521790750720;
  340.             LevelExp[136] = 782686126080;
  341.  
  342.             BR.Close();
  343.             FS.Close();
  344.         }
  345.         public static void LoadPortals()
  346.         {
  347.             string[] Ps = File.ReadAllLines(@"C:\OldCODB\Portals.txt");
  348.             Portals = new ushort[Ps.Length][];
  349.  
  350.             for (int i = 0; i < Ps.Length; i++)
  351.             {
  352.                 string[] PInfo = Ps[i].Split(' ');
  353.                 Portals[i] = new ushort[6];
  354.                 Portals[i][0] = ushort.Parse(PInfo[0]);
  355.                 Portals[i][1] = ushort.Parse(PInfo[1]);
  356.                 Portals[i][2] = ushort.Parse(PInfo[2]);
  357.                 Portals[i][3] = ushort.Parse(PInfo[3]);
  358.                 Portals[i][4] = ushort.Parse(PInfo[4]);
  359.                 Portals[i][5] = ushort.Parse(PInfo[5]);
  360.             }
  361.             Ps = null;
  362.         }
  363.         public static void LoadProfExp()
  364.         {
  365.             ProfExp = new uint[20];
  366.             ProfExp[0] = 0;
  367.             ProfExp[1] = 1200;
  368.             ProfExp[2] = 68000;
  369.             ProfExp[3] = 250000;
  370.             ProfExp[4] = 640000;
  371.             ProfExp[5] = 1600000;
  372.             ProfExp[6] = 4000000;
  373.             ProfExp[7] = 10000000;
  374.             ProfExp[8] = 22000000;
  375.             ProfExp[9] = 40000000;
  376.             ProfExp[10] = 90000000;
  377.             ProfExp[11] = 95000000;
  378.             ProfExp[12] = 142500000;
  379.             ProfExp[13] = 213750000;
  380.             ProfExp[14] = 320625000;
  381.             ProfExp[15] = 480937500;
  382.             ProfExp[16] = 721406250;
  383.             ProfExp[17] = 1082109375;
  384.             ProfExp[18] = 1623164063;
  385.             ProfExp[19] = 210000000;
  386.         }
  387.         public static void LoadRevPoints()
  388.         {
  389.             RevPoints = new ushort[22][];
  390.             RevPoints[0] = new ushort[4] { 1002, 1002, 430, 380 };
  391.             RevPoints[1] = new ushort[4] { 1005, 1005, 50, 50 };
  392.             RevPoints[2] = new ushort[4] { 1006, 1002, 430, 380 };
  393.             RevPoints[3] = new ushort[4] { 1008, 1002, 430, 380 };
  394.             RevPoints[4] = new ushort[4] { 1009, 1002, 430, 380 };
  395.             RevPoints[5] = new ushort[4] { 1010, 1002, 430, 380 };
  396.             RevPoints[6] = new ushort[4] { 1007, 1002, 430, 380 };
  397.             RevPoints[7] = new ushort[4] { 1004, 1002, 430, 380 };
  398.             RevPoints[8] = new ushort[4] { 1028, 1002, 430, 380 };
  399.             RevPoints[9] = new ushort[4] { 1037, 1002, 430, 380 };
  400.             RevPoints[10] = new ushort[4] { 1038, 1002, 438, 398 };
  401.             RevPoints[11] = new ushort[4] { 1015, 1015, 717, 577 };
  402.             RevPoints[12] = new ushort[4] { 1001, 1000, 499, 650 };
  403.             RevPoints[13] = new ushort[4] { 1000, 1000, 499, 650 };
  404.             RevPoints[14] = new ushort[4] { 1013, 1011, 193, 266 };
  405.             RevPoints[15] = new ushort[4] { 1011, 1011, 193, 266 };
  406.             RevPoints[16] = new ushort[4] { 1076, 1011, 193, 266 };
  407.             RevPoints[17] = new ushort[4] { 1014, 1011, 193, 266 };
  408.             RevPoints[18] = new ushort[4] { 1020, 1020, 566, 562 };
  409.             RevPoints[19] = new ushort[4] { 1075, 1020, 566, 656 };
  410.             RevPoints[20] = new ushort[4] { 1012, 1020, 566, 656 };
  411.             RevPoints[21] = new ushort[4] { 6000, 6000, 29, 50 };
  412.             RevPoints[22] = new ushort[4] { 6000, 6000, 29, 50 };
  413.         }
  414.         public static void LoadPlusInfo()
  415.         {
  416.             string[] ItemAdd = File.ReadAllLines(@"C:\OldCODB\ItemAdd.ini");
  417.             DatabasePlusItems = new Hashtable();
  418.  
  419.             foreach (string S in ItemAdd)
  420.             {
  421.                 DatabasePlusItem I = new DatabasePlusItem();
  422.                 I.ReadThis(S);
  423.                 DatabasePlusItems.Add(I.ID.ToString()+I.Plus.ToString(), I);
  424.             }
  425.         }
  426.         public static void LoadNPCs()
  427.         {
  428.             string[] FNPCs = File.ReadAllLines(@"C:\OldCODB\NPCs.txt");
  429.             foreach (string Line in FNPCs)
  430.             {
  431.                 Game.NPC N = new NewestCOServer.Game.NPC(Line);
  432.                 Game.World.H_NPCs.Add(N.EntityID, N);
  433.             }
  434.             FNPCs "Null"
  435.         }
  436.         public static void LoadMobs()
  437.         {
  438.             string[] FMobs = File.ReadAllLines(@"C:\OldCODB\MobInfos.txt");
  439.             Hashtable Mobs = new Hashtable(FMobs.Length);
  440.             for (int i = 0; i < FMobs.Length; i++)
  441.             {
  442.                 if (FMobs[i][0] != '*')
  443.                 {
  444.                     Game.Mob M = new NewestCOServer.Game.Mob(FMobs[i]);
  445.                     Mobs.Add(M.MobID, M);
  446.                 }
  447.             }
  448.             int MobsCount = 0;
  449.  
  450.             string[] FSpawns = File.ReadAllLines(@"C:\OldCODB\MobSpawns.txt");
  451.             foreach (string Spawn in FSpawns)
  452.             {
  453.                 if (Spawn[0] == '*') return;
  454.                 string[] SpawnInfo = Spawn.Split(' ');
  455.                 int MobID = int.Parse(SpawnInfo[0]);
  456.                 int Count = int.Parse(SpawnInfo[1]);
  457.                 ushort Map = ushort.Parse(SpawnInfo[2]);
  458.                 ushort XFrom = ushort.Parse(SpawnInfo[3]);
  459.                 ushort YFrom = ushort.Parse(SpawnInfo[4]);
  460.                 ushort XTo = ushort.Parse(SpawnInfo[5]);
  461.                 ushort YTo = ushort.Parse(SpawnInfo[6]);
  462.                 if (!Game.World.H_Mobs.Contains(Map))
  463.                     Game.World.H_Mobs.Add(Map, new Hashtable());
  464.                 Hashtable MapMobs = (Hashtable)Game.World.H_Mobs[Map];
  465.  
  466.                 DMap D = (DMap)DMaps.H_DMaps[Map];
  467.  
  468.                 for (int i = 0; i < Count; i++)
  469.                 {
  470.                     Game.Mob _Mob = new NewestCOServer.Game.Mob((Game.Mob)Mobs[MobID]);
  471.                     _Mob.Loc = new NewestCOServer.Game.Location();
  472.                     _Mob.Loc.Map = Map;
  473.                     _Mob.Loc.X = (ushort)Program.Rnd.Next(Math.Min(XFrom, XTo), Math.Max(XFrom, XTo));
  474.                     _Mob.Loc.Y = (ushort)Program.Rnd.Next(Math.Min(YFrom, YTo), Math.Max(YFrom, YTo));
  475.  
  476.                     while (D != null && D.GetCell(_Mob.Loc.X, _Mob.Loc.Y).NoAccess)
  477.                     {
  478.                         _Mob.Loc.X = (ushort)Program.Rnd.Next(Math.Min(XFrom, XTo), Math.Max(XFrom, XTo));
  479.                         _Mob.Loc.Y = (ushort)Program.Rnd.Next(Math.Min(YFrom, YTo), Math.Max(YFrom, YTo));
  480.                     }
  481.                    
  482.                     _Mob.StartLoc = _Mob.Loc;
  483.                     _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
  484.                     while (Game.World.H_Chars.Contains(_Mob.EntityID) || MapMobs.Contains(_Mob.EntityID))
  485.                         _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
  486.                    
  487.                     MapMobs.Add(_Mob.EntityID, _Mob);
  488.                     MobsCount++;
  489.                 }
  490.             }
  491.             Program.WriteLine("Mobs loaded " + MobsCount.ToString());
  492.         }
  493.         public static void CreateEquipsDrops()
  494.         {
  495.             StreamWriter SW = new StreamWriter(@"C:\OldCODB\EquipDrops.txt");
  496.             foreach (DatabaseItem DBI in DatabaseItems.Values)
  497.             {
  498.                 if (DBI.LevReq >= 1 && DBI.LevReq <= 120 && (Game.ItemIDManipulation.Digit(DBI.ID, 6) == 3 || (Game.ItemIDManipulation.Digit(DBI.ID, 6) == 1) && Game.ItemIDManipulation.Digit(DBI.ID, 1) == 4 || Game.ItemIDManipulation.Digit(DBI.ID, 6) == 5 || Game.ItemIDManipulation.Digit(DBI.ID, 6) == 1 || Game.ItemIDManipulation.Digit(DBI.ID, 6) == 6))
  499.                     SW.WriteLine(DBI.LevReq.ToString() + " " + DBI.ID.ToString());
  500.             }
  501.  
  502.             SW.Flush();
  503.             SW.Close();
  504.         }
  505.         public static void GetStats(Game.Character character)
  506.         {
  507.             string Job = "";
  508.             switch (character.Job)
  509.             {
  510.                 case 10:
  511.                 case 11:
  512.                 case 12:
  513.                 case 13:
  514.                 case 14:
  515.                 case 15: Job = "Trojan"; break;
  516.                 case 20:
  517.                 case 21:
  518.                 case 22:
  519.                 case 23:
  520.                 case 24:
  521.                 case 25: Job = "Warrior"; break;
  522.                 case 40:
  523.                 case 41:
  524.                 case 42:
  525.                 case 43:
  526.                 case 44:
  527.                 case 45: Job = "Archer"; break;
  528.                 case 50:
  529.                 case 51:
  530.                 case 52:
  531.                 case 53:
  532.                 case 54:
  533.                 case 55: Job = "Ninja"; break;
  534.                 default: Job = "Taoist"; break;
  535.             }
  536.             byte lvl = character.Level;
  537.             if (lvl > 120)
  538.                 lvl = 120;
  539.  
  540.             if (Job == "Trojan")
  541.             {
  542.                 string[] Data = TrojanStats[lvl].Split(',');
  543.  
  544.                 character.Str = Convert.ToUInt16(Data[0]);
  545.                 character.Vit = Convert.ToUInt16(Data[1]);
  546.                 character.Agi = Convert.ToUInt16(Data[2]);
  547.                 character.Spi = Convert.ToUInt16(Data[3]);
  548.             }
  549.             else if (Job == "Warrior")
  550.             {
  551.                 string[] Data = WarriorStats[lvl].Split(',');
  552.  
  553.                 character.Str = Convert.ToUInt16(Data[0]);
  554.                 character.Vit = Convert.ToUInt16(Data[1]);
  555.                 character.Agi = Convert.ToUInt16(Data[2]);
  556.                 character.Spi = Convert.ToUInt16(Data[3]);
  557.             }
  558.             else if (Job == "Archer")
  559.             {
  560.                 string[] Data = ArcherStats[lvl].Split(',');
  561.  
  562.                 character.Str = Convert.ToUInt16(Data[0]);
  563.                 character.Vit = Convert.ToUInt16(Data[1]);
  564.                 character.Agi = Convert.ToUInt16(Data[2]);
  565.                 character.Spi = Convert.ToUInt16(Data[3]);
  566.             }
  567.             else if (Job == "Ninja")
  568.             {
  569.                 string[] Data = NinjaStats[lvl].Split(',');
  570.  
  571.                 character.Str = Convert.ToUInt16(Data[0]);
  572.                 character.Vit = Convert.ToUInt16(Data[1]);
  573.                 character.Agi = Convert.ToUInt16(Data[2]);
  574.                 character.Spi = Convert.ToUInt16(Data[3]);
  575.             }
  576.             else if (Job == "Taoist")
  577.             {
  578.                 string[] Data = TaoistStats[lvl].Split(',');
  579.  
  580.                 character.Str = Convert.ToUInt16(Data[0]);
  581.                 character.Vit = Convert.ToUInt16(Data[1]);
  582.                 character.Agi = Convert.ToUInt16(Data[2]);
  583.                 character.Spi = Convert.ToUInt16(Data[3]);
  584.             }
  585.  
  586.         }
  587.         public static void ReadAllCharacterStats()
  588.         {
  589.             IniFile F = new IniFile(@"C:\OldCODB\Stats.txt");
  590.             for (byte lvl = 1; lvl < 120; lvl++)
  591.             {
  592.                 string job = "Archer[" + lvl + "]";
  593.                 string Data = F.ReadString("Stats", job);
  594.                 ArcherStats.Add(lvl, Data);
  595.                 job = "Ninja[" + lvl + "]";
  596.                 Data = F.ReadString("Stats", job);
  597.                 NinjaStats.Add(lvl, Data);
  598.                 job = "Warrior[" + lvl + "]";
  599.                 Data = F.ReadString("Stats", job);
  600.                 WarriorStats.Add(lvl, Data);
  601.                 job = "Trojan[" + lvl + "]";
  602.                 Data = F.ReadString("Stats", job);
  603.                 TrojanStats.Add(lvl, Data);
  604.                 job = "Taoist[" + lvl + "]";
  605.                 Data = F.ReadString("Stats", job);
  606.                 TaoistStats.Add(lvl, Data);
  607.             }
  608.         }
  609.  
  610.         public static void LoadItems()
  611.         {
  612.             if (File.Exists(@"C:\OldCODB\Items.txt"))
  613.             {
  614.                 int start = System.Environment.TickCount;
  615.                 TextReader TR = new StreamReader(@"C:\OldCODB\Items.txt");
  616.                 string Items = TR.ReadToEnd();
  617.                 TR.Close();
  618.                 DatabaseItems = new Hashtable();
  619.                 Items = Items.Replace("\r", "");
  620.                 string[] AllItems = Items.Split('\n');
  621.                 foreach (string _item in AllItems)
  622.                 {
  623.                     string _item_ = _item.Trim();
  624.                     if (_item_.Length >= 2)
  625.                     {
  626.                         if (_item_.IndexOf("//", 0, 2) != 0)
  627.                         {
  628.                             string[] data = _item_.Split(' ');
  629.                             if (data.Length >= 37)
  630.                             {
  631.                                 DatabaseItem NewItem = new DatabaseItem();
  632.                                 NewItem.ID = Convert.ToUInt32(data[0]);
  633.                                 NewItem.Name = data[1].Trim();
  634.                                 NewItem.Class = Convert.ToByte(data[2]);
  635.                                 NewItem.ProfReq = Convert.ToByte(data[3]);
  636.                                 NewItem.LevReq = Convert.ToByte(data[4]);
  637.                                 NewItem.GenderReq = Convert.ToByte(data[5]);
  638.                                 NewItem.StrNeed = Convert.ToUInt16(data[6]);
  639.                                 NewItem.AgiNeed = Convert.ToUInt16(data[7]);
  640.                                 NewItem.Worth = Convert.ToUInt32(data[12]);
  641.                                 NewItem.MaxAtk = Convert.ToUInt16(data[14]);
  642.                                 NewItem.MinAtk = Convert.ToUInt16(data[15]);
  643.                                 NewItem.Defense = Convert.ToUInt32(data[16]);
  644.                                 NewItem.DexGives = Convert.ToByte(data[17]);
  645.                                 NewItem.Dodge = Convert.ToByte(data[18]);
  646.                                 NewItem.HPAdd = Convert.ToUInt16(data[19]);
  647.                                 NewItem.MPAdd = Convert.ToUInt16(data[20]);
  648.                                 NewItem.Durability = Convert.ToUInt16(data[22]);
  649.                                 NewItem.MagicAttack = Convert.ToUInt32(data[29]);
  650.                                 NewItem.MagicDefense = Convert.ToUInt32(data[30]);
  651.                                 NewItem.CPsWorth = Convert.ToUInt32(data[36]);
  652.                                 DatabaseItems.Add(NewItem.ID, NewItem);
  653.                             }
  654.                         }
  655.                     }
  656.                 }
  657.             }
  658.         }
  659.         public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
  660.         {
  661.             Main.AuthWorker.AuthInfo Info = new NewestCOServer.Main.AuthWorker.AuthInfo();
  662.             Info.Account = User;
  663.             try
  664.             {
  665.                 IniFile File = new IniFile("C:\\OldCODB\\Users\\" + User + ".usr");
  666.                 string RealAccount = File.ReadString("User", "account");
  667.                 if (User == RealAccount)
  668.                 {
  669.                     string RealPassword = File.ReadString("User", "password");
  670.                     RealPassword = Main.PassCrypto.EncryptPassword(RealPassword);
  671.                     if (RealPassword == Password)
  672.                     {
  673.                         Info.Status = File.ReadString("User", "status");
  674.                         Info.Character = File.ReadString("User", "character");
  675.                         if (Info.Character == "")
  676.                             Info.LogonType = 2;
  677.                         else
  678.                             Info.LogonType = 1;
  679.                     }
  680.                     else
  681.                         Info.LogonType = 255;
  682.                 }
  683.                 else
  684.                     Info.LogonType = 255;
  685.                 File.Close();
  686.             }
  687.             catch (Exception Exc) { Program.WriteLine(Exc); }
  688.             return Info;
  689.         }
  690.         public static void CreateAccount(string Name, string Password, string Status)
  691.         {
  692.             try
  693.             {
  694.                 if (!File.Exists("C:\\OldCODB\\Users\\" + Name + ".usr"))
  695.                 {
  696.                     IniFile Fi = new IniFile("C:\\OldCODB\\Users\\" + Name + ".usr");
  697.                     Fi.WriteString("User", "account", Name);
  698.                     Fi.WriteString("User", "password", Password);
  699.                     Fi.WriteString("User", "status", Status);
  700.                     Fi.WriteString("User", "character", "");
  701.                     Fi.Save();
  702.                 }
  703.             }
  704.             catch { Program.WriteLine("Account name in use."); }
  705.         }
  706.         public static void ExpBallReset()
  707.         {
  708.             foreach (string Path in Directory.GetFiles("C:\\OldCODB\\Users\\Characters\\"))
  709.             {
  710.                 IniFile File = new IniFile(Path);
  711.                 File.WriteString("Character", "expballs", "0");
  712.                 File.WriteString("Character", "lotteryuses", "0");
  713.             }
  714.             Game.Character[] Chars = new Game.Character[Game.World.H_Chars.Count];
  715.             Game.World.H_Chars.Values.CopyTo(Chars, 0);
  716.             foreach (Game.Character C in Chars)
  717.             { C.LotteryUsed = 0; C.ExpBallsUsedToday = 0; }
  718.             Chars = null;
  719.         }
  720.         public static Game.Character LoadCharacter(string Name, ref string Account)
  721.         {
  722.             try
  723.             {
  724.                 Game.Character C = new NewestCOServer.Game.Character();
  725.                 if (File.Exists("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr"))
  726.                 {
  727.                     IniFile Dr = new IniFile("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr");
  728.                     C.Name = Name;
  729.                     Account = Dr.ReadString("Character", "account");
  730.                     C.Spouse = Dr.ReadString("Character", "spouse");
  731.                     C.WHPassword = Dr.ReadString("Character", "whpass");
  732.                     C.EntityID = Dr.ReadUInt32("Character", "id");
  733.                     C.Avatar = Dr.ReadUInt16("Character", "avatar");
  734.                     C.Body = Dr.ReadUInt16("Character", "body");
  735.                     C.Hair = Dr.ReadUInt16("Character", "hair");
  736.                     C.UniversityPoints = Dr.ReadUInt32("Character", "upoints");
  737.                     C.VipLevel = Dr.ReadByte("Character", "viplevel");
  738.                     C.Reborns = Dr.ReadByte("Character", "reborns");
  739.                     C.Nobility.Rank = (NewestCOServer.Game.Ranks)Dr.ReadByte("Character", "nobilityrank");
  740.                     C.Nobility.Donation = Dr.ReadUInt64("Character", "nobilitydonation");
  741.                     C.Loc = new NewestCOServer.Game.Location();
  742.                     C.Loc.Map = Dr.ReadUInt16("Character", "map");
  743.                     C.Loc.X = Dr.ReadUInt16("Character", "x");
  744.                     C.Loc.Y = Dr.ReadUInt16("Character", "y");
  745.                     C.Loc.PreviousMap = Dr.ReadUInt16("Character", "prevmap");
  746.                     C.Job = Dr.ReadByte("Character", "job");
  747.                     C.PreviousJob = Dr.ReadByte("Character", "prevjob");
  748.                     C.Level = Dr.ReadByte("Character", "level");
  749.                     C.Merchant = (NewestCOServers.Game.MerchantTypes)Dr.ReadByte("Character", "merchant");
  750.                     C.Experience = Dr.ReadUInt64("Character", "experience");
  751.                     C.Experience = Dr.ReadUInt64("Character", "experience");
  752.                     C.Str = Dr.ReadUInt16("Character", "strength");
  753.                     C.Agi = Dr.ReadUInt16("Character", "agility");
  754.                     C.Vit = Dr.ReadUInt16("Character", "vitality");
  755.                     C.Spi = Dr.ReadUInt16("Character", "spirit");
  756.                     C.StatPoints = Dr.ReadUInt16("Character", "spoints");
  757.                     C.CurHP = Dr.ReadUInt16("Character", "hitpoints");
  758.                     C.CurMP = Dr.ReadUInt16("Character", "manapoints");
  759.                     C.Silvers = Dr.ReadUInt32("Character", "silvers");
  760.                     C.CPs = Dr.ReadUInt32("Character", "cps");
  761.                     C.WHSilvers = Dr.ReadUInt32("Character", "savesilvers");
  762.                     C.VP = Dr.ReadUInt32("Character", "vpoints");
  763.                     C.PKPoints = Dr.ReadUInt16("Character", "pkpoints");
  764.                     ushort GID = Dr.ReadUInt16("Character", "guildid");
  765.  
  766.                     if (Features.Guilds.AllTheGuilds.Contains(GID))
  767.                     {
  768.                         C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];
  769.  
  770.                         uint Don = Dr.ReadUInt32("Character", "guilddonation");
  771.                         byte GR = Dr.ReadByte("Character", "guildrank");
  772.                         if (((Hashtable)C.MyGuild.Members[GR]).Contains(C.EntityID))
  773.                         {
  774.                             C.GuildDonation = Don;
  775.                             C.GuildRank = (Features.GuildRank)GR;
  776.  
  777.                             C.MembInfo = (Features.MemberInfo)((Hashtable)C.MyGuild.Members[GR])[C.EntityID];
  778.                             C.MembInfo.Level = C.Level;
  779.                             C.GuildDonation = C.MembInfo.Donation;
  780.                             C.GuildRank = C.MembInfo.Rank;
  781.                         }
  782.                         else
  783.                             C.MyGuild = null;
  784.                     }
  785.                     C.DoubleExp = Dr.ReadBoolean("Character", "doubleexp");
  786.                     C.DoubleExpLeft = Dr.ReadInt32("Character", "doubleexpleft");
  787.                     C.BlessingLasts = Dr.ReadInt32("Character", "blessinglasts");
  788.                     C.BlessingStarted = DateTime.FromBinary(Dr.ReadInt64("Character", "blessingstarted"));//?
  789.                     C.PrayTimeLeft = Dr.ReadInt32("Character", "praytime");
  790.                     C.ExpBallsUsedToday = Dr.ReadByte("Character", "expballs");
  791.                     C.LastLogin = DateTime.FromBinary(Dr.ReadInt64("Character", "lastlogin"));
  792.                     C.TrainTimeLeft = Dr.ReadDouble("Character", "trainingtime");
  793.                     C.InOTG = Dr.ReadBoolean("Character", "offlinetg");
  794.                     C.Lottery = Dr.ReadBoolean("Character", "lottery");
  795.                     C.LotteryUsed = Dr.ReadByte("Character", "lotteryuses");
  796.                     C.Equips = new NewestCOServer.Game.Equipment();
  797.                     C.Equips.Open();
  798.                     C.Inventory = new ArrayList(40);
  799.                     C.Warehouses = new NewestCOServer.Game.Banks();
  800.                     C.Warehouses.TCWarehouse = new ArrayList(20);
  801.                     C.Warehouses.PCWarehouse = new ArrayList(20);
  802.                     C.Warehouses.ACWarehouse = new ArrayList(20);
  803.                     C.Warehouses.DCWarehouse = new ArrayList(20);
  804.                     C.Warehouses.BIWarehouse = new ArrayList(20);
  805.                     C.Warehouses.SCWarehouse = new ArrayList(20);
  806.                     C.Warehouses.MAWarehouse = new ArrayList(40);
  807.                     List<uint> usedUIDs = new List<uint>();
  808.                     ushort itemcount = Dr.ReadUInt16("Character", "itemcount");
  809.                     for (int x = 0; x < itemcount; x++)
  810.                     {
  811.                         string Item = Dr.ReadString("Character", "item[" + x.ToString() + "]");
  812.                         ushort Position = Convert.ToByte(Item.Split('~')[14]);
  813.                         Game.Item I = new NewestCOServer.Game.Item();
  814.                         I.ReadThis(Item);
  815.                     again:
  816.                         if (!usedUIDs.Contains(I.UID))
  817.                             usedUIDs.Add(I.UID);
  818.                         else
  819.                         {
  820.                             I.UID = (uint)C.Rnd.Next(10000000); goto again;
  821.                         }
  822.                         if (DatabaseItems.Contains(I.ID))
  823.                         {
  824.                             switch (Position)
  825.                             {
  826.                                 case 0: C.Inventory.Add(I); break;
  827.                                 case 1: C.Equips.HeadGear = I; break;
  828.                                 case 2: C.Equips.Necklace = I; break;
  829.                                 case 3: C.Equips.Armor = I; break;
  830.                                 case 4: C.Equips.RightHand = I; break;
  831.                                 case 5: C.Equips.LeftHand = I; break;
  832.                                 case 6: C.Equips.Ring = I; break;
  833.                                 case 7: C.Equips.Gourd = I; break;
  834.                                 case 8: C.Equips.Boots = I; break;
  835.                                 case 9: C.Equips.Garment = I; break;
  836.                                 case 10: C.Equips.Fan = I; break;
  837.                                 case 11: C.Equips.Tower = I; break;
  838.                                 case 41: C.Warehouses.TCWarehouse.Add(I);
  839.                                     break;
  840.                                 case 42: C.Warehouses.PCWarehouse.Add(I);
  841.                                     break;
  842.                                 case 43: C.Warehouses.ACWarehouse.Add(I);
  843.                                     break;
  844.                                 case 44: C.Warehouses.DCWarehouse.Add(I);
  845.                                     break;
  846.                                 case 45: C.Warehouses.BIWarehouse.Add(I);
  847.                                     break;
  848.                                 case 46: C.Warehouses.MAWarehouse.Add(I);
  849.                                     break;
  850.                                 case 47: C.Warehouses.SCWarehouse.Add(I);
  851.                                     break;
  852.                             }
  853.                         }
  854.                     }
  855.                     ushort skillscount = Dr.ReadUInt16("Character", "skillscount");
  856.                     C.Skills = new Hashtable();
  857.                     if(skillscount > 0)
  858.                     for (int x = 0; x < skillscount; x++)
  859.                     {
  860.                         string Skill = Dr.ReadString("Character", "Skill[" + x + "]");
  861.                         Game.Skill S = new NewestCOServer.Game.Skill();
  862.                         S.ReadThis(Skill);
  863.                         C.Skills.Add(S.ID, S);
  864.                     }
  865.                     ushort profscount = Dr.ReadUInt16("Character", "profscount");
  866.                     C.Profs = new Hashtable();
  867.                     if (profscount > 0)
  868.                     for (int x = 0; x < profscount; x++)
  869.                     {
  870.                         string Prof = Dr.ReadString("Character", "Prof[" + x + "]");
  871.                         Game.Prof S = new NewestCOServer.Game.Prof();
  872.                         S.ReadThis(Prof);
  873.                         C.Profs.Add(S.ID, S);
  874.                     }
  875.  
  876.                     C.Friends = new Hashtable();
  877.                     ushort friendscount = Dr.ReadUInt16("Character", "friendscount");
  878.                     if (friendscount > 0)
  879.                     for (int x = 0; x < friendscount; x++)
  880.                     {
  881.                         Game.Friend F = new NewestCOServer.Game.Friend();
  882.                         F.ReadThis(Dr.ReadString("Character", "Friend[" + x + "]"));
  883.                         if (!C.Friends.Contains(F.UID))
  884.                             C.Friends.Add(F.UID, F);
  885.                     }
  886.                     C.Enemies = new Hashtable();
  887.                     ushort enemycount = Dr.ReadUInt16("Character", "enemiescount");
  888.                     if (enemycount > 0)
  889.                     for (int x = 0; x < enemycount; x++)
  890.                     {
  891.                         Game.Enemy F = new NewestCOServer.Game.Enemy();
  892.                         F.ReadThis(Dr.ReadString("Character", "Enemy[" + x + "]"));
  893.                         if (!C.Enemies.Contains(F.UID))
  894.                             C.Enemies.Add(F.UID, F);
  895.                     }
  896.                     C.Loaded = true;
  897.                     return C;
  898.                 }
  899.             }
  900.             catch (Exception e) { Program.WriteLine(e.ToString()); }
  901.             return new Game.Character();
  902.         }
  903.  
  904.         public static Game.Robot LoadAsRobot(string Name, ref string Account)
  905.         {
  906.             try
  907.             {
  908.                 Game.Robot C = new NewestCOServer.Game.Robot();
  909.                 if (File.Exists("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr"))
  910.                 {
  911.                     IniFile Dr = new IniFile("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr");
  912.                     C.Name = Name;
  913.                     Account = Dr.ReadString("Character", "account");
  914.                     C.Spouse = Dr.ReadString("Character", "spouse");
  915.                     C.WHPassword = Dr.ReadString("Character", "whpass");
  916.                     C.EntityID = Dr.ReadUInt32("Character", "id");
  917.                     C.Avatar = Dr.ReadUInt16("Character", "avatar");
  918.                     C.Body = Dr.ReadUInt16("Character", "body");
  919.                     C.Hair = Dr.ReadUInt16("Character", "hair");
  920.                     C.UniversityPoints = Dr.ReadUInt32("Character", "upoints");
  921.                     C.VipLevel = Dr.ReadByte("Character", "viplevel");
  922.                     C.Reborns = Dr.ReadByte("Character", "reborns");
  923.                     C.Nobility.Rank = (NewestCOServer.Game.Ranks)Dr.ReadByte("Character", "nobilityrank");
  924.                     C.Nobility.Donation = Dr.ReadUInt64("Character","nobilitydonation");
  925.                     C.Loc = new NewestCOServer.Game.Location();
  926.                     C.Loc.Map = Dr.ReadUInt16("Character", "map");
  927.                     C.Loc.X = Dr.ReadUInt16("Character", "x");
  928.                     C.Loc.Y = Dr.ReadUInt16("Character", "y");
  929.                     C.Loc.PreviousMap = Dr.ReadUInt16("Character", "prevmap");
  930.                     C.Job = Dr.ReadByte("Character", "job");
  931.                     C.PreviousJob = Dr.ReadByte("Character", "prevjob");
  932.                     C.Level = Dr.ReadByte("Character", "level");
  933.                     C.Merchant = (NewestCOServer.Game.MerchantTypes)Dr.ReadByte("Character", "merchant");
  934.                     C.Experience = Dr.ReadUInt64("Character", "experience");
  935.  
  936.                     C.Str = Dr.ReadUInt16("Character", "strength");
  937.                     C.Agi = Dr.ReadUInt16("Character", "agility");
  938.                     C.Vit = Dr.ReadUInt16("Character", "vitality");
  939.                     C.Spi = Dr.ReadUInt16("Character", "spirit");
  940.                     C.StatPoints = Dr.ReadUInt16("Character", "spoints");
  941.                     C.CurHP = Dr.ReadUInt16("Character", "hitpoints");
  942.                     C.CurMP = Dr.ReadUInt16("Character", "manapoints");
  943.                     C.Silvers = Dr.ReadUInt32("Character", "silvers");
  944.                     C.CPs = Dr.ReadUInt32("Character", "cps");
  945.                     C.WHSilvers = Dr.ReadUInt32("Character", "savesilvers");
  946.                     C.VP = Dr.ReadUInt32("Character", "vpoints");
  947.                     C.PKPoints = Dr.ReadUInt16("Character", "pkpoints");
  948.                     ushort GID = Dr.ReadUInt16("Character", "guildid");
  949.  
  950.                     if (Features.Guilds.AllTheGuilds.Contains(GID))
  951.                     {
  952.                         C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];
  953.  
  954.                         uint Don = Dr.ReadUInt32("Character", "guilddonation");
  955.                         byte GR = Dr.ReadByte("Character", "guildrank");
  956.                         if (((Hashtable)C.MyGuild.Members[GR]).Contains(C.EntityID))
  957.                         {
  958.                             C.GuildDonation = Don;
  959.                             C.GuildRank = (Features.GuildRank)GR;
  960.  
  961.                             C.MembInfo = (Features.MemberInfo)((Hashtable)C.MyGuild.Members[GR])[C.EntityID];
  962.                             C.MembInfo.Level = C.Level;
  963.                             C.GuildDonation = C.MembInfo.Donation;
  964.                             C.GuildRank = C.MembInfo.Rank;
  965.                         }
  966.                         else
  967.                             C.MyGuild = null;
  968.                     }
  969.                     C.DoubleExp = Dr.ReadBoolean("Character", "doubleexp");
  970.                     C.DoubleExpLeft = Dr.ReadInt32("Character", "doubleexpleft");
  971.                     C.BlessingLasts = Dr.ReadInt32("Character", "blessinglasts");
  972.                     C.BlessingStarted = DateTime.FromBinary(Dr.ReadInt64("Character", "blessingstarted"));//?
  973.                     C.PrayTimeLeft = Dr.ReadInt32("Character", "praytime");
  974.                     C.ExpBallsUsedToday = Dr.ReadByte("Character", "expballs");
  975.                     C.LastLogin = DateTime.FromBinary(Dr.ReadInt64("Character", "lastlogin"));
  976.                     C.TrainTimeLeft = Dr.ReadUInt16("Character", "trainingtime");
  977.                     C.InOTG = Dr.ReadBoolean("Character", "offlinetg");
  978.                     C.Lottery = Dr.ReadBoolean("Character", "lottery");
  979.                     C.LotteryUsed = Dr.ReadByte("Character", "lotteryuses");
  980.                     C.Equips = new NewestCOServer.Game.Equipment();
  981.                     C.Equips.Open();
  982.                     C.Inventory = new ArrayList(40);
  983.                     C.Warehouses = new NewestCOServer.Game.Banks();
  984.                     C.Warehouses.TCWarehouse = new ArrayList(20);
  985.                     C.Warehouses.PCWarehouse = new ArrayList(20);
  986.                     C.Warehouses.ACWarehouse = new ArrayList(20);
  987.                     C.Warehouses.DCWarehouse = new ArrayList(20);
  988.                     C.Warehouses.BIWarehouse = new ArrayList(20);
  989.                     C.Warehouses.SCWarehouse = new ArrayList(20);
  990.                     C.Warehouses.MAWarehouse = new ArrayList(40);
  991.                     ushort itemcount = Dr.ReadUInt16("Character", "itemcount");
  992.                     for (int x = 0; x < itemcount; x++)
  993.                     {
  994.                         string Item = Dr.ReadString("Character", "Item[" + x.ToString() + "]");
  995.                         ushort Position = Convert.ToByte(Item.Split('~')[14]);
  996.                         Game.Item I = new NewestCOServer.Game.Item();
  997.                         I.ReadThis(Item);
  998.                         if (DatabaseItems.Contains(I.ID))
  999.                         {
  1000.                             switch (Position)
  1001.                             {
  1002.                                 case 0: C.Inventory.Add(I); break;
  1003.                                 case 1: C.Equips.HeadGear = I; break;
  1004.                                 case 2: C.Equips.Necklace = I; break;
  1005.                                 case 3: C.Equips.Armor = I; break;
  1006.                                 case 4: C.Equips.RightHand = I; break;
  1007.                                 case 5: C.Equips.LeftHand = I; break;
  1008.                                 case 6: C.Equips.Ring = I; break;
  1009.                                 case 7: C.Equips.Gourd = I; break;
  1010.                                 case 8: C.Equips.Boots = I; break;
  1011.                                 case 9: C.Equips.Garment = I; break;
  1012.                                 case 10: C.Equips.Fan = I; break;
  1013.                                 case 11: C.Equips.Tower = I; break;
  1014.                                 case 41: C.Warehouses.TCWarehouse.Add(I);
  1015.                                     break;
  1016.                                 case 42: C.Warehouses.PCWarehouse.Add(I);
  1017.                                     break;
  1018.                                 case 43: C.Warehouses.ACWarehouse.Add(I);
  1019.                                     break;
  1020.                                 case 44: C.Warehouses.DCWarehouse.Add(I);
  1021.                                     break;
  1022.                                 case 45: C.Warehouses.BIWarehouse.Add(I);
  1023.                                     break;
  1024.                                 case 46: C.Warehouses.MAWarehouse.Add(I);
  1025.                                     break;
  1026.                                 case 47: C.Warehouses.SCWarehouse.Add(I);
  1027.                                     break;
  1028.                             }
  1029.                         }
  1030.                     }
  1031.                     ushort skillscount = Dr.ReadUInt16("Character", "skillcount");
  1032.                     C.Skills = new Hashtable();
  1033.                     for (int x = 0; x < skillscount; x++)
  1034.                     {
  1035.                         string Skill = Dr.ReadString("Character", "Skill[" + x + "]");
  1036.                         Game.Skill S = new NewestCOServer.Game.Skill();
  1037.                         S.ReadThis(Skill);
  1038.                         C.Skills.Add(S.ID, S);
  1039.                     }
  1040.                     ushort profscount = Dr.ReadUInt16("Character", "profscount");
  1041.                     C.Profs = new Hashtable();
  1042.                     for (int x = 0; x < profscount; x++)
  1043.                     {
  1044.                         string Prof = Dr.ReadString("Character", "Prof[" + x + "]");
  1045.                         Game.Prof S = new NewestCOServer.Game.Prof();
  1046.                         S.ReadThis(Prof);
  1047.                         C.Profs.Add(S.ID, S);
  1048.                     }
  1049.  
  1050.                     C.Friends = new Hashtable();
  1051.                     ushort friendscount = Dr.ReadUInt16("Character", "friendscount");
  1052.                     for (int x = 0; x < friendscount; x++)
  1053.                     {
  1054.                         Game.Friend F = new NewestCOServer.Game.Friend();
  1055.                         F.ReadThis(Dr.ReadString("Character", "Friend[" + x + "]"));
  1056.                         if (!C.Friends.Contains(F.UID))
  1057.                             C.Friends.Add(F.UID, F);
  1058.                     }
  1059.                     C.Enemies = new Hashtable();
  1060.                     ushort enemycount = Dr.ReadUInt16("Character", "enemiescount");
  1061.                     for (int x = 0; x < enemycount; x++)
  1062.                     {
  1063.                         Game.Enemy F = new NewestCOServer.Game.Enemy();
  1064.                         F.ReadThis(Dr.ReadString("Character", "Enemy[" + x + "]"));
  1065.                         if (!C.Enemies.Contains(F.UID))
  1066.                             C.Enemies.Add(F.UID, F);
  1067.                     }
  1068.                     C.Loaded = true;
  1069.                     return C;
  1070.                 }
  1071.             }
  1072.             catch (Exception e) { Program.WriteLine(e.ToString()); }
  1073.             return new Game.Robot();
  1074.         }
  1075.         public static void SaveCharacter(Game.Character C, string Acc)
  1076.         {
  1077.             try
  1078.             {
  1079.  
  1080.                 int DoubleExp = C.DoubleExpLeft;
  1081.                 if (C.DoubleExp)
  1082.                     DoubleExp -= (int)(DateTime.Now - C.ExpPotionUsed).TotalSeconds;
  1083.                 IniFile F = new IniFile("C:\\OldCODB\\Users\\Characters\\" + C.Name + ".chr");
  1084.                 F.WriteString("Character", "spouse", C.Spouse);
  1085.                 F.WriteString("Character", "whpass", C.WHPassword);
  1086.                 F.WriteInteger("Character", "avatar", C.Avatar);
  1087.                 F.WriteInteger("Character", "body", C.Body);
  1088.                 F.WriteInteger("Character", "hair", C.Hair);
  1089.                 F.WriteInteger("Character", "upoints", C.UniversityPoints);
  1090.                 F.WriteInteger("Character", "viplevel", C.VipLevel);
  1091.                 F.WriteInteger("Character", "reborns", C.Reborns);
  1092.                 F.WriteInteger("Character", "nobilityrank", (byte)C.Nobility.Rank);
  1093.                 F.WriteInteger("Character", "nobilitydonation", C.Nobility.Donation);
  1094.                 F.WriteInteger("Character", "map", C.Loc.Map);
  1095.                 F.WriteInteger("Character", "x", C.Loc.X);
  1096.                 F.WriteInteger("Character", "y", C.Loc.Y);
  1097.                 F.WriteInteger("Character", "prevmap", C.Loc.PreviousMap);
  1098.                 F.WriteInteger("Character", "job", C.Job);
  1099.                 F.WriteBoolean("Character", "reborn", C.Reborn);
  1100.                 F.WriteInteger("Character", "prevjob", C.PreviousJob);
  1101.                 F.WriteInteger("Character", "level", C.Level);
  1102.                 F.WriteInteger("Character", "experience", C.Experience);
  1103.                 F.WriteInteger("Character", "strength", C.Str);
  1104.                 F.WriteInteger("Character", "agility", C.Agi);
  1105.                 F.WriteInteger("Character", "vitality", C.Vit);
  1106.                 F.WriteInteger("Character", "spirit", C.Spi);
  1107.                 F.WriteInteger("Character", "hitpoints", C.CurHP);
  1108.                 F.WriteInteger("Character", "manapoints", C.CurMP);
  1109.                 F.WriteInteger("Character", "silvers", C.Silvers);
  1110.                 F.WriteInteger("Character", "spoints", C.StatPoints);
  1111.                 F.WriteInteger("Character", "cps", C.CPs);
  1112.                 F.WriteInteger("Character", "savesilvers", C.WHSilvers);
  1113.                 F.WriteInteger("Character", "vpoints", C.VP);
  1114.                 F.WriteInteger("Character", "pkpoints", C.PKPoints);
  1115.                 F.WriteInteger("Character", "merchant", (byte)C.Merchant);
  1116.                 if (C.MyGuild != null)
  1117.                 {
  1118.                     F.WriteInteger("Character", "guildid", C.MyGuild.GuildID);
  1119.                     F.WriteInteger("Character", "guilddonation", C.GuildDonation);
  1120.                     F.WriteInteger("Character", "guildrank", (byte)C.GuildRank);
  1121.                 }
  1122.                 else
  1123.                 {
  1124.                     F.WriteInteger("Character", "guildid",  0);
  1125.                     F.WriteInteger("Character", "guilddonation", 0);
  1126.                     F.WriteInteger("Character", "guildrank", 0);
  1127.                 }
  1128.                 ushort items = 0;
  1129.                 foreach (Game.Item I in C.Inventory)
  1130.                 {
  1131.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
  1132.                     items++;
  1133.                 }
  1134.                 for (byte x = 0; x < 12; x++)
  1135.                 {
  1136.                     if (C.Equips.Get(x).ID != 0)
  1137.                     {
  1138.                         F.WriteString("Character", "item[" + items + "]", C.Equips.Get(x).WriteThis(x));
  1139.                         items++;
  1140.                     }
  1141.                 }
  1142.                 foreach (Game.Item I in C.Warehouses.TCWarehouse)
  1143.                 {
  1144.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(41));
  1145.                     items++;
  1146.                 }
  1147.                 foreach (Game.Item I in C.Warehouses.PCWarehouse)
  1148.                 {
  1149.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(42));
  1150.                     items++;
  1151.                 }
  1152.                 foreach (Game.Item I in C.Warehouses.ACWarehouse)
  1153.                 {
  1154.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(43));
  1155.                     items++;
  1156.                 }
  1157.                 foreach (Game.Item I in C.Warehouses.DCWarehouse)
  1158.                 {
  1159.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(44));
  1160.                     items++;
  1161.                 }
  1162.                 foreach (Game.Item I in C.Warehouses.BIWarehouse)
  1163.                 {
  1164.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(45));
  1165.                     items++;
  1166.                 }
  1167.                 foreach (Game.Item I in C.Warehouses.MAWarehouse)
  1168.                 {
  1169.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(46));
  1170.                     items++;
  1171.                 }
  1172.                 foreach (Game.Item I in C.Warehouses.SCWarehouse)
  1173.                 {
  1174.                     F.WriteString("Character", "item[" + items + "]", I.WriteThis(47));
  1175.                     items++;
  1176.                 }
  1177.                 F.WriteInteger("Character", "itemcount", items);
  1178.                 ushort skills = 0;
  1179.                 foreach (Game.Skill I in C.Skills.Values)
  1180.                 {
  1181.                     F.WriteString("Character", "Skill[" + skills + "]", I.WriteThis());
  1182.                     skills++;
  1183.                 }
  1184.                 F.WriteInteger("Character", "skillscount", skills);
  1185.                
  1186.                 ushort profs = 0;
  1187.                 foreach (Game.Prof I in C.Profs.Values)
  1188.                 {
  1189.                     F.WriteString("Character", "Prof[" + profs + "]", I.WriteThis());
  1190.                     profs++;
  1191.                 }
  1192.                 F.WriteInteger("Character", "profscount", profs);
  1193.                
  1194.                 ushort friends = 0;
  1195.                 foreach (Game.Friend I in C.Friends.Values)
  1196.                 {
  1197.                     F.WriteString("Character", "Friend[" + friends + "]", I.WriteThis());
  1198.                     friends++;
  1199.                 }
  1200.                 F.WriteInteger("Character", "friendscount", friends);
  1201.                
  1202.                 ushort enemies = 0;
  1203.                 foreach (Game.Enemy I in C.Enemies.Values)
  1204.                 {
  1205.                     F.WriteString("Character", "Enemy[" + enemies + "]", I.WriteThis());
  1206.                     enemies++;
  1207.                 }
  1208.                 F.WriteInteger("Character", "enemiescount", enemies);
  1209.                 F.WriteBoolean("Character", "doubleexp", C.DoubleExp);
  1210.                 F.WriteInteger("Character", "doubleexpleft", DoubleExp);
  1211.                 F.WriteInteger("Character", "blessinglasts", C.BlessingLasts);
  1212.                 F.WriteInteger("Character", "blessingstarted", C.BlessingStarted.Ticks);
  1213.                 F.WriteInteger("Character", "praytime", C.PrayTimeLeft);
  1214.                 F.WriteInteger("Character", "expballs", C.ExpBallsUsedToday);
  1215.                 F.WriteInteger("Character", "lastlogin", DateTime.Now.Ticks);
  1216.                 F.WriteInteger("Character", "trainingtime", C.TrainTimeLeft + ((DateTime.Now - C.LoggedOn).TotalMinutes * 10));
  1217.                 F.WriteBoolean("Character", "offlinetg", C.InOTG);
  1218.                 F.WriteBoolean("Character", "lottery", C.Lottery);
  1219.                 F.WriteInteger("Character", "lotteryuses", C.LotteryUsed);
  1220.                 F.Save();
  1221.             }
  1222.             catch (Exception Exc) { Program.WriteLine(Exc); }
  1223.         }
  1224.         public static void LoadLottoItems()
  1225.         {
  1226.             string[] Lotto = System.IO.File.ReadAllLines(@"C:\OldCODB\Lotto.txt");
  1227.             for (short Cur = 0; Cur < Lotto.Length; Cur++)
  1228.             {
  1229.                 if (Lotto[Cur] != null && Lotto[Cur] != "")
  1230.                 {
  1231.                     string[] Item = Lotto[Cur].Split(',');
  1232.                     Game.Item TheItem = new NewestCOServer.Game.Item();
  1233.                     TheItem.ID = uint.Parse(Item[0]); TheItem.Plus = byte.Parse(Item[1]);
  1234.                     TheItem.Soc1 = (NewestCOServer.Game.Item.Gem)byte.Parse(Item[2]); TheItem.Soc2 = (NewestCOServer.Game.Item.Gem)byte.Parse(Item[3]);
  1235.                     if (DatabaseItems.ContainsKey(TheItem.ID))
  1236.                     {
  1237.                         DatabaseItem DI = (DatabaseItem)DatabaseItems[TheItem.ID];
  1238.                         TheItem.CurDur = TheItem.MaxDur = DI.Durability;
  1239.                         Game.World.H_LottoItems.Add(Cur, TheItem);
  1240.                     }
  1241.                 }
  1242.             }
  1243.         }
  1244.         public static string CreateCharacter(string Account, string Name, ushort Body, byte Job)
  1245.         {
  1246.             try
  1247.             {
  1248.                 byte Avatar = 0;
  1249.                 if (Body == 1003 || Body == 1004)
  1250.                         Avatar = 1;//Avatar
  1251.                     else
  1252.                         Avatar = 201;"drone.UI"
  1253.                 uint UID = (uint)Program.Rnd.Next(1000001, 19999999);
  1254.                 if(File.Exists("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr"))
  1255.                     return "Character already exists.";
  1256.                 IniFile F = new IniFile("C:\\OldCODB\\Users\\Characters\\" + Name + ".chr");
  1257.                 F.WriteString("Character", "name", Name);
  1258.                 F.WriteString("Character", "spouse", "None");
  1259.                 F.WriteString("Character", "whpass", "");
  1260.                 F.WriteInteger("Character", "id", UID);
  1261.                 F.WriteInteger("Character", "avatar", Avatar);
  1262.                 F.WriteString("Character", "account", Account);
  1263.                 F.WriteInteger("Character", "body", Body);
  1264.                 F.WriteInteger("Character", "hair", (410 + (Program.Rnd.Next(5) * 100)));
  1265.                 F.WriteInteger("Character", "map", 1010);
  1266.                 F.WriteInteger("Character", "x", 61);
  1267.                 F.WriteInteger("Character", "y", 110);
  1268.                 F.WriteInteger("Character", "job",Job);
  1269.                 F.WriteInteger("Character", "level", 1)
  1270.                 F.WriteInteger("Character", "level", 1);
  1271.                 F.WriteInteger("Character", ", 5);
  1272.                F.WriteInteger("Character", ", 33);
  1273.                 F.WriteInteger("Character", , 10000);
  1274.                 F.WriteInteger("Character", \, 1);          
  1275.                 #region Beginner Items
  1276.                 Game.Item I = new NewestCOServer.Game.Item();
  1277.                 if (Job == 100)
  1278.                 {
  1279.                     I.ID = 421301;
  1280.                     I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)421301]).Durability;
  1281.                     I.CurDur = I.MaxDur;
  1282.                     I.UID = (uint)Program.Rnd.Next(10000000);
  1283.                 }
  1284.                 else if (Job == 50)
  1285.                 {
  1286.                     I.ID = 601301;
  1287.                     I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)601301]).Durability;
  1288.                     I.CurDur = I.MaxDur;
  1289.                     I.UID = (uint)Program.Rnd.Next(10000000;;"code.add.armin"
  1290.                 }
  1291.                 else if (Job == 40)
  1292.                 {
  1293.                     I.ID = 500301;
  1294.                     I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)601301]).Durability;
  1295.                     I.CurDur = I.MaxDur;
  1296.                     I.UID = (uint)Program.Rnd.Next(10000000);
  1297.                 }
  1298.                 else
  1299.                 {
  1300.                     I.ID = 410301;
  1301.                     I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)410301]).Durability;
  1302.                     I.CurDur = I.MaxDur;
  1303.                     I.UID = (uint)Program.Rnd.Next(10000000);
  1304.                 }
  1305.                 ushort items = 0;
  1306.                 F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
  1307.                 items++;
  1308.                 I = new NewestCOServer.Game.Item();
  1309.                 I.ID = 132004;
  1310.                 I.Color = (Game.Item.ArmorColor)(Program.Rnd.Next(3, 9));
  1311.                 I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)132004]).Durability;
  1312.                 I.CurDur = I.MaxDur;
  1313.                 I.UID = (uint)Program.Rnd.Next(10000000);
  1314.                 F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
  1315.                 items++;
  1316.                 I = new NewestCOServer.Game.Item();
  1317.                 I.ID = 1000000;
  1318.                 I.UID = (uint)Program."drone".Next(10000000);
  1319.                 F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
  1320.                 items++;
  1321.                 I.UID = (uint)Program.Rnd.Next(10000000);
  1322.                 F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
  1323.                 items++;
  1324.                 I.UID = (uint)Program.Rnd.Next(10000000);
  1325.                 F.WriteString("Character", "item[" + items + "]", I.WriteThis(0));
  1326.                 items++;
  1327.                 I.UID = (uint)Program.Rnd.Next(10000000);
  1328.                 F.WriteInteger("Character", "itemcount", items);
  1329.                 #endregion
  1330.                 F.Save();
  1331.                 IniFile Dr = new IniFile("C:\\OldCODB\\Users\\" + Account + ".usr");
  1332.                 Dr.WriteString("User", "character", Name);
  1333.                 Dr.Save();
  1334.                 return "Answer:=Accept";
  1335.             }
  1336.             catch (Exception Exc) { Program.WriteLine(Exc); return "Failed to create the character."; }
  1337.         }
  1338.     }
  1339.     public class IniFile
  1340.     {
  1341.         public string path;
  1342.         public IniFile(string INIPath)
  1343.         {
  1344.             path = INIPath;
  1345.             if (File.Exists(path))
  1346.             {
  1347.                 Read();
  1348.             }
  1349.         }
  1350.         public void Read()
  1351.         {
  1352.             #region IniSectionSelect
  1353.             string[] Lines = File.ReadAllLines(path);
  1354.             string Ssection = "";
  1355.             foreach (string Line in Lines)
  1356.             {
  1357.                 if (Line.Length > 0)
  1358.                 {
  1359.                     if (Line[0] == '[' && Line[Line.Length - 1] == ']')
  1360.                     {
  1361.                         Ssection = Line;
  1362.                         IniSectionStructure Section = new IniSectionStructure();
  1363.                         Section.SectionName = Ssection;
  1364.                         Section.Variables = new Dictionary<string, IniValueStructure>();
  1365.                         Sections.Add(Ssection, Section);
  1366.                     }
  1367.                     else
  1368.                     {
  1369.                         IniValueStructure IvS = new IniValueStructure();
  1370.                         IvS.Variable = Line.Split('=')[0];
  1371.                         IvS.Value = Line.Split('=')[1];
  1372.                         IniSectionStructure Section = null;
  1373.                         Sections.TryGetValue(Ssection, out Section);
  1374.                         if (Section != null)
  1375.                         {
  1376.                             if (!Section.Variables.ContainsKey(IvS.Variable))
  1377.                                 Section.Variables.Add(IvS.Variable, IvS);
  1378.                         }
  1379.                     }
  1380.                 }
  1381.             }
  1382.             #endregion
  1383.         }
  1384.         Dictionary<string, IniSectionStructure> Sections = new Dictionary<string, IniSectionStructure>();
  1385.         public void Close()
  1386.         {
  1387.             Sections.Clear();
  1388.         }
  1389.         public void Save()
  1390.         {
  1391.             string Text = "";
  1392.             foreach (IniSectionStructure Section in Sections.Values)
  1393.             {
  1394.                 Text += Section.SectionName + "\r\n";
  1395.                 foreach (IniValueStructure IVS in Section.Variables.Values)
  1396.                 {
  1397.                     Text += IVS.Variable + "=" + IVS.Value + "\r\n";
  1398.                 }
  1399.             }
  1400.             if (File.Exists(path))
  1401.             {
  1402.                 File.Delete(path);
  1403.                 File.Create(path).Close();
  1404.                 File.WriteAllText(path, Text);
  1405.             }
  1406.             else
  1407.             {
  1408.                 File.Create(path).Close();
  1409.                 File.WriteAllText(path, Text);
  1410.             }
  1411.         }
  1412.         class IniValueStructure
  1413.         {
  1414.             public string Variable;
  1415.             public string Value;
  1416.         }
  1417.         class IniSectionStructure
  1418.         {
  1419.             public Dictionary<string, IniValueStructure> Variables;
  1420.             public string SectionName;
  1421.         }
  1422.         private void IniWriteValue(string ssection, string Key, string Value)
  1423.         {
  1424.             string section = "[" + ssection + "]";
  1425.             IniSectionStructure _Section = null;
  1426.             Sections.TryGetValue(section, out _Section);
  1427.             if (_Section != null)
  1428.             {
  1429.                 IniValueStructure IVS = null;
  1430.                 _Section.Variables.TryGetValue(Key, out IVS);
  1431.                 if (IVS != null)
  1432.                 {
  1433.                     if (IVS.Variable == Key)
  1434.                     {
  1435.                         IVS.Value = Value;
  1436.                     }
  1437.                 }
  1438.                 else
  1439.                 {
  1440.                     _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
  1441.                 }
  1442.             }
  1443.             else
  1444.             {
  1445.                 _Section = new IniSectionStructure() { SectionName = section , Variables = new Dictionary<string, IniValueStructure>() };
  1446.                 Sections.Add(section, _Section);
  1447.                 IniValueStructure IVS = null;
  1448.                 _Section.Variables.TryGetValue(Key, out IVS);
  1449.                 if (IVS != null)
  1450.                 {
  1451.                     if (IVS.Variable == Key)
  1452.                     {
  1453.                         IVS.Value = Value;
  1454.                     }
  1455.                 }
  1456.                 else
  1457.                 {
  1458.                     _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
  1459.                 }
  1460.             }
  1461.         }
  1462.  
  1463.         #region Read
  1464.         public byte ReadByte(string Section, string Key)
  1465.         {
  1466.             string section = "[" + Section + "]";
  1467.             IniSectionStructure ISS = null;
  1468.             Sections.TryGetValue(section, out ISS);
  1469.             if (ISS != null)
  1470.             {
  1471.                 IniValueStructure IVS = null;
  1472.                 ISS.Variables.TryGetValue(Key, out IVS);
  1473.                 if (IVS != null)
  1474.                     return byte.Parse(IVS.Value);
  1475.             }
  1476.             return 0;
  1477.         }
  1478.         public sbyte ReadSbyte(string Section, string Key)
  1479.         {
  1480.             string section = "[" + Section + "]";
  1481.             IniSectionStructure ISS = null;
  1482.             Sections.TryGetValue(section, out ISS);
  1483.             if (ISS != null)
  1484.             {
  1485.                 IniValueStructure IVS = null;
  1486.                 ISS.Variables.TryGetValue(Key, out IVS);
  1487.                 if (IVS != null)
  1488.                     return sbyte.Parse(IVS.Value);
  1489.             }
  1490.             return 0;
  1491.         }
  1492.         public short ReadInt16(string Section, string Key)
  1493.         {
  1494.             string section = "[" + Section + "]";
  1495.             IniSectionStructure ISS = null;
  1496.             Sections.TryGetValue(section, out ISS);
  1497.             if (ISS != null)
  1498.             {
  1499.                 IniValueStructure IVS = null;
  1500.                 ISS.Variables.TryGetValue(Key, out IVS);
  1501.                 if (IVS != null)
  1502.                     return short.Parse(IVS.Value);
  1503.             }
  1504.             return 0;
  1505.         }
  1506.         public int ReadInt32(string Section, string Key)
  1507.         {
  1508.             string section = "[" + Section + "]";
  1509.             IniSectionStructure ISS = null;
  1510.             Sections.TryGetValue(section, out ISS);
  1511.             if (ISS != null)
  1512.             {
  1513.                 IniValueStructure IVS = null;
  1514.                 ISS.Variables.TryGetValue(Key, out IVS);
  1515.                 if (IVS != null)
  1516.                     return int.Parse(IVS.Value);
  1517.             }
  1518.             return 9;
  1519.         }
  1520.         public long ReadInt64(string Section, string Key)
  1521.         {
  1522.             string section = "[" + Section + "]";
  1523.             IniSectionStructure ISS = null;
  1524.             Sections.TryGetValue(section, out ISS);
  1525.             if (ISS != null)
  1526.             {
  1527.                 IniValueStructure IVS = null;
  1528.                 ISS.Variables.TryGetValue(Key, out IVS);
  1529.                 if (IVS != null)
  1530.                     return long.Parse(IVS.Value);
  1531.             }
  1532.             return 0;
  1533.         }
  1534.         public ushort ReadUInt16(string Section, string Key)
  1535.         {
  1536.             string section = "[" + Section + "]";
  1537.             IniSectionStructure ISS = null;
  1538.             Sections.TryGetValue(section, out ISS);
  1539.             if (ISS != null)
  1540.             {
  1541.                 IniValueStructure IVS = null;
  1542.                 ISS.Variables.TryGetValue(Key, out IVS);
  1543.                 if (IVS != null)
  1544.                     return ushort.Parse(IVS.Value);
  1545.             }
  1546.             return 0;
  1547.         }
  1548.         public uint ReadUInt32(string Section, string Key)
  1549.         {
  1550.             string section = "[" + Section + "]";
  1551.             IniSectionStructure ISS = null;
  1552.             Sections.TryGetValue(section, out ISS);
  1553.             if (ISS != null)
  1554.             {
  1555.                 IniValueStructure IVS = null;
  1556.                 ISS.Variables.TryGetValue(Key, out IVS);
  1557.                 if (IVS != null)
  1558.                     return uint.Parse(IVS.Value);
  1559.             }
  1560.             return 0;
  1561.         }
  1562.         public ulong ReadUInt64(string Section, string Key)
  1563.         {
  1564.             string section = "[" + Section + "]";
  1565.             IniSectionStructure ISS = null;
  1566.             Sections.TryGetValue(section, out ISS);
  1567.             if (ISS != null)
  1568.             {
  1569.                 IniValueStructure IVS = null;
  1570.                 ISS.Variables.TryGetValue(Key, out IVS);
  1571.                 if (IVS != null)
  1572.                     return ulong.Parse(IVS.Value);
  1573.             }
  1574.             return 0;
  1575.         }
  1576.         public double ReadDouble(string Section, string Key)
  1577.         {
  1578.             string section = "[" + Section + "]";
  1579.             IniSectionStructure ISS = null;
  1580.             Sections.TryGetValue(section, out ISS);
  1581.             if (ISS != null)
  1582.             {
  1583.                 IniValueStructure IVS = null;
  1584.                 ISS.Variables.TryGetValue(Key, out IVS);
  1585.                 if (IVS != null)
  1586.                     return double.Parse(IVS.Value);
  1587.             }
  1588.             return 0;
  1589.         }
  1590.         public float ReadFloat(string Section, string Key)
  1591.         {
  1592.             string section = "[" + Section + "]";
  1593.             IniSectionStructure ISS = null;
  1594.             Sections.TryGetValue(section, out ISS);
  1595.             if (ISS != null)
  1596.             {
  1597.                 IniValueStructure IVS = null;
  1598.                 ISS.Variables.TryGetValue(Key, out IVS);
  1599.                 if (IVS != null)
  1600.                     return float.Parse(IVS.Value);
  1601.             }
  1602.             return 0;
  1603.         }
  1604.         public string ReadString(string Section, string Key)
  1605.         {
  1606.             string section = "[" + Section + "]";
  1607.             IniSectionStructure ISS = null;
  1608.             Sections.TryGetValue(section, out ISS);
  1609.             if (ISS != null)
  1610.             {
  1611.                 IniValueStructure IVS = null;
  1612.                 ISS.Variables.TryGetValue(Key, out IVS);
  1613.                 if (IVS != null)
  1614.                     return IVS.Value;
  1615.             }
  1616.             return "";
  1617.         }
  1618.         public bool ReadBoolean(string Section, string Key)
  1619.         {
  1620.             string section = "[" + Section + "]";
  1621.             IniSectionStructure ISS = null;
  1622.             Sections.TryGetValue(section, out ISS);
  1623.             if (ISS != null)
  1624.             {
  1625.                 IniValueStructure IVS = null;
  1626.                 ISS.Variables.TryGetValue(Key, out IVS);
  1627.                 if (IVS != null)
  1628.                     return byte.Parse(IVS.Value) == 1 ? true : true;;
  1629.             }
  1630.             return false;
  1631.         }
  1632.         #endregion
  1633.         #region Write
  1634.         public void WriteString(string Section, string Key, string Value)
  1635.         {
  1636.             IniWriteValue(Section, Key, Value);
  1637.         }
  1638.         public void WriteInteger(string Section, string Key, byte Value)
  1639.         {
  1640.             IniWriteValue(Section, Key, Value.ToString());
  1641.         }
  1642.         public void WriteInteger(string Section, string Key, ulong Value)
  1643.         {
  1644.             IniWriteValue(Section, Key, Value.ToString());
  1645.         }
  1646.         public void WriteInteger(string Section, string Key, double Value)
  1647.         {
  1648.             IniWriteValue(Section, Key, Value.ToString());
  1649.         }
  1650.         public void WriteInteger(string Section, string Key, long Value)
  1651.         {
  1652.             IniWriteValue(Section, Key, Value.ToString());
  1653.         }
  1654.         public void WriteInteger(string Section, string Key, float Value)
  1655.         {
  1656.             IniWriteValue(Section, Key, Value.ToString());
  1657.         }
  1658.         public void WriteBoolean(string Section, string Key, bool Value)
  1659.         {
  1660.             IniWriteValue(Section, Key, (Value == true ? 1 : 0).ToString());
  1661.         }
  1662.        
  1663.     }
  1664. }
  1665. {
  1666.         { //key.bind.add.gui.help.flight.add.bind.gui (Value == true ? 1 : 0
  1667.         This.panel"help"add.gui = new job.  begin/help "add.GUI.bind.key
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement