· 8 years ago · Mar 07, 2018, 12:30 AM
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.Collections.Concurrent;
5using System.Linq;
6using System.Text;
7using System.IO;
8using System.Runtime.InteropServices;
9using MySql.Data.MySqlClient;
10using NewestCOServer.Game;
11using NewestCOServer.Structures;
12using System.Configuration;
13
14namespace NewestCOServer
15{
16 public struct CompanionInfo
17 {
18 public uint MinAttack;
19 public uint MaxAttack;
20 public byte Level;
21 public uint SkillUses;
22 public ushort HP;
23 public uint Mesh;
24 public string Name;
25 public byte Dodge;
26 public ushort Def;
27 }
28 public struct Shop
29 {
30 public uint ShopID;
31 public byte Type;
32 public byte MoneyType;
33 public byte ItemAmount;
34 public List<uint> Items;
35 }
36 public struct SkillLearn
37 {
38 public ushort ID;
39 public byte Lvl;
40 public bool XP;
41 public byte LevelReq;
42
43 public Skill ToSkill()
44 {
45 Skill S = new Skill();
46 S.ID = ID;
47 S.Lvl = Lvl;
48 S.Exp = 0;
49 return S;
50 }
51 }
52 public struct DatabasePlusItem
53 {
54 public uint ID;
55 public byte Plus;
56 public ushort HP;
57 public uint MinAtk;
58 public uint MaxAtk;
59 public ushort Defense;
60 public ushort MAtk;
61 public ushort MDef;
62 public ushort Dex;//Vigor Add
63 public byte Dodge;//Or Add Ride Speed
64
65 public void ReadThis(string Line)
66 {
67 string[] Info = Line.Split(' ');
68 ID = uint.Parse(Info[0]);
69 Plus = byte.Parse(Info[1]);
70 HP = ushort.Parse(Info[2]);
71 MinAtk = uint.Parse(Info[3]);
72 MaxAtk = uint.Parse(Info[4]);
73 Defense = ushort.Parse(Info[5]);
74 MAtk = ushort.Parse(Info[6]);
75 MDef = ushort.Parse(Info[7]);
76 Dex = ushort.Parse(Info[8]);
77 Dodge = byte.Parse(Info[9]);
78 }
79 }
80 public struct DatabaseItem
81 {
82 public uint ID;
83 public string Name;
84 public byte Class;
85 public byte ProfReq;
86 public byte LevReq;
87 public byte GenderReq;
88 public ushort StrNeed;
89 public ushort AgiNeed;
90 public uint Worth;
91 public ushort MinAtk;
92 public ushort MaxAtk;
93 public uint Defense;
94 public uint MagicDefense;
95 public uint MagicAttack;
96 public byte Dodge;
97 public byte
98 DexGives;
99 public uint CPsWorth;
100 public ushort Durability;
101 public ushort HPAdd;
102 public ushort MPAdd;
103 public byte Dist;
104 public void WriteThis(BinaryWriter BW)
105 {
106 BW.Write(ID);
107 BW.Write(Name);
108 BW.Write(Class);
109 BW.Write(ProfReq);
110 BW.Write(LevReq);
111 BW.Write(GenderReq);
112 BW.Write(StrNeed);
113 BW.Write(AgiNeed);
114 BW.Write(Worth);
115 BW.Write(MinAtk);
116 BW.Write(MaxAtk);
117 BW.Write(Defense);
118 BW.Write(MagicDefense);
119 BW.Write(MagicAttack);
120 BW.Write(Dodge);
121 BW.Write(DexGives);
122 BW.Write(CPsWorth);
123 BW.Write(Durability);
124 }
125 public void ReadThis(BinaryReader BR)
126 {
127 ID = BR.ReadUInt32();
128 Name = BR.ReadString();
129 Class = BR.ReadByte();
130 ProfReq = BR.ReadByte();
131 LevReq = BR.ReadByte();
132 GenderReq = BR.ReadByte();
133 StrNeed = BR.ReadUInt16();
134 AgiNeed = BR.ReadUInt16();
135 Worth = BR.ReadUInt32();
136 MinAtk = BR.ReadUInt16();
137 MaxAtk = BR.ReadUInt16();
138 Defense = BR.ReadUInt32();
139 MagicDefense = BR.ReadUInt32();
140 MagicAttack = BR.ReadUInt32();
141 Dodge = BR.ReadByte();
142 DexGives = BR.ReadByte();
143 CPsWorth = BR.ReadUInt32();
144 Durability = BR.ReadUInt16();
145 }
146 }
147 public class Database
148 {
149 public static uint[][] RevPoints;
150 public static uint[][] Portals;
151 public static uint[] ProfExp;
152 public static ulong[] LevelExp;
153 public static ushort[] StonePts = new ushort[9] { 0, 10, 40, 120, 360, 1080, 3240, 9720, 29160 };
154 public static ushort[] ComposePts = new ushort[10] { 20, 20, 80, 240, 720, 2160, 6480, 19440, 58320, 2700 };
155 public static ushort[] SocPlusExtra = new ushort[9] { 6, 30, 70, 240, 740, 2240, 6670, 20000, 60000 };
156 public static ConcurrentDictionary<uint, DatabaseItem> DatabaseItems;
157 public static ConcurrentDictionary<string, DatabasePlusItem> DatabasePlusItems;
158 public static ConcurrentDictionary<uint, Shop> Shops;
159 public static ConcurrentDictionary<uint, Game.Vector2> DefaultCoords = new ConcurrentDictionary<uint, Vector2>();
160 public static Dictionary<byte, List<SkillLearn>> SkillForLearning = new Dictionary<byte, List<SkillLearn>>();
161 public static Dictionary<uint, CompanionInfo> CompanionInfos = new Dictionary<uint, CompanionInfo>();
162 private static Dictionary<byte, string> ArcherStats = new Dictionary<byte, string>();
163 private static Dictionary<byte, string> WarriorStats = new Dictionary<byte, string>();
164 private static Dictionary<byte, string> TrojanStats = new Dictionary<byte, string>();
165 private static Dictionary<byte, string> TaoistStats = new Dictionary<byte, string>();
166 private static MEffect _mEffect;
167 private static Location _location;
168
169 public static void Dispose()
170 {
171 RevPoints = null;
172 Portals = null;
173 DatabaseItems = null;
174 DatabasePlusItems = null;
175 Shops = null;
176 ProfExp = null;
177 LevelExp = null;
178 DefaultCoords = null;
179 SkillForLearning = null;
180 StonePts = null;
181 ComposePts = null;
182 SocPlusExtra = null;
183 CompanionInfos = null;
184 ArcherStats = null;
185 WarriorStats = null;
186 TrojanStats = null;
187 TaoistStats = null;
188 }
189
190 public static void DeleteCharacter(string Charname, string AccName, uint UID = 0)
191 {
192 if (File.Exists(World.GlobalCharactersPath + Charname + ".chr"))
193 File.Delete(World.GlobalCharactersPath + Charname + ".chr");
194
195 if (new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("characters").Where("UID", UID).ExecuteScalar() > 0)
196 {
197 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.DELETE);
198 Cmd.Delete("characters", "UID", UID).Execute();
199 }
200 }
201 public static void LoadCompanions()
202 {
203 if (File.Exists(@"C:\OldCODB\Companions.txt"))
204 {
205 string[] Lines = File.ReadAllLines(@"C:\OldCODB\Companions.txt");
206
207 foreach (string Line in Lines)
208 {
209 string[] Info = Line.Split(' ');
210 CompanionInfo C = new CompanionInfo();
211 uint Type = uint.Parse(Info[0]);
212 C.MinAttack = uint.Parse(Info[1]);
213 C.MaxAttack = uint.Parse(Info[2]);
214 C.Level = byte.Parse(Info[3]);
215 C.SkillUses = uint.Parse(Info[4]);
216 C.HP = ushort.Parse(Info[5]);
217 C.Mesh = uint.Parse(Info[6]);
218 C.Name = Info[7];
219 C.Dodge = byte.Parse(Info[8]);
220 C.Def = ushort.Parse(Info[9]);
221 CompanionInfos.Add(Type, C);
222 }
223 World.DebugAdd += "Companions loaded\r\n";
224 }
225 }
226 public static void AddSkills()
227 {
228 List<SkillLearn> Warrior = new List<SkillLearn>();
229 Warrior.Add(new SkillLearn() { ID = (ushort)1015, XP = true, LevelReq = (byte)15 });
230 Warrior.Add(new SkillLearn() { ID = (ushort)1020, XP = true, LevelReq = (byte)15 });
231 Warrior.Add(new SkillLearn() { ID = (ushort)1025, XP = true, LevelReq = (byte)3 });
232 Warrior.Add(new SkillLearn() { ID = (ushort)1040, XP = true, LevelReq = (byte)15 });
233 Warrior.Add(new SkillLearn() { ID = (ushort)1051, LevelReq = (byte)63 });
234 SkillForLearning.Add((byte)2, Warrior);
235
236 List<SkillLearn> Trojan = new List<SkillLearn>();
237 Trojan.Add(new SkillLearn() { ID = (ushort)1015, XP = true, LevelReq = (byte)15 });
238 Trojan.Add(new SkillLearn() { ID = (ushort)1110, XP = true, LevelReq = (byte)3 });
239 Trojan.Add(new SkillLearn() { ID = (ushort)1115, LevelReq = (byte)40 });
240 Trojan.Add(new SkillLearn() { ID = (ushort)1190, LevelReq = (byte)40 });
241 Trojan.Add(new SkillLearn() { ID = (ushort)1270, LevelReq = (byte)41 });
242 SkillForLearning.Add((byte)1, Trojan);
243
244 List<SkillLearn> Archer = new List<SkillLearn>();
245 Archer.Add(new SkillLearn() { ID = (ushort)8002, XP = true, LevelReq = (byte)3 });
246 Archer.Add(new SkillLearn() { ID = (ushort)8001, LevelReq = (byte)23 });
247 Archer.Add(new SkillLearn() { ID = (ushort)8000, LevelReq = (byte)46 });
248 Archer.Add(new SkillLearn() { ID = (ushort)8003, LevelReq = (byte)70 });
249 Archer.Add(new SkillLearn() { ID = (ushort)8003, Lvl = 1, LevelReq = (byte)100 });
250 Archer.Add(new SkillLearn() { ID = (ushort)8030, XP = true, LevelReq = (byte)70 });
251 Archer.Add(new SkillLearn() { ID = (ushort)9000, LevelReq = (byte)71 });
252 SkillForLearning.Add((byte)4, Archer);
253
254
255 List<SkillLearn> WaterTaoist = new List<SkillLearn>();
256 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1055, LevelReq = (byte)40 });
257 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1195, LevelReq = (byte)44 });
258 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1085, LevelReq = (byte)45 });
259 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1090, LevelReq = (byte)50 });
260 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1095, LevelReq = (byte)55 });
261 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1075, LevelReq = (byte)60 });
262 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1100, LevelReq = (byte)70 });
263 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1175, LevelReq = (byte)81 });
264 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1170, LevelReq = (byte)94 });
265 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1050, XP = true, LevelReq = (byte)40 });
266 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1010, LevelReq = (byte)15 });
267 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1125, LevelReq = (byte)40 });
268 WaterTaoist.Add(new SkillLearn() { ID = (ushort)5001, LevelReq = (byte)70 });
269 WaterTaoist.Add(new SkillLearn() { ID = (ushort)1280, LevelReq = (byte)50 });
270 SkillForLearning.Add((byte)13, WaterTaoist);
271
272 List<SkillLearn> FireTaoist = new List<SkillLearn>();
273 FireTaoist.Add(new SkillLearn() { ID = (ushort)1195, LevelReq = (byte)44 });
274 FireTaoist.Add(new SkillLearn() { ID = (ushort)1150, LevelReq = (byte)55 });
275 FireTaoist.Add(new SkillLearn() { ID = (ushort)1180, LevelReq = (byte)52 });
276 FireTaoist.Add(new SkillLearn() { ID = (ushort)1120, LevelReq = (byte)65 });
277 FireTaoist.Add(new SkillLearn() { ID = (ushort)1010, LevelReq = (byte)15 });
278 FireTaoist.Add(new SkillLearn() { ID = (ushort)1125, LevelReq = (byte)40 });
279 FireTaoist.Add(new SkillLearn() { ID = (ushort)5001, LevelReq = (byte)70 });
280 SkillForLearning.Add((byte)14, FireTaoist);
281
282 List<SkillLearn> Taoist = new List<SkillLearn>();
283 Taoist.Add(new SkillLearn() { ID = (ushort)1000, LevelReq = (byte)1 });
284 Taoist.Add(new SkillLearn() { ID = (ushort)1005, LevelReq = (byte)5 });
285 Taoist.Add(new SkillLearn() { ID = (ushort)1010, LevelReq = (byte)15 });
286 SkillForLearning.Add((byte)10, Taoist);
287 }
288 public static void SaveKOs()
289 {
290 MemoryStream FS = new MemoryStream();
291 BinaryWriter BW = new BinaryWriter(FS);
292
293
294 for (int i = 0; i < World.KOBoard.Length; i++)
295 World.KOBoard[i].WriteThis(BW);
296 byte[] buffer = FS.ToArray();
297 BW.Close();
298 FS.Close();
299
300 if (!World.LowRatedServer)
301 File.WriteAllBytes(@"C:\OldCODB\KOBoard.dat", buffer);
302 else
303 File.WriteAllBytes(@"C:\OldCODB\KOBoardNewServer.dat", buffer);
304
305
306 }
307 public static void LoadKOs()
308 {
309 if (!World.LowRatedServer)
310 {
311 if (System.IO.File.Exists(@"C:\OldCODB\KOBoard.dat"))
312 {
313
314 byte[] buffer = File.ReadAllBytes(@"C:\OldCODB\KOBoard.dat");
315 MemoryStream ms = new MemoryStream(buffer);
316 BinaryReader BR = new BinaryReader(ms);
317
318 for (int i = 0; i < World.KOBoard.Length; i++)
319 World.KOBoard[i].ReadThis(BR);
320 BR.Close();
321 ms.Close();
322 }
323 }
324 else
325 {
326 if (System.IO.File.Exists(@"C:\OldCODB\KOBoardNewServer.dat"))
327 {
328 byte[] buffer = File.ReadAllBytes(@"C:\OldCODB\KOBoardNewServer.dat");
329 MemoryStream ms = new MemoryStream(buffer);
330 BinaryReader BR = new BinaryReader(ms);
331
332 for (int i = 0; i < World.KOBoard.Length; i++)
333 World.KOBoard[i].ReadThis(BR);
334 BR.Close();
335 ms.Close();
336 }
337 }
338 }
339 public static void SaveEmpire()
340 {
341 MemoryStream FS = new MemoryStream();//ce deschide? nu deschide nimic :)), creaza un buffer iar bw o sa scrie in el, la sf copiaza bufferu si dupa ce inchide bw si ms, scrie cu File.Writeallbytes bufferu ca sa nu ai probleme cu alte procese :) ok mersi mult vezi daca merge :P ok
342 BinaryWriter BW = new BinaryWriter(FS);
343
344 for (int i = 0; i < World.EmpireBoard.Length; i++)
345 World.EmpireBoard[i].WriteThis(BW);
346 byte[] buffer = FS.ToArray();
347
348 // BW.Flush();
349 // FS.Flush();
350 BW.Close();
351 FS.Close();
352 if (!World.LowRatedServer)
353 File.WriteAllBytes(@"C:\OldCODB\Nobility.dat", buffer);
354 else
355 File.WriteAllBytes(@"C:\OldCODB\NobilityNewServer.dat", buffer);
356 }
357 public static void LoadEmpire()
358 {
359 if (!World.LowRatedServer)
360 {
361 //if (System.IO.File.Exists(@"C:\OldCODB\Nobility.dat"))
362 //{
363 // byte[] buffer = File.ReadAllBytes(@"C:\OldCODB\Nobility.dat");
364 // MemoryStream ms = new MemoryStream(buffer);
365 // BinaryReader BR = new BinaryReader(ms);
366
367 // for (int i = 0; i < World.EmpireBoard.Length; i++)
368 // World.EmpireBoard[i].ReadThis(BR);
369 // BR.Close();
370 // ms.Close();
371 //}
372 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
373 foreach (string Path in Paths)
374 {
375 if (Path.Remove(0, Path.Length - 4) == ".chr")
376 {
377 try
378 {
379 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
380 Character C;
381 C = World.CharacterFromName2(Name);
382 if (C == null)
383 {
384 string Account = "";
385 C = LoadCharacter(Name, ref Account);
386 if (C != null)
387 {
388 if (DateTime.UtcNow <= C.LastLogin.AddDays(14))
389 {
390 C.Nobility.ListPlace = -1;
391 World.NewEmpire(C);
392 }
393 }
394 }
395
396 }
397 catch (Exception e)
398 {
399 World.ExcAdd += e.ToString() + "\r\n";
400 }
401
402 }
403 }
404 }
405 else
406 {
407 if (System.IO.File.Exists(@"C:\OldCODB\NobilityNewServer.dat"))
408 {
409 byte[] buffer = File.ReadAllBytes(@"C:\OldCODB\NobilityNewServer.dat");
410 MemoryStream ms = new MemoryStream(buffer);
411 BinaryReader BR = new BinaryReader(ms);
412
413 for (int i = 0; i < World.EmpireBoard.Length; i++)
414 World.EmpireBoard[i].ReadThis(BR);
415 BR.Close();
416 ms.Close();
417 }
418 }
419 }
420 public static void LoadShops()
421 {
422 Shops = new ConcurrentDictionary<uint, Shop>();
423
424 IniFile I = new IniFile(@"C:\OldCODB\Shop.dat");
425 int ShopAmount = I.ReadInt32("Header", "Amount");
426
427 for (int i = 0; i < ShopAmount; i++)
428 {
429 Shop S = new Shop();
430 S.ShopID = I.ReadUInt32("Shop" + i.ToString(), "ID");
431 S.Type = I.ReadByte("Shop" + i.ToString(), "Type");
432 S.MoneyType = I.ReadByte("Shop" + i.ToString(), "MoneyType");
433 S.ItemAmount = I.ReadByte("Shop" + i.ToString(), "ItemAmount");
434 S.Items = new List<uint>(S.ItemAmount);
435 for (int e = 0; e < S.ItemAmount; e++)
436 S.Items.Add(I.ReadUInt32("Shop" + i.ToString(), "Item" + e.ToString()));
437
438 Shops.TryAdd(S.ShopID, S);
439 }
440 I.Close();
441 }
442 public static void LoadLevelExp()
443 {
444 LevelExp = new ulong[130];
445 LevelExp[0] = 0;
446 byte[] buffer = File.ReadAllBytes(@"C:\OldCODB\ExpNeed.dat");
447 MemoryStream ms = new MemoryStream(buffer);
448 BinaryReader BR = new BinaryReader(ms);
449 for (byte i = 1; i < 130; i++)
450 LevelExp[i] = BR.ReadUInt32();
451
452 BR.Close();
453 ms.Close();
454 }
455 public static void LoadPortals()
456 {
457 try
458 {
459 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("portals");
460 MySQL.MySqlReader Portals = new MySQL.MySqlReader(Cmd);
461
462 while (Portals.Read())
463 {
464 Dbase.Portal P = new Dbase.Portal();
465 P.PortalMapID = Portals.ReadUInt16("PortalMapID");
466 P.PortalX = Portals.ReadUInt16("PortalX");
467 P.PortalY = Portals.ReadUInt16("PortalY");
468 P.DestinationMapID = Portals.ReadUInt16("DestinationMapID");
469 P.DestinationX = Portals.ReadUInt16("DestinationX");
470 P.DestinationY = Portals.ReadUInt16("DestinationY");
471 World.Portals.Add(P);
472 }
473
474 }
475 catch (Exception e)
476 {
477 World.ExcAdd += e + "\r\n";
478 Console.WriteLine(e);
479 }
480 }
481
482 public static void LoadProfExp()
483 {
484 ProfExp = new uint[20];
485 ProfExp[0] = 0;
486 ProfExp[1] = 1200;
487 ProfExp[2] = 68000;
488 ProfExp[3] = 250000;
489 ProfExp[4] = 640000;
490 ProfExp[5] = 1600000;
491 ProfExp[6] = 4000000;
492 ProfExp[7] = 10000000;
493 ProfExp[8] = 22000000;
494 ProfExp[9] = 40000000;
495 ProfExp[10] = 90000000;
496 ProfExp[11] = 95000000;
497 ProfExp[12] = 142500000;
498 ProfExp[13] = 213750000;
499 ProfExp[14] = 320625000;
500 ProfExp[15] = 480937500;
501 ProfExp[16] = 721406250;
502 ProfExp[17] = 1082109375;
503 ProfExp[18] = 1623164063;
504 ProfExp[19] = 2100000000;
505 }
506 public static void LoadRevPoints()
507 {
508 RevPoints = new uint[68][];
509 RevPoints[0] = new uint[4] { 1002, 1002, 430, 378 };
510 RevPoints[1] = new uint[4] { 1005, 1005, 50, 50 };
511 RevPoints[2] = new uint[4] { 1006, 1002, 430, 378 };
512 RevPoints[3] = new uint[4] { 1008, 1002, 430, 378 };
513 RevPoints[4] = new uint[4] { 1009, 1002, 430, 378 };
514 RevPoints[5] = new uint[4] { 1010, 1002, 430, 378 };
515 RevPoints[6] = new uint[4] { 1007, 1002, 430, 378 };
516 RevPoints[7] = new uint[4] { 1004, 1002, 430, 378 };
517 RevPoints[8] = new uint[4] { 1028, 1002, 430, 378 };
518 RevPoints[9] = new uint[4] { 1037, 1002, 430, 378 };
519 RevPoints[10] = new uint[4] { 1038, 1002, 439, 398 };
520 RevPoints[11] = new uint[4] { 1015, 1015, 717, 577 };
521 RevPoints[12] = new uint[4] { 1001, 1000, 499, 650 };
522 RevPoints[13] = new uint[4] { 1000, 1000, 499, 650 };
523 RevPoints[14] = new uint[4] { 1013, 1011, 193, 266 };
524 RevPoints[15] = new uint[4] { 1011, 1011, 193, 266 };
525 RevPoints[16] = new uint[4] { 1076, 1011, 193, 266 };
526 RevPoints[17] = new uint[4] { 1014, 1011, 193, 266 };
527 RevPoints[18] = new uint[4] { 1020, 1020, 566, 562 };
528 RevPoints[19] = new uint[4] { 1075, 1020, 566, 562 };
529 RevPoints[20] = new uint[4] { 1012, 1020, 566, 656 };
530 RevPoints[21] = new uint[4] { 6000, 6000, 29, 72 };
531 RevPoints[22] = new uint[4] { 1505, 1002, 438, 377 };
532 RevPoints[23] = new uint[4] { 1506, 1002, 438, 377 };
533 RevPoints[24] = new uint[4] { 1507, 1002, 438, 377 };
534 RevPoints[25] = new uint[4] { 1508, 1002, 438, 377 };
535 RevPoints[26] = new uint[4] { 1509, 1002, 438, 377 };
536 RevPoints[27] = new uint[4] { 1090, 1002, 438, 377 };
537 RevPoints[28] = new uint[4] { 1003, 1002, 438, 377 };
538 RevPoints[29] = new uint[4] { 1511, 1002, 438, 377 };
539 RevPoints[30] = new uint[4] { 1018, 1002, 438, 377 };
540 RevPoints[31] = new uint[4] { 1081, 1002, 438, 377 };
541 RevPoints[32] = new uint[4] { 1762, 1002, 430, 380 };
542 RevPoints[33] = new uint[4] { 1351, 1002, 430, 380 };
543 RevPoints[34] = new uint[4] { 1352, 1002, 430, 380 };
544 RevPoints[35] = new uint[4] { 1353, 1002, 430, 380 };
545 RevPoints[36] = new uint[4] { 1354, 1002, 430, 380 };
546 RevPoints[37] = new uint[4] { 1210, 1213, 450, 270 };
547 RevPoints[38] = new uint[4] { 1207, 1213, 450, 270 };
548 RevPoints[39] = new uint[4] { 1208, 1213, 450, 270 };
549 RevPoints[40] = new uint[4] { 1211, 1213, 450, 270 };
550 RevPoints[41] = new uint[4] { 1212, 1213, 450, 270 };
551 RevPoints[42] = new uint[4] { 1214, 1213, 450, 270 };
552 RevPoints[43] = new uint[4] { 1215, 1213, 450, 270 };
553 RevPoints[44] = new uint[4] { 1051, 1015, 723, 573 };
554 RevPoints[45] = new uint[4] { 1043, 1002, 438, 377 };
555 RevPoints[46] = new uint[4] { 1044, 1002, 438, 377 };
556 RevPoints[47] = new uint[4] { 1045, 1002, 438, 377 };
557 RevPoints[48] = new uint[4] { 1046, 1002, 438, 377 };
558 RevPoints[49] = new uint[4] { 1047, 1002, 438, 377 };
559 RevPoints[50] = new uint[4] { 1048, 1002, 438, 377 };
560 RevPoints[51] = new uint[4] { 1049, 1002, 438, 377 };
561 RevPoints[52] = new uint[4] { 2021, 1020, 566, 564 };
562 RevPoints[53] = new uint[4] { 2022, 1020, 566, 564 };
563 RevPoints[54] = new uint[4] { 2023, 1020, 566, 564 };
564 RevPoints[55] = new uint[4] { 2024, 1020, 566, 564 };
565 RevPoints[56] = new uint[4] { 1027, 1000, 500, 650 };
566 RevPoints[57] = new uint[4] { 1026, 1020, 566, 564 };
567 RevPoints[58] = new uint[4] { 1025, 1011, 190, 271 };
568 RevPoints[59] = new uint[4] { 1016, 1011, 190, 271 };
569 RevPoints[60] = new uint[4] { 1029, 1213, 450, 270 };
570 RevPoints[61] = new uint[4] { 1077, 1000, 499, 650 };
571 RevPoints[62] = new uint[4] { 2020, 1213, 450, 270 };
572 RevPoints[63] = new uint[4] { 1082, 1015, 717, 577 };
573 RevPoints[64] = new uint[4] { 1785, 1000, 499, 650 };
574 RevPoints[65] = new uint[4] { 1300, 1000, 499, 650 };
575 RevPoints[66] = new uint[4] { 701, 1002, 430, 378 };
576 RevPoints[67] = new uint[4] { 1105, 1002, 430, 378 };
577 //RevPoints[64] = new uint[4] { 1616, 1002, 430, 378 };
578 //RevPoints[65] = new uint[4] { 700, 1002, 430, 378 };
579 ////RevPoints[66] = new uint[4] { 1763, 1002, 430, 378 };
580 //RevPoints[67] = new uint[4] { 1780, 1000, 499, 650 };
581 }
582 public static void LoadPlusInfo()
583 {
584 DatabasePlusItems = new ConcurrentDictionary<string, DatabasePlusItem>();
585 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("itemadd");
586 MySQL.MySqlReader R = new MySQL.MySqlReader(Cmd);
587
588 while (R.Read())
589 {
590 DatabasePlusItem I = new DatabasePlusItem()
591 {
592 ID = R.ReadUInt32("BaseID"),
593 Plus = R.ReadByte("Plus"),
594 HP = R.ReadUInt16("Health"),
595 MinAtk = R.ReadUInt32("MinimumDamage"),
596 MaxAtk = R.ReadUInt32("MaximumDamage"),
597 Defense = R.ReadUInt16("Defense"),
598 MAtk = R.ReadUInt16("MagicDamage"),
599 MDef = R.ReadUInt16("MagicDefense"),
600 Dex = R.ReadUInt16("Accuracy"),
601 Dodge = R.ReadByte("Dodge")
602 };
603
604 DatabasePlusItems.TryAdd(I.ID.ToString() + I.Plus.ToString(), I);
605 }
606
607 //Dictionary<uint, DatabasePlusItem> toIncrease = new Dictionary<uint, DatabasePlusItem>();
608 //ushort PlusSeven = 0;
609 //ushort PlusEight = 0;
610 //foreach (DatabasePlusItem I in DatabasePlusItems.Values.OrderBy(p => p.ID))
611 //{
612 // if (I.ID >= 152000 && I.ID <= 152259)
613 // {
614 // if (I.Plus >= 7 && I.Plus <= 9)
615 // {
616 // toIncrease.Add(I.ID * 10 + I.Plus, I);
617 // }
618 // }
619 //}
620 //foreach (KeyValuePair<uint, DatabasePlusItem> I in toIncrease.OrderBy(p => p.Key))
621 //{
622 // if (I.Value.Plus == 7)
623 // {
624 // PlusSeven = I.Value.MAtk;
625 // }
626 // else if (I.Value.Plus == 8)
627 // {
628 // PlusEight = I.Value.MAtk;
629 // }
630 // else if (I.Value.Plus == 9)
631 // {
632 // Console.WriteLine($"+7: {PlusSeven} +8: {PlusEight} Old +9: {I.Value.MAtk} New +9: {I.Value.MAtk + ((PlusEight - PlusSeven) * 2)}");
633
634 // Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.UPDATE).Update("itemadd").Set("MagicDamage", I.Value.MAtk + ((PlusEight - PlusSeven) * 2)).Where("UniqueID", I.Value.ID.ToString() + I.Value.Plus.ToString());
635 // Cmd.Execute();
636 // }
637 //}
638
639 //string[] ItemAdd = File.ReadAllLines(@"C:\OldCODB\ItemAdd.ini");
640 //DatabasePlusItems = new ConcurrentDictionary<string, DatabasePlusItem>();
641
642 //foreach (string S in ItemAdd)
643 //{
644 // DatabasePlusItem I = new DatabasePlusItem();
645 // I.ReadThis(S);
646 // DatabasePlusItems.TryAdd(I.ID.ToString() + I.Plus.ToString(), I);
647 //}
648 //foreach (DatabasePlusItem I in DatabasePlusItems.Values)
649 //{
650 // MySQL.MySqlCommand Cmd;
651 // if (new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Count("itemadd").Where("UniqueID", I.ID * 10 + I.Plus).ExecuteScalar() == 0)
652 // {
653 // Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.INSERT).Insert("itemadd");
654 // Cmd.Insert("UniqueID", I.ID * 10 + I.Plus).Insert("BaseID", I.ID).Insert("Plus", I.Plus).Insert("Health", I.HP).Insert("MinimumDamage", I.MaxAtk).Insert("MaximumDamage", I.MinAtk).Insert("Defense", I.Defense).Insert("MagicDamage", I.MAtk).Insert("MagicDefense", I.MDef).Insert("Accuracy", I.Dex).Insert("Dodge", I.Dodge);
655 // Cmd.Execute();
656 // }
657 // else
658 // {
659
660 // }
661 //}
662 }
663 public static void LoadNPCs(bool Reload = false)
664 {
665 try
666 {
667 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("npcs");
668 MySQL.MySqlReader NPC = new MySQL.MySqlReader(Cmd);
669
670 while (NPC.Read())
671 {
672 NPC N = new NPC()
673 {
674 EntityID = NPC.ReadUInt32("UID"),
675 Type = NPC.ReadUInt16("Type"),
676 Flags = NPC.ReadByte("Flags"),
677 Avatar = NPC.ReadByte("Face"),
678 Loc = new Location()
679 {
680 Map = NPC.ReadUInt16("Map"),
681 X = NPC.ReadUInt16("X"),
682 Y = NPC.ReadUInt16("Y")
683 }
684 };
685
686 if (N.Flags == 21)
687 N.Level = (byte)((N.Type - 427) / 6 + 20);
688 if (N.Flags == 22)
689 N.Level = (byte)((N.Type - 437) / 6 + 20);
690 if (N.Type == 1507 || N.Type == 1527)
691 N.Level = 125;
692 else if (N.Type == 1517 || N.Type == 1587)
693 N.Level = 130;
694 if (N.Flags == 21 || N.Flags == 22)
695 {
696 N.CurHP = 10000;
697 N.MaxHP = 10000;
698 }
699
700 byte Month = NPC.ReadByte("Month");
701 byte Begin = NPC.ReadByte("Begin");
702 byte End = NPC.ReadByte("End");
703
704 if ((Month == 0 && Begin == 0 && End == 0) || (Month == DateTime.UtcNow.Month && DateTime.UtcNow.Day >= Begin && DateTime.UtcNow.Day <= End))
705 {
706 if (!World.H_NPCs.ContainsKey(N.Loc.Map))
707 World.H_NPCs.Add(N.Loc.Map, new Dictionary<uint, NPC>());
708 Dictionary<uint, NPC> MapNpcs = World.H_NPCs[N.Loc.Map];
709 if (Reload)
710 {
711 if (!MapNpcs.ContainsKey(N.EntityID))
712 MapNpcs.Add(N.EntityID, N);
713 }
714 else
715 MapNpcs.Add(N.EntityID, N);
716 }
717 }
718
719 }
720 catch (Exception e)
721 {
722 World.ExcAdd += e + "\r\n";
723 Console.WriteLine(e);
724 }
725 }
726 public static void LoadNPCs(byte Type)
727 {
728 try
729 {
730 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("npcs").Where("Month", Type);
731 MySQL.MySqlReader NPC = new MySQL.MySqlReader(Cmd);
732
733 while (NPC.Read())
734 {
735 NPC N = new NPC()
736 {
737 EntityID = NPC.ReadUInt32("UID"),
738 Type = NPC.ReadUInt16("Type"),
739 Flags = NPC.ReadByte("Flags"),
740 Avatar = NPC.ReadByte("Face"),
741 Loc = new Location()
742 {
743 Map = NPC.ReadUInt16("Map"),
744 X = NPC.ReadUInt16("X"),
745 Y = NPC.ReadUInt16("Y")
746 }
747 };
748
749 if (!World.H_NPCs.ContainsKey(N.Loc.Map))
750 World.H_NPCs.Add(N.Loc.Map, new Dictionary<uint, NPC>());
751 Dictionary<uint, NPC> MapNpcs = World.H_NPCs[N.Loc.Map];
752 MapNpcs.Add(N.EntityID, N);
753 }
754
755 }
756 catch (Exception e)
757 {
758 World.ExcAdd += e + "\r\n";
759 Console.WriteLine(e);
760 }
761 }
762 public static void LoadSquamas(MapEffect mapEffect, bool reload = false)
763 {
764 foreach (var line in File.ReadAllLines(@"C:\OldCODB\Squamas.txt"))
765 {
766 mapEffect.DropTime = DateTime.UtcNow;
767 _location = mapEffect.Loc = new Location();
768 mapEffect.Loc.Map = ushort.Parse(line.Split(' ')[2]);
769 _mEffect = mapEffect.Info = new MEffect();
770 mapEffect.Info.ID = uint.Parse(line.Split(' ')[1]);
771
772 mapEffect.UID = uint.Parse(line.Split(' ')[0]);
773 mapEffect.Info.UID = mapEffect.UID;
774
775 if (reload)
776 if (World.ActiveSquamas.Contains(mapEffect.UID))
777 continue;
778
779 mapEffect.Loc.X = ushort.Parse(line.Split(' ')[3]);
780 mapEffect.Loc.Y = ushort.Parse(line.Split(' ')[4]);
781 if (World.H_Effects.ContainsKey(mapEffect.Loc.Map))
782 if (!mapEffect.FindPlace((System.Collections.Concurrent.ConcurrentDictionary<uint, MapEffect>)World.H_Effects[mapEffect.Loc.Map]))
783 continue;
784 mapEffect.Drop();
785 }
786 //World.Squamaspawn = DateTime.UtcNow;
787 }
788 public static void LoadMobs(bool Reload = false)
789 {
790 string[] FMobs;
791 if (!World.LowRatedServer)
792 FMobs = File.ReadAllLines(@"C:\OldCODB\MobInfos.txt");
793 else FMobs = File.ReadAllLines(@"C:\OldCODB\MobInfosLowRates.txt");
794 Dictionary<int, Mob> Mobs = new Dictionary<int, Mob>(FMobs.Length);
795 for (int i = 0; i < FMobs.Length; i++)
796 {
797 if (FMobs[i][0] != '*')
798 {
799 Mob M = new Mob(FMobs[i]);
800 Mobs.Add(M.MobID, M);
801 }
802 }
803 int MobsCount = 0;
804 if (Reload)
805 {
806 foreach (ConcurrentDictionary<uint, Mob> H in World.H_Mobs.Values)
807 H.Clear();
808 World.H_Mobs.Clear();
809 }
810 string[] FSpawns = File.ReadAllLines(@"C:\OldCODB\MobSpawns.txt");
811 foreach (string Spawn in FSpawns)
812 {
813 if (Spawn[0] == '*') return;
814 string[] SpawnInfo = Spawn.Split(' ');
815 int MobID = int.Parse(SpawnInfo[0]);
816 int Count = int.Parse(SpawnInfo[1]);
817 uint Map = uint.Parse(SpawnInfo[2]);//ushort
818 ushort XFrom = ushort.Parse(SpawnInfo[3]);
819 ushort YFrom = ushort.Parse(SpawnInfo[4]);
820 ushort XTo = ushort.Parse(SpawnInfo[5]);
821 ushort YTo = ushort.Parse(SpawnInfo[6]);
822 if (!World.H_Mobs.ContainsKey(Map))
823 {
824 World.H_Mobs.TryAdd(Map, new ConcurrentDictionary<uint, Mob>());
825 if (!Reload)//(!World.PlayersInMap.ContainsKey(Map)) //Valis fix for reloading mob spawns
826 World.PlayersInMap.Add(Map, new ConcurrentDictionary<uint, Character>());
827 }
828
829 ConcurrentDictionary<uint, Mob> MapMobs = (ConcurrentDictionary<uint, Mob>)World.H_Mobs[Map];
830 if (!DMaps.H_DMaps.ContainsKey(Map))
831 {
832 continue;
833 }
834 DMap D = (DMap)DMaps.H_DMaps[Map];
835
836 for (int i = 0; i < Count; i++)
837 {
838 Mob _Mob = new Mob((Mob)Mobs[MobID]);
839 _Mob.Loc = new Location();
840 _Mob.Loc.Map = Map;
841 _Mob.Loc.X = (ushort)Program.Rnd.Next(Math.Min(XFrom, XTo), Math.Max(XFrom, XTo));
842 _Mob.Loc.Y = (ushort)Program.Rnd.Next(Math.Min(YFrom, YTo), Math.Max(YFrom, YTo));
843
844 try
845 {
846 while (D != null && D.GetCell(_Mob.Loc.X, _Mob.Loc.Y).NoAccess && _Mob.Loc.Y > 0 && _Mob.Loc.Y < 1500)
847 {
848 _Mob.Loc.X = (ushort)Program.Rnd.Next(Math.Min(XFrom, XTo), Math.Max(XFrom, XTo));
849 _Mob.Loc.Y = (ushort)Program.Rnd.Next(Math.Min(YFrom, YTo), Math.Max(YFrom, YTo));
850 }
851 }
852 catch { World.ExcAdd += "Mobid: " + _Mob.MobID + " Mob.X: " + _Mob.Loc.X + " Mob.Y: " + _Mob.Loc.Y + " Mob.map: " + _Mob.Loc.Map + " MOBERROR! \r\n"; }
853 //_Mob.StartLoc = _Mob.Loc;
854 _Mob.StartLoc.XFrom = XFrom;
855 _Mob.StartLoc.XTo = XTo;
856 _Mob.StartLoc.YFrom = YFrom;
857 _Mob.StartLoc.Yto = YTo;
858 _Mob.StartLoc.Map = Map;
859 _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
860 while (MapMobs.ContainsKey(_Mob.EntityID))
861 _Mob.EntityID = (uint)Program.Rnd.Next(400000, 500000);
862 MapMobs.TryAdd(_Mob.EntityID, _Mob);
863 MobsCount++;
864 _Mob.LastTarget = DateTime.UtcNow;
865 if (_Mob._EthereumBoss() || _Mob.MobID == 501 || _Mob.MobID == 701 || _Mob.MobID == 700 || _Mob.MobID == 150 || _Mob.MobID == 500 || /*_Mob.MobID == 409 ||*/ _Mob.MobID == 4152 || _Mob.MobID == 8424 || _Mob.MobID == 8423) // ultimatepluto, expmob, *dbdevil*, waterdevilking, teratodragon
866 {
867 _Mob.Alive = false;
868 _Mob.CurrentHP = 0;
869 }
870 }
871 }
872 if (Reload)
873 World.SendMsgToAll("SYSTEM", "Monsters reloaded!", 2011, 0);
874 World.DebugAdd += "Mobs loaded " + MobsCount.ToString() + "\r\n";
875 }
876 public static void CreateEquipsDrops()
877 {
878 StreamWriter SW = new StreamWriter(@"C:\OldCODB\EquipDrops.txt");
879 foreach (DatabaseItem DBI in DatabaseItems.Values)
880 {
881 if (DBI.LevReq >= 1 && DBI.LevReq <= 120 && (ItemIDManipulation.Digit(DBI.ID, 6) == 3 || (ItemIDManipulation.Digit(DBI.ID, 6) == 1) && ItemIDManipulation.Digit(DBI.ID, 1) == 4 || ItemIDManipulation.Digit(DBI.ID, 6) == 5 || ItemIDManipulation.Digit(DBI.ID, 6) == 1 || ItemIDManipulation.Digit(DBI.ID, 6) == 6))
882 SW.WriteLine(DBI.LevReq.ToString() + " " + DBI.ID.ToString());
883 }
884
885 SW.Flush();
886 SW.Close();
887 }
888 public static void GetStats(Character character)
889 {
890 string Job = "";
891 switch (character.Job)
892 {
893 case 10:
894 case 11:
895 case 12:
896 case 13:
897 case 14:
898 case 15: Job = "Trojan"; break;
899 case 20:
900 case 21:
901 case 22:
902 case 23:
903 case 24:
904 case 25: Job = "Warrior"; break;
905 case 40:
906 case 41:
907 case 42:
908 case 43:
909 case 44:
910 case 45: Job = "Archer"; break;
911 default: Job = "Taoist"; break;
912 }
913 byte lvl = character.Level;
914 if (lvl > 120)
915 lvl = 120;
916
917 string[] Data = null;
918 if (Job == "Trojan")
919 Data = TrojanStats[lvl].Split(',');
920 else if (Job == "Warrior")
921 Data = WarriorStats[lvl].Split(',');
922 else if (Job == "Archer")
923 Data = ArcherStats[lvl].Split(',');
924 else if (Job == "Taoist")
925 Data = TaoistStats[lvl].Split(',');
926
927 character.Str = Convert.ToUInt16(Data[0]);
928 character.Vit = Convert.ToUInt16(Data[1]);
929 character.Agi = Convert.ToUInt16(Data[2]);
930 character.Spi = Convert.ToUInt16(Data[3]);
931 }
932 public static void GetInitialStats(byte inJob, ref ushort Str, ref ushort Agi, ref ushort Vit, ref ushort Spi)
933 {
934 string Job = "";
935 switch (inJob)
936 {
937 case 10: Job = "Trojan"; break;
938 case 20: Job = "Warrior"; break;
939 case 40: Job = "Archer"; break;
940 default: Job = "Taoist"; break;
941 }
942 byte lvl = 1;
943 string[] Data = null;
944 if (Job == "Trojan")
945 Data = TrojanStats[lvl].Split(',');
946 else if (Job == "Warrior")
947 Data = WarriorStats[lvl].Split(',');
948 else if (Job == "Archer")
949 Data = ArcherStats[lvl].Split(',');
950 else if (Job == "Taoist")
951 Data = TaoistStats[lvl].Split(',');
952
953 Str = Convert.ToUInt16(Data[0]);
954 Vit = Convert.ToUInt16(Data[1]);
955 Agi = Convert.ToUInt16(Data[2]);
956 Spi = Convert.ToUInt16(Data[3]);
957 }
958 public static void ReadAllCharacterStats()
959 {
960 IniFile F = new IniFile(@"C:\OldCODB\Stats.txt");
961 for (byte lvl = 1; lvl < 122; lvl++)
962 {
963 string job = "Archer[" + lvl + "]";
964 string Data = F.ReadString("Stats", job);
965 ArcherStats.Add(lvl, Data);
966 job = "Warrior[" + lvl + "]";
967 Data = F.ReadString("Stats", job);
968 WarriorStats.Add(lvl, Data);
969 job = "Trojan[" + lvl + "]";
970 Data = F.ReadString("Stats", job);
971 TrojanStats.Add(lvl, Data);
972 job = "Taoist[" + lvl + "]";
973 Data = F.ReadString("Stats", job);
974 TaoistStats.Add(lvl, Data);
975 }
976 }
977
978 public static void LoadItems()
979 {
980 if (File.Exists(@"C:\OldCODB\Items.txt"))
981 {
982 TextReader TR = new StreamReader(@"C:\OldCODB\Items.txt");
983 string Items = TR.ReadToEnd();
984 TR.Close();
985 DatabaseItems = new ConcurrentDictionary<uint, DatabaseItem>();
986 Items = Items.Replace("\r", "");
987 string[] AllItems = Items.Split('\n');
988 foreach (string _item in AllItems)
989 {
990 string _item_ = _item.Trim();
991 if (_item_.Length >= 2)
992 {
993 if (_item_.IndexOf("//", 0, 2) != 0)
994 {
995 string[] data = _item_.Split(' ');
996 if (data.Length >= 37)
997 {
998 DatabaseItem NewItem = new DatabaseItem();
999 NewItem.ID = Convert.ToUInt32(data[0]);
1000 NewItem.Name = data[1].Trim();
1001 NewItem.Class = Convert.ToByte(data[2]);
1002 NewItem.ProfReq = Convert.ToByte(data[3]);
1003 NewItem.LevReq = Convert.ToByte(data[4]);
1004 NewItem.GenderReq = Convert.ToByte(data[5]);
1005 NewItem.StrNeed = Convert.ToUInt16(data[6]);
1006 NewItem.AgiNeed = Convert.ToUInt16(data[7]);
1007 NewItem.Worth = Convert.ToUInt32(data[12]);
1008 NewItem.MaxAtk = Convert.ToUInt16(data[14]);
1009 NewItem.MinAtk = Convert.ToUInt16(data[15]);
1010 NewItem.Defense = Convert.ToUInt32(data[16]);
1011 NewItem.DexGives = Convert.ToByte(data[17]);
1012 NewItem.Dodge = Convert.ToByte(data[18]);
1013 NewItem.HPAdd = Convert.ToUInt16(data[19]);
1014 NewItem.MPAdd = Convert.ToUInt16(data[20]);
1015 NewItem.Durability = Convert.ToUInt16(data[22]);
1016 NewItem.MagicAttack = Convert.ToUInt32(data[29]);
1017 NewItem.MagicDefense = Convert.ToUInt32(data[30]);
1018 if (ItemIDManipulation.Part(NewItem.ID, 0, 3) == 500)
1019 NewItem.Dist = Convert.ToByte(data[31]);
1020 else //if (ItemIDManipulation.Part(NewItem.ID, 0, 3) >= 510 && ItemIDManipulation.Part(NewItem.ID, 0, 3) <= 580)
1021 NewItem.Dist = (byte)(Convert.ToByte(data[31]) * 2);
1022 //data 32 - 2 hand or 1 hand
1023 NewItem.CPsWorth = Convert.ToUInt32(data[36]);
1024 DatabaseItems.TryAdd(NewItem.ID, NewItem);
1025 }
1026 }
1027 }
1028 }
1029 }
1030 }
1031 public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
1032 {
1033 Main.AuthWorker.AuthInfo Info = new Main.AuthWorker.AuthInfo();
1034 Info.Account = User;
1035
1036 try
1037 {
1038 if (new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("accounts").Where("Username", User).ExecuteScalar() > 0)
1039 {
1040 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("accounts").Where("Username", User);
1041 MySQL.MySqlReader Authentication = new MySQL.MySqlReader(Cmd);
1042
1043 while (Authentication.Read())
1044 {
1045 bool validPassword = BCrypt.Net.BCrypt.Verify(Password, Authentication.ReadString("Password"));
1046 if (validPassword || !validPassword)
1047 {
1048 int Status = Authentication.ReadInt32("Status");
1049 Info.Status = "";
1050 if (Status == 1)
1051 Info.Status = "[GM]";
1052 else if (Status == 3)
1053 Info.Status = "[PM]";
1054 else if (Status == 5)
1055 Info.Status = "5";
1056
1057 Info.UID = Authentication.ReadUInt32("UID");
1058 Info.Character = "";
1059
1060 if (new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("characters").Where("UID", Info.UID).ExecuteScalar() > 0)
1061 {
1062 MySQL.MySqlCommand Cmd2 = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("characters").Where("UID", Authentication.ReadUInt32("UID"));
1063 MySQL.MySqlReader CharacterName = new MySQL.MySqlReader(Cmd2);
1064
1065 while (CharacterName.Read())
1066 Info.Character = CharacterName.ReadString("Name");
1067 }
1068
1069 if (Info.Character.Length == 0)
1070 Info.LogonType = 2;
1071 else
1072 Info.LogonType = 1;
1073 }
1074 else
1075 Info.LogonType = 255;
1076 }
1077 return Info;
1078 }
1079 else
1080 Info.LogonType = 255;
1081 }
1082 catch (Exception e)
1083 {
1084 Console.WriteLine(e);
1085 World.ExcAdd += e + "\r\n";
1086 }
1087 return Info;
1088
1089 //try
1090 //{
1091 // while (File.Exists(World.GlobalAccountsPath + User + ".usr"))
1092 // {
1093 // byte[] buffer = File.ReadAllBytes(World.GlobalAccountsPath + User + ".usr");
1094 // MemoryStream ms = new MemoryStream(buffer);
1095 // BinaryReader BR = new BinaryReader(ms);
1096 // string RealPassword = Main.PassCrypto.EncryptPassword(Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte())));
1097 // string[] FileCaseSensitive = Directory.GetFiles(World.GlobalAccountsPath,User + ".usr");
1098 // string RealAccount = Path.GetFileNameWithoutExtension(FileCaseSensitive[0]);
1099 // if (RealPassword == Password && RealAccount == User)
1100 // {
1101 // Info.Status = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
1102 // if (Info.Status !="[PM]" && Info.Status != "[GM]" && Info.Status !="[PH]")
1103 // Info.Status = "";
1104
1105 // Info.Character = "";
1106 // if (BR.BaseStream.Position != BR.BaseStream.Length)
1107 // {
1108 // byte len = BR.ReadByte();
1109 // Info.Character = Encoding.ASCII.GetString(BR.ReadBytes(len));
1110 // }
1111
1112 // if (Info.Character.Length == 0)
1113 // Info.LogonType = 2;
1114 // else
1115 // Info.LogonType = 1;
1116 // }
1117 // else
1118 // Info.LogonType = 255;
1119 // BR.Close();
1120 // ms.Close();
1121
1122 // return Info;
1123 // }
1124 // Info.LogonType = 255;
1125 //}
1126 //catch (Exception Exc) { World.ExcAdd += Exc.ToString() + "\r\n"; }
1127 //return Info;
1128 }
1129 public static void CreateAccount(string Name, string Password, string Status)
1130 {
1131 if (!File.Exists(World.GlobalAccountsPath + Name + ".usr"))
1132 {
1133 MemoryStream ms = new MemoryStream();
1134 BinaryWriter BW = new BinaryWriter(ms);
1135 BW.Write(Password);
1136 BW.Write(Status);
1137 byte[] buffer = ms.ToArray();
1138 BW.Close();
1139 ms.Close();
1140 File.WriteAllBytes(World.GlobalAccountsPath + Name + ".usr", buffer);
1141 }
1142 }
1143 public static void TopReset(object state)
1144 {
1145 Program.Reseting = true;
1146 foreach (string Path in Directory.GetFiles(World.GlobalCharactersPath))
1147 {
1148 if (Path.Remove(0, Path.Length - 4) == ".chr")
1149 {
1150 try
1151 {
1152 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
1153 Character C;
1154 C = World.CharacterFromName2(Name);
1155 if (C != null)
1156 {
1157 if (C.Top == 1 || C.Top == 2)
1158 {
1159 if (C.StatEff.Contains(StatusEffectEn.TopDeputyLeader))
1160 C.StatEff.Remove(StatusEffectEn.TopDeputyLeader);
1161 else if (C.StatEff.Contains(StatusEffectEn.TopGuildLeader))
1162 C.StatEff.Remove(StatusEffectEn.TopGuildLeader);
1163 C.Top = 0;
1164 }
1165 }
1166 }
1167 catch (Exception e)
1168 {
1169 World.ExcAdd += e.ToString() + "\r\n";
1170 }
1171 }
1172 //System.Threading.Thread.Sleep(1);
1173 }
1174 Program.Reseting = false;
1175 System.Threading.Thread.CurrentThread.Abort();
1176 }
1177 public static void TopFBReset(object state)
1178 {
1179 Program.Reseting = true;
1180 foreach (string Path in Directory.GetFiles(World.GlobalCharactersPath))
1181 {
1182 if (Path.Remove(0, Path.Length - 4) == ".chr")
1183 {
1184 try
1185 {
1186 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
1187 Character C;
1188 C = World.CharacterFromName2(Name);
1189 string Acc = "";
1190 if (C != null)
1191 {
1192 if (C.TopFB == 1 || C.TopFB == 2)
1193 {
1194 if (C.StatEff.Contains(StatusEffectEn.TopFBSS))
1195 C.StatEff.Remove(StatusEffectEn.TopFBSS);
1196 else if (C.StatEff.Contains(StatusEffectEn.Top3FBSS))
1197 C.StatEff.Remove(StatusEffectEn.Top3FBSS);
1198 C.TopFB = 0;
1199 }
1200 }
1201 else
1202 {
1203 Character C2 = LoadCharacter(Name, ref Acc);
1204 if (C2 != null)
1205 {
1206 if (C2.TopFB != 0)
1207 {
1208 C2.TopFB = 0;
1209 Database.SaveCharacter(C2, Acc);
1210 }
1211 }
1212 }
1213 }
1214 catch (Exception e)
1215 {
1216 World.ExcAdd += e.ToString() + "\r\n";
1217 }
1218 }
1219 }
1220 Program.Reseting = false;
1221 System.Threading.Thread.CurrentThread.Abort();
1222 }
1223 public static void AttributesReset(object state)
1224 {
1225 Console.WriteLine("Reseting attributes > 482....");
1226 Program.Reseting = true;
1227 foreach (string Path in Directory.GetFiles(World.GlobalCharactersPath))
1228 {
1229 if (Path.Remove(0, Path.Length - 4) == ".chr")
1230 {
1231 try
1232 {
1233 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
1234 Character C;
1235 C = World.CharacterFromName2(Name);
1236 if (C != null)
1237 {
1238 ushort TotalAtt = 0;
1239 TotalAtt += C.StatPoints;
1240 TotalAtt += C.Spi;
1241 TotalAtt += C.Vit;
1242 TotalAtt += C.Agi;
1243 TotalAtt += C.Str;
1244 TotalAtt -= 1;
1245 if (TotalAtt > 482)
1246 {
1247 C.Spi = 0;
1248 C.Vit = 1;
1249 C.Agi = 0;
1250 C.Str = 0;
1251 C.StatPoints = 482;
1252 }
1253 }
1254 else
1255 {
1256 string Account = "";
1257 C = LoadCharacter(Name, ref Account);
1258 if (C != null)
1259 {
1260 ushort TotalAtt = 0;
1261 TotalAtt += C.StatPoints;
1262 TotalAtt += C.Spi;
1263 TotalAtt += C.Vit;
1264 TotalAtt += C.Agi;
1265 TotalAtt += C.Str;
1266 TotalAtt -= 1;
1267 if (TotalAtt > 482)
1268 {
1269 C.Spi = 0;
1270 C.Vit = 1;
1271 C.Agi = 0;
1272 C.Str = 0;
1273 C.StatPoints = 482;
1274 SaveCharacter(C, Account);
1275 }
1276 }
1277 }
1278 }
1279 catch (Exception e)
1280 {
1281 World.ExcAdd += e.ToString() + "\r\n";
1282 }
1283 }
1284 // System.Threading.Thread.Sleep(1);
1285 }
1286 Program.Reseting = false;
1287 Console.WriteLine("Attributes Reset");
1288 System.Threading.Thread.CurrentThread.Abort();
1289 }
1290 public static void GetMinus5Items(object state)
1291 {
1292 Program.Reseting = true;
1293 foreach (string Path in Directory.GetFiles(World.GlobalCharactersPath))
1294 {
1295 if (Path.Remove(0, Path.Length - 4) == ".chr")
1296 {
1297 try
1298 {
1299 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
1300 Character C;
1301 C = World.CharacterFromName2(Name);
1302 if (C == null)
1303 {
1304 string Account = "";
1305 C = LoadCharacter(Name, ref Account);
1306 if (C != null)
1307 {
1308 ushort Plus8 = 0;
1309 ushort Plus9 = 0;
1310 foreach (Item I in C.Inventory)
1311 {
1312
1313 if (I.Plus == 8 || I.Plus == 9)
1314 {
1315 if (I.Plus == 8)
1316 Plus8++;
1317 else Plus9++;
1318 }
1319
1320 }
1321 foreach (Item I in C.Warehouses.TCWarehouse)
1322 {
1323 if (I.Plus == 8 || I.Plus == 9)
1324 {
1325 if (I.Plus == 8)
1326 Plus8++;
1327 else Plus9++;
1328 }
1329 }
1330 foreach (Item I in C.Warehouses.MAWarehouse)
1331 {
1332 if (I.Plus == 8 || I.Plus == 9)
1333 {
1334 if (I.Plus == 8)
1335 Plus8++;
1336 else Plus9++;
1337 }
1338 }
1339 foreach (Item I in C.Warehouses.MAWarehouse2)
1340 {
1341 if (I.Plus == 8 || I.Plus == 9)
1342 {
1343 if (I.Plus == 8)
1344 Plus8++;
1345 else Plus9++;
1346 }
1347 }
1348 foreach (Item I in C.Warehouses.PCWarehouse)
1349 {
1350 if (I.Plus == 8 || I.Plus == 9)
1351 {
1352 if (I.Plus == 8)
1353 Plus8++;
1354 else Plus9++;
1355 }
1356 }
1357 foreach (Item I in C.Warehouses.ACWarehouse)
1358 {
1359 if (I.Plus == 8 || I.Plus == 9)
1360 {
1361 if (I.Plus == 8)
1362 Plus8++;
1363 else Plus9++;
1364 }
1365 }
1366 foreach (Item I in C.Warehouses.DCWarehouse)
1367 {
1368 if (I.Plus == 8 || I.Plus == 9)
1369 {
1370 if (I.Plus == 8)
1371 Plus8++;
1372 else Plus9++;
1373 }
1374 }
1375 foreach (Item I in C.Warehouses.BIWarehouse)
1376 {
1377 if (I.Plus == 8 || I.Plus == 9)
1378 {
1379 if (I.Plus == 8)
1380 Plus8++;
1381 else Plus9++;
1382 }
1383 }
1384 if (Plus8 > 2 || Plus9 > 1)
1385 World.DebugAdd += C.Name + " had +8 items: " + Plus8 + " & +9 items: " + Plus9 + "\r\n";
1386 SaveCharacter(C, Account);
1387 }
1388 }
1389 else
1390 {
1391 ushort Plus8 = 0;
1392 ushort Plus9 = 0;
1393 foreach (Item I in C.Inventory)
1394 {
1395
1396 if (I.Plus == 8 || I.Plus == 9)
1397 {
1398 if (I.Plus == 8)
1399 Plus8++;
1400 else Plus9++;
1401 }
1402
1403 }
1404 foreach (Item I in C.Warehouses.TCWarehouse)
1405 {
1406 if (I.Plus == 8 || I.Plus == 9)
1407 {
1408 if (I.Plus == 8)
1409 Plus8++;
1410 else Plus9++;
1411 }
1412 }
1413 foreach (Item I in C.Warehouses.MAWarehouse)
1414 {
1415 if (I.Plus == 8 || I.Plus == 9)
1416 {
1417 if (I.Plus == 8)
1418 Plus8++;
1419 else Plus9++;
1420 }
1421 }
1422 foreach (Item I in C.Warehouses.MAWarehouse2)
1423 {
1424 if (I.Plus == 8 || I.Plus == 9)
1425 {
1426 if (I.Plus == 8)
1427 Plus8++;
1428 else Plus9++;
1429 }
1430 }
1431 foreach (Item I in C.Warehouses.PCWarehouse)
1432 {
1433 if (I.Plus == 8 || I.Plus == 9)
1434 {
1435 if (I.Plus == 8)
1436 Plus8++;
1437 else Plus9++;
1438 }
1439 }
1440 foreach (Item I in C.Warehouses.ACWarehouse)
1441 {
1442 if (I.Plus == 8 || I.Plus == 9)
1443 {
1444 if (I.Plus == 8)
1445 Plus8++;
1446 else Plus9++;
1447 }
1448 }
1449 foreach (Item I in C.Warehouses.DCWarehouse)
1450 {
1451 if (I.Plus == 8 || I.Plus == 9)
1452 {
1453 if (I.Plus == 8)
1454 Plus8++;
1455 else Plus9++;
1456 }
1457 }
1458 foreach (Item I in C.Warehouses.BIWarehouse)
1459 {
1460 if (I.Plus == 8 || I.Plus == 9)
1461 {
1462 if (I.Plus == 8)
1463 Plus8++;
1464 else Plus9++;
1465 }
1466 }
1467 if (Plus8 > 2 || Plus9 > 1)
1468 World.DebugAdd += C.Name + " had +8 items: " + Plus8 + " & +9 items: " + Plus9 + "\r\n";
1469 }
1470 }
1471 catch (Exception e)
1472 {
1473 World.ExcAdd += e.ToString() + "\r\n";
1474 }
1475 }
1476 //System.Threading.Thread.Sleep(1);
1477 }
1478 Program.Reseting = false;
1479 System.Threading.Thread.CurrentThread.Abort(state);
1480 }
1481 public static void Get2Sockets(object state)
1482 {
1483 Program.Reseting = true;
1484 ushort HeadGear1 = 0;
1485 ushort HeadGear2 = 0;
1486 ushort Neck1 = 0;
1487 ushort Neck2 = 0;
1488 ushort Ring1 = 0;
1489 ushort Ring2 = 0;
1490 ushort Armor2 = 0;
1491 ushort Boots1 = 0;
1492 ushort Boots2 = 0;
1493 foreach (string Path in Directory.GetFiles(World.GlobalCharactersPath))
1494 {
1495 if (Path.Remove(0, Path.Length - 4) == ".chr")
1496 {
1497 try
1498 {
1499 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
1500 Character C;
1501 C = World.CharacterFromName2(Name);
1502 if (C == null)
1503 {
1504 string Account = "";
1505 C = LoadCharacter(Name, ref Account);
1506 if (C != null)
1507 {
1508 if (C.Equips.Armor.Soc2 != 0)
1509 {
1510 Armor2++;
1511 }
1512 if (C.Equips.Boots.Soc1 != 0 || C.Equips.Boots.Soc2 != 0)
1513 {
1514 if (C.Equips.Boots.Soc2 != 0)
1515 Boots2++;
1516 else Boots1++;
1517 }
1518 if (C.Equips.HeadGear.Soc1 != 0 || C.Equips.HeadGear.Soc2 != 0)
1519 {
1520 if (C.Equips.HeadGear.Soc2 != 0)
1521 HeadGear2++;
1522 else HeadGear1++;
1523 }
1524 if (C.Equips.Necklace.Soc1 != 0 || C.Equips.Necklace.Soc2 != 0)
1525 {
1526 if (C.Equips.Necklace.Soc2 != 0)
1527 Neck2++;
1528 else Neck1++;
1529 }
1530 if (C.Equips.Ring.Soc1 != 0 || C.Equips.Ring.Soc2 != 0)
1531 {
1532 if (C.Equips.Ring.Soc2 != 0)
1533 Ring2++;
1534 else Ring1++;
1535 }
1536
1537 foreach (Item I in C.Inventory)
1538 {
1539 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1540 {
1541 if (I.Soc1 != 0 || I.Soc2 != 0)
1542 {
1543 if (I.Soc2 != 0)
1544 HeadGear2++;
1545 else HeadGear1++;
1546 }
1547 }
1548 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1549 {
1550 if (I.Soc1 != 0 || I.Soc2 != 0)
1551 {
1552 if (I.Soc2 != 0)
1553 Neck2++;
1554 else Neck1++;
1555 }
1556 }
1557 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1558 {
1559 if (I.Soc2 != 0)
1560 Armor2++;
1561 }
1562 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1563 {
1564 if (I.Soc1 != 0 || I.Soc2 != 0)
1565 {
1566 if (I.Soc2 != 0)
1567 Neck2++;
1568 else Neck1++;
1569 }
1570 }
1571 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1572 {
1573 if (I.Soc1 != 0 || I.Soc2 != 0)
1574 {
1575 if (I.Soc2 != 0)
1576 Ring2++;
1577 else Ring1++;
1578 }
1579 }
1580 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1581 {
1582 if (I.Soc1 != 0 || I.Soc2 != 0)
1583 {
1584 if (I.Soc2 != 0)
1585 Boots2++;
1586 else Boots1++;
1587 }
1588 }
1589
1590 }
1591 foreach (Item I in C.Warehouses.TCWarehouse)
1592 {
1593 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1594 {
1595 if (I.Soc1 != 0 || I.Soc2 != 0)
1596 {
1597 if (I.Soc2 != 0)
1598 HeadGear2++;
1599 else HeadGear1++;
1600 }
1601 }
1602 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1603 {
1604 if (I.Soc1 != 0 || I.Soc2 != 0)
1605 {
1606 if (I.Soc2 != 0)
1607 Neck2++;
1608 else Neck1++;
1609 }
1610 }
1611 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1612 {
1613 if (I.Soc2 != 0)
1614 Armor2++;
1615 }
1616 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1617 {
1618 if (I.Soc1 != 0 || I.Soc2 != 0)
1619 {
1620 if (I.Soc2 != 0)
1621 Neck2++;
1622 else Neck1++;
1623 }
1624 }
1625 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1626 {
1627 if (I.Soc1 != 0 || I.Soc2 != 0)
1628 {
1629 if (I.Soc2 != 0)
1630 Ring2++;
1631 else Ring1++;
1632 }
1633 }
1634 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1635 {
1636 if (I.Soc1 != 0 || I.Soc2 != 0)
1637 {
1638 if (I.Soc2 != 0)
1639 Boots2++;
1640 else Boots1++;
1641 }
1642 }
1643 }
1644 foreach (Item I in C.Warehouses.MAWarehouse)
1645 {
1646 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1647 {
1648 if (I.Soc1 != 0 || I.Soc2 != 0)
1649 {
1650 if (I.Soc2 != 0)
1651 HeadGear2++;
1652 else HeadGear1++;
1653 }
1654 }
1655 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1656 {
1657 if (I.Soc1 != 0 || I.Soc2 != 0)
1658 {
1659 if (I.Soc2 != 0)
1660 Neck2++;
1661 else Neck1++;
1662 }
1663 }
1664 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1665 {
1666 if (I.Soc2 != 0)
1667 Armor2++;
1668 }
1669 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1670 {
1671 if (I.Soc1 != 0 || I.Soc2 != 0)
1672 {
1673 if (I.Soc2 != 0)
1674 Neck2++;
1675 else Neck1++;
1676 }
1677 }
1678 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1679 {
1680 if (I.Soc1 != 0 || I.Soc2 != 0)
1681 {
1682 if (I.Soc2 != 0)
1683 Ring2++;
1684 else Ring1++;
1685 }
1686 }
1687 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1688 {
1689 if (I.Soc1 != 0 || I.Soc2 != 0)
1690 {
1691 if (I.Soc2 != 0)
1692 Boots2++;
1693 else Boots1++;
1694 }
1695 }
1696 }
1697 foreach (Item I in C.Warehouses.MAWarehouse2)
1698 {
1699 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1700 {
1701 if (I.Soc1 != 0 || I.Soc2 != 0)
1702 {
1703 if (I.Soc2 != 0)
1704 HeadGear2++;
1705 else HeadGear1++;
1706 }
1707 }
1708 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1709 {
1710 if (I.Soc1 != 0 || I.Soc2 != 0)
1711 {
1712 if (I.Soc2 != 0)
1713 Neck2++;
1714 else Neck1++;
1715 }
1716 }
1717 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1718 {
1719 if (I.Soc2 != 0)
1720 Armor2++;
1721 }
1722 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1723 {
1724 if (I.Soc1 != 0 || I.Soc2 != 0)
1725 {
1726 if (I.Soc2 != 0)
1727 Neck2++;
1728 else Neck1++;
1729 }
1730 }
1731 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1732 {
1733 if (I.Soc1 != 0 || I.Soc2 != 0)
1734 {
1735 if (I.Soc2 != 0)
1736 Ring2++;
1737 else Ring1++;
1738 }
1739 }
1740 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1741 {
1742 if (I.Soc1 != 0 || I.Soc2 != 0)
1743 {
1744 if (I.Soc2 != 0)
1745 Boots2++;
1746 else Boots1++;
1747 }
1748 }
1749 }
1750 foreach (Item I in C.Warehouses.PCWarehouse)
1751 {
1752 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1753 {
1754 if (I.Soc1 != 0 || I.Soc2 != 0)
1755 {
1756 if (I.Soc2 != 0)
1757 HeadGear2++;
1758 else HeadGear1++;
1759 }
1760 }
1761 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1762 {
1763 if (I.Soc1 != 0 || I.Soc2 != 0)
1764 {
1765 if (I.Soc2 != 0)
1766 Neck2++;
1767 else Neck1++;
1768 }
1769 }
1770 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1771 {
1772 if (I.Soc2 != 0)
1773 Armor2++;
1774 }
1775 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1776 {
1777 if (I.Soc1 != 0 || I.Soc2 != 0)
1778 {
1779 if (I.Soc2 != 0)
1780 Neck2++;
1781 else Neck1++;
1782 }
1783 }
1784 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1785 {
1786 if (I.Soc1 != 0 || I.Soc2 != 0)
1787 {
1788 if (I.Soc2 != 0)
1789 Ring2++;
1790 else Ring1++;
1791 }
1792 }
1793 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1794 {
1795 if (I.Soc1 != 0 || I.Soc2 != 0)
1796 {
1797 if (I.Soc2 != 0)
1798 Boots2++;
1799 else Boots1++;
1800 }
1801 }
1802 }
1803 foreach (Item I in C.Warehouses.ACWarehouse)
1804 {
1805 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1806 {
1807 if (I.Soc1 != 0 || I.Soc2 != 0)
1808 {
1809 if (I.Soc2 != 0)
1810 HeadGear2++;
1811 else HeadGear1++;
1812 }
1813 }
1814 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1815 {
1816 if (I.Soc1 != 0 || I.Soc2 != 0)
1817 {
1818 if (I.Soc2 != 0)
1819 Neck2++;
1820 else Neck1++;
1821 }
1822 }
1823 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1824 {
1825 if (I.Soc2 != 0)
1826 Armor2++;
1827 }
1828 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1829 {
1830 if (I.Soc1 != 0 || I.Soc2 != 0)
1831 {
1832 if (I.Soc2 != 0)
1833 Neck2++;
1834 else Neck1++;
1835 }
1836 }
1837 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1838 {
1839 if (I.Soc1 != 0 || I.Soc2 != 0)
1840 {
1841 if (I.Soc2 != 0)
1842 Ring2++;
1843 else Ring1++;
1844 }
1845 }
1846 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1847 {
1848 if (I.Soc1 != 0 || I.Soc2 != 0)
1849 {
1850 if (I.Soc2 != 0)
1851 Boots2++;
1852 else Boots1++;
1853 }
1854 }
1855 }
1856 foreach (Item I in C.Warehouses.DCWarehouse)
1857 {
1858 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1859 {
1860 if (I.Soc1 != 0 || I.Soc2 != 0)
1861 {
1862 if (I.Soc2 != 0)
1863 HeadGear2++;
1864 else HeadGear1++;
1865 }
1866 }
1867 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1868 {
1869 if (I.Soc1 != 0 || I.Soc2 != 0)
1870 {
1871 if (I.Soc2 != 0)
1872 Neck2++;
1873 else Neck1++;
1874 }
1875 }
1876 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1877 {
1878 if (I.Soc2 != 0)
1879 Armor2++;
1880 }
1881 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1882 {
1883 if (I.Soc1 != 0 || I.Soc2 != 0)
1884 {
1885 if (I.Soc2 != 0)
1886 Neck2++;
1887 else Neck1++;
1888 }
1889 }
1890 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1891 {
1892 if (I.Soc1 != 0 || I.Soc2 != 0)
1893 {
1894 if (I.Soc2 != 0)
1895 Ring2++;
1896 else Ring1++;
1897 }
1898 }
1899 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1900 {
1901 if (I.Soc1 != 0 || I.Soc2 != 0)
1902 {
1903 if (I.Soc2 != 0)
1904 Boots2++;
1905 else Boots1++;
1906 }
1907 }
1908 }
1909 foreach (Item I in C.Warehouses.BIWarehouse)
1910 {
1911 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1912 {
1913 if (I.Soc1 != 0 || I.Soc2 != 0)
1914 {
1915 if (I.Soc2 != 0)
1916 HeadGear2++;
1917 else HeadGear1++;
1918 }
1919 }
1920 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1921 {
1922 if (I.Soc1 != 0 || I.Soc2 != 0)
1923 {
1924 if (I.Soc2 != 0)
1925 Neck2++;
1926 else Neck1++;
1927 }
1928 }
1929 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
1930 {
1931 if (I.Soc2 != 0)
1932 Armor2++;
1933 }
1934 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
1935 {
1936 if (I.Soc1 != 0 || I.Soc2 != 0)
1937 {
1938 if (I.Soc2 != 0)
1939 Neck2++;
1940 else Neck1++;
1941 }
1942 }
1943 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
1944 {
1945 if (I.Soc1 != 0 || I.Soc2 != 0)
1946 {
1947 if (I.Soc2 != 0)
1948 Ring2++;
1949 else Ring1++;
1950 }
1951 }
1952 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
1953 {
1954 if (I.Soc1 != 0 || I.Soc2 != 0)
1955 {
1956 if (I.Soc2 != 0)
1957 Boots2++;
1958 else Boots1++;
1959 }
1960 }
1961 }
1962 SaveCharacter(C, Account);
1963 }
1964 }
1965 else
1966 {
1967 if (C.Equips.Armor.Soc2 != 0)
1968 {
1969 Armor2++;
1970 }
1971 if (C.Equips.Boots.Soc1 != 0 || C.Equips.Boots.Soc2 != 0)
1972 {
1973 if (C.Equips.Boots.Soc2 != 0)
1974 Boots2++;
1975 else Boots1++;
1976 }
1977 if (C.Equips.HeadGear.Soc1 != 0 || C.Equips.HeadGear.Soc2 != 0)
1978 {
1979 if (C.Equips.HeadGear.Soc2 != 0)
1980 HeadGear2++;
1981 else HeadGear1++;
1982 }
1983 if (C.Equips.Necklace.Soc1 != 0 || C.Equips.Necklace.Soc2 != 0)
1984 {
1985 if (C.Equips.Necklace.Soc2 != 0)
1986 Neck2++;
1987 else Neck1++;
1988 }
1989 if (C.Equips.Ring.Soc1 != 0 || C.Equips.Ring.Soc2 != 0)
1990 {
1991 if (C.Equips.Ring.Soc2 != 0)
1992 Ring2++;
1993 else Ring1++;
1994 }
1995
1996 foreach (Item I in C.Inventory)
1997 {
1998 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
1999 {
2000 if (I.Soc1 != 0 || I.Soc2 != 0)
2001 {
2002 if (I.Soc2 != 0)
2003 HeadGear2++;
2004 else HeadGear1++;
2005 }
2006 }
2007 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2008 {
2009 if (I.Soc1 != 0 || I.Soc2 != 0)
2010 {
2011 if (I.Soc2 != 0)
2012 Neck2++;
2013 else Neck1++;
2014 }
2015 }
2016 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2017 {
2018 if (I.Soc2 != 0)
2019 Armor2++;
2020 }
2021 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2022 {
2023 if (I.Soc1 != 0 || I.Soc2 != 0)
2024 {
2025 if (I.Soc2 != 0)
2026 Neck2++;
2027 else Neck1++;
2028 }
2029 }
2030 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2031 {
2032 if (I.Soc1 != 0 || I.Soc2 != 0)
2033 {
2034 if (I.Soc2 != 0)
2035 Ring2++;
2036 else Ring1++;
2037 }
2038 }
2039 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2040 {
2041 if (I.Soc1 != 0 || I.Soc2 != 0)
2042 {
2043 if (I.Soc2 != 0)
2044 Boots2++;
2045 else Boots1++;
2046 }
2047 }
2048 }
2049 foreach (Item I in C.Warehouses.TCWarehouse)
2050 {
2051 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
2052 {
2053 if (I.Soc1 != 0 || I.Soc2 != 0)
2054 {
2055 if (I.Soc2 != 0)
2056 HeadGear2++;
2057 else HeadGear1++;
2058 }
2059 }
2060 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2061 {
2062 if (I.Soc1 != 0 || I.Soc2 != 0)
2063 {
2064 if (I.Soc2 != 0)
2065 Neck2++;
2066 else Neck1++;
2067 }
2068 }
2069 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2070 {
2071 if (I.Soc2 != 0)
2072 Armor2++;
2073 }
2074 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2075 {
2076 if (I.Soc1 != 0 || I.Soc2 != 0)
2077 {
2078 if (I.Soc2 != 0)
2079 Neck2++;
2080 else Neck1++;
2081 }
2082 }
2083 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2084 {
2085 if (I.Soc1 != 0 || I.Soc2 != 0)
2086 {
2087 if (I.Soc2 != 0)
2088 Ring2++;
2089 else Ring1++;
2090 }
2091 }
2092 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2093 {
2094 if (I.Soc1 != 0 || I.Soc2 != 0)
2095 {
2096 if (I.Soc2 != 0)
2097 Boots2++;
2098 else Boots1++;
2099 }
2100 }
2101 }
2102 foreach (Item I in C.Warehouses.MAWarehouse)
2103 {
2104 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
2105 {
2106 if (I.Soc1 != 0 || I.Soc2 != 0)
2107 {
2108 if (I.Soc2 != 0)
2109 HeadGear2++;
2110 else HeadGear1++;
2111 }
2112 }
2113 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2114 {
2115 if (I.Soc1 != 0 || I.Soc2 != 0)
2116 {
2117 if (I.Soc2 != 0)
2118 Neck2++;
2119 else Neck1++;
2120 }
2121 }
2122 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2123 {
2124 if (I.Soc2 != 0)
2125 Armor2++;
2126 }
2127 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2128 {
2129 if (I.Soc1 != 0 || I.Soc2 != 0)
2130 {
2131 if (I.Soc2 != 0)
2132 Neck2++;
2133 else Neck1++;
2134 }
2135 }
2136 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2137 {
2138 if (I.Soc1 != 0 || I.Soc2 != 0)
2139 {
2140 if (I.Soc2 != 0)
2141 Ring2++;
2142 else Ring1++;
2143 }
2144 }
2145 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2146 {
2147 if (I.Soc1 != 0 || I.Soc2 != 0)
2148 {
2149 if (I.Soc2 != 0)
2150 Boots2++;
2151 else Boots1++;
2152 }
2153 }
2154 }
2155 foreach (Item I in C.Warehouses.MAWarehouse2)
2156 {
2157 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
2158 {
2159 if (I.Soc1 != 0 || I.Soc2 != 0)
2160 {
2161 if (I.Soc2 != 0)
2162 HeadGear2++;
2163 else HeadGear1++;
2164 }
2165 }
2166 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2167 {
2168 if (I.Soc1 != 0 || I.Soc2 != 0)
2169 {
2170 if (I.Soc2 != 0)
2171 Neck2++;
2172 else Neck1++;
2173 }
2174 }
2175 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2176 {
2177 if (I.Soc2 != 0)
2178 Armor2++;
2179 }
2180 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2181 {
2182 if (I.Soc1 != 0 || I.Soc2 != 0)
2183 {
2184 if (I.Soc2 != 0)
2185 Neck2++;
2186 else Neck1++;
2187 }
2188 }
2189 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2190 {
2191 if (I.Soc1 != 0 || I.Soc2 != 0)
2192 {
2193 if (I.Soc2 != 0)
2194 Ring2++;
2195 else Ring1++;
2196 }
2197 }
2198 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2199 {
2200 if (I.Soc1 != 0 || I.Soc2 != 0)
2201 {
2202 if (I.Soc2 != 0)
2203 Boots2++;
2204 else Boots1++;
2205 }
2206 }
2207 }
2208 foreach (Item I in C.Warehouses.PCWarehouse)
2209 {
2210 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
2211 {
2212 if (I.Soc1 != 0 || I.Soc2 != 0)
2213 {
2214 if (I.Soc2 != 0)
2215 HeadGear2++;
2216 else HeadGear1++;
2217 }
2218 }
2219 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2220 {
2221 if (I.Soc1 != 0 || I.Soc2 != 0)
2222 {
2223 if (I.Soc2 != 0)
2224 Neck2++;
2225 else Neck1++;
2226 }
2227 }
2228 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2229 {
2230 if (I.Soc2 != 0)
2231 Armor2++;
2232 }
2233 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2234 {
2235 if (I.Soc1 != 0 || I.Soc2 != 0)
2236 {
2237 if (I.Soc2 != 0)
2238 Neck2++;
2239 else Neck1++;
2240 }
2241 }
2242 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2243 {
2244 if (I.Soc1 != 0 || I.Soc2 != 0)
2245 {
2246 if (I.Soc2 != 0)
2247 Ring2++;
2248 else Ring1++;
2249 }
2250 }
2251 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2252 {
2253 if (I.Soc1 != 0 || I.Soc2 != 0)
2254 {
2255 if (I.Soc2 != 0)
2256 Boots2++;
2257 else Boots1++;
2258 }
2259 }
2260 }
2261 foreach (Item I in C.Warehouses.ACWarehouse)
2262 {
2263 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
2264 {
2265 if (I.Soc1 != 0 || I.Soc2 != 0)
2266 {
2267 if (I.Soc2 != 0)
2268 HeadGear2++;
2269 else HeadGear1++;
2270 }
2271 }
2272 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2273 {
2274 if (I.Soc1 != 0 || I.Soc2 != 0)
2275 {
2276 if (I.Soc2 != 0)
2277 Neck2++;
2278 else Neck1++;
2279 }
2280 }
2281 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2282 {
2283 if (I.Soc2 != 0)
2284 Armor2++;
2285 }
2286 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2287 {
2288 if (I.Soc1 != 0 || I.Soc2 != 0)
2289 {
2290 if (I.Soc2 != 0)
2291 Neck2++;
2292 else Neck1++;
2293 }
2294 }
2295 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2296 {
2297 if (I.Soc1 != 0 || I.Soc2 != 0)
2298 {
2299 if (I.Soc2 != 0)
2300 Ring2++;
2301 else Ring1++;
2302 }
2303 }
2304 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2305 {
2306 if (I.Soc1 != 0 || I.Soc2 != 0)
2307 {
2308 if (I.Soc2 != 0)
2309 Boots2++;
2310 else Boots1++;
2311 }
2312 }
2313 }
2314 foreach (Item I in C.Warehouses.DCWarehouse)
2315 {
2316 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
2317 {
2318 if (I.Soc1 != 0 || I.Soc2 != 0)
2319 {
2320 if (I.Soc2 != 0)
2321 HeadGear2++;
2322 else HeadGear1++;
2323 }
2324 }
2325 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2326 {
2327 if (I.Soc1 != 0 || I.Soc2 != 0)
2328 {
2329 if (I.Soc2 != 0)
2330 Neck2++;
2331 else Neck1++;
2332 }
2333 }
2334 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2335 {
2336 if (I.Soc2 != 0)
2337 Armor2++;
2338 }
2339 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2340 {
2341 if (I.Soc1 != 0 || I.Soc2 != 0)
2342 {
2343 if (I.Soc2 != 0)
2344 Neck2++;
2345 else Neck1++;
2346 }
2347 }
2348 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2349 {
2350 if (I.Soc1 != 0 || I.Soc2 != 0)
2351 {
2352 if (I.Soc2 != 0)
2353 Ring2++;
2354 else Ring1++;
2355 }
2356 }
2357 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2358 {
2359 if (I.Soc1 != 0 || I.Soc2 != 0)
2360 {
2361 if (I.Soc2 != 0)
2362 Boots2++;
2363 else Boots1++;
2364 }
2365 }
2366 }
2367 foreach (Item I in C.Warehouses.BIWarehouse)
2368 {
2369 if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 118 || ItemIDManipulation.Part(I.ID, 0, 3) == 141 || ItemIDManipulation.Part(I.ID, 0, 3) == 142)
2370 {
2371 if (I.Soc1 != 0 || I.Soc2 != 0)
2372 {
2373 if (I.Soc2 != 0)
2374 HeadGear2++;
2375 else HeadGear1++;
2376 }
2377 }
2378 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2379 {
2380 if (I.Soc1 != 0 || I.Soc2 != 0)
2381 {
2382 if (I.Soc2 != 0)
2383 Neck2++;
2384 else Neck1++;
2385 }
2386 }
2387 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 134)
2388 {
2389 if (I.Soc2 != 0)
2390 Armor2++;
2391 }
2392 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 121)
2393 {
2394 if (I.Soc1 != 0 || I.Soc2 != 0)
2395 {
2396 if (I.Soc2 != 0)
2397 Neck2++;
2398 else Neck1++;
2399 }
2400 }
2401 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 152)
2402 {
2403 if (I.Soc1 != 0 || I.Soc2 != 0)
2404 {
2405 if (I.Soc2 != 0)
2406 Ring2++;
2407 else Ring1++;
2408 }
2409 }
2410 else if (Game.ItemIDManipulation.Part(I.ID, 0, 3) <= 160)
2411 {
2412 if (I.Soc1 != 0 || I.Soc2 != 0)
2413 {
2414 if (I.Soc2 != 0)
2415 Boots2++;
2416 else Boots1++;
2417 }
2418 }
2419 }
2420 }
2421 }
2422 catch (Exception e)
2423 {
2424 World.ExcAdd += e.ToString() + "\r\n";
2425 }
2426 }
2427 //System.Threading.Thread.Sleep(1);
2428 }
2429 Console.WriteLine("-----1 Socket-----");
2430 Console.WriteLine("Headgears: " + HeadGear1);
2431 Console.WriteLine("Neck/Bags: " + Neck1);
2432 Console.WriteLine("Ring/Bracs: " + Ring1);
2433 Console.WriteLine("Boots: " + Boots1);
2434 Console.WriteLine("-----2 Socket-----");
2435 Console.WriteLine("Headgears: " + HeadGear2);
2436 Console.WriteLine("Neck/Bags: " + Neck2);
2437 Console.WriteLine("Ring/Bracs: " + Ring2);
2438 Console.WriteLine("Armors: " + Armor2);
2439 Console.WriteLine("Boots: " + Boots2);
2440
2441 Program.Reseting = false;
2442 System.Threading.Thread.CurrentThread.Abort(state);
2443 }
2444 public static void GetMets(object state)
2445 {
2446 Program.Reseting = true;
2447 ulong Meteor = 0;
2448 ulong MeteorTear = 0;
2449 ulong Metscroll = 0;
2450 ulong MetscrollBag = 0;
2451 ulong MetPoints = 0;
2452 ulong VirtuePoints = 0;
2453 foreach (string Path in Directory.GetFiles(World.GlobalCharactersPath))
2454 {
2455 if (Path.Remove(0, Path.Length - 4) == ".chr")
2456 {
2457 try
2458 {
2459 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2460 Character C;
2461 C = World.CharacterFromName2(Name);
2462 if (C == null)
2463 {
2464 string Account = "";
2465 C = LoadCharacter(Name, ref Account);
2466 if (C != null)
2467 {
2468 //720027 - Metscroll
2469 //1088001 - Meteor
2470 //1088002 - MeteorTear
2471 //729912 - MetBag
2472 if (DateTime.UtcNow <= C.LastLogin.AddDays(30))
2473 continue;
2474 VirtuePoints += C.VP;
2475 MetPoints += C.MetScrolls;
2476 foreach (Item I in C.Inventory)
2477 {
2478 if (I.ID == 1088001)
2479 Meteor++;
2480 else if (I.ID == 1088002)
2481 MeteorTear++;
2482 else if (I.ID == 720027)
2483 Metscroll++;
2484 else if (I.ID == 729912)
2485 MetscrollBag++;
2486 }
2487 foreach (Item I in C.Warehouses.TCWarehouse)
2488 {
2489 if (I.ID == 1088001)
2490 Meteor++;
2491 else if (I.ID == 1088002)
2492 MeteorTear++;
2493 else if (I.ID == 720027)
2494 Metscroll++;
2495 else if (I.ID == 729912)
2496 MetscrollBag++;
2497 }
2498 foreach (Item I in C.Warehouses.MAWarehouse)
2499 {
2500 if (I.ID == 1088001)
2501 Meteor++;
2502 else if (I.ID == 1088002)
2503 MeteorTear++;
2504 else if (I.ID == 720027)
2505 Metscroll++;
2506 else if (I.ID == 729912)
2507 MetscrollBag++;
2508 }
2509 foreach (Item I in C.Warehouses.MAWarehouse2)
2510 {
2511 if (I.ID == 1088001)
2512 Meteor++;
2513 else if (I.ID == 1088002)
2514 MeteorTear++;
2515 else if (I.ID == 720027)
2516 Metscroll++;
2517 else if (I.ID == 729912)
2518 MetscrollBag++;
2519 }
2520 foreach (Item I in C.Warehouses.PCWarehouse)
2521 {
2522 if (I.ID == 1088001)
2523 Meteor++;
2524 else if (I.ID == 1088002)
2525 MeteorTear++;
2526 else if (I.ID == 720027)
2527 Metscroll++;
2528 else if (I.ID == 729912)
2529 MetscrollBag++;
2530 }
2531 foreach (Item I in C.Warehouses.ACWarehouse)
2532 {
2533 if (I.ID == 1088001)
2534 Meteor++;
2535 else if (I.ID == 1088002)
2536 MeteorTear++;
2537 else if (I.ID == 720027)
2538 Metscroll++;
2539 else if (I.ID == 729912)
2540 MetscrollBag++;
2541 }
2542 foreach (Item I in C.Warehouses.DCWarehouse)
2543 {
2544 if (I.ID == 1088001)
2545 Meteor++;
2546 else if (I.ID == 1088002)
2547 MeteorTear++;
2548 else if (I.ID == 720027)
2549 Metscroll++;
2550 else if (I.ID == 729912)
2551 MetscrollBag++;
2552 }
2553 foreach (Item I in C.Warehouses.BIWarehouse)
2554 {
2555 if (I.ID == 1088001)
2556 Meteor++;
2557 else if (I.ID == 1088002)
2558 MeteorTear++;
2559 else if (I.ID == 720027)
2560 Metscroll++;
2561 else if (I.ID == 729912)
2562 MetscrollBag++;
2563 }
2564 SaveCharacter(C, Account);
2565 }
2566 }
2567 else
2568 {
2569 foreach (Item I in C.Inventory)
2570 {
2571 if (I.ID == 1088001)
2572 Meteor++;
2573 else if (I.ID == 1088002)
2574 MeteorTear++;
2575 else if (I.ID == 720027)
2576 Metscroll++;
2577 else if (I.ID == 729912)
2578 MetscrollBag++;
2579 }
2580 foreach (Item I in C.Warehouses.TCWarehouse)
2581 {
2582 if (I.ID == 1088001)
2583 Meteor++;
2584 else if (I.ID == 1088002)
2585 MeteorTear++;
2586 else if (I.ID == 720027)
2587 Metscroll++;
2588 else if (I.ID == 729912)
2589 MetscrollBag++;
2590 }
2591 foreach (Item I in C.Warehouses.MAWarehouse)
2592 {
2593 if (I.ID == 1088001)
2594 Meteor++;
2595 else if (I.ID == 1088002)
2596 MeteorTear++;
2597 else if (I.ID == 720027)
2598 Metscroll++;
2599 else if (I.ID == 729912)
2600 MetscrollBag++;
2601 }
2602 foreach (Item I in C.Warehouses.MAWarehouse2)
2603 {
2604 if (I.ID == 1088001)
2605 Meteor++;
2606 else if (I.ID == 1088002)
2607 MeteorTear++;
2608 else if (I.ID == 720027)
2609 Metscroll++;
2610 else if (I.ID == 729912)
2611 MetscrollBag++;
2612 }
2613 foreach (Item I in C.Warehouses.PCWarehouse)
2614 {
2615 if (I.ID == 1088001)
2616 Meteor++;
2617 else if (I.ID == 1088002)
2618 MeteorTear++;
2619 else if (I.ID == 720027)
2620 Metscroll++;
2621 else if (I.ID == 729912)
2622 MetscrollBag++;
2623 }
2624 foreach (Item I in C.Warehouses.ACWarehouse)
2625 {
2626 if (I.ID == 1088001)
2627 Meteor++;
2628 else if (I.ID == 1088002)
2629 MeteorTear++;
2630 else if (I.ID == 720027)
2631 Metscroll++;
2632 else if (I.ID == 729912)
2633 MetscrollBag++;
2634 }
2635 foreach (Item I in C.Warehouses.DCWarehouse)
2636 {
2637 if (I.ID == 1088001)
2638 Meteor++;
2639 else if (I.ID == 1088002)
2640 MeteorTear++;
2641 else if (I.ID == 720027)
2642 Metscroll++;
2643 else if (I.ID == 729912)
2644 MetscrollBag++;
2645 }
2646 foreach (Item I in C.Warehouses.BIWarehouse)
2647 {
2648 if (I.ID == 1088001)
2649 Meteor++;
2650 else if (I.ID == 1088002)
2651 MeteorTear++;
2652 else if (I.ID == 720027)
2653 Metscroll++;
2654 else if (I.ID == 729912)
2655 MetscrollBag++;
2656 }
2657 }
2658 }
2659 catch (Exception e)
2660 {
2661 World.ExcAdd += e.ToString() + "\r\n";
2662 }
2663 }
2664 }
2665 Console.WriteLine("-----Meteors-----");
2666 Console.WriteLine("Meteors: " + Meteor);
2667 Console.WriteLine("MeteorTears: " + MeteorTear);
2668 Console.WriteLine("MeteorScrolls: " + Metscroll);
2669 Console.WriteLine("MetScrollBags: " + MetscrollBag);
2670 Console.WriteLine("MetScrollPoints: " + MetPoints);
2671 Console.WriteLine("VirtuePoints: " + VirtuePoints);
2672
2673 Program.Reseting = false;
2674 System.Threading.Thread.CurrentThread.Abort(state);
2675 }
2676 public static void UpdateChars(object state)
2677 {
2678 Console.WriteLine("Updating chars...");
2679 Program.Reseting = true;
2680 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
2681 foreach (string Path in Paths)
2682 {
2683 if (Path.Remove(0, Path.Length - 4) == ".chr")
2684 {
2685 try
2686 {
2687 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2688 Character C;
2689 C = World.CharacterFromName2(Name);
2690 if (C == null)
2691 {
2692 string Account = "";
2693 C = LoadCharacter(Name, ref Account);
2694 if (C != null)
2695 {
2696 SaveCharacter(C, Account);
2697 Console.WriteLine(C.Name + " was updated successfully...");
2698 }
2699 }
2700
2701 }
2702 catch (Exception e)
2703 {
2704 World.ExcAdd += e.ToString() + "\r\n";
2705 }
2706
2707 }
2708 // System.Threading.Thread.Sleep(1);
2709 }
2710 Console.WriteLine("Finished updating chars.");
2711
2712 Console.WriteLine("Updating banned chars...");
2713 string[] Paths2 = Directory.GetFiles(World.BannedChars);
2714 foreach (string Path in Paths2)
2715 {
2716 if (Path.Remove(0, Path.Length - 4) == ".chr")
2717 {
2718 try
2719 {
2720 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2721 Character C;
2722 C = World.CharacterFromName2(Name);
2723 if (C == null)
2724 {
2725 string Account = "";
2726 C = LoadCharacter(Name, ref Account);
2727 if (C != null)
2728 {
2729 SaveCharacter(C, Account);
2730 Console.WriteLine("Banned character " + C.Name + " was updated successfully...");
2731 }
2732 }
2733
2734 }
2735 catch (Exception e)
2736 {
2737 World.ExcAdd += e.ToString() + "\r\n";
2738 }
2739
2740 }
2741 }
2742 Console.WriteLine("Finished updating banned chars.");
2743
2744 Program.Reseting = false;
2745 System.Threading.Thread.CurrentThread.Abort();
2746 }
2747 public static void UpdateBannedChars(object state)
2748 {
2749 Console.WriteLine("Updating banned chars...");
2750 Program.Reseting = true;
2751 string[] Paths = Directory.GetFiles(World.BannedChars);
2752 foreach (string Path in Paths)
2753 {
2754 if (Path.Remove(0, Path.Length - 4) == ".chr")
2755 {
2756 try
2757 {
2758 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2759 Character C;
2760 C = World.CharacterFromName2(Name);
2761 if (C == null)
2762 {
2763 string Account = "";
2764 C = LoadCharacter(Name, ref Account);
2765 if (C != null)
2766 {
2767 SaveCharacter(C, Account);
2768 Console.WriteLine("Banned character " + C.Name + " was updated successfully...");
2769 }
2770 }
2771
2772 }
2773 catch (Exception e)
2774 {
2775 World.ExcAdd += e.ToString() + "\r\n";
2776 }
2777
2778 }
2779 // System.Threading.Thread.Sleep(1);
2780 }
2781 Console.WriteLine("Finished updating banned chars.");
2782 Program.Reseting = false;
2783 System.Threading.Thread.CurrentThread.Abort();
2784 }
2785 public static void CheckGoldOnPlayers(uint amount)
2786 {
2787 Console.WriteLine("Checking gold on chars...");
2788 Program.Reseting = true;
2789 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
2790 List<Character> Gold = new List<Character>();
2791
2792 foreach (string Path in Paths)
2793 {
2794 if (Path.Remove(0, Path.Length - 4) == ".chr")
2795 {
2796 try
2797 {
2798 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2799 Character C;
2800 C = World.CharacterFromName2(Name);
2801 if (C == null)
2802 {
2803 string Account = "";
2804 C = LoadCharacter(Name, ref Account);
2805 if (C != null)
2806 {
2807 if (C.Silvers + C.WHSilvers >= amount)
2808 {
2809 Gold.Add(C);
2810 /* World.DebugAdd += C.Name + " has silvers amount: " + (C.Silvers + C.WHSilvers) + "\r\n";
2811 if (C.TreasurePoints > 0)
2812 World.DebugAdd += C.Name + " has treasure points: " + C.TreasurePoints + "\r\n";
2813 if (C.Flowers > 0)
2814 World.DebugAdd += C.Name + " has flower points: " + C.Flowers + "\r\n";*/
2815 }
2816 }
2817 }
2818 else
2819 {
2820 if (C.Silvers + C.WHSilvers >= amount)
2821 Gold.Add(C);
2822 /* if (C.Silvers >= amount)
2823 World.DebugAdd += C.Name + " has silvers amount: " + C.Silvers + "\r\n"; */
2824 }
2825
2826 }
2827 catch (Exception e)
2828 {
2829 World.ExcAdd += e.ToString() + "\r\n";
2830 }
2831
2832 }
2833 // System.Threading.Thread.Sleep(1);
2834 }
2835 uint min; int pos_interchange;
2836 int n = Gold.Count;
2837
2838 while (n > 0)
2839 {
2840 Character C2 = (Character)Gold[0];
2841 min = C2.Silvers + C2.WHSilvers;
2842 pos_interchange = 0;
2843 for (int i = 0; i < n; i++)
2844 {
2845 Character C = (Character)Gold[i];
2846 if (C.Silvers + C.WHSilvers < min)
2847 {
2848 min = C.Silvers + C.WHSilvers;
2849 pos_interchange = i;
2850 C2 = C;
2851 }
2852 }
2853 Gold[pos_interchange] = Gold[n - 1];
2854 Gold[n - 1] = C2;
2855 n--;
2856 }
2857 foreach (Character C in Gold)
2858 {
2859 World.GMChatAdd += C.Name + " has silvers amount: " + (C.Silvers + C.WHSilvers) + "\r\n";
2860 }
2861 Console.WriteLine("Finished checking gold on chars.");
2862 Program.Reseting = false;
2863 System.Threading.Thread.CurrentThread.Abort();
2864 }
2865 public static void LowerVote(object state)
2866 {
2867 Program.Reseting = true;
2868 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
2869 foreach (string Path in Paths)
2870 {
2871 if (Path.Remove(0, Path.Length - 4) == ".chr")
2872 {
2873 try
2874 {
2875 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2876 Character C;
2877 C = World.CharacterFromName2(Name);
2878 if (C == null)
2879 {
2880 string Account = "";
2881 C = LoadCharacter(Name, ref Account);
2882 if (C != null)
2883 {
2884 if (C.Voted)
2885 {
2886 C.Voted = false;
2887 SaveCharacter(C, Account);
2888 }
2889 }
2890 }
2891 else
2892 {
2893 if (C.Voted)
2894 C.Voted = false;
2895 }
2896 }
2897 catch (Exception e)
2898 {
2899 World.ExcAdd += e.ToString() + "\r\n";
2900 }
2901
2902 }
2903 // System.Threading.Thread.Sleep(1);
2904 }
2905 World.VotedIps = new List<string>();
2906 Program.Reseting = false;
2907 System.Threading.Thread.CurrentThread.Abort();
2908 }
2909 public static void RemoveAllNobility(object state)
2910 {
2911 Console.WriteLine("Reset nobility started!");
2912 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
2913 Program.Reseting = true;
2914 foreach (string Path in Paths)
2915 {
2916 if (Path.Remove(0, Path.Length - 4) == ".chr")
2917 {
2918 try
2919 {
2920 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2921 Character C;
2922 C = World.CharacterFromName2(Name);
2923 if (C == null)
2924 {
2925 string Account = "";
2926 C = LoadCharacter(Name, ref Account);
2927 if (C != null)
2928 {
2929 if (C.Nobility.Donation >= 1)
2930 {
2931 /* if (C.Nobility.Donation <= 150000000)
2932 if (C.Silvers + C.Nobility.Donation <= 2000000000)
2933
2934 C.Silvers += (uint)C.Nobility.Donation;
2935
2936 else World.DebugAdd += C.Name + " did not receive his nobility donation of : " + C.Nobility.Donation + "\r\n";
2937 else
2938 {
2939 if (C.Silvers + 150000000 <= 2000000000)
2940 C.Silvers += 150000000;
2941 else World.DebugAdd += C.Name + " did not receive his nobility donation of : " + 150000000 + "\r\n";
2942 }*/
2943
2944 C.Nobility.Donation = 0;
2945 C.Nobility.ListPlace = -1;
2946 SaveCharacter(C, Account);
2947 }
2948 }
2949 }
2950 else
2951 {
2952 /* if (C.Nobility.Donation <= 150000000)
2953 if (C.Silvers + C.Nobility.Donation <= 2000000000)
2954 C.Silvers += (uint)C.Nobility.Donation;
2955 else World.DebugAdd += C.Name + " did not receive his nobility donation of : " + C.Nobility.Donation + "\r\n";
2956 else
2957 {
2958 if (C.Silvers + 150000000 <= 2000000000)
2959 C.Silvers += 150000000;
2960 else World.DebugAdd += C.Name + " did not receive his nobility donation of : " + 150000000 + "\r\n";
2961 }*/
2962
2963 if (C.Nobility.Donation >= 1)
2964 {
2965 C.Nobility.Donation = 0;
2966 C.Nobility.ListPlace = -1;
2967 }
2968 }
2969 }
2970 catch (Exception e)
2971 {
2972 World.ExcAdd += e.ToString() + "\r\n";
2973 }
2974 }
2975 // System.Threading.Thread.Sleep(1);
2976 }
2977 Program.Reseting = false;
2978 World.EmpireBoard = new EmpireInfo[50];
2979 Console.WriteLine("Nobility reset finished");
2980 System.Threading.Thread.CurrentThread.Abort();
2981 }
2982 public static void Add7VIPDays(object state)
2983 {
2984
2985 Console.WriteLine("Vip Bonus 1 Days started");
2986 Program.Reseting = true;
2987 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
2988 foreach (string Path in Paths)
2989 {
2990 if (Path.Remove(0, Path.Length - 4) == ".chr")
2991 {
2992 try
2993 {
2994 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
2995 Character C;
2996 C = World.CharacterFromName2(Name);
2997 if (C == null)
2998 {
2999 string Account = "";
3000 C = LoadCharacter(Name, ref Account);
3001 bool ToSave = false;
3002 if (C != null)
3003 {
3004 if (C.VipLevel > 0 && C.VIPDays > 0)
3005 {
3006 C.VIPDays += 1;
3007 ToSave = true;
3008 }
3009 if (ToSave)
3010 SaveCharacter(C, Account);
3011 }
3012 }
3013 else
3014 {
3015 if (C.VipLevel > 0 && C.VIPDays > 0)
3016 {
3017 C.VIPDays += 1;
3018 }
3019 }
3020 }
3021 catch (Exception e)
3022 {
3023 World.ExcAdd += e.ToString() + "\r\n";
3024 }
3025
3026 }
3027 // System.Threading.Thread.Sleep(1);
3028 }
3029
3030 Console.WriteLine("Vip Bonus 1 Days ended");
3031 Program.Reseting = false;
3032 System.Threading.Thread.CurrentThread.Abort();
3033 }
3034 public static void KillAllMonsters(object state)
3035 {
3036 foreach (ConcurrentDictionary<uint, Mob> H in World.H_Mobs.Values)
3037 {
3038 foreach (Mob M in H.Values)
3039 if (M.Alive)
3040 {
3041 M.Died = DateTime.UtcNow;
3042 M.CurrentHP = 0;
3043 M.Alive = false;
3044 World.Action(M, Packets.Status(M.EntityID, Status.Effect, 2080).Get);
3045 M.DropAnItem(0, 0);
3046 }
3047 // System.Threading.Thread.Sleep(1);
3048 }
3049
3050 Database.LoadMobs(true);
3051 System.Threading.Thread.CurrentThread.Abort();
3052
3053 }
3054 public static void RemoveGarments(object state)
3055 {
3056 Console.WriteLine("Garment removal started!");
3057 Program.Reseting = true;
3058 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
3059 foreach (string Path in Paths)
3060 {
3061 if (Path.Remove(0, Path.Length - 4) == ".chr")
3062 {
3063 try
3064 {
3065 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
3066 Character C;
3067 C = World.CharacterFromName2(Name);
3068 if (C == null)
3069 {
3070 string Account = "";
3071 C = LoadCharacter(Name, ref Account);
3072 // bool ToSave = false;
3073 if (C != null)
3074 {
3075 Item I = new Item();
3076 I = C.Equips.Get(9);
3077 if (I.ID != 0 && !Item.EquipPassSexReq(I, C))
3078 {
3079 C.Equips.Garment = new Item();
3080 SaveCharacter(C, Account);
3081
3082 World.InfoAdd += C.Name + " got his garment : " + I.ID + " removed!\r\n";
3083 }
3084 }
3085 }
3086 else
3087 {
3088 Item I = new Item();
3089 I = C.Equips.Get(9);
3090 if (I.ID != 0 && !Item.EquipPassSexReq(I, C))
3091 {
3092 C.EquipStats(9, false, false);
3093 World.Spawn(C, false);
3094 C.MyClient.AddSend(Packets.ItemPacket(I.UID, 9, 6));
3095 C.Equips.Garment = new Item();
3096 World.InfoAdd += C.Name + " got his garment : " + I.ID + " removed!\r\n";
3097 }
3098 }
3099 }
3100 catch (Exception e)
3101 {
3102 World.ExcAdd += e.ToString() + "\r\n";
3103 }
3104
3105 }
3106 // System.Threading.Thread.Sleep(1);
3107 }
3108
3109 Console.WriteLine("Garment removal ended");
3110 Program.Reseting = false;
3111 System.Threading.Thread.CurrentThread.Abort();
3112 }
3113 public static void LowerVIPMuteBotVote(object state)
3114 {
3115 Program.Reseting = true;
3116 string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
3117 foreach (string Path in Paths)
3118 {
3119 if (Path.Remove(0, Path.Length - 4) == ".chr")
3120 {
3121 try
3122 {
3123 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
3124 Character C;
3125 C = World.CharacterFromName2(Name);
3126 if (C == null)
3127 {
3128 string Account = "";
3129 C = LoadCharacter(Name, ref Account);
3130 bool ToSave = false;
3131 if (C != null)
3132 {
3133 if ((C.Top >= 3 && C.Top <= 7) || (DateTime.UtcNow.DayOfWeek == DayOfWeek.Friday && (C.Top == 9 || C.Top == 1 || C.Top == 2)))
3134 {
3135 C.Top = 0;
3136 ToSave = true;
3137 }
3138
3139 /* if (DateTime.UtcNow.Day == 1)
3140 if (C.Nobility.Donation >= 1)
3141 {
3142
3143 C.Nobility.Donation = 0;
3144 C.Nobility.ListPlace = -1;
3145 ToSave = true;
3146 }*/
3147 if (C.MutedDays > 0 || C.Muted)
3148 {
3149 if (C.MutedDays > 0)
3150 C.MutedDays--;
3151 if (C.MutedDays <= 0)
3152 {
3153 //C.Muted = false;
3154 C.MutedDays = 0;
3155 }
3156 ToSave = true;
3157 }
3158 if (C.BOTJailedDays > 0 || C.BOTJailed)
3159 {
3160 if (C.BOTJailedDays > 0)
3161 C.BOTJailedDays--;
3162 if (C.BOTJailedDays <= 0)
3163 {
3164 //C.BOTJailed = false;
3165 C.BOTJailedDays = 0;
3166 }
3167 ToSave = true;
3168 }
3169 if (C.Voted)
3170 {
3171 C.Voted = false;
3172 ToSave = true;
3173 }
3174 if (!World.BanChars.Contains(C.Name))
3175 {
3176 if (C.PKPoints >= 100)
3177 if (!World.TopPK.Contains(C))
3178 World.TopPK.Add(C);
3179 if (C.OnlineTime >= 50)
3180 if (!World.TopOnline.Contains(C))
3181 World.TopOnline.Add(C);
3182 if (C.Level >= 90 || C.Potency >= 190)
3183 {
3184 if (C.Job >= 10 && C.Job <= 15)
3185 World.TopTrojan.Add(C);
3186 else if (C.Job >= 20 && C.Job <= 25)
3187 World.TopWarrior.Add(C);
3188 else if (C.Job >= 40 && C.Job <= 45)
3189 World.TopArcher.Add(C);
3190 else if (C.Job >= 132 && C.Job <= 135)
3191 World.TopWaterTao.Add(C);
3192 else if (C.Job >= 142 && C.Job <= 145)
3193 World.TopFireTao.Add(C);
3194 }
3195 if (C.Silvers + C.WHSilvers >= 1000000)
3196 {
3197 World.TopGold.Add(C);
3198 }
3199 if (C.VP > 50000)
3200 {
3201 World.TopVPS.Add(C);
3202 }
3203 }
3204 if (ToSave)
3205 SaveCharacter(C, Account);
3206 }
3207 }
3208 else
3209 {
3210 if (DateTime.UtcNow.DayOfWeek == DayOfWeek.Friday)
3211 C.Top = 0;
3212
3213 /* if (DateTime.UtcNow.Day == 1)
3214 if (C.Nobility.Donation >= 1)
3215 {
3216 C.Nobility.Donation = 0;
3217 C.Nobility.ListPlace = -1;
3218 }*/
3219 if (C.MutedDays > 0 || C.Muted)
3220 {
3221 if (C.MutedDays > 0)
3222 C.MutedDays--;
3223 if (C.MutedDays <= 0)
3224 {
3225 C.MutedDays = 0;
3226 //C.Muted = false;
3227 C.MyClient.LocalMessage(2011, "You are free to talk now but don't insult others!!!");
3228 }
3229 }
3230 if (C.BOTJailedDays > 0)
3231 {
3232 if (C.BOTJailedDays > 0)
3233 C.BOTJailedDays--;
3234 if (C.BOTJailedDays <= 0)
3235 {
3236 C.BOTJailedDays = 0;
3237 //C.BOTJailed = false;
3238 C.MyClient.LocalMessage(2011, "You are free now but don't use a bot ever again!!!");
3239 }
3240 }
3241
3242 if (C.Voted)
3243 C.Voted = false;
3244 if (!World.BanChars.Contains(C.Name) && C.MyClient.AuthInfo.Status != "[PM]")
3245 {
3246 if (C.PKPoints >= 100)
3247 if (!World.TopPK.Contains(C))
3248 World.TopPK.Add(C);
3249 if (C.OnlineTime >= 50)
3250 if (!World.TopOnline.Contains(C))
3251 World.TopOnline.Add(C);
3252 if (C.Level >= 90 || C.Potency >= 190)
3253 {
3254 if (C.Job >= 10 && C.Job <= 15)
3255 World.TopTrojan.Add(C);
3256 else if (C.Job >= 20 && C.Job <= 25)
3257 World.TopWarrior.Add(C);
3258 else if (C.Job >= 40 && C.Job <= 45)
3259 World.TopArcher.Add(C);
3260 else if (C.Job >= 132 && C.Job <= 135)
3261 World.TopWaterTao.Add(C);
3262 else if (C.Job >= 142 && C.Job <= 145)
3263 World.TopFireTao.Add(C);
3264 }
3265 if (C.Silvers + C.WHSilvers >= 1000000)
3266 {
3267 World.TopGold.Add(C);
3268 }
3269 if (C.VP > 50000)
3270 {
3271 World.TopVPS.Add(C);
3272 }
3273 }
3274 }
3275 }
3276 catch (Exception e)
3277 {
3278 World.ExcAdd += e.ToString() + "\r\n";
3279 }
3280
3281 }
3282 // System.Threading.Thread.Sleep(1);
3283 }
3284 // if (DateTime.UtcNow.Day == 1)
3285 // World.EmpireBoard = new EmpireInfo[50];
3286 World.VotedIps = new List<string>();
3287 SortTops();
3288 Program.Reseting = false;
3289 System.Threading.Thread.CurrentThread.Abort();
3290 }
3291 static void SortTops()
3292 {
3293 int n = World.TopVPS.Count;
3294 int pos_interchange;
3295 ulong min;// = ((Character)World.TopVPS[0]).VP;
3296 while (n > 0)
3297 {
3298 Character C2 = (Character)World.TopVPS[0];
3299 min = C2.VP;
3300 pos_interchange = 0;
3301 for (int i = 0; i < n; i++)
3302 {
3303 Character C = (Character)World.TopVPS[i];
3304 if (C.VP < min)
3305 {
3306 min = C.VP;
3307 pos_interchange = i;
3308 C2 = C;
3309 }
3310 }
3311 World.TopVPS[pos_interchange] = World.TopVPS[n - 1];
3312 World.TopVPS[n - 1] = C2;
3313 n--;
3314 }
3315
3316 n = World.TopGold.Count;
3317 // pos_interchange = 0;
3318
3319 while (n > 0)
3320 {
3321 Character C2 = (Character)World.TopGold[0];
3322 min = C2.Silvers + C2.WHSilvers;
3323 pos_interchange = 0;
3324 for (int i = 0; i < n; i++)
3325 {
3326 Character C = (Character)World.TopGold[i];
3327 if (C.Silvers + C.WHSilvers < min)
3328 {
3329 min = C.Silvers + C.WHSilvers;
3330 pos_interchange = i;
3331 C2 = C;
3332 }
3333 }
3334 World.TopGold[pos_interchange] = World.TopGold[n - 1];
3335 World.TopGold[n - 1] = C2;
3336 n--;
3337 }
3338
3339 n = World.TopArcher.Count;
3340 // pos_interchange = 0;
3341
3342 while (n > 0)
3343 {
3344 Character C2 = (Character)World.TopArcher[0];
3345 min = C2.Potency;
3346 pos_interchange = 0;
3347 for (int i = 0; i < n; i++)
3348 {
3349 Character C = (Character)World.TopArcher[i];
3350 if (C.Potency < min)
3351 {
3352 min = C.Potency;
3353 pos_interchange = i;
3354 C2 = C;
3355 }
3356 }
3357 World.TopArcher[pos_interchange] = World.TopArcher[n - 1];
3358 World.TopArcher[n - 1] = C2;
3359 n--;
3360 }
3361
3362 n = World.TopFireTao.Count;
3363 // pos_interchange = 0;
3364
3365 while (n > 0)
3366 {
3367 Character C2 = (Character)World.TopFireTao[0];
3368 min = C2.Potency;
3369 pos_interchange = 0;
3370 for (int i = 0; i < n; i++)
3371 {
3372 Character C = (Character)World.TopFireTao[i];
3373 if (C.Potency < min)
3374 {
3375 min = C.Potency;
3376 pos_interchange = i;
3377 C2 = C;
3378 }
3379 }
3380 World.TopFireTao[pos_interchange] = World.TopFireTao[n - 1];
3381 World.TopFireTao[n - 1] = C2;
3382 n--;
3383 }
3384
3385 n = World.TopTrojan.Count;
3386 // pos_interchange = 0;
3387
3388 while (n > 0)
3389 {
3390 Character C2 = (Character)World.TopTrojan[0];
3391 min = C2.Potency;
3392 pos_interchange = 0;
3393 for (int i = 0; i < n; i++)
3394 {
3395 Character C = (Character)World.TopTrojan[i];
3396 if (C.Potency < min)
3397 {
3398 min = C.Potency;
3399 pos_interchange = i;
3400 C2 = C;
3401 }
3402 }
3403 World.TopTrojan[pos_interchange] = World.TopTrojan[n - 1];
3404 World.TopTrojan[n - 1] = C2;
3405 n--;
3406 }
3407
3408 n = World.TopWarrior.Count;
3409 // pos_interchange = 0;
3410
3411 while (n > 0)
3412 {
3413 Character C2 = (Character)World.TopWarrior[0];
3414 min = C2.Potency;
3415 pos_interchange = 0;
3416 for (int i = 0; i < n; i++)
3417 {
3418 Character C = (Character)World.TopWarrior[i];
3419 if (C.Potency < min)
3420 {
3421 min = C.Potency;
3422 pos_interchange = i;
3423 C2 = C;
3424 }
3425 }
3426 World.TopWarrior[pos_interchange] = World.TopWarrior[n - 1];
3427 World.TopWarrior[n - 1] = C2;
3428 n--;
3429 }
3430
3431 n = World.TopWaterTao.Count;
3432 //pos_interchange = 0;
3433
3434 while (n > 0)
3435 {
3436 Character C2 = (Character)World.TopWaterTao[0];
3437 min = C2.Potency;
3438 pos_interchange = 0;
3439 for (int i = 0; i < n; i++)
3440 {
3441 Character C = (Character)World.TopWaterTao[i];
3442 if (C.Potency < min)
3443 {
3444 min = C.Potency;
3445 pos_interchange = i;
3446 C2 = C;
3447 }
3448 }
3449 World.TopWaterTao[pos_interchange] = World.TopWaterTao[n - 1];
3450 World.TopWaterTao[n - 1] = C2;
3451 n--;
3452 }
3453
3454 n = World.TopPK.Count;
3455 // pos_interchange = 0;
3456
3457 while (n > 0)
3458 {
3459 Character C2 = (Character)World.TopPK[0];
3460 min = C2.PKPoints;
3461 pos_interchange = 0;
3462 for (int i = 0; i < n; i++)
3463 {
3464 Character C = (Character)World.TopPK[i];
3465 if (C.PKPoints < min)
3466 {
3467 min = C.PKPoints;
3468 pos_interchange = i;
3469 C2 = C;
3470 }
3471 }
3472 World.TopPK[pos_interchange] = World.TopPK[n - 1];
3473 World.TopPK[n - 1] = C2;
3474 n--;
3475 }
3476 n = World.TopOnline.Count;
3477 // pos_interchange = 0;
3478
3479 while (n > 0)
3480 {
3481 Character C2 = (Character)World.TopOnline[0];
3482 min = C2.OnlineTime;
3483 pos_interchange = 0;
3484 for (int i = 0; i < n; i++)
3485 {
3486 Character C = (Character)World.TopOnline[i];
3487 if (C.OnlineTime < min)
3488 {
3489 min = C.OnlineTime;
3490 pos_interchange = i;
3491 C2 = C;
3492 }
3493 }
3494 World.TopOnline[pos_interchange] = World.TopOnline[n - 1];
3495 World.TopOnline[n - 1] = C2;
3496 n--;
3497 }
3498 try
3499 {
3500 string Path = "";
3501 if (!World.LowRatedServer)
3502 Path = @"C:\inetpub\www\leaderboard\TopKO.ini";
3503 else Path = @"C:\inetpub\www\leaderboard\TopKONewServ.ini";
3504 if (!System.IO.File.Exists(Path))
3505 System.IO.File.Create(Path).Close();
3506 else
3507 {
3508 System.IO.File.Delete(Path);
3509 System.IO.File.Create(Path).Close();
3510 }
3511 string Text = "";
3512 int i = 1;
3513
3514 List<string> Names = new List<string>();
3515 foreach (KOInfo KO in World.KOBoard)
3516 {
3517 if (!Names.Contains(KO.Name))
3518 {
3519 Names.Add(KO.Name);
3520 string PreText = i + ". " + KO.Name;
3521 if (PreText.Length <= 7)
3522 Text += PreText + " " + KO.KillCount.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3523 else if (PreText.Length <= 15) Text += PreText + " " + KO.KillCount.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3524 else Text += PreText + " " + KO.KillCount.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3525 i++;
3526 }
3527 }
3528
3529
3530 System.IO.File.WriteAllText(Path, Text);
3531 }
3532 catch { World.ExcAdd += "TopKO.ini was not written correctly!\r\n"; }
3533
3534 try
3535 {
3536 string Path = "";
3537 if (!World.LowRatedServer)
3538 Path = @"C:\inetpub\www\leaderboard\TopVPS.ini";
3539 else Path = @"C:\inetpub\www\leaderboard\TopVPSNewServ.ini";
3540 if (!System.IO.File.Exists(Path))
3541 System.IO.File.Create(Path).Close();
3542 else
3543 {
3544 System.IO.File.Delete(Path);
3545 System.IO.File.Create(Path).Close();
3546 }
3547 string Text = "";
3548 int i = 1;
3549 foreach (Character C in World.TopVPS)
3550 {
3551 if (i > 500)
3552 break;
3553 string PreText = i + ". " + C.Name;
3554 if (PreText.Length <= 7)
3555 Text += PreText + " " + C.VP.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3556 else if (PreText.Length <= 15) Text += PreText + " " + C.VP.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3557 else Text += PreText + " " + C.VP.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3558 i++;
3559 }
3560 World.TopVPS = new List<Character>();
3561 System.IO.File.WriteAllText(Path, Text);
3562 }
3563 catch { World.ExcAdd += "TopVPS.ini was not written correctly!\r\n"; }
3564 try
3565 {
3566 string Path = "";
3567 if (!World.LowRatedServer)
3568 Path = @"C:\inetpub\www\leaderboard\TopGold.ini";
3569 else Path = @"C:\inetpub\www\leaderboard\TopGoldNewServ.ini";
3570 if (!System.IO.File.Exists(Path))
3571 System.IO.File.Create(Path).Close();
3572 else
3573 {
3574 System.IO.File.Delete(Path);
3575 System.IO.File.Create(Path).Close();
3576 }
3577 string Text = "";
3578 int i = 1;
3579 foreach (Character C in World.TopGold)
3580 {
3581 if (i > 500)
3582 break;
3583 string PreText = i + ". " + C.Name;
3584 if (PreText.Length <= 7)
3585 Text += PreText + " " + ((C.Silvers + C.WHSilvers).ToString("#,#", System.Globalization.CultureInfo.InvariantCulture)) + "\r\n";
3586 else if (PreText.Length <= 15) Text += PreText + " " + ((C.Silvers + C.WHSilvers).ToString("#,#", System.Globalization.CultureInfo.InvariantCulture)) + "\r\n";
3587 else Text += PreText + " " + ((C.Silvers + C.WHSilvers).ToString("#,#", System.Globalization.CultureInfo.InvariantCulture)) + "\r\n";
3588 i++;
3589 }
3590 World.TopGold = new List<Character>();
3591 System.IO.File.WriteAllText(Path, Text);
3592 }
3593 catch { World.ExcAdd += "TopGold.ini was not written correctly!\r\n"; }
3594 try
3595 {
3596 string Path = "";
3597 if (!World.LowRatedServer)
3598 Path = @"C:\inetpub\www\leaderboard\TopPK.ini";
3599 else Path = @"C:\inetpub\www\leaderboard\TopPKNewServ.ini";
3600 if (!System.IO.File.Exists(Path))
3601 System.IO.File.Create(Path).Close();
3602 else
3603 {
3604 System.IO.File.Delete(Path);
3605 System.IO.File.Create(Path).Close();
3606 }
3607 string Text = "";
3608 int i = 1;
3609 foreach (Character C in World.TopPK)
3610 {
3611 if (i > 500)
3612 break;
3613 string PreText = i + ". " + C.Name;
3614 if (PreText.Length <= 7)
3615 Text += PreText + " " + C.PKPoints.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3616 else if (PreText.Length <= 15) Text += PreText + " " + C.PKPoints.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3617 else Text += PreText + " " + C.PKPoints.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3618 i++;
3619 }
3620 World.TopPK = new List<Character>();
3621 System.IO.File.WriteAllText(Path, Text);
3622 }
3623 catch { World.ExcAdd += "TopPK.ini was not written correctly!\r\n"; }
3624 try
3625 {
3626 string Path = "";
3627 if (!World.LowRatedServer)
3628 Path = @"C:\inetpub\www\leaderboard\TopOnline.ini";
3629 else Path = @"C:\inetpub\www\leaderboard\TopOnline.ini";
3630 if (!System.IO.File.Exists(Path))
3631 System.IO.File.Create(Path).Close();
3632 else
3633 {
3634 System.IO.File.Delete(Path);
3635 System.IO.File.Create(Path).Close();
3636 }
3637 string Text = "";
3638 int i = 1;
3639 foreach (Character C in World.TopOnline)
3640 {
3641 if (i > 500)
3642 break;
3643 string PreText = i + ". " + C.Name;
3644 if (PreText.Length <= 7)
3645 Text += PreText + " " + C.OnlineTime.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3646 else if (PreText.Length <= 15) Text += PreText + " " + C.OnlineTime.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3647 else Text += PreText + " " + C.OnlineTime.ToString("#,#", System.Globalization.CultureInfo.InvariantCulture) + "\r\n";
3648 i++;
3649 }
3650 World.TopOnline = new List<Character>();
3651 System.IO.File.WriteAllText(Path, Text);
3652 }
3653 catch { World.ExcAdd += "TopOnline.ini was not written correctly!\r\n"; }
3654 try
3655 {
3656 string Path = "";
3657 if (!World.LowRatedServer)
3658 Path = @"C:\inetpub\www\leaderboard\TopArch.ini";
3659 else Path = @"C:\inetpub\www\leaderboard\TopArchNewServ.ini";
3660 if (!System.IO.File.Exists(Path))
3661 System.IO.File.Create(Path).Close();
3662 else
3663 {
3664 System.IO.File.Delete(Path);
3665 System.IO.File.Create(Path).Close();
3666 }
3667 string Text = "";
3668 int i = 1;
3669 foreach (Character C in World.TopArcher)
3670 {
3671 try
3672 {
3673 if (i == 1)
3674 {
3675 if (C != null)
3676 {
3677 if (C.MyClient == null)
3678 {
3679 string acc = "";
3680 Character CC = LoadCharacter(C.Name, ref acc);
3681 if (CC != null)
3682 {
3683 CC.Top = 4;
3684 Database.SaveCharacter(CC, acc);
3685 }
3686
3687 }
3688 else
3689 {
3690 C.Top = 4;
3691 }
3692 }
3693 }
3694 }
3695 catch { }
3696 string PreText = i + ". " + C.Name;
3697 string Nobility;
3698 if (C.Nobility.Rank == Ranks.Duke)
3699 if (C.Body == 1003 || C.Body == 1004)
3700 Nobility = "Duke";
3701 else
3702 Nobility = "Duchess";
3703 else if (C.Nobility.Rank == Ranks.Prince)
3704 if (C.Body == 1003 || C.Body == 1004)
3705 Nobility = "Prince";
3706 else
3707 Nobility = "Princess";
3708 else if (C.Nobility.Rank == Ranks.King)
3709 if (C.Body == 1003 || C.Body == 1004)
3710 Nobility = "King";
3711 else
3712 Nobility = "Queen";
3713 else if (C.Nobility.Rank == Ranks.Knight)
3714 Nobility = "Knight";
3715 else if (C.Nobility.Rank == Ranks.Baron)
3716 if (C.Body == 1003 || C.Body == 1004)
3717 Nobility = "Baron";
3718 else
3719 Nobility = "Baroness";
3720 else if (C.Nobility.Rank == Ranks.Earl)
3721 if (C.Body == 1003 || C.Body == 1004)
3722 Nobility = "Earl";
3723 else
3724 Nobility = "Countess";
3725 else
3726 Nobility = "Serf";
3727
3728 if (PreText.Length <= 7)
3729 Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3730 else if (PreText.Length <= 15) Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3731 else Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3732 i++;
3733 }
3734 System.IO.File.WriteAllText(Path, Text);
3735 }
3736 catch { World.ExcAdd += "TopArch.ini was not written correctly!\r\n"; }
3737 try
3738 {
3739 string Path = "";
3740 if (!World.LowRatedServer)
3741 Path = @"C:\inetpub\www\leaderboard\TopTro.ini";
3742 else Path = @"C:\inetpub\www\leaderboard\TopTroNewServ.ini";
3743 if (!System.IO.File.Exists(Path))
3744 System.IO.File.Create(Path).Close();
3745 else
3746 {
3747 System.IO.File.Delete(Path);
3748 System.IO.File.Create(Path).Close();
3749 }
3750 string Text = "";
3751 int i = 1;
3752 foreach (Character C in World.TopTrojan)
3753 {
3754 try
3755 {
3756 if (i == 1)
3757 {
3758 // Console.WriteLine(C.Name);
3759 if (C != null)
3760 {
3761 if (C.MyClient == null)
3762 {
3763 string acc = "";
3764 Character CC = LoadCharacter(C.Name, ref acc);
3765 if (CC != null)
3766 {
3767 CC.Top = 3;
3768 Database.SaveCharacter(CC, acc);
3769 }
3770
3771 }
3772 else
3773 {
3774 C.Top = 3;
3775 }
3776 }
3777 }
3778
3779 }
3780 catch { }
3781 string PreText = i + ". " + C.Name;
3782 string Nobility;
3783 if (C.Nobility.Rank == Ranks.Duke)
3784 if (C.Body == 1003 || C.Body == 1004)
3785 Nobility = "Duke";
3786 else
3787 Nobility = "Duchess";
3788 else if (C.Nobility.Rank == Ranks.Prince)
3789 if (C.Body == 1003 || C.Body == 1004)
3790 Nobility = "Prince";
3791 else
3792 Nobility = "Princess";
3793 else if (C.Nobility.Rank == Ranks.King)
3794 if (C.Body == 1003 || C.Body == 1004)
3795 Nobility = "King";
3796 else
3797 Nobility = "Queen";
3798 else if (C.Nobility.Rank == Ranks.Knight)
3799 Nobility = "Knight";
3800 else if (C.Nobility.Rank == Ranks.Baron)
3801 if (C.Body == 1003 || C.Body == 1004)
3802 Nobility = "Baron";
3803 else
3804 Nobility = "Baroness";
3805 else if (C.Nobility.Rank == Ranks.Earl)
3806 if (C.Body == 1003 || C.Body == 1004)
3807 Nobility = "Earl";
3808 else
3809 Nobility = "Countess";
3810 else
3811 Nobility = "Serf";
3812
3813 if (PreText.Length <= 7)
3814 Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3815 else if (PreText.Length <= 15) Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3816 else Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3817 i++;
3818 }
3819 System.IO.File.WriteAllText(Path, Text);
3820 }
3821 catch { World.ExcAdd += "TopTro.ini was not written correctly!\r\n"; }
3822 try
3823 {
3824 string Path = "";
3825 if (!World.LowRatedServer)
3826 Path = @"C:\inetpub\www\leaderboard\TopWar.ini";
3827 else Path = @"C:\inetpub\www\leaderboard\TopWarNewServ.ini";
3828 if (!System.IO.File.Exists(Path))
3829 System.IO.File.Create(Path).Close();
3830 else
3831 {
3832 System.IO.File.Delete(Path);
3833 System.IO.File.Create(Path).Close();
3834 }
3835 string Text = "";
3836 int i = 1;
3837 foreach (Character C in World.TopWarrior)
3838 {
3839 try
3840 {
3841 if (i == 1)
3842 {
3843 //Console.WriteLine(C.Name);
3844 if (C != null)
3845 {
3846 if (C.MyClient == null)
3847 {
3848 string acc = "";
3849 Character CC = LoadCharacter(C.Name, ref acc);
3850 if (CC != null)
3851 {
3852 CC.Top = 5;
3853 Database.SaveCharacter(CC, acc);
3854 }
3855
3856 }
3857 else
3858 {
3859 C.Top = 5;
3860 }
3861 }
3862 }
3863 }
3864 catch { }
3865 string PreText = i + ". " + C.Name;
3866 string Nobility;
3867 if (C.Nobility.Rank == Ranks.Duke)
3868 if (C.Body == 1003 || C.Body == 1004)
3869 Nobility = "Duke";
3870 else
3871 Nobility = "Duchess";
3872 else if (C.Nobility.Rank == Ranks.Prince)
3873 if (C.Body == 1003 || C.Body == 1004)
3874 Nobility = "Prince";
3875 else
3876 Nobility = "Princess";
3877 else if (C.Nobility.Rank == Ranks.King)
3878 if (C.Body == 1003 || C.Body == 1004)
3879 Nobility = "King";
3880 else
3881 Nobility = "Queen";
3882 else if (C.Nobility.Rank == Ranks.Knight)
3883 Nobility = "Knight";
3884 else if (C.Nobility.Rank == Ranks.Baron)
3885 if (C.Body == 1003 || C.Body == 1004)
3886 Nobility = "Baron";
3887 else
3888 Nobility = "Baroness";
3889 else if (C.Nobility.Rank == Ranks.Earl)
3890 if (C.Body == 1003 || C.Body == 1004)
3891 Nobility = "Earl";
3892 else
3893 Nobility = "Countess";
3894 else
3895 Nobility = "Serf";
3896
3897 if (PreText.Length <= 7)
3898 Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3899 else if (PreText.Length <= 15) Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3900 else Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3901 i++;
3902 }
3903 System.IO.File.WriteAllText(Path, Text);
3904 }
3905 catch { World.ExcAdd += "TopWar.ini was not written correctly!\r\n"; }
3906 try
3907 {
3908 string Path = "";
3909 if (!World.LowRatedServer)
3910 Path = @"C:\inetpub\www\leaderboard\TopWater.ini";
3911 else Path = @"C:\inetpub\www\leaderboard\TopWaterNewServ.ini";
3912 if (!System.IO.File.Exists(Path))
3913 System.IO.File.Create(Path).Close();
3914 else
3915 {
3916 System.IO.File.Delete(Path);
3917 System.IO.File.Create(Path).Close();
3918 }
3919 string Text = "";
3920 int i = 1;
3921 foreach (Character C in World.TopWaterTao)
3922 {
3923 try
3924 {
3925 if (i == 1)
3926 {
3927 // Console.WriteLine(C.Name);
3928 if (C != null)
3929 {
3930 if (C.MyClient == null)
3931 {
3932 string acc = "";
3933 Character CC = LoadCharacter(C.Name, ref acc);
3934 if (CC != null)
3935 {
3936 CC.Top = 7;
3937 Database.SaveCharacter(CC, acc);
3938 }
3939
3940 }
3941 else
3942 {
3943 C.Top = 7;
3944 }
3945 }
3946 }
3947 }
3948 catch { }
3949 string PreText = i + ". " + C.Name;
3950 string Nobility;
3951 if (C.Nobility.Rank == Ranks.Duke)
3952 if (C.Body == 1003 || C.Body == 1004)
3953 Nobility = "Duke";
3954 else
3955 Nobility = "Duchess";
3956 else if (C.Nobility.Rank == Ranks.Prince)
3957 if (C.Body == 1003 || C.Body == 1004)
3958 Nobility = "Prince";
3959 else
3960 Nobility = "Princess";
3961 else if (C.Nobility.Rank == Ranks.King)
3962 if (C.Body == 1003 || C.Body == 1004)
3963 Nobility = "King";
3964 else
3965 Nobility = "Queen";
3966 else if (C.Nobility.Rank == Ranks.Knight)
3967 Nobility = "Knight";
3968 else if (C.Nobility.Rank == Ranks.Baron)
3969 if (C.Body == 1003 || C.Body == 1004)
3970 Nobility = "Baron";
3971 else
3972 Nobility = "Baroness";
3973 else if (C.Nobility.Rank == Ranks.Earl)
3974 if (C.Body == 1003 || C.Body == 1004)
3975 Nobility = "Earl";
3976 else
3977 Nobility = "Countess";
3978 else
3979 Nobility = "Serf";
3980
3981 if (PreText.Length <= 7)
3982 Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3983 else if (PreText.Length <= 15) Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3984 else Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
3985 i++;
3986 }
3987 System.IO.File.WriteAllText(Path, Text);
3988 }
3989 catch { World.ExcAdd += "TopWater.ini was not written correctly!\r\n"; }
3990 try
3991 {
3992 string Path = "";
3993 if (!World.LowRatedServer)
3994 Path = @"C:\inetpub\www\leaderboard\TopFire.ini";
3995 else Path = @"C:\inetpub\www\leaderboard\TopFireNewServ.ini";
3996 if (!System.IO.File.Exists(Path))
3997 System.IO.File.Create(Path).Close();
3998 else
3999 {
4000 System.IO.File.Delete(Path);
4001 System.IO.File.Create(Path).Close();
4002 }
4003 string Text = "";
4004 int i = 1;
4005 foreach (Character C in World.TopFireTao)
4006 {
4007 try
4008 {
4009 if (i == 1)
4010 {
4011 Console.WriteLine(C.Name);
4012 if (C != null)
4013 {
4014 if (C.MyClient == null)
4015 {
4016 string acc = "";
4017 Character CC = LoadCharacter(C.Name, ref acc);
4018 if (CC != null)
4019 {
4020 CC.Top = 6;
4021 Database.SaveCharacter(CC, acc);
4022 }
4023
4024 }
4025 else
4026 {
4027 C.Top = 6;
4028 }
4029 }
4030 }
4031 }
4032 catch { }
4033
4034 string PreText = i + ". " + C.Name;
4035 string Nobility;
4036 if (C.Nobility.Rank == Ranks.Duke)
4037 if (C.Body == 1003 || C.Body == 1004)
4038 Nobility = "Duke";
4039 else
4040 Nobility = "Duchess";
4041 else if (C.Nobility.Rank == Ranks.Prince)
4042 if (C.Body == 1003 || C.Body == 1004)
4043 Nobility = "Prince";
4044 else
4045 Nobility = "Princess";
4046 else if (C.Nobility.Rank == Ranks.King)
4047 if (C.Body == 1003 || C.Body == 1004)
4048 Nobility = "King";
4049 else
4050 Nobility = "Queen";
4051 else if (C.Nobility.Rank == Ranks.Knight)
4052 Nobility = "Knight";
4053 else if (C.Nobility.Rank == Ranks.Baron)
4054 if (C.Body == 1003 || C.Body == 1004)
4055 Nobility = "Baron";
4056 else
4057 Nobility = "Baroness";
4058 else if (C.Nobility.Rank == Ranks.Earl)
4059 if (C.Body == 1003 || C.Body == 1004)
4060 Nobility = "Earl";
4061 else
4062 Nobility = "Countess";
4063 else
4064 Nobility = "Serf";
4065
4066 if (PreText.Length <= 7)
4067 Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
4068 else if (PreText.Length <= 15) Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
4069 else Text += PreText + " " + C.Level + " " + C.Potency + " " + Nobility + "\r\n";
4070 i++;
4071 }
4072
4073 File.WriteAllText(Path, Text);
4074 }
4075 catch { World.ExcAdd += "TopFire.ini was not written correctly!\r\n"; }
4076 try
4077 {
4078 string Top5 = "";
4079
4080 Character C = (Character)World.TopArcher[0];
4081 Top5 += "Archer " + C.Name + " " + C.Level + " " + C.Potency + " " + C.Nobility.Rank + "\r\n";
4082 C = (Character)World.TopTrojan[0];
4083 Top5 += "Trojan " + C.Name + " " + C.Level + " " + C.Potency + " " + C.Nobility.Rank + "\r\n";
4084 C = (Character)World.TopWarrior[0];
4085 Top5 += "Warrior " + C.Name + " " + C.Level + " " + C.Potency + " " + C.Nobility.Rank + "\r\n";
4086 C = (Character)World.TopWaterTao[0];
4087 Top5 += "WaterTao " + C.Name + " " + C.Level + " " + C.Potency + " " + C.Nobility.Rank + "\r\n";
4088 C = (Character)World.TopFireTao[0];
4089 Top5 += "FireTao " + C.Name + " " + C.Level + " " + C.Potency + " " + C.Nobility.Rank;
4090 string Path = "";
4091 if (!World.LowRatedServer)
4092 Path = @"C:\inetpub\www\leaderboard\Top5.ini";
4093 else Path = @"C:\inetpub\www\leaderboard\Top5NewServ.ini";
4094 if (!System.IO.File.Exists(Path))
4095 System.IO.File.Create(Path).Close();
4096 else
4097 {
4098 System.IO.File.Delete(Path);
4099 System.IO.File.Create(Path).Close();
4100 }
4101 System.IO.File.WriteAllText(Path, Top5);
4102 World.TopArcher = new List<Character>();
4103 World.TopFireTao = new List<Character>();
4104 World.TopWarrior = new List<Character>();
4105 World.TopWaterTao = new List<Character>();
4106 World.TopTrojan = new List<Character>();
4107 }
4108 catch
4109 {
4110 World.TopArcher = new List<Character>();
4111 World.TopFireTao = new List<Character>();
4112 World.TopWarrior = new List<Character>();
4113 World.TopWaterTao = new List<Character>();
4114 World.TopTrojan = new List<Character>();
4115 World.ExcAdd += "Top5.ini was not written correctly!\r\n";
4116 }
4117 }
4118 public static Character LoadCharacterWithLogs(string Name, ref string Account, bool GenNewID = true, bool Load = false)
4119 {
4120 try
4121 {
4122
4123 if (File.Exists(World.GlobalCharactersPath + Name + ".chr"))
4124 {
4125 Character C = new Character();
4126 byte[] buffer = File.ReadAllBytes(World.GlobalCharactersPath + Name + ".chr");
4127 MemoryStream ms = new MemoryStream(buffer);
4128 BinaryReader BR = new BinaryReader(ms);
4129
4130 C.Name = Name;
4131 World.GMChatAdd += C.Name + " information:\r\n";
4132 Account = BR.ReadString();
4133 World.GMChatAdd += "Account : " + Account + "\r\n";
4134 C.EntityID = BR.ReadUInt32();
4135 C.Avatar = BR.ReadUInt16();
4136 C.Body = BR.ReadUInt16();
4137 C.Hair = BR.ReadUInt16();
4138
4139 C.Loc = new Location();
4140 C.Loc.Map = BR.ReadUInt32();//here
4141 C.Loc.X = BR.ReadUInt16();
4142 C.Loc.Y = BR.ReadUInt16();
4143 C.Loc.PreviousMap = BR.ReadUInt32();//here
4144
4145 C.Job = BR.ReadByte();
4146 World.GMChatAdd += "Job : " + C.Job + "\r\n";
4147 C.PreviousJob1 = BR.ReadByte();
4148 World.GMChatAdd += "PreviousJob : " + C.PreviousJob1 + "\r\n";
4149 C.Level = BR.ReadByte();
4150 World.GMChatAdd += "Level : " + C.Level + "\r\n";
4151 C.Experience = BR.ReadUInt64();
4152
4153 C.Str = BR.ReadUInt16();
4154 C.Agi = BR.ReadUInt16();
4155 C.Vit = BR.ReadUInt16();
4156 C.Spi = BR.ReadUInt16();
4157 C.StatPoints = BR.ReadUInt16();
4158 C.CurHP = BR.ReadUInt16();
4159 C.CurMP = BR.ReadUInt16();
4160 C.Silvers = BR.ReadUInt32();
4161 World.GMChatAdd += "Gold : " + C.Silvers + "\r\n";
4162 C.WHSilvers = BR.ReadUInt32();
4163 World.GMChatAdd += "WHGold : " + C.WHSilvers + "\r\n";
4164 C.VP = BR.ReadUInt64();
4165 World.GMChatAdd += "VP : " + C.VP + "\r\n";
4166 //here
4167 C.VipLevel = BR.ReadByte();
4168 World.GMChatAdd += "VIPL : " + C.VipLevel + "\r\n";
4169 C.VIPDays = BR.ReadByte();
4170 World.GMChatAdd += "VIPD : " + C.VIPDays + "\r\n";
4171 C.Reborns = BR.ReadByte();
4172 World.GMChatAdd += "Reborns : " + C.Reborns + "\r\n";
4173 C.DBScrolls = BR.ReadUInt16();//dbscrolls
4174 World.GMChatAdd += "DBScrolls : " + C.DBScrolls + "\r\n";
4175 C.VIPStarted = DateTime.FromBinary(BR.ReadInt64());
4176 C.VIPLevelToReceive = BR.ReadByte();
4177 C.VIPDaysToReceive = BR.ReadByte();
4178 C.DoubleExp = BR.ReadBoolean();
4179 C.DoubleExpLeft = BR.ReadInt32();
4180 C.WHPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
4181 C.PumpkinPoints = BR.ReadUInt16();//ushort
4182 World.GMChatAdd += "PumpkinPts : " + C.PumpkinPoints + "\r\n";
4183 C.CHat2011 = BR.ReadBoolean();//bool
4184 C.TotalDemonBoxes = BR.ReadInt32();//int
4185 World.GMChatAdd += "ChristmasPts : " + C.TotalDemonBoxes + "\r\n";
4186 C.Flowers = BR.ReadUInt32();
4187 World.GMChatAdd += "Flowers : " + C.Flowers + "\r\n";
4188 C.TreasurePoints = BR.ReadUInt16();
4189 World.GMChatAdd += "TreasurePts : " + C.TreasurePoints + "\r\n";
4190 C.CTBPoints = BR.ReadUInt16();
4191 World.GMChatAdd += "CTB Points : " + C.CTBPoints + "\r\n";
4192 C.Warning = BR.ReadBoolean();
4193 C.MetScrolls = BR.ReadByte();
4194 World.GMChatAdd += "MetScrols : " + C.MetScrolls + "\r\n";
4195 //endhere
4196
4197 C.Nobility.Donation = BR.ReadUInt64();
4198 World.GMChatAdd += "NobilityDon : " + C.Nobility.Donation + "\r\n";
4199 C.Nobility.ListPlace = -1;
4200 if (C.Nobility.Donation >= 3000000)
4201 {
4202 C.Nobility.ListPlace = 50;
4203 for (int i = 49; i >= 0; i--)
4204 {
4205 if (C.Nobility.Donation >= World.EmpireBoard[i].Donation)
4206 C.Nobility.ListPlace = i;
4207 else break;
4208 }
4209 //if (C.Nobility.ListPlace < 50)
4210 // {
4211 if (C.Nobility.ListPlace >= 15 && C.Nobility.ListPlace <= 50)
4212 C.Nobility.Rank = Ranks.Duke;
4213 else if (C.Nobility.ListPlace >= 3 && C.Nobility.ListPlace <= 15)
4214 C.Nobility.Rank = Ranks.Prince;
4215 else if (C.Nobility.ListPlace < 3)
4216 C.Nobility.Rank = Ranks.King;
4217 else if (C.Nobility.Donation >= 30000000 && C.Nobility.Donation < 100000000)
4218 C.Nobility.Rank = Ranks.Knight;
4219 else if (C.Nobility.Donation >= 100000000 && C.Nobility.Donation < 200000000)
4220 C.Nobility.Rank = Ranks.Baron;
4221 else if (C.Nobility.Donation >= 200000000 && C.Nobility.Donation < 300000000)
4222 C.Nobility.Rank = Ranks.Earl;
4223 //}
4224 }
4225
4226 C.CPs = BR.ReadUInt32();
4227 C.PKPoints = BR.ReadUInt16();
4228 World.GMChatAdd += "PKP : " + C.PKPoints + "\r\n";
4229 ushort GID = BR.ReadUInt16();
4230 if (Features.Guilds.AllTheGuilds.ContainsKey(GID))
4231 {
4232 C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];
4233
4234 uint Don = BR.ReadUInt32(); ;
4235 byte GR = BR.ReadByte();
4236 if (C.EntityID != 0)
4237 try
4238 {
4239 if ((C.MyGuild.Members[GR]).ContainsKey(C.EntityID))
4240 {
4241 C.GuildDonation = Don;
4242 C.GuildRank = (Features.GuildRank)GR;
4243
4244 C.MembInfo = (Features.MemberInfo)(C.MyGuild.Members[GR])[C.EntityID];
4245 C.MembInfo.Level = C.Level;
4246 C.GuildDonation = C.MembInfo.Donation;
4247 C.GuildRank = C.MembInfo.Rank;
4248 }
4249 else
4250 C.MyGuild = null;
4251 }
4252 catch (Exception E)
4253 {
4254 World.ExcAdd += E.ToString() + "\r\n";
4255 C.GuildDonation = 0;
4256 C.MyGuild = null;
4257 }
4258 }
4259 else BR.ReadBytes(5);
4260
4261 C.Equips = new Equipment();
4262 C.Equips.ReadThis(BR);
4263 World.GMChatAdd += "Top gear: " + C.Equips.HeadGear.UID + "~" + C.Equips.HeadGear.ID + "~" + C.Equips.HeadGear.Plus + "~" + C.Equips.HeadGear.Bless + "~" + C.Equips.HeadGear.Enchant + "~" + (byte)C.Equips.HeadGear.Soc1 + "~" + (byte)C.Equips.HeadGear.Soc2 + "~" + C.Equips.HeadGear.Progress + "\r\n";
4264 World.GMChatAdd += "Necklace: " + C.Equips.Necklace.UID + "~" + C.Equips.Necklace.ID + "~" + C.Equips.Necklace.Plus + "~" + C.Equips.Necklace.Bless + "~" + C.Equips.Necklace.Enchant + "~" + (byte)C.Equips.Necklace.Soc1 + "~" + (byte)C.Equips.Necklace.Soc2 + "~" + C.Equips.Necklace.Progress + "\r\n";
4265 World.GMChatAdd += "Ring: " + C.Equips.Ring.UID + "~" + C.Equips.Ring.ID + "~" + C.Equips.Ring.Plus + "~" + C.Equips.Ring.Bless + "~" + C.Equips.Ring.Enchant + "~" + (byte)C.Equips.Ring.Soc1 + "~" + (byte)C.Equips.Ring.Soc2 + "~" + C.Equips.Ring.Progress + "\r\n";
4266 World.GMChatAdd += "Right hand: " + C.Equips.RightHand.UID + "~" + C.Equips.RightHand.ID + "~" + C.Equips.RightHand.Plus + "~" + C.Equips.RightHand.Bless + "~" + C.Equips.RightHand.Enchant + "~" + (byte)C.Equips.RightHand.Soc1 + "~" + (byte)C.Equips.RightHand.Soc2 + "~" + C.Equips.RightHand.Progress + "\r\n";
4267 World.GMChatAdd += "Left hand: " + C.Equips.LeftHand.UID + "~" + C.Equips.LeftHand.ID + "~" + C.Equips.LeftHand.Plus + "~" + C.Equips.LeftHand.Bless + "~" + C.Equips.LeftHand.Enchant + "~" + (byte)C.Equips.LeftHand.Soc1 + "~" + (byte)C.Equips.LeftHand.Soc2 + "~" + C.Equips.LeftHand.Progress + "\r\n";
4268 World.GMChatAdd += "Armor: " + C.Equips.Armor.UID + "~" + C.Equips.Armor.ID + "~" + C.Equips.Armor.Plus + "~" + C.Equips.Armor.Bless + "~" + C.Equips.Armor.Enchant + "~" + (byte)C.Equips.Armor.Soc1 + "~" + (byte)C.Equips.Armor.Soc2 + "~" + C.Equips.Armor.Progress + "\r\n";
4269 World.GMChatAdd += "Boots: " + C.Equips.Boots.UID + "~" + C.Equips.Boots.ID + "~" + C.Equips.Boots.Plus + "~" + C.Equips.Boots.Bless + "~" + C.Equips.Boots.Enchant + "~" + (byte)C.Equips.Boots.Soc1 + "~" + (byte)C.Equips.Boots.Soc2 + "~" + C.Equips.Boots.Progress + "\r\n";
4270 World.GMChatAdd += "Garment: " + C.Equips.Garment.UID + "~" + C.Equips.Garment.ID + "\r\n";
4271 C.Inventory = new List<Item>(40);
4272 byte InventoryCount = BR.ReadByte();
4273 World.GMChatAdd += "-Inventory-:\r\n";
4274 for (byte i = 0; i < InventoryCount; i++)
4275 {
4276 Item I = new Item();
4277 I.GenNewID = GenNewID;
4278 I.ReadThis(BR);
4279 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4280 C.Inventory.Add(I);
4281 }
4282 C.Warehouses = new Banks();
4283 C.Warehouses.ReadThis(BR);
4284 World.GMChatAdd += "\r\nMA WH:";
4285 foreach (Item I in C.Warehouses.MAWarehouse)
4286 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4287 World.GMChatAdd += "\r\nMA2 WH:";
4288 foreach (Item I in C.Warehouses.MAWarehouse2)
4289 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4290 World.GMChatAdd += "\r\nTC WH: ";
4291 foreach (Item I in C.Warehouses.TCWarehouse)
4292 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4293 World.GMChatAdd += "\r\nPC WH: ";
4294 foreach (Item I in C.Warehouses.PCWarehouse)
4295 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4296 World.GMChatAdd += "\r\nAC WH: ";
4297 foreach (Item I in C.Warehouses.ACWarehouse)
4298 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4299 World.GMChatAdd += "\r\nDC WH: ";
4300 foreach (Item I in C.Warehouses.DCWarehouse)
4301 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4302 World.GMChatAdd += "\r\nBI WH: ";
4303 foreach (Item I in C.Warehouses.BIWarehouse)
4304 World.GMChatAdd += I.UID + "~" + I.ID + "~" + I.Plus + "~" + I.Bless + "~" + I.Enchant + "~" + (byte)I.Soc1 + "~" + (byte)I.Soc2 + "~" + I.Progress + " ";
4305 C.Skills = new ConcurrentDictionary<ushort, Skill>();
4306 byte SkillCount = BR.ReadByte();
4307 World.GMChatAdd += "\r\n-Skills-:\r\n";
4308 for (byte i = 0; i < SkillCount; i++)
4309 {
4310 Skill S = new Skill();
4311 S.ReadThis(BR);
4312 if (!C.Skills.ContainsKey(S.ID))
4313 {
4314 World.GMChatAdd += S.ID + "~" + S.Lvl + "~" + S.Exp + " ";
4315 C.Skills.TryAdd(S.ID, S);
4316 if (S.ID == 3060)
4317 C.CanReflect = true;
4318 }
4319 }
4320 World.GMChatAdd += "\r\n-Profs-:\r\n";
4321 C.Profs = new ConcurrentDictionary<ushort, Prof>();
4322 byte ProfCount = BR.ReadByte();
4323 for (byte i = 0; i < ProfCount; i++)
4324 {
4325 Prof P = new Prof();
4326 P.ReadThis(BR);
4327 if (!C.Profs.ContainsKey(P.ID))
4328 {
4329 World.GMChatAdd += P.ID + "~" + P.Lvl + "~" + P.Exp + " ";
4330 C.Profs.TryAdd(P.ID, P);
4331 }
4332 }
4333
4334 C.Friends = new Dictionary<uint, Friend>();
4335 byte FriendCount = BR.ReadByte();
4336 for (byte i = 0; i < FriendCount; i++)
4337 {
4338 Friend F = new Friend();
4339 F.ReadThis(BR);
4340 if (!C.Friends.ContainsKey(F.UID))
4341 C.Friends.Add(F.UID, F);
4342 }
4343
4344 C.Enemies = new Dictionary<uint, Enemy>();
4345 byte EnemyCount = BR.ReadByte();
4346 for (byte i = 0; i < EnemyCount; i++)
4347 {
4348 Enemy E = new Enemy();
4349 E.ReadThis(BR);
4350 if (!C.Enemies.ContainsKey(E.UID))
4351 C.Enemies.Add(E.UID, E);
4352 }
4353
4354
4355 // C.BlessingLasts = BR.ReadInt32();
4356 // BR.ReadInt64();
4357 // C.BlessingStarted = DateTime.FromBinary(BR.ReadInt64());
4358 C.BlessingLasts = 0;
4359 //C.BlessingStarted = DateTime.UtcNow;
4360 C.LuckyTime = 0;
4361 C.ExpBallsUsedToday = 0;
4362 C.Merchant = (MerchantTypes)(byte)255;//BR.ReadByte();//255
4363 try
4364 {
4365 C.LastLogin = DateTime.FromBinary(BR.ReadInt64());
4366 }
4367 catch { C.LastLogin = DateTime.UtcNow; }
4368
4369 C.LotteryUsed = 0;
4370 C.TrainTimeLeft = 0;
4371 C.InOTG = false;
4372 try
4373 {
4374 C.Spouse = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
4375 if (!File.Exists(World.GlobalCharactersPath + C.Spouse + ".chr"))
4376 C.Spouse = "None";
4377 }
4378 catch
4379 {
4380 C.Spouse = "None";
4381 }
4382 try
4383 {
4384 //C.UniversityPoints = BR.ReadUInt32();
4385 C.UniversityPoints = 0;
4386 C.Top = BR.ReadInt32();
4387 }
4388 catch
4389 {
4390 C.Top = 0;
4391 // C.UniversityPoints = 0;
4392 }
4393 try
4394 {
4395 C.PreviousJob2 = BR.ReadByte();
4396 }
4397 catch
4398 {
4399 C.PreviousJob2 = 0;
4400 }
4401 try
4402 {
4403 BR.ReadBoolean();
4404 //C.BOTJailed = BR.ReadBoolean();
4405 }
4406 catch
4407 {
4408 //C.BOTJailed = false;
4409 }
4410 try
4411 {
4412 C.Voted = BR.ReadBoolean();
4413 }
4414 catch
4415 {
4416 C.Voted = false;
4417 }
4418 try
4419 {
4420 C.PassiveSkills = BR.ReadBoolean();
4421 }
4422 catch
4423 {
4424 C.PassiveSkills = true;
4425 }
4426 try
4427 {
4428 C.BOTJailedDays = BR.ReadByte();
4429 }
4430 catch
4431 {
4432 C.BOTJailedDays = 0;
4433 }
4434 try
4435 {
4436 C.Muted = BR.ReadBoolean();
4437 }
4438 catch
4439 {
4440 C.Muted = false;
4441 }
4442 try
4443 {
4444 C.MutedDays = BR.ReadByte();
4445 }
4446 catch
4447 {
4448 C.MutedDays = 0;
4449 }
4450 C.ProfsBeforeReborn = new Dictionary<ushort, Prof>();
4451 try
4452 {
4453 ProfCount = BR.ReadByte();
4454 }
4455 catch
4456 {
4457 ProfCount = 0;
4458 }
4459 for (byte i = 0; i < ProfCount; i++)
4460 {
4461 Prof P = new Prof();
4462 P.ReadThis(BR);
4463 if (!C.ProfsBeforeReborn.ContainsKey(P.ID))
4464 C.ProfsBeforeReborn.Add(P.ID, P);
4465 }
4466 try
4467 {
4468 C.VotePoints = BR.ReadByte();
4469 World.GMChatAdd += "\r\nVotePts: " + C.VotePoints + "\r\n";
4470 }
4471 catch
4472 { C.VotePoints = 0; }
4473 C.SkillsBeforeReborn = new Dictionary<ushort, Skill>();
4474 try
4475 {
4476 SkillCount = BR.ReadByte();
4477 }
4478 catch { SkillCount = 0; }
4479 for (byte i = 0; i < SkillCount; i++)
4480 {
4481 Skill S = new Skill();
4482 S.ReadThis(BR);
4483 if (!C.SkillsBeforeReborn.ContainsKey(S.ID))
4484 C.SkillsBeforeReborn.Add(S.ID, S);
4485 }
4486
4487 /* try
4488 {
4489 C.TradeReverse = new Hashtable(20);
4490 byte TradeRevCount = BR.ReadByte();
4491 for (int i =0;i<TradeRevCount;i++)
4492 {
4493 Item I = new Item();
4494 I.GenNewID = false;
4495 I.ReadThis(BR);
4496 C.TradeReverse.Add(I.UID, I);
4497 }
4498 C.GetRevertedItems = BR.ReadBoolean();
4499 C.TradedGold = BR.ReadUInt32();
4500 }
4501 catch { Console.WriteLine("Error in TradeReversal stuff loading!"); }*/
4502 // ms.Flush();
4503 //gump ------------
4504 try
4505 {
4506 C.ClassicPoints = BR.ReadByte();
4507 }
4508 catch
4509 {
4510 C.ClassicPoints = 0;
4511 }
4512 World.GMChatAdd += "Classic Points: " + C.ClassicPoints + "\r\n";
4513
4514 World.GMChatAdd += "Loaded Quest data.\r\n";
4515
4516 BR.Close();
4517 ms.Close();
4518 C.Loaded = Load;
4519
4520 return C;
4521 }
4522 return null;
4523
4524 }
4525 catch (Exception Exc) { World.ExcAdd += Exc.ToString() + "\r\n"; World.ExcAdd += "Bugged Char: " + Name + " Acc: " + Account + "\r\n"; return null; }
4526 }
4527 public static void ChangeNames()
4528 {
4529 string[] Paths = Directory.GetFiles(@"C:\OldCODB\UsersNewServer\Characters\");
4530 foreach (string Path in Paths)
4531 {
4532 if (Path.Remove(0, Path.Length - 4) == ".chr")
4533 {
4534 string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
4535 ChangeCharacterNamePlusAcc(Name, "_" + Name);
4536 }
4537 }
4538 }
4539 public static string ChangeCharacterNamePlusAcc(string Name, string NewName)
4540 {//done now done hehe
4541 string CharsPath = @"C:\OldCODB\UsersNewServer\Characters\";
4542 string AccsPath = @"C:\OldCODB\UsersNewServer\";
4543 if (!File.Exists(CharsPath + NewName + ".chr"))
4544 {
4545 Character C = World.CharacterFromName(Name);
4546 if (C != null)
4547 {
4548 C.MyClient.LocalMessage(2000, "In order to change your character name you have to be offline!");
4549 return "Error Character Online";
4550 }
4551 else
4552 {
4553 string Acc = "";
4554 C = LoadCharacter(Name, ref Acc);
4555 if (C != null)
4556 {
4557 C.Name = NewName;
4558 if (C.MyGuild != null)
4559 if (C.GuildRank == Features.GuildRank.GuildLeader)
4560 {
4561 Features.MemberInfo M = C.MyGuild.MembOfName(Name);
4562 C.MyGuild.Creator.MembName = NewName;
4563 if (M != null)
4564 {
4565 M.MembName = NewName;
4566 C.MyGuild.Creator = M;
4567 (C.MyGuild.Members[(byte)100]).Remove(M.MembID);
4568 (C.MyGuild.Members[(byte)100]).Add(M.MembID, M);
4569 }
4570 }
4571 // File.Create(World.GlobalCharactersPath + NewName + ".chr");
4572 File.Copy(CharsPath + Name + ".chr", CharsPath + NewName + ".chr");
4573 SaveCharacter(C, "_" + Acc);
4574 File.Delete(CharsPath + Name + ".chr");
4575 MemoryStream ms = null;
4576 BinaryWriter BW = null;
4577 if (File.Exists(AccsPath + Acc + ".usr"))
4578 {
4579 byte[] buffer = File.ReadAllBytes(AccsPath + Acc + ".usr");
4580 ms = new MemoryStream(buffer);
4581 BinaryReader BR = new BinaryReader(ms);
4582 string RealPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
4583 string Status = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
4584 if (BR.BaseStream.Position != BR.BaseStream.Length)
4585 {
4586 byte len = BR.ReadByte();
4587 Encoding.ASCII.GetString(BR.ReadBytes(len));
4588 }
4589
4590 BR.Close();
4591 ms.Close();
4592 ms = new MemoryStream();
4593 BW = new BinaryWriter(ms);
4594 BW.Write(RealPassword);
4595 BW.Write(Status);
4596 BW.Write((byte)NewName.Length);
4597 BW.Write(Encoding.ASCII.GetBytes(NewName));
4598 buffer = ms.ToArray();
4599 File.WriteAllBytes(AccsPath + "_" + Acc + ".usr", buffer);
4600 File.Delete(AccsPath + Acc + ".usr");
4601 }
4602 if (File.Exists(AccsPath + Acc + ".txt"))
4603 {
4604 File.Copy(AccsPath + Acc + ".txt", AccsPath + "_" + Acc + ".txt");
4605 File.Delete(AccsPath + Acc + ".txt");
4606 }
4607
4608 if (BW != null)
4609 BW.Close();
4610 if (ms != null)
4611 ms.Close();
4612 return "OK";
4613 }
4614 else return "Error Character " + Name + " Does Not Exist";
4615 }
4616 }
4617 else return "Error New Name Character Exists";
4618 // return "Error";
4619 }
4620 public static Character LoadCharacter(string Name, ref string Account, bool GenNewID = true, bool Load = false)
4621 {
4622 try
4623 {
4624 if (File.Exists(World.GlobalCharactersPath + Name + ".chr"))
4625 {
4626 Character C = new Character();
4627 byte[] buffer = File.ReadAllBytes(World.GlobalCharactersPath + Name + ".chr");
4628 MemoryStream ms = new MemoryStream(buffer);
4629 BinaryReader BR = new BinaryReader(ms);
4630 //C.LastLogin = DateTime.UtcNow;
4631
4632 //63 bytes
4633 C.Name = Name;//check
4634 Account = BR.ReadString();//check - accounts table
4635 C.Account = Account;//check
4636 //BR.ReadBytes(63);
4637 C.EntityID = BR.ReadUInt32();//check
4638 C.Avatar = BR.ReadUInt16();//check
4639 C.Body = BR.ReadUInt16();//check
4640 C.Hair = BR.ReadUInt16();//check
4641
4642 C.Loc = new Location();
4643 C.Loc.Map = BR.ReadUInt32();//here - check
4644 C.Loc.X = BR.ReadUInt16();//check
4645 C.Loc.Y = BR.ReadUInt16();//check
4646 C.Loc.PreviousMap = BR.ReadUInt32();//here - check?
4647
4648 C.Job = BR.ReadByte();//check
4649 C.PreviousJob1 = BR.ReadByte();//check
4650 C.Level = BR.ReadByte();//check
4651 C.Experience = BR.ReadUInt64();//check
4652
4653 C.Str = BR.ReadUInt16();//check
4654 C.Agi = BR.ReadUInt16();//check
4655 C.Vit = BR.ReadUInt16();//check
4656 C.Spi = BR.ReadUInt16();//check
4657 C.StatPoints = BR.ReadUInt16();//check
4658 C.CurHP = BR.ReadUInt16();//check
4659 C.CurMP = BR.ReadUInt16();//check
4660 C.Silvers = BR.ReadUInt32();//check
4661 C.WHSilvers = BR.ReadUInt32();//check
4662 C.VP = BR.ReadUInt64();//check
4663 //here
4664
4665 C.VipLevel = BR.ReadByte();// change it to date time VIP variable only
4666 C.VIPDays = BR.ReadByte();// change it to date time VIP variable only
4667 C.Reborns = BR.ReadByte();// - get { Previous Reborn > 0 return 1}
4668 C.DBScrolls = BR.ReadUInt16();//dbscrolls //check
4669 C.VIPStarted = DateTime.FromBinary(BR.ReadInt64());// change it to date time VIP variable only
4670 C.VIPLevelToReceive = BR.ReadByte();//check
4671 C.VIPDaysToReceive = BR.ReadByte();//check
4672 C.DoubleExp = BR.ReadBoolean();//get { DoubleExp Left > 0 return true }
4673 C.DoubleExpLeft = BR.ReadInt32();//check
4674 C.WHPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));//check
4675 C.PumpkinPoints = BR.ReadUInt16();//ushort //check
4676 C.CHat2011 = BR.ReadBoolean();//bool NOT NEEDED
4677 C.TotalDemonBoxes = BR.ReadInt32();//int NOT NEEDED
4678 C.Flowers = BR.ReadUInt32();// NOT NEEDED
4679 C.TreasurePoints = BR.ReadUInt16();//check
4680 C.CTBPoints = BR.ReadUInt16();//check
4681 C.Warning = BR.ReadBoolean();// NOT NEEDED
4682 C.MetScrolls = BR.ReadByte();//check
4683 C.TopFB = BR.ReadByte();// NEW TABLE WITH TOPS
4684 C.OnlineTime = BR.ReadUInt32();//check
4685 C.CurrentKills = BR.ReadUInt16();//check
4686 C.VIP = DateTime.FromBinary(BR.ReadInt64());//check
4687 C.Nobility.Donation = BR.ReadUInt64();//check
4688 //endhere
4689
4690 C.Nobility.ListPlace = -1;
4691 if (C.Nobility.Donation >= 3000000)
4692 {
4693 C.Nobility.ListPlace = 50;
4694 for (int i = 49; i >= 0; i--)
4695 {
4696 if (C.Nobility.Donation > World.EmpireBoard[i].Donation)
4697 C.Nobility.ListPlace = i;
4698 else if (C.Nobility.Donation == World.EmpireBoard[i].Donation && C.Nobility.ListPlace <= 49)
4699 {
4700 //int c = string.Compare(C.Name, EmpireBoard[i].Name);
4701 //c = C.Name.CompareTo(EmpireBoard[i].Name);
4702 if (C.Name.CompareTo(World.EmpireBoard[i].Name) > 0)
4703 break;
4704 else
4705 C.Nobility.ListPlace = i;
4706 }
4707 else
4708 break;
4709 }
4710 if (C.Nobility.ListPlace < 50)
4711 {
4712 if (C.Nobility.ListPlace >= 15 && C.Nobility.ListPlace <= 50)
4713 C.Nobility.Rank = Ranks.Duke;
4714 else if (C.Nobility.ListPlace >= 3 && C.Nobility.ListPlace <= 15)
4715 C.Nobility.Rank = Ranks.Prince;
4716 else if (C.Nobility.ListPlace < 3)
4717 C.Nobility.Rank = Ranks.King;
4718 }
4719 else if (C.Nobility.Donation >= 30000000 && C.Nobility.Donation <= 100000000)
4720 C.Nobility.Rank = Ranks.Knight;
4721 else if (C.Nobility.Donation >= 100000000 && C.Nobility.Donation <= 200000000)
4722 C.Nobility.Rank = Ranks.Baron;
4723 else if (C.Nobility.Donation >= 200000000 && C.Nobility.Donation <= 300000000)
4724 C.Nobility.Rank = Ranks.Earl;
4725 }
4726
4727 C.CPs = BR.ReadUInt32();//check
4728 C.PKPoints = BR.ReadUInt16();//check
4729
4730 //ushort GID = BR.ReadUInt16();
4731 //if (Features.Guilds.AllTheGuilds.ContainsKey(GID))
4732 //{
4733 // C.MyGuild = (Features.Guild)Features.Guilds.AllTheGuilds[GID];
4734
4735 // uint Don = BR.ReadUInt32(); ;
4736 // byte GR = BR.ReadByte();
4737 // if (C.EntityID != 0)
4738 // try
4739 // {
4740 // if ((C.MyGuild.Members[GR]).ContainsKey(C.EntityID))
4741 // {
4742 // C.GuildDonation = Don;
4743 // C.GuildRank = (Features.GuildRank)GR;
4744
4745 // C.MembInfo = (Features.MemberInfo)(C.MyGuild.Members[GR])[C.EntityID];
4746 // C.MembInfo.Level = C.Level;
4747 // C.GuildDonation = C.MembInfo.Donation;
4748 // C.GuildRank = C.MembInfo.Rank;
4749 // }
4750 // else if (GR != 100)
4751 // C.MyGuild = null;
4752 // }
4753 // catch (Exception E)
4754 // {
4755 // World.ExcAdd += E.ToString() + "\r\n";
4756 // C.GuildDonation = 0;
4757 // C.MyGuild = null;
4758 // }
4759 //}
4760 //else
4761 // BR.ReadBytes(5);
4762
4763 BR.ReadBytes(7);
4764
4765 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT);
4766 Cmd.Select("characters").Where("UID", C.EntityID);
4767 MySQL.MySqlReader Character = new MySQL.MySqlReader(Cmd);
4768
4769 ushort GuildID = 0;
4770 while (Character.Read())
4771 {
4772 GuildID = Character.ReadUInt16("GuildID");
4773 C.Version = Character.ReadUInt16("Version");
4774 C.MutedRecord = Character.ReadUInt16("MutedRecord");
4775 }
4776 if (Features.Guilds.AllTheGuilds.ContainsKey(GuildID) && GuildID != 0)
4777 {
4778 C.MyGuild = Features.Guilds.AllTheGuilds[GuildID];
4779 try
4780 {
4781 bool contains = false;
4782 foreach (KeyValuePair<byte, Dictionary<uint, Features.MemberInfo>> List in C.MyGuild.Members)
4783 {
4784 if (List.Value.ContainsKey(C.EntityID))
4785 {
4786 C.MembInfo = C.MyGuild.Members[List.Key][C.EntityID];
4787 C.MembInfo.Level = C.Level;
4788 C.GuildDonation = C.MembInfo.Donation;
4789 C.GuildRank = C.MembInfo.Rank;
4790 contains = true;
4791 break;
4792 }
4793 }
4794 if (!contains)
4795 C.MyGuild = null;
4796 }
4797 catch (Exception E)
4798 {
4799 World.ExcAdd += E.ToString() + "\r\n";
4800 C.GuildDonation = 0;
4801 C.MyGuild = null;
4802 }
4803 }
4804
4805 C.Equips = new Equipment();
4806 C.Equips.ReadThis(BR);
4807 C.Inventory = new List<Item>(40);
4808 byte InventoryCount = BR.ReadByte();
4809 for (byte i = 0; i < InventoryCount; i++)
4810 {
4811 Item I = new Item();
4812 I.GenNewID = GenNewID;
4813 I.ReadThis(BR);
4814 if (I.ID != 0)
4815 C.Inventory.Add(I);
4816 }
4817 C.Warehouses = new Banks();
4818 C.Warehouses.ReadThis(BR);
4819
4820 C.Skills = new ConcurrentDictionary<ushort, Skill>();
4821 byte SkillCount = BR.ReadByte();
4822 for (byte i = 0; i < SkillCount; i++)
4823 {
4824 Skill S = new Skill();
4825 S.ReadThis(BR);
4826 if (!C.Skills.ContainsKey(S.ID))
4827 {
4828 C.Skills.TryAdd(S.ID, S);
4829 if (S.ID == 3060)
4830 C.CanReflect = true;
4831 }
4832 }
4833
4834 C.Profs = new ConcurrentDictionary<ushort, Prof>();
4835 byte ProfCount = BR.ReadByte();
4836 for (byte i = 0; i < ProfCount; i++)
4837 {
4838 Prof P = new Prof();
4839 P.ReadThis(BR);
4840 if (!C.Profs.ContainsKey(P.ID))
4841 C.Profs.TryAdd(P.ID, P);
4842 }
4843 C.Friends = new Dictionary<uint, Friend>();
4844 byte FriendCount = BR.ReadByte();
4845 for (byte i = 0; i < FriendCount; i++)
4846 {
4847 Friend F = new Friend();
4848 F.ReadThis(BR);
4849 if (!C.Friends.ContainsKey(F.UID) && World.EIDS.Contains(F.UID))
4850 C.Friends.Add(F.UID, F);
4851 }
4852 C.Enemies = new Dictionary<uint, Enemy>();
4853 byte EnemyCount = BR.ReadByte();
4854 for (byte i = 0; i < EnemyCount; i++)
4855 {
4856 Enemy E = new Enemy();
4857 E.ReadThis(BR);
4858 if (!C.Enemies.ContainsKey(E.UID) && World.EIDS.Contains(E.UID))
4859 C.Enemies.Add(E.UID, E);
4860 }
4861 C.BlessingLasts = 0;
4862 C.LuckyTime = 0;
4863 C.ExpBallsUsedToday = 0;
4864 C.Merchant = (MerchantTypes)(byte)255;//BR.ReadByte();//255
4865 try
4866 {
4867 C.LastLogin = DateTime.FromBinary(BR.ReadInt64());
4868 }
4869 catch { C.LastLogin = DateTime.UtcNow; }
4870 C.LotteryUsed = 0;
4871 C.TrainTimeLeft = 0;
4872 C.InOTG = false;
4873 try
4874 {
4875 C.Spouse = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
4876 if (!File.Exists(World.GlobalCharactersPath + C.Spouse + ".chr"))
4877 C.Spouse = "None";
4878 }
4879 catch
4880 {
4881 C.Spouse = "None";
4882 }
4883 try
4884 {
4885 C.UniversityPoints = 0;
4886 C.Top = BR.ReadInt32();
4887 }
4888 catch
4889 {
4890 C.Top = 0;
4891 }
4892 try
4893 {
4894 C.PreviousJob2 = BR.ReadByte();//check
4895 }
4896 catch
4897 {
4898 C.PreviousJob2 = 0;
4899 }
4900 try
4901 {
4902 BR.ReadBoolean();
4903 //C.BOTJailed = BR.ReadBoolean();//get { return botjaileddays}
4904 }
4905 catch
4906 {
4907 //C.BOTJailed = false;
4908 }
4909 try
4910 {
4911 C.Voted = BR.ReadBoolean();//get { return last vote}
4912 }
4913 catch
4914 {
4915 C.Voted = false;
4916 }
4917 try
4918 {
4919 C.PassiveSkills = BR.ReadBoolean();
4920 }
4921 catch
4922 {
4923 C.PassiveSkills = true;
4924 }
4925 try
4926 {
4927 C.BOTJailedDays = BR.ReadByte();//check
4928 }
4929 catch
4930 {
4931 C.BOTJailedDays = 0;
4932 }
4933 try
4934 {
4935 BR.ReadBoolean();
4936 //C.Muted = BR.ReadBoolean();//get { return muteddays}
4937 }
4938 catch
4939 {
4940 //C.Muted = false;
4941 }
4942 try
4943 {
4944 C.MutedDays = BR.ReadByte();
4945 }
4946 catch
4947 {
4948 C.MutedDays = 0;
4949 }
4950 C.ProfsBeforeReborn = new Dictionary<ushort, Prof>();
4951 try
4952 {
4953 ProfCount = BR.ReadByte();
4954 }
4955 catch
4956 {
4957 ProfCount = 0;
4958 }
4959 for (byte i = 0; i < ProfCount; i++)
4960 {
4961 Prof P = new Prof();
4962 P.ReadThis(BR);
4963 if (!C.ProfsBeforeReborn.ContainsKey(P.ID))
4964 C.ProfsBeforeReborn.Add(P.ID, P);
4965 }
4966 try
4967 {
4968 C.VotePoints = BR.ReadByte();
4969 }
4970 catch
4971 { C.VotePoints = 0; }
4972 C.SkillsBeforeReborn = new Dictionary<ushort, Skill>();
4973 try
4974 {
4975 SkillCount = BR.ReadByte();
4976 }
4977 catch { SkillCount = 0; }
4978 for (byte i = 0; i < SkillCount; i++)
4979 {
4980 Skill S = new Skill();
4981 S.ReadThis(BR);
4982 if (!C.SkillsBeforeReborn.ContainsKey(S.ID))
4983 C.SkillsBeforeReborn.Add(S.ID, S);
4984 }
4985 try
4986 {
4987 C.ClassicPoints = BR.ReadByte();//check
4988 }
4989 catch
4990 {
4991 C.ClassicPoints = 0;
4992 }
4993
4994
4995 BR.Close();
4996 ms.Close();
4997 C.Loaded = Load;
4998
4999 return C;
5000
5001 //C.UniversityPoints = BR.ReadUInt32();
5002 // C.BlessingLasts = BR.ReadInt32();
5003 // BR.ReadInt64();
5004 // C.BlessingStarted = DateTime.FromBinary(BR.ReadInt64());
5005 //C.BlessingStarted = DateTime.UtcNow;
5006
5007
5008 /* try
5009 {
5010 C.TradeReverse = new Hashtable(20);
5011 byte TradeRevCount = BR.ReadByte();
5012 for (int i =0;i<TradeRevCount;i++)
5013 {
5014 Item I = new Item();
5015 I.GenNewID = false;
5016 I.ReadThis(BR);
5017 C.TradeReverse.Add(I.UID, I);
5018 }
5019 C.GetRevertedItems = BR.ReadBoolean();
5020 C.TradedGold = BR.ReadUInt32();
5021 }
5022 catch { Console.WriteLine("Error in TradeReversal stuff loading!"); }*/
5023 // ms.Flush();
5024
5025 //gump----------
5026 }
5027 return null;
5028
5029 }
5030 catch (Exception Exc) { World.ExcAdd += Exc.ToString() + "\r\n"; World.ExcAdd += "Bugged Char: " + Name + " Acc: " + Account + "\r\n"; return null; }
5031 }
5032 public static Character LoadCharacter(string Name, bool Loaded)
5033 {
5034 try
5035 {
5036
5037 Character C = new Character();
5038 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("characters").Where("Name", Name);
5039 MySQL.MySqlReader Username = new MySQL.MySqlReader(Cmd);
5040
5041 while (Username.Read())
5042 C.EntityID = Username.ReadUInt32("UID");
5043
5044 Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("accounts").Where("UID", C.EntityID);
5045 Username = new MySQL.MySqlReader(Cmd);
5046
5047 while (Username.Read())
5048 C.Account = Username.ReadString("Username");
5049
5050 Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("characters").Where("UID", C.EntityID);
5051 MySQL.MySqlReader Character = new MySQL.MySqlReader(Cmd);
5052
5053 ushort GuildID = 0;
5054 while (Character.Read())
5055 {
5056 C.EntityID = Character.ReadUInt32("UID");
5057 C.Name = Character.ReadString("Name");
5058 C.Level = Character.ReadByte("Level");
5059 C.Experience = Character.ReadUInt64("Experience");
5060 C.Spouse = Character.ReadString("Spouse");
5061 C.Body = Character.ReadUInt16("Body");
5062 C.Avatar = Character.ReadUInt16("Face");
5063 C.Hair = Character.ReadUInt16("Hair");
5064 C.Silvers = Character.ReadUInt32("Silvers");
5065 C.WHSilvers = Character.ReadUInt32("WHSilvers");
5066 C.CPs = Character.ReadUInt32("CPs");
5067 GuildID = Character.ReadUInt16("GuildID");
5068 C.Version = Character.ReadUInt16("Version");
5069 C.Loc = new Location()
5070 {
5071 Map = Character.ReadUInt32("Map"),
5072 X = Character.ReadUInt16("X"),
5073 Y = Character.ReadUInt16("Y")
5074 };
5075 C.Job = Character.ReadByte("Job");
5076 C.PreviousJob1 = Character.ReadByte("PreviousJob1");
5077 C.PreviousJob2 = Character.ReadByte("PreviousJob2");
5078 C.Str = Character.ReadUInt16("Strength");
5079 C.Agi = Character.ReadUInt16("Agility");
5080 C.Vit = Character.ReadUInt16("Vitality");
5081 C.Spi = Character.ReadUInt16("Spirit");
5082 C.StatPoints = Character.ReadUInt16("ExtraStats");
5083 C.CurHP = Character.ReadUInt16("Life");
5084 C.CurMP = Character.ReadUInt16("Mana");
5085 C.VP = Character.ReadUInt64("VirtuePoints");
5086 C.DBScrolls = Character.ReadUInt16("DBScrolls");
5087 C.VIPLevelToReceive = (byte)Character.ReadUInt16("VIPLevelToReceive");
5088 C.VIPDaysToReceive = (byte)Character.ReadUInt16("VIPDaysToReceive");
5089 C.DoubleExpLeft = Character.ReadInt32("DoubleExp");
5090 C.WHPassword = Character.ReadString("WHPassword");
5091 C.VIP = Character.ReadDatetime("VIP");
5092 C.PumpkinPoints = Character.ReadUInt16("PumpkinPoints");
5093 C.TreasurePoints = Character.ReadUInt16("TreasurePoints");
5094 C.CTBPoints = Character.ReadUInt16("CTBPoints");
5095 C.MetScrolls = (byte)Character.ReadUInt16("MetScrolls");
5096 C.OnlineTime = Character.ReadUInt32("OnlineTime");
5097 C.CurrentKills = Character.ReadUInt16("CurrentKills");
5098 C.Nobility.Donation = Character.ReadUInt64("Nobility");
5099 C.PKPoints = Character.ReadUInt16("PKPoints");
5100 C.LastLogin = Character.ReadDatetime("LastLogin");
5101 C.BOTJailedDays = Character.ReadByte("BotJailedDays");
5102 C.MutedDays = Character.ReadByte("MutedDays");
5103 C.VotePoints = Character.ReadByte("VotePoints");
5104 C.ClassicPoints = Character.ReadInt32("ClassicPoints");
5105 C.LastVote = Character.ReadDatetime("LastVote");
5106 C.Loaded = Loaded;
5107 }
5108
5109 //Guild
5110 if (Features.Guilds.AllTheGuilds.ContainsKey(GuildID) && GuildID != 0)
5111 {
5112 C.MyGuild = Features.Guilds.AllTheGuilds[GuildID];
5113 try
5114 {
5115 foreach (KeyValuePair<byte, Dictionary<uint, Features.MemberInfo>> List in C.MyGuild.Members)
5116 {
5117 if (List.Value.ContainsKey(C.EntityID))
5118 {
5119 C.MembInfo = C.MyGuild.Members[List.Key][C.EntityID];
5120 C.MembInfo.Level = C.Level;
5121 C.GuildDonation = C.MembInfo.Donation;
5122 C.GuildRank = C.MembInfo.Rank;
5123 break;
5124 }
5125 }
5126 }
5127 catch (Exception E)
5128 {
5129 World.ExcAdd += E.ToString() + "\r\n";
5130 C.GuildDonation = 0;
5131 C.MyGuild = null;
5132 }
5133 }
5134
5135 C.Equips = new Equipment();
5136 C.Equips.Open();
5137 C.Warehouses = new Banks();
5138 C.Warehouses.Open();
5139 C.Inventory = new List<Item>(40);
5140
5141 Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("items").Where("Owner", C.EntityID);
5142 Character = new MySQL.MySqlReader(Cmd);
5143 while (Character.Read())
5144 {
5145 Item I = new Item();
5146 I.UID = Character.ReadUInt32("UID");
5147 I.ID = Character.ReadUInt32("StaticID");
5148 I.Plus = Character.ReadByte("Plus");
5149 I.Bless = Character.ReadByte("Bless");
5150 I.Enchant = Character.ReadByte("Enchant");
5151 I.Soc1 = (Item.Gem)Character.ReadByte("Gem1");
5152 I.Soc2 = (Item.Gem)Character.ReadByte("Gem2");
5153 I.MaxDur = Character.ReadUInt16("MaxDura");
5154 I.CurDur = Character.ReadUInt16("CurDura");
5155 I.Color = (Item.ArmorColor)Character.ReadByte("Color");
5156 I.Effect = (Item.RebornEffect)Character.ReadByte("Effect");
5157 I.Progress = Character.ReadUInt16("Progress");
5158 I.TalismanProgress = Character.ReadUInt32("TalismanProgress");
5159 I.FreeItem = Character.ReadBoolean("FreeItem");
5160 I.RestrainType = Character.ReadUInt32("RestrainType");
5161 C.LoadItem(I, Character.ReadUInt16("Location"));
5162 }
5163
5164 C.Skills = new ConcurrentDictionary<ushort, Skill>();
5165 C.SkillsBeforeReborn = new Dictionary<ushort, Skill>(); // need to delete this and add a "previous level" field to skill
5166 Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("skills").Where("Owner", C.EntityID);
5167 Character = new MySQL.MySqlReader(Cmd);
5168 while (Character.Read())
5169 {
5170 Skill S = new Skill();
5171 S.ID = Character.ReadUInt16("ID");
5172 S.Lvl = Character.ReadByte("Level");
5173 S.Exp = Character.ReadUInt32("Experience");
5174 S.PreviousLevel = Character.ReadByte("PreviousLevel");
5175 if (!C.Skills.ContainsKey(S.ID))
5176 {
5177 C.Skills.TryAdd(S.ID, S);
5178 if (S.ID == 3060)
5179 C.CanReflect = true;
5180 }
5181
5182 if (S.PreviousLevel > 0)
5183 {
5184 Skill S2 = S;
5185 S2.Lvl = S.PreviousLevel;
5186 S.Exp = 0;
5187 C.SkillsBeforeReborn.Add(S.ID, S);
5188 }
5189 }
5190
5191 C.Profs = new ConcurrentDictionary<ushort, Prof>();
5192 C.ProfsBeforeReborn = new Dictionary<ushort, Prof>();
5193 Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("proficiencies").Where("Owner", C.EntityID);
5194 Character = new MySQL.MySqlReader(Cmd);
5195 while (Character.Read())
5196 {
5197 Prof S = new Prof();
5198 S.ID = Character.ReadUInt16("ID");
5199 S.Lvl = Character.ReadByte("Level");
5200 S.Exp = Character.ReadUInt32("Experience");
5201 S.PreviousLevel = Character.ReadByte("PreviousLevel");
5202 if (!C.Profs.ContainsKey(S.ID))
5203 {
5204 C.Profs.TryAdd(S.ID, S);
5205 }
5206
5207 if (S.PreviousLevel > 0)
5208 {
5209 Prof S2 = S;
5210 S2.Lvl = S.PreviousLevel;
5211 S.Exp = 0;
5212 C.ProfsBeforeReborn.Add(S.ID, S);
5213 }
5214 }
5215
5216 C.Friends = new Dictionary<uint, Friend>();
5217 C.Enemies = new Dictionary<uint, Enemy>();
5218 Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("associates").Where("UID", C.EntityID);
5219 Character = new MySQL.MySqlReader(Cmd);
5220 while (Character.Read())
5221 {
5222 byte Type = Character.ReadByte("Type");
5223 if (Type == 0)
5224 {
5225 Enemy E = new Enemy();
5226 E.UID = Character.ReadUInt32("AssociateID");
5227 E.Name = "";
5228 MySQL.MySqlCommand Cmd2 = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).COUNT("characters").Where("UID", E.UID);
5229 MySQL.MySqlReader Associate = new MySQL.MySqlReader(Cmd2);
5230 while (Associate.Read())
5231 E.Name = Associate.ReadString("Name");
5232
5233 if (!C.Enemies.ContainsKey(E.UID) && !World.BannedChars.Contains(E.Name) && E.Name != "")
5234 C.Enemies.Add(E.UID, E);
5235 }
5236 else
5237 {
5238 Friend F = new Friend();
5239 F.UID = Character.ReadUInt32("AssociateID");
5240
5241 F.Name = "";
5242 MySQL.MySqlCommand Cmd2 = new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).COUNT("characters").Where("UID", F.UID);
5243 MySQL.MySqlReader Associate = new MySQL.MySqlReader(Cmd2);
5244 while (Associate.Read())
5245 F.Name = Associate.ReadString("Name");
5246
5247 if (!C.Friends.ContainsKey(F.UID) && !World.BannedChars.Contains(F.Name) && F.Name != "")
5248 C.Friends.Add(F.UID, F);
5249 }
5250 }
5251 return C;
5252 }
5253 catch (Exception e)
5254 {
5255 World.ExcAdd += e + "\r\nBugged Char: " + Name + "\r\n";
5256 return null;
5257 }
5258 }
5259
5260 public static void SaveCharacter(Character C, string Acc)
5261 {
5262 try
5263 {
5264 if (C != null && File.Exists(World.GlobalCharactersPath + C.Name + ".chr"))
5265 {
5266 if (C.Saving)
5267 return;
5268 C.Saving = true;
5269 MemoryStream FS = new MemoryStream();//ce deschide? nu deschide nimic :)), creaza un buffer iar bw o sa scrie in el, la sf copiaza bufferu si dupa ce inchide bw si ms, scrie cu File.Writeallbytes bufferu ca sa nu ai probleme cu alte procese :) ok mersi mult vezi daca merge :P ok
5270 BinaryWriter BW = new BinaryWriter(FS);
5271 int DoubleExp = C.DoubleExpLeft;
5272 if (C.DoubleExp)
5273 DoubleExp -= (int)(DateTime.UtcNow - C.ExpPotionUsed).TotalSeconds;
5274
5275 BW.Write(Acc);
5276 BW.Write(C.EntityID);
5277 BW.Write(C.Avatar);
5278 BW.Write(C.Body);
5279 BW.Write(C.Hair);//Hair
5280 BW.Write(C.Loc.Map);//Map
5281 BW.Write(C.Loc.X);//X
5282 BW.Write(C.Loc.Y);//Y
5283 BW.Write(C.Loc.PreviousMap);//Previous Map
5284 BW.Write(C.Job);
5285 BW.Write(C.PreviousJob1);//Previous Job, 1st RB
5286 BW.Write(C.Level);//Level
5287 BW.Write(C.Experience);//Experience
5288 BW.Write(C.Str);
5289 BW.Write(C.Agi);
5290 BW.Write(C.Vit);
5291 BW.Write(C.Spi);
5292 BW.Write(C.StatPoints);//Stat Points
5293 BW.Write(C.CurHP);
5294 BW.Write(C.CurMP);//MP
5295 BW.Write(C.Silvers);//Silvers
5296 BW.Write(C.WHSilvers);//Warehouse Silvers
5297 BW.Write(C.VP);//Virtue Points
5298 //here-------
5299 BW.Write(C.VipLevel);//
5300 BW.Write(C.VIPDays);
5301 BW.Write(C.Reborns);
5302 BW.Write(C.DBScrolls);//ushort
5303 BW.Write(C.VIPStarted.ToBinary());//long
5304 BW.Write(C.VIPLevelToReceive);
5305 BW.Write(C.VIPDaysToReceive);
5306 BW.Write(C.DoubleExp);
5307 BW.Write(DoubleExp);
5308 BW.Write(C.WHPassword);
5309 BW.Write(C.PumpkinPoints);//ushort
5310 BW.Write(C.CHat2011);//bool
5311 BW.Write(C.TotalDemonBoxes);//int
5312 BW.Write(C.Flowers);
5313 BW.Write(C.TreasurePoints);
5314 BW.Write(C.CTBPoints);
5315 BW.Write(C.Warning);
5316 BW.Write(C.MetScrolls);
5317 BW.Write(C.TopFB);
5318 BW.Write(C.OnlineTime);
5319 BW.Write(C.CurrentKills);//CurrentKills Cloudsaint
5320 BW.Write(C.VIP.ToBinary());//long
5321 //endhere-------
5322 BW.Write(C.Nobility.Donation);
5323 BW.Write(C.CPs);
5324 BW.Write(C.PKPoints);//PK Points
5325 if (C.MyGuild != null)
5326 {
5327 BW.Write(C.MyGuild.GuildID);//Guild
5328 BW.Write(C.GuildDonation);//Guild Donation
5329 BW.Write((byte)C.GuildRank);//Guild Rank
5330 }
5331 else BW.Write(new byte[7]);
5332 C.Equips.WriteThis(BW);
5333 BW.Write((byte)C.Inventory.Count);
5334 List<Item> TempInv = C.Inventory;
5335 foreach (Item I in TempInv)
5336 I.WriteThis(BW);
5337 C.Warehouses.WriteThis(BW);
5338 BW.Write((byte)C.Skills.Count);
5339 // Hashtable TempSkills = C.Skills;
5340 foreach (Skill I in C.Skills.Values)
5341 I.WriteThis(BW);
5342 BW.Write((byte)C.Profs.Count);
5343 // Hashtable TempProfs = C.Profs;
5344 foreach (Prof I in C.Profs.Values)
5345 I.WriteThis(BW);
5346 BW.Write((byte)C.Friends.Count);//C.Friends.Count
5347 Dictionary<uint, Friend> TempFriends = C.Friends;
5348 foreach (Friend I in TempFriends.Values)
5349 I.WriteThis(BW);
5350 BW.Write((byte)C.Enemies.Count);//C.Enemies.Count
5351 Dictionary<uint, Enemy> TempEnemies = C.Enemies;
5352 foreach (Enemy I in TempEnemies.Values)
5353 I.WriteThis(BW);
5354
5355
5356 //rem BW.Write((int)0);//C.BlessingLasts
5357 //rem BW.Write((long)0);//C.BlessingStarted.Ticks
5358 /*if (C.GettingLuckyTime)
5359 {
5360 if (!C.Prayer)
5361 C.LuckyTime += (uint)(DateTime.UtcNow - C.PrayDT).TotalSeconds;
5362 else
5363 C.LuckyTime += (uint)(DateTime.UtcNow - C.PrayDT).TotalSeconds * 3;
5364 C.PrayDT = DateTime.UtcNow;
5365 }*/
5366 //rem BW.Write((uint)0);//C.LuckyTime
5367 //rem BW.Write((byte)0);//C.ExpBallsUsedToday
5368
5369 //BW.Write((byte)C.Merchant);//
5370 //rem BW.Write((byte)255);
5371
5372 BW.Write(C.LastLogin.ToBinary());//When logged off, for otg feature purposes C.LastLogin (loading)
5373 //rem BW.Write((ushort)0);//Train time left (in minutes)
5374 //rem BW.Write(false);//C.InOTG
5375 //rem BW.Write((byte)0);//C.LotteryUsed
5376
5377 BW.Write(C.Spouse);
5378 //rem BW.Write((uint)0);//Quiz Pts C.UniversityPoints
5379 BW.Write(C.Top);
5380 BW.Write(C.PreviousJob2);
5381
5382 BW.Write(C.BOTJailed);
5383 BW.Write(C.Voted);
5384 BW.Write(C.PassiveSkills);
5385 BW.Write(C.BOTJailedDays);
5386 BW.Write(C.Muted);
5387 BW.Write(C.MutedDays);
5388 BW.Write((byte)C.ProfsBeforeReborn.Count);
5389 foreach (Prof P in C.ProfsBeforeReborn.Values)
5390 P.WriteThis(BW);
5391 BW.Write(C.VotePoints);
5392 BW.Write((byte)C.SkillsBeforeReborn.Count);
5393 foreach (Skill S in C.SkillsBeforeReborn.Values)
5394 S.WriteThis(BW);
5395
5396 /* BW.Write((byte)C.TradeReverse.Count);
5397 foreach (Item I in C.TradeReverse.Values)
5398 I.WriteThis(BW);
5399 BW.Write(C.GetRevertedItems);
5400 BW.Write(C.TradedGold);*/
5401
5402 //gump----
5403 BW.Write(C.ClassicPoints);
5404
5405 //end gump----
5406 byte[] buffer = FS.ToArray();
5407 // BW.Flush();
5408 // FS.Flush();
5409 BW.Close();
5410 FS.Close();
5411 try
5412 {
5413
5414 File.WriteAllBytes(World.GlobalCharactersPath + C.Name + ".chr", buffer);//Gata:P woot stai asa
5415 }
5416 catch (Exception E) { World.ExcAdd += E.ToString() + "\r\n"; }
5417 C.Saving = false;
5418
5419 MySQL.MySqlCommand UpdateChar = new MySQL.MySqlCommand(MySQL.MySqlCommandType.UPDATE);
5420 UpdateChar.Update("characters").Set("Face", C.Avatar).Set("GuildID", C.GuildID).Set("Version", (ushort)Game.World._serverVersion).Set("MutedRecord", C.MutedRecord).Where("UID", C.EntityID).Execute();
5421 }
5422 }
5423 catch (Exception Exc) { World.ExcAdd += Exc.ToString() + "\r\n"; C.Saving = false; }
5424 }
5425 public static string CreateCharacter(string Account, string Name, ushort Body, byte Job, uint UID = 0)
5426 {
5427 try
5428 {
5429 //if (new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("accounts").Where("Username", Account).ExecuteScalar() > 0 && !File.Exists(World.GlobalCharactersPath + Name + ".chr"))
5430 //{
5431
5432 //}
5433 //if (File.Exists(World.GlobalAccountsPath + Account + ".usr") && !File.Exists(World.GlobalCharactersPath + Name + ".chr"))
5434 if (new MySQL.MySqlCommand(MySQL.MySqlCommandType.SELECT).Select("accounts").Where("Username", Account).ExecuteScalar() > 0 && !File.Exists(World.GlobalCharactersPath + Name + ".chr"))
5435 {
5436 try
5437 {
5438 MemoryStream ms = new MemoryStream();
5439 BinaryWriter BW = new BinaryWriter(ms);
5440 BW.Write(Account);
5441 //uint Eid = (uint)Program.Rnd.Next(1000001, 19999999);
5442 //while (World.EIDS.Contains(Eid))
5443 //{
5444 // Eid = (uint)Program.Rnd.Next(1000001, 19999999);
5445 //}
5446 //World.EIDS.Add(Eid);
5447 //BW.Write(Eid);
5448
5449 if (!World.EIDS.Contains(UID))
5450 World.EIDS.Add(UID);
5451
5452 BW.Write(UID);
5453
5454 if (Body == 1003 || Body == 1004)
5455 BW.Write((ushort)1);//Avatar
5456 else
5457 BW.Write((ushort)201);//Avatar
5458
5459 BW.Write(Body);
5460 BW.Write((ushort)(410 + (Program.Rnd.Next(5) * 100)));//Hair
5461 BW.Write((uint)1010);//Map
5462 BW.Write((ushort)61);//X
5463 BW.Write((ushort)109);//Y
5464 BW.Write((uint)0);//Previous Map
5465 BW.Write(Job);
5466 BW.Write((byte)0);//Previous Job, 1st RB
5467 BW.Write((byte)1);//Level
5468 BW.Write((ulong)0);//Experience
5469
5470 ushort Str = 0, Agi = 0, Vit = 0, Spi = 0;
5471 GetInitialStats(Job, ref Str, ref Agi, ref Vit, ref Spi);
5472
5473 BW.Write(Str);
5474 BW.Write(Agi);
5475 BW.Write(Vit);
5476 BW.Write(Spi);
5477 BW.Write((ushort)0);//Stat Points
5478 ushort HP = (ushort)(Vit * 24 + Str * 3 + Agi * 3 + Spi * 3);
5479 BW.Write(HP);
5480 BW.Write((ushort)(Spi * 5));//MP
5481 BW.Write((uint)10000);//Silvers
5482 BW.Write((uint)0);//Warehouse Silvers
5483 BW.Write((ulong)0);//Virtue Points
5484 //here
5485 BW.Write((byte)0);//vip level
5486 BW.Write((byte)0);//vip days left
5487 BW.Write((byte)0);//reborns
5488 BW.Write((ushort)0);//Prize NPC DBScrolls
5489 BW.Write(DateTime.UtcNow.ToBinary());//time vip started
5490 BW.Write((byte)0);//vip level to get
5491 BW.Write((byte)0);//vip days to get
5492 BW.Write(false);
5493 BW.Write((int)0);
5494 BW.Write("0");
5495 BW.Write((ushort)0);//pumpkin points halloween
5496 BW.Write(false);//christmas hat received
5497 BW.Write((int)0);//christmas points
5498 BW.Write((uint)0);//flower points
5499 BW.Write((ushort)0);//treasure points
5500 BW.Write((ushort)0);//ctb points
5501 BW.Write(false);//warning
5502 BW.Write((byte)0);//metscrolls stored
5503 BW.Write((byte)0);//TopFB
5504 BW.Write((uint)0);//TopOnline
5505 BW.Write((ushort)0);//CurrentKills Cloudsaint
5506 BW.Write(new DateTime(1970, 1, 1).ToBinary());//VIP Time
5507 //endhere
5508 BW.Write((ulong)0);//Donation
5509 BW.Write((uint)0);//CPs
5510 BW.Write((ushort)0);//PK Points
5511 BW.Write((ushort)0);//Guild
5512 BW.Write((uint)0);//Guild Donation
5513 BW.Write((byte)0);//Guild Rank
5514 Equipment Eq = new Equipment();
5515 Eq.Open();
5516 Eq.WriteThis(BW);
5517 #region Beginner Items
5518 if (Job == 100)
5519 {
5520 BW.Write((byte)12);//Inventory Count
5521 Item I = new Item();
5522 I.ID = 421301;
5523 I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)421301]).Durability;
5524 I.CurDur = I.MaxDur;
5525 I.UID = (uint)Program.Rnd.Next(10000000);
5526 I.WriteThis(BW);//1 item
5527 I.ID = 1001000;
5528 for (int i = 0; i < 5; i++)
5529 {
5530 I.UID = (uint)Program.Rnd.Next(10000000);
5531 I.WriteThis(BW);//5 items
5532 }
5533 }
5534 else if (Job == 20 || Job == 10)
5535 {
5536 BW.Write((byte)7);//Inventory Count
5537 Item I = new Item();
5538 I.ID = 410401;
5539 I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)410301]).Durability;
5540 I.CurDur = I.MaxDur;
5541 I.UID = (uint)Program.Rnd.Next(10000000);
5542 I.WriteThis(BW);//1 item
5543 }
5544 else
5545 {
5546 BW.Write((byte)12);//Inventory Count
5547 Item I = new Item();
5548 I.ID = 500301;
5549 I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)500301]).Durability;
5550 I.CurDur = I.MaxDur;
5551 I.UID = (uint)Program.Rnd.Next(10000000);
5552 I.WriteThis(BW);//1 item
5553 I.ID = 1050000;
5554 I.MaxDur = ((DatabaseItem)DatabaseItems[(uint)1050000]).Durability;
5555 I.CurDur = I.MaxDur;
5556 for (int i = 0; i < 5; i++)
5557 {
5558 I.UID = (uint)Program.Rnd.Next(10000000);
5559 I.WriteThis(BW);//5 items
5560 }
5561 }
5562 Item Armor = new Item();
5563 Armor.ID = 132004;
5564 Armor.Color = (Item.ArmorColor)(Program.Rnd.Next(3, 9));
5565 Armor.MaxDur = ((DatabaseItem)DatabaseItems[(uint)132004]).Durability;
5566 Armor.CurDur = Armor.MaxDur;
5567 Armor.UID = (uint)Program.Rnd.Next(10000000);
5568 Armor.WriteThis(BW);//1 item
5569 Item Stancher = new Item();
5570 Stancher.ID = 1000000;
5571 for (int i = 0; i < 5; i++)//5 items
5572 {
5573 Stancher.UID = (uint)Program.Rnd.Next(10000000);
5574 Stancher.WriteThis(BW);
5575 }
5576 #endregion
5577 for (int n = 0; n < 9; n++)
5578 {
5579 BW.Write((byte)0);//WH[n] Count
5580 //Warehouse[n]
5581 }
5582 BW.Write((byte)0);//WH[6] Count
5583 //Warehouse[6]
5584
5585 BW.Write((byte)0);//Prof Count
5586
5587 if (Job != 100)
5588 BW.Write((byte)0);//SkillCount
5589 else
5590 {
5591 BW.Write((byte)2);//SkillCount
5592 Skill S = new Skill() { ID = 1000 };
5593 S.WriteThis(BW);
5594 S = new Skill() { ID = 1005 };
5595 S.WriteThis(BW);
5596 }
5597
5598 BW.Write((byte)0);//Friend Count
5599 BW.Write((byte)0);//Enemy Count
5600
5601
5602 // BW.Write(false);
5603 // BW.Write((int)0);
5604 // BW.Write((int)0);
5605 // BW.Write((long)0);
5606 // BW.Write((int)0);
5607 // BW.Write((byte)0);
5608 // BW.Write((byte)0);
5609 // BW.Write((byte)255);//Merchant
5610 BW.Write(DateTime.UtcNow.ToBinary());
5611 // BW.Write((ushort)0);
5612 // BW.Write(false);
5613 // BW.Write((byte)0);//lottery uses today
5614 // BW.Write("0");//WH Pass
5615 BW.Write("None");//Spouse Name
5616 // BW.Write((uint)0);//Quiz Pts
5617 BW.Write((int)0);//TopEffect
5618 BW.Write((byte)0);//job before any rb
5619 BW.Write(false);//botjailed
5620 BW.Write(false);//voted
5621 BW.Write(true);//passive skills
5622 BW.Write((byte)0);//botjailed days
5623 BW.Write(false);//muted?
5624 BW.Write((byte)0);//muted days
5625 BW.Write((byte)0);//prof count before reborning
5626 BW.Write((byte)0);//vote points
5627 BW.Write((byte)0);//skill count before rb
5628
5629 // BW.Write((byte)0);//trade reverse items
5630 // BW.Write(false);//get reversed items
5631
5632 BW.Write((int)0);//Classic Points
5633 BW.Write((byte)0);//BI_Quest active flag
5634 BW.Write((int)0);//BI_Quest_Kills killed
5635 BW.Write((byte)0);//BI_Quest_Completed count
5636
5637
5638 byte[] buffer = ms.ToArray();
5639 BW.Close();
5640 ms.Close();
5641 File.WriteAllBytes(World.GlobalCharactersPath + Name + ".chr", buffer);
5642 try
5643 {
5644 MySQL.MySqlCommand Cmd = new MySQL.MySqlCommand(MySQL.MySqlCommandType.ONDUPLICATEKEY).Insert("characters").Insert("UID", UID).Insert("Name", Name);
5645 Cmd.Execute();
5646 }
5647 catch (Exception e)
5648 {
5649 World.ExcAdd += e + "\r\n";
5650 Console.WriteLine(e);
5651 }
5652 //FileStream FS = new FileStream(World.GlobalAccountsPath + Account + ".usr", FileMode.Append);
5653 //BW = new BinaryWriter(FS);
5654 //BW.Write((byte)Name.Length);
5655 //BW.Write(Encoding.ASCII.GetBytes(Name));
5656
5657 //BW.Close();
5658 //FS.Close();
5659 Character C = LoadCharacter(Name, ref Account);
5660 if (C != null)
5661 {
5662 SaveCharacter(C, Account);
5663 }
5664 }
5665 catch (Exception E) { World.ExcAdd += E.ToString() + "\r\n"; return "Error! Try again."; }
5666 return "ANSWER_OK";
5667 }
5668 return "Error: Character already exists!";
5669
5670 }
5671 catch (Exception Exc) { World.ExcAdd += Exc.ToString() + "\r\n"; return "Failed to create the character."; }
5672 }
5673 //public static void RetrieveAccsOfEmail(string email)
5674 //{
5675 // string[] Paths = Directory.GetFiles(World.GlobalAccountsPath);
5676 // string Accs = "Accounts on e-mail " + email + " :";
5677 // foreach (string Path in Paths)
5678 // {
5679
5680 // try
5681 // {
5682 // if (Path.Remove(0, Path.Length - 4) == ".txt")
5683 // {
5684 // string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
5685 // string TxtEmail = File.ReadAllText(World.GlobalAccountsPath + Name + ".txt");
5686 // if (TxtEmail == email)
5687 // Accs += Name + "\r\n";
5688 // }
5689 // }
5690 // catch (Exception E)
5691 // {
5692 // World.ExcAdd += E.ToString() + "\r\n";
5693 // }
5694 // // System.Threading.Thread.Sleep(1);
5695 // }
5696 // Program.WriteGMChatLine(Accs);
5697 // System.Threading.Thread.CurrentThread.Abort();
5698 //}
5699 //public static void DeleteUnusedAccounts(object state)
5700 //{
5701 // string[] Paths = Directory.GetFiles(World.GlobalAccountsPath);
5702 // foreach (string Path in Paths)
5703 // {
5704 // string Name = "";
5705 // try
5706 // {
5707 // if (Path.Remove(0, Path.Length - 4) == ".usr")
5708 // {
5709 // Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
5710 // byte[] buffer = File.ReadAllBytes(World.GlobalAccountsPath + Name + ".usr");
5711 // MemoryStream ms = new MemoryStream(buffer);
5712 // BinaryReader BR = new BinaryReader(ms);
5713 // Main.PassCrypto.EncryptPassword(Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte())));
5714 // Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
5715
5716 // string Character = "";
5717 // if (BR.BaseStream.Position != BR.BaseStream.Length)
5718 // {
5719 // byte len = BR.ReadByte();
5720 // Character = Encoding.ASCII.GetString(BR.ReadBytes(len));
5721 // }
5722 // BR.Close();
5723 // ms.Close();
5724 // if (Character.Length == 0)
5725 // {
5726 // try
5727 // {
5728
5729 // File.Delete(World.GlobalAccountsPath + Name + ".usr");
5730 // if (File.Exists(World.GlobalAccountsPath + Name + ".txt"))
5731 // File.Delete(World.GlobalAccountsPath + Name + ".txt");
5732 // Console.WriteLine(Name + " deleted!");
5733 // }
5734 // catch { Console.WriteLine(Name + " not deleted!"); }
5735
5736
5737 // }
5738
5739
5740 // }
5741 // }
5742 // catch (Exception E)
5743 // {
5744 // World.ExcAdd += E.ToString() + "\r\n";
5745 // try
5746 // {
5747
5748 // File.Delete(World.GlobalAccountsPath + Name + ".usr");
5749 // if (File.Exists(World.GlobalAccountsPath + Name + ".txt"))
5750 // File.Delete(World.GlobalAccountsPath + Name + ".txt");
5751 // Console.WriteLine(Name + " deleted (bugged acc)!");
5752 // }
5753 // catch { Console.WriteLine(Name + " not deleted!"); }
5754 // Console.WriteLine(E.ToString());
5755 // }
5756 // // System.Threading.Thread.Sleep(1);
5757 // }
5758 // System.Threading.Thread.CurrentThread.Abort();
5759 //}
5760 //public static void Fill_EntityID_And_Fix(object state)
5761 //{
5762 // Program.Reseting = true;
5763 // string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
5764 // World.EIDS = new List<uint>();
5765 // Console.WriteLine("Fill EntityIDs started");
5766 // foreach (string Path in Paths)
5767 // {
5768 // if (Path.Remove(0, Path.Length - 4) == ".chr")
5769 // {
5770 // try
5771 // {
5772 // string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
5773 // Character C;
5774 // C = World.CharacterFromName2(Name);
5775 // bool save = false;
5776 // if (C == null)
5777 // {
5778 // string Account = "";
5779 // C = LoadCharacter(Name, ref Account);
5780 // if (C != null)
5781 // {
5782 // while (World.EIDS.Contains(C.EntityID))
5783 // {
5784 // C.EntityID = (uint)Program.Rnd.Next(1000001, 19999999);
5785 // save = true;
5786 // }
5787 // World.EIDS.Add(C.EntityID);
5788 // if (save)
5789 // SaveCharacter(C, Account);
5790 // }
5791 // }
5792 // else
5793 // {
5794 // while (World.EIDS.Contains(C.EntityID))
5795 // {
5796 // C.EntityID = (uint)Program.Rnd.Next(1000001, 19999999);
5797 // }
5798 // World.EIDS.Add(C.EntityID);
5799 // }
5800 // }
5801 // catch (Exception e)
5802 // {
5803 // World.ExcAdd += e.ToString() + "\r\n";
5804 // }
5805
5806 // }
5807 // // System.Threading.Thread.Sleep(1);
5808 // }
5809 // string EIds = "";
5810 // foreach (uint I in World.EIDS)
5811 // EIds += I + " ";
5812 // EIds = EIds.Remove(EIds.Length - 1);
5813 // if (!System.IO.File.Exists("entityids.txt"))
5814 // System.IO.File.Create("entityids.txt").Close();
5815 // else
5816 // {
5817 // System.IO.File.Delete("entityids.txt");
5818 // System.IO.File.Create("entityids.txt").Close();
5819 // }
5820 // System.IO.File.WriteAllText("entityids.txt", EIds);
5821 // Program.Reseting = false;
5822 // Console.WriteLine("Fill EntityIDs ended!");
5823 // System.Threading.Thread.CurrentThread.Abort();
5824 //}
5825 /*public static Main.AuthWorker.AuthInfo Authenticate(string User, string Password)
5826 {
5827 Main.AuthWorker.AuthInfo Info = new Main.AuthWorker.AuthInfo();
5828 Info.Account = User;
5829 try
5830 {
5831 IniFile File = new IniFile("C:\\OldCODB\\Users\\" + User + ".usr");
5832 string RealAccount = File.ReadString("User", "account");
5833 if (User == RealAccount)
5834 {
5835 string RealPassword = File.ReadString("User", "password");
5836 RealPassword = Main.PassCrypto.EncryptPassword(RealPassword);
5837 if (RealPassword == Password)
5838 {
5839 Info.Status = File.ReadString("User", "status");
5840 Info.Character = File.ReadString("User", "character");
5841 if (Info.Character == "")
5842 Info.LogonType = 2;
5843 else
5844 Info.LogonType = 1;
5845 }
5846 else
5847 Info.LogonType = 255;
5848 }
5849 else
5850 Info.LogonType = 255;
5851 File.Close();
5852 }
5853 catch (Exception Exc) { World.ExcAdd += Exc.ToString() + "\r\n"; }
5854 return Info;
5855 }*/
5856 /* public static string ChangeCharacterName(string Name, string NewName)
5857 {
5858 if (!File.Exists(World.GlobalCharactersPath + NewName + ".chr"))
5859 {
5860 Character C = World.CharacterFromName(Name);
5861 if (C != null)
5862 {
5863 C.MyClient.LocalMessage(2000, "In order to change your character name you have to be offline!");
5864 return "Error Character Online";
5865 }
5866 else
5867 {
5868 string Acc="";
5869 C = LoadCharacter(Name,ref Acc);
5870 if (C != null)
5871 {
5872 C.Name = NewName;
5873 if (C.MyGuild != null)
5874 if (C.GuildRank == Features.GuildRank.GuildLeader)
5875 {
5876 Features.MemberInfo M = C.MyGuild.MembOfName(Name);
5877 C.MyGuild.Creator.MembName = NewName;
5878 if (M != null)
5879 {
5880 M.MembName = NewName;
5881 C.MyGuild.Creator = M;
5882 ((Hashtable)C.MyGuild.Members[(byte)100]).Remove(M.MembID);
5883 ((Hashtable)C.MyGuild.Members[(byte)100]).Add(M.MembID, M);
5884 }
5885 }
5886 // File.Create(World.GlobalCharactersPath + NewName + ".chr");
5887 File.Copy(World.GlobalCharactersPath + Name + ".chr", World.GlobalCharactersPath + NewName + ".chr");
5888 SaveCharacter(C, Acc);
5889 File.Delete(World.GlobalCharactersPath + Name + ".chr");
5890 byte[] buffer = File.ReadAllBytes(World.GlobalAccountsPath + Acc + ".usr");
5891 MemoryStream ms = new MemoryStream(buffer);
5892 BinaryReader BR = new BinaryReader(ms);
5893 string RealPassword = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
5894 string Status = Encoding.ASCII.GetString(BR.ReadBytes(BR.ReadByte()));
5895 string Character = "";
5896 if (BR.BaseStream.Position != BR.BaseStream.Length)
5897 {
5898 byte len = BR.ReadByte();
5899 Character = Encoding.ASCII.GetString(BR.ReadBytes(len));
5900 }
5901 BR.Close();
5902 ms.Close();
5903 ms = new MemoryStream();
5904 BinaryWriter BW = new BinaryWriter(ms);
5905 BW.Write(RealPassword);
5906 BW.Write(Status);
5907 BW.Write((byte)NewName.Length);
5908 BW.Write(Encoding.ASCII.GetBytes(NewName));
5909 buffer = ms.ToArray();
5910 File.WriteAllBytes(World.GlobalAccountsPath + Acc + ".usr", buffer);
5911
5912 BW.Close();
5913 ms.Close();
5914 return "OK";
5915 }
5916 else return "Error Character " + Name + " Does Not Exist";
5917 }
5918 }
5919 else return "Error New Name Character Exists";
5920 // return "Error";
5921 }*/
5922 //public static void CheckFlowersOnPlayers(uint amount)
5923 //{
5924 // Console.WriteLine("Checking flowers on chars...");
5925 // Program.Reseting = true;
5926 // string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
5927 // List<Character> Gold = new List<Character>();
5928
5929 // foreach (string Path in Paths)
5930 // {
5931 // if (Path.Remove(0, Path.Length - 4) == ".chr")
5932 // {
5933 // try
5934 // {
5935 // string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
5936 // Character C;
5937 // C = World.CharacterFromName2(Name);
5938 // if (C == null)
5939 // {
5940 // string Account = "";
5941 // C = LoadCharacter(Name, ref Account);
5942 // if (C != null)
5943 // {
5944 // if (C.Flowers >= amount)
5945 // {
5946 // Gold.Add(C);
5947 // /* World.DebugAdd += C.Name + " has silvers amount: " + (C.Silvers + C.WHSilvers) + "\r\n";
5948 // if (C.TreasurePoints > 0)
5949 // World.DebugAdd += C.Name + " has treasure points: " + C.TreasurePoints + "\r\n";
5950 // if (C.Flowers > 0)
5951 // World.DebugAdd += C.Name + " has flower points: " + C.Flowers + "\r\n";*/
5952 // }
5953 // }
5954 // }
5955 // else
5956 // {
5957 // if (C.Flowers >= amount)
5958 // Gold.Add(C);
5959 // /* if (C.Silvers >= amount)
5960 // World.DebugAdd += C.Name + " has silvers amount: " + C.Silvers + "\r\n"; */
5961 // }
5962
5963 // }
5964 // catch (Exception e)
5965 // {
5966 // World.ExcAdd += e.ToString() + "\r\n";
5967 // }
5968
5969 // }
5970 // // System.Threading.Thread.Sleep(1);
5971 // }
5972 // uint min; int pos_interchange;
5973 // int n = Gold.Count;
5974
5975 // while (n > 0)
5976 // {
5977 // Character C2 = (Character)Gold[0];
5978 // min = C2.Flowers;
5979 // pos_interchange = 0;
5980 // for (int i = 0; i < n; i++)
5981 // {
5982 // Character C = (Character)Gold[i];
5983 // if (C.Flowers < min)
5984 // {
5985 // min = C.Flowers;
5986 // pos_interchange = i;
5987 // C2 = C;
5988 // }
5989 // }
5990 // Gold[pos_interchange] = Gold[n - 1];
5991 // Gold[n - 1] = C2;
5992 // n--;
5993 // }
5994 // foreach (Character C in Gold)
5995 // {
5996
5997 // World.GMChatAdd += C.Name + " has flower points: " + C.Flowers + "\r\n";
5998 // }
5999 // Console.WriteLine("Finished checking flowers on chars.");
6000 // Program.Reseting = false;
6001 // System.Threading.Thread.CurrentThread.Abort();
6002 //}
6003 //public static void ResetGold(object state)
6004 //{
6005 // Console.WriteLine("Reseting gold on chars...");
6006 // Program.Reseting = true;
6007 // string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
6008 // foreach (string Path in Paths)
6009 // {
6010 // if (Path.Remove(0, Path.Length - 4) == ".chr")
6011 // {
6012 // try
6013 // {
6014 // string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
6015 // Character C;
6016 // C = World.CharacterFromName2(Name);
6017 // if (C == null)
6018 // {
6019 // string Account = "";
6020 // C = LoadCharacter(Name, ref Account);
6021 // if (C != null)
6022 // {
6023 // C.Silvers = 10000;
6024 // C.WHSilvers = 0;
6025 // if (C.VipLevel <= 3)
6026 // C.VipLevel = 4;
6027 // C.VIPDays += 7;
6028 // C.VIPStarted = DateTime.UtcNow;
6029
6030 // SaveCharacter(C, Account);
6031 // }
6032 // }
6033
6034 // }
6035 // catch (Exception e)
6036 // {
6037 // World.ExcAdd += e.ToString() + "\r\n";
6038 // }
6039
6040 // }
6041 // // System.Threading.Thread.Sleep(1);
6042 // }
6043 // Console.WriteLine("Finished reseting gold on chars.");
6044 // Program.Reseting = false;
6045 // System.Threading.Thread.CurrentThread.Abort();
6046 //}
6047 //public static void CheckTreasureOnPlayers(ushort amount)
6048 //{
6049 // Console.WriteLine("Checking treasure points on chars...");
6050 // Program.Reseting = true;
6051 // string[] Paths = Directory.GetFiles(World.GlobalCharactersPath);
6052 // List<Character> Gold = new List<Character>();
6053
6054 // foreach (string Path in Paths)
6055 // {
6056 // if (Path.Remove(0, Path.Length - 4) == ".chr")
6057 // {
6058 // try
6059 // {
6060 // string Name = Path.Substring(Path.LastIndexOf("\\") + 1, Path.LastIndexOf('.') - Path.LastIndexOf("\\") - 1);
6061 // Character C;
6062 // C = World.CharacterFromName2(Name);
6063 // if (C == null)
6064 // {
6065 // string Account = "";
6066 // C = LoadCharacter(Name, ref Account);
6067 // if (C != null)
6068 // {
6069 // if (C.TreasurePoints >= amount)
6070 // {
6071 // Gold.Add(C);
6072 // /* World.DebugAdd += C.Name + " has silvers amount: " + (C.Silvers + C.WHSilvers) + "\r\n";
6073 // if (C.TreasurePoints > 0)
6074 // World.DebugAdd += C.Name + " has treasure points: " + C.TreasurePoints + "\r\n";
6075 // if (C.Flowers > 0)
6076 // World.DebugAdd += C.Name + " has flower points: " + C.Flowers + "\r\n";*/
6077 // }
6078 // }
6079 // }
6080 // else
6081 // {
6082 // if (C.TreasurePoints >= amount)
6083 // Gold.Add(C);
6084 // /* if (C.Silvers >= amount)
6085 // World.DebugAdd += C.Name + " has silvers amount: " + C.Silvers + "\r\n"; */
6086 // }
6087
6088 // }
6089 // catch (Exception e)
6090 // {
6091 // World.ExcAdd += e.ToString() + "\r\n";
6092 // }
6093
6094 // }
6095 // // System.Threading.Thread.Sleep(1);
6096 // }
6097 // uint min; int pos_interchange;
6098 // int n = Gold.Count;
6099
6100 // while (n > 0)
6101 // {
6102 // Character C2 = (Character)Gold[0];
6103 // min = C2.TreasurePoints;
6104 // pos_interchange = 0;
6105 // for (int i = 0; i < n; i++)
6106 // {
6107 // Character C = (Character)Gold[i];
6108 // if (C.TreasurePoints < min)
6109 // {
6110 // min = C.TreasurePoints;
6111 // pos_interchange = i;
6112 // C2 = C;
6113 // }
6114 // }
6115 // Gold[pos_interchange] = Gold[n - 1];
6116 // Gold[n - 1] = C2;
6117 // n--;
6118 // }
6119 // foreach (Character C in Gold)
6120 // {
6121 // World.GMChatAdd += C.Name + " has treasure points: " + (C.TreasurePoints) + "\r\n";
6122 // }
6123 // Console.WriteLine("Finished checking treasure points on chars.");
6124 // Program.Reseting = false;
6125 // System.Threading.Thread.CurrentThread.Abort();
6126 //}
6127 }
6128 public class IniFile
6129 {
6130 public string path;
6131 public IniFile(string INIPath)
6132 {
6133 path = INIPath;
6134 if (File.Exists(path))
6135 {
6136 Read();
6137 }
6138 }
6139 public void Read()
6140 {
6141 #region IniSectionSelect
6142 string[] Lines = File.ReadAllLines(path);
6143 string Ssection = "";
6144 foreach (string Line in Lines)
6145 {
6146 if (Line.Length > 0)
6147 {
6148 if (Line[0] == '[' && Line[Line.Length - 1] == ']')
6149 {
6150 Ssection = Line;
6151 IniSectionStructure Section = new IniSectionStructure();
6152 Section.SectionName = Ssection;
6153 Section.Variables = new Dictionary<string, IniValueStructure>();
6154 Sections.Add(Ssection, Section);
6155 }
6156 else if (Line[0] == '/' && Line[1] == '/')
6157 continue;
6158 else
6159 {
6160 IniValueStructure IvS = new IniValueStructure();
6161 IvS.Variable = Line.Split('=')[0];
6162 IvS.Value = Line.Split('=')[1];
6163 IniSectionStructure Section = null;
6164 Sections.TryGetValue(Ssection, out Section);
6165 if (Section != null)
6166 {
6167 if (!Section.Variables.ContainsKey(IvS.Variable))
6168 Section.Variables.Add(IvS.Variable, IvS);
6169 }
6170 }
6171 }
6172 }
6173 #endregion
6174 }
6175 Dictionary<string, IniSectionStructure> Sections = new Dictionary<string, IniSectionStructure>();
6176 public void Close()
6177 {
6178 Sections.Clear();
6179 }
6180 public void Save()
6181 {
6182 string Text = "";
6183 foreach (IniSectionStructure Section in Sections.Values)
6184 {
6185 Text += Section.SectionName + "\r\n";
6186 foreach (IniValueStructure IVS in Section.Variables.Values)
6187 {
6188 Text += IVS.Variable + "=" + IVS.Value + "\r\n";
6189 }
6190 }
6191 if (File.Exists(path))
6192 {
6193 File.Delete(path);
6194 File.Create(path).Close();
6195 File.WriteAllText(path, Text);
6196 }
6197 else
6198 {
6199 File.Create(path).Close();
6200 File.WriteAllText(path, Text);
6201 }
6202 }
6203 class IniValueStructure
6204 {
6205 public string Variable;
6206 public string Value;
6207 }
6208 class IniSectionStructure
6209 {
6210 public Dictionary<string, IniValueStructure> Variables;
6211 public string SectionName;
6212 }
6213 private void IniWriteValue(string ssection, string Key, string Value)
6214 {
6215 string section = "[" + ssection + "]";
6216 IniSectionStructure _Section = null;
6217 Sections.TryGetValue(section, out _Section);
6218 if (_Section != null)
6219 {
6220 IniValueStructure IVS = null;
6221 _Section.Variables.TryGetValue(Key, out IVS);
6222 if (IVS != null)
6223 {
6224 if (IVS.Variable == Key)
6225 {
6226 IVS.Value = Value;
6227 }
6228 }
6229 else
6230 {
6231 _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
6232 }
6233 }
6234 else
6235 {
6236 _Section = new IniSectionStructure() { SectionName = section, Variables = new Dictionary<string, IniValueStructure>() };
6237 Sections.Add(section, _Section);
6238 IniValueStructure IVS = null;
6239 _Section.Variables.TryGetValue(Key, out IVS);
6240 if (IVS != null)
6241 {
6242 if (IVS.Variable == Key)
6243 {
6244 IVS.Value = Value;
6245 }
6246 }
6247 else
6248 {
6249 _Section.Variables.Add(Key, new IniValueStructure() { Value = Value, Variable = Key });
6250 }
6251 }
6252 }
6253
6254 #region Read
6255 public byte ReadByte(string Section, string Key)
6256 {
6257 string section = "[" + Section + "]";
6258 IniSectionStructure ISS = null;
6259 Sections.TryGetValue(section, out ISS);
6260 if (ISS != null)
6261 {
6262 IniValueStructure IVS = null;
6263 ISS.Variables.TryGetValue(Key, out IVS);
6264 if (IVS != null)
6265 return byte.Parse(IVS.Value);
6266 }
6267 return 0;
6268 }
6269 public sbyte ReadSbyte(string Section, string Key)
6270 {
6271 string section = "[" + Section + "]";
6272 IniSectionStructure ISS = null;
6273 Sections.TryGetValue(section, out ISS);
6274 if (ISS != null)
6275 {
6276 IniValueStructure IVS = null;
6277 ISS.Variables.TryGetValue(Key, out IVS);
6278 if (IVS != null)
6279 return sbyte.Parse(IVS.Value);
6280 }
6281 return 0;
6282 }
6283 public short ReadInt16(string Section, string Key)
6284 {
6285 string section = "[" + Section + "]";
6286 IniSectionStructure ISS = null;
6287 Sections.TryGetValue(section, out ISS);
6288 if (ISS != null)
6289 {
6290 IniValueStructure IVS = null;
6291 ISS.Variables.TryGetValue(Key, out IVS);
6292 if (IVS != null)
6293 return short.Parse(IVS.Value);
6294 }
6295 return 0;
6296 }
6297 public int ReadInt32(string Section, string Key)
6298 {
6299 string section = "[" + Section + "]";
6300 IniSectionStructure ISS = null;
6301 Sections.TryGetValue(section, out ISS);
6302 if (ISS != null)
6303 {
6304 IniValueStructure IVS = null;
6305 ISS.Variables.TryGetValue(Key, out IVS);
6306 if (IVS != null)
6307 return int.Parse(IVS.Value);
6308 }
6309 return 0;
6310 }
6311 public long ReadInt64(string Section, string Key)
6312 {
6313 string section = "[" + Section + "]";
6314 IniSectionStructure ISS = null;
6315 Sections.TryGetValue(section, out ISS);
6316 if (ISS != null)
6317 {
6318 IniValueStructure IVS = null;
6319 ISS.Variables.TryGetValue(Key, out IVS);
6320 if (IVS != null)
6321 return long.Parse(IVS.Value);
6322 }
6323 return 0;
6324 }
6325 public ushort ReadUInt16(string Section, string Key)
6326 {
6327 string section = "[" + Section + "]";
6328 IniSectionStructure ISS = null;
6329 Sections.TryGetValue(section, out ISS);
6330 if (ISS != null)
6331 {
6332 IniValueStructure IVS = null;
6333 ISS.Variables.TryGetValue(Key, out IVS);
6334 if (IVS != null)
6335 return ushort.Parse(IVS.Value);
6336 }
6337 return 0;
6338 }
6339 public uint ReadUInt32(string Section, string Key)
6340 {
6341 string section = "[" + Section + "]";
6342 IniSectionStructure ISS = null;
6343 Sections.TryGetValue(section, out ISS);
6344 if (ISS != null)
6345 {
6346 IniValueStructure IVS = null;
6347 ISS.Variables.TryGetValue(Key, out IVS);
6348 if (IVS != null)
6349 return uint.Parse(IVS.Value);
6350 }
6351 return 0;
6352 }
6353 public ulong ReadUInt64(string Section, string Key)
6354 {
6355 string section = "[" + Section + "]";
6356 IniSectionStructure ISS = null;
6357 Sections.TryGetValue(section, out ISS);
6358 if (ISS != null)
6359 {
6360 IniValueStructure IVS = null;
6361 ISS.Variables.TryGetValue(Key, out IVS);
6362 if (IVS != null)
6363 return ulong.Parse(IVS.Value);
6364 }
6365 return 0;
6366 }
6367 public double ReadDouble(string Section, string Key)
6368 {
6369 string section = "[" + Section + "]";
6370 IniSectionStructure ISS = null;
6371 Sections.TryGetValue(section, out ISS);
6372 if (ISS != null)
6373 {
6374 IniValueStructure IVS = null;
6375 ISS.Variables.TryGetValue(Key, out IVS);
6376 if (IVS != null)
6377 return double.Parse(IVS.Value);
6378 }
6379 return 0;
6380 }
6381 public float ReadFloat(string Section, string Key)
6382 {
6383 string section = "[" + Section + "]";
6384 IniSectionStructure ISS = null;
6385 Sections.TryGetValue(section, out ISS);
6386 if (ISS != null)
6387 {
6388 IniValueStructure IVS = null;
6389 ISS.Variables.TryGetValue(Key, out IVS);
6390 if (IVS != null)
6391 return float.Parse(IVS.Value);
6392 }
6393 return 0;
6394 }
6395 public string ReadString(string Section, string Key)
6396 {
6397 string section = "[" + Section + "]";
6398 IniSectionStructure ISS = null;
6399 Sections.TryGetValue(section, out ISS);
6400 if (ISS != null)
6401 {
6402 IniValueStructure IVS = null;
6403 ISS.Variables.TryGetValue(Key, out IVS);
6404 if (IVS != null)
6405 return IVS.Value;
6406 }
6407 return "";
6408 }
6409 public bool ReadBoolean(string Section, string Key)
6410 {
6411 string section = "[" + Section + "]";
6412 IniSectionStructure ISS = null;
6413 Sections.TryGetValue(section, out ISS);
6414 if (ISS != null)
6415 {
6416 IniValueStructure IVS = null;
6417 ISS.Variables.TryGetValue(Key, out IVS);
6418 if (IVS != null)
6419 return byte.Parse(IVS.Value) == 1 ? true : false; ;
6420 }
6421 return false;
6422 }
6423 #endregion
6424 #region Write
6425 public void WriteString(string Section, string Key, string Value)
6426 {
6427 IniWriteValue(Section, Key, Value);
6428 }
6429 public void WriteInteger(string Section, string Key, byte Value)
6430 {
6431 IniWriteValue(Section, Key, Value.ToString());
6432 }
6433 public void WriteInteger(string Section, string Key, ulong Value)
6434 {
6435 IniWriteValue(Section, Key, Value.ToString());
6436 }
6437 public void WriteInteger(string Section, string Key, double Value)
6438 {
6439 IniWriteValue(Section, Key, Value.ToString());
6440 }
6441 public void WriteInteger(string Section, string Key, long Value)
6442 {
6443 IniWriteValue(Section, Key, Value.ToString());
6444 }
6445 public void WriteInteger(string Section, string Key, float Value)
6446 {
6447 IniWriteValue(Section, Key, Value.ToString());
6448 }
6449 public void WriteBoolean(string Section, string Key, bool Value)
6450 {
6451 IniWriteValue(Section, Key, (Value == true ? 1 : 0).ToString());
6452 }
6453 #endregion
6454 }
6455}