· 8 years ago · Mar 19, 2018, 03:44 PM
1using MySql.Data.MySqlClient;
2using System;
3using System.Collections.Generic;
4using System.Security.Cryptography;
5using System.Text;
6using System.Linq;
7using GoldTree.Core;
8using GoldTree.HabboHotel;
9using GoldTree.Net;
10using GoldTree.Storage;
11using GoldTree.Communication;
12using GoldTree.Messages;
13using System.Threading.Tasks;
14using System.Net;
15using System.Reflection;
16using System.Data;
17using GoldTree.WebSocket;
18namespace GoldTree
19{
20 internal sealed class GoldTree
21 {
22 public static readonly int build = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.Build;
23 public const string string_0 = "localhost";
24
25 private static PacketManager PacketManager;
26
27 private static ConfigurationData Configuration;
28
29 private static DatabaseManager DatabaseManager;
30 private static SocketsManager SocketsManager;
31 //private static ConnectionHandeling ConnectionManage;
32 private static MusListener MusListener;
33
34 private static Game Internal_Game;
35
36 internal static DateTime ServerStarted;
37
38 public string string_2 = GoldTree.smethod_1(14986.ToString());
39
40 public static bool bool_0 = false;
41 public static int int_1 = 0;
42 public static int int_2 = 0;
43 public static string string_5 = null;
44
45 private static bool bool_1 = false;
46 public static WebSocketServerManager webSocketManager;
47
48 public static List<string> UserAdMessage;
49 public static int UserAdType;
50 public static string UserAdLink;
51
52 // Unnötige Lottokacke, die eigentlich gar nicht hier sein sollte.
53
54 public static int hour_lastlotto = DateTime.Now.Hour;
55 public static double lotto_end = GoldTree.GetUnixTimestamp();
56 public static bool lotto = false;
57 public static int lottozahl = 999;
58 public static uint lottowinner = 0;
59
60
61 public static int lotto_einsatz;
62
63 // Unnötige Lottokacke ende.
64 public static int Build
65 {
66 get
67 {
68 return Build;
69 }
70 }
71
72
73 internal static Game Game
74 {
75 get
76 {
77 return GoldTree.Internal_Game;
78 }
79 set
80 {
81 GoldTree.Internal_Game = value;
82 }
83 }
84
85 public static string FilterText(string Input)
86 {
87 string lower = Input.ToLower();
88 if (lower.Contains("select") && lower.Contains("from") || lower.Contains("insert") && lower.Contains("into") || lower.Contains("update") && lower.Contains("users") && lower.Contains("rank") || (lower.Contains("drop table") || lower.Contains("truncate") || lower.Contains("delete")) || lower.Contains("char("))
89 return "";
90 return Input;
91 }
92
93 public static PacketManager GetPacketManager()
94 {
95 return GoldTree.PacketManager;
96 }
97
98 public static ConfigurationData GetConfig()
99 {
100 return Configuration;
101 }
102
103 public static DatabaseManager GetDatabase()
104 {
105 return DatabaseManager;
106 }
107
108 public static Encoding GetDefaultEncoding()
109 {
110 return Encoding.Default;
111 }
112
113 public static string Version
114 {
115 get
116 {
117 return "Unicorn Emulator v" + Assembly.GetExecutingAssembly().GetName().Version;
118 }
119 }
120 public static void Check()
121 {
122 try
123 {
124
125
126
127
128
129 Console.ForegroundColor = ConsoleColor.Green;
130 Console.WriteLine("Dieser Emulator ist signiert! Version: " + Assembly.GetExecutingAssembly().GetName().Version);
131 Console.ForegroundColor = ConsoleColor.Gray;
132 return;
133
134
135 }
136 catch
137 {
138 Console.ForegroundColor = ConsoleColor.Red;
139 Console.WriteLine("Unable to check for updates now...");
140 Console.ForegroundColor = ConsoleColor.Gray;
141 return;
142 }
143
144 }
145 public static Version getNewestVersion(int choose)
146 {
147 if (choose == 1)
148 {
149 try
150 {
151 var match = DownloadServerVersion();
152
153 var gitVersion = new Version(match);
154
155 return gitVersion;
156
157 }
158 catch (Exception)
159 {
160 return Assembly.GetExecutingAssembly().GetName().Version;
161 }
162 }
163 else
164 {
165 var match = "0.0.0.0";
166
167 var gitVersion = new Version(match);
168
169 return gitVersion;
170 }
171 }
172
173 public static string DownloadServerVersion()
174 {
175 using (var wC = new WebClient())
176 return
177 wC.DownloadString(
178 "https://raw.githubusercontent.com/Hazed1337/Unicorn/master/Eric");
179 }
180 public static SocketsManager GetSocketsManager()
181 {
182 return GoldTree.SocketsManager;
183 }
184
185 //public static ConnectionHandeling smethod_14()
186 //{
187 // return GoldTree.ConnectionManage;
188 //}
189
190 internal static Game GetGame()
191 {
192 return Internal_Game;
193 }
194
195 public static string smethod_0(string string_8)
196 {
197 MD5CryptoServiceProvider mD5CryptoServiceProvider = new MD5CryptoServiceProvider();
198 byte[] array = Encoding.UTF8.GetBytes(string_8);
199 array = mD5CryptoServiceProvider.ComputeHash(array);
200 StringBuilder stringBuilder = new StringBuilder();
201 byte[] array2 = array;
202 for (int i = 0; i < array2.Length; i++)
203 {
204 byte b = array2[i];
205 stringBuilder.Append(b.ToString("x2").ToLower());
206 }
207 string text = stringBuilder.ToString();
208 return text.ToUpper();
209 }
210
211 public static string smethod_1(string string_8)
212 {
213 byte[] bytes = Encoding.ASCII.GetBytes(string_8);
214 byte[] array = new SHA1Managed().ComputeHash(bytes);
215 string text = string.Empty;
216 byte[] array2 = array;
217 for (int i = 0; i < array2.Length; i++)
218 {
219 byte b = array2[i];
220 text += b.ToString("X2");
221 }
222 return text;
223 }
224 static string GetMd5Hash(MD5 md5Hash, string input)
225 {
226
227 // Convert the input string to a byte array and compute the hash.
228 byte[] data = md5Hash.ComputeHash(Encoding.UTF8.GetBytes(input));
229
230 // Create a new Stringbuilder to collect the bytes
231 // and create a string.
232 StringBuilder sBuilder = new StringBuilder();
233
234 // Loop through each byte of the hashed data
235 // and format each one as a hexadecimal string.
236 for (int i = 0; i < data.Length; i++)
237 {
238 sBuilder.Append(data[i].ToString("x2"));
239 }
240
241 // Return the hexadecimal string.
242 return sBuilder.ToString();
243 }
244
245 public void Initialize()
246 {
247 /******************************************************************
248 * Actually Developer:Momo, Robin ©
249 * Base of this Server: "Phoenix by Sojobo" & "Uber by Meth0d"
250 * Axed Scripting Vulnerability is here fixed!
251 * SQLi Vulnerabilities are here fixed
252 * Automatically RAM ( Memory ) usage downer!
253 * CPU = good
254 *
255 * Functions:
256 * - Freeze Works
257 * - new Look
258 * - WebSockets
259 *
260 * new Concepts:
261 * - Beziehungssystem
262 * - There are many new Commands and functions
263 * - There is a Advertisement Filter which blocks certain words and Hotel names
264 *
265 * Many Vulnerabilities which arent released are here fixed
266 * © Dieser Server gehört nur Affectum und hat die Basis vom Phoenix Emulator 3.11.0
267 * Alle Rechte vorbehalten bei Affectum 2016 ©
268 ******************************************************************/
269
270 GoldTree.ServerStarted = DateTime.Now;
271 Console.Title = "X Emulator wird gestartet..";
272 Console.SetWindowPosition(0, 0);
273 Console.SetWindowSize(115, 30);
274 Console.BackgroundColor = ConsoleColor.White;
275 Console.CursorVisible = false;
276 Console.Clear();
277 Console.ForegroundColor = ConsoleColor.Red;
278 /* try
279 {
280 MD5 md5Hash = MD5.Create();
281
282 GoldTree.Configuration = new ConfigurationData("config.conf");
283 string configlizens = GetMd5Hash(md5Hash, GoldTree.GetConfig().data["uni.lizens"]);
284 string configname = GetMd5Hash(md5Hash, GoldTree.GetConfig().data["uni.name"]);
285 if (configlizens != "fbe865d685324eedf56a7496d04c244b" || configname != "a1d95279670584b1c96e5dc9f277498e")
286 {
287 Logging.WriteLine("License failed ");
288 Logging.WriteLine("Press any key to shut down ...");
289 Console.ReadKey(true);
290 GoldTree.Close();
291 } */
292
293 Console.WriteLine();
294 Console.Clear();
295 Console.WriteLine(" ");
296 Console.ForegroundColor = ConsoleColor.DarkBlue;
297 Console.WriteLine(" ::: ::: :::::::::: :::: :::: ::: ::: ::: ::: ::::::::::: :::::::: ::::::::: ");
298 Console.WriteLine(" :+: :+: :+: +:+:+: :+:+:+ :+: :+: :+: :+: :+: :+: :+: :+: :+: :+: ");
299 Console.WriteLine(" +:+ +:+ +:+ +:+ +:+:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ +:+ ");
300 Console.WriteLine(" +#++:+ +#++:++# +#+ +:+ +#+ +#+ +:+ +#+ +#++:++#++: +#+ +#+ +:+ +#++:++#: ");
301 Console.WriteLine(" +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+ ");
302 Console.WriteLine(" #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# #+# ");
303 Console.WriteLine(" ### ### ########## ### ### ######## ########## ### ### ### ######## ### ### ");
304 Console.ForegroundColor = ConsoleColor.Gray;
305 Console.WriteLine("");
306 Console.WriteLine("");
307 Console.ForegroundColor = ConsoleColor.Black;
308 Console.WriteLine("__________________________________________________________________________________________________________________");
309 Console.WriteLine(" Dieser Emulator wurde ReHotel.AT angepasst. ");
310 Console.WriteLine();
311
312
313 Console.ForegroundColor = ConsoleColor.DarkCyan;
314 Console.WriteLine("Lotto gestartet! Nächste Ziehung um " + (hour_lastlotto+1) + ":00 Uhr");
315 Console.ResetColor();
316
317 Console.BackgroundColor = ConsoleColor.White;
318 try
319 {
320 DateTime now = DateTime.Now;
321 try
322 {
323 GoldTree.Configuration = new ConfigurationData("config.conf");
324
325
326 Check();
327
328 //Lookds = new Random().Next(Int32.MaxValue).ToString();
329
330 DatabaseServer dbServer = new DatabaseServer(GoldTree.GetConfig().data["db.hostname"], uint.Parse(GoldTree.GetConfig().data["db.port"]), GoldTree.GetConfig().data["db.username"], GoldTree.GetConfig().data["db.password"]);
331 Database database = new Database(GoldTree.GetConfig().data["db.name"], uint.Parse(GoldTree.GetConfig().data["db.pool.minsize"]), uint.Parse(GoldTree.GetConfig().data["db.pool.maxsize"]));
332 GoldTree.DatabaseManager = new DatabaseManager(dbServer, database);
333 }
334 catch
335 {
336 Logging.WriteLine("Der Emulator wurde falsch konfiguriert!");
337 Logging.WriteLine("Press any key to shut down ...");
338 Console.ReadKey(true);
339 GoldTree.Destroy();
340
341
342 }
343 try
344 {
345 using (DatabaseClient dbClient = GoldTree.GetDatabase().GetClient())
346 {
347 dbClient.ExecuteQuery("SET @@global.sql_mode= '';");
348 dbClient.ExecuteQuery("UPDATE users SET online = '0' WHERE online = '1' ");
349 dbClient.ExecuteQuery("UPDATE rooms SET users_now = '0' WHERE users_now > 0");
350
351 DataRow DataRow;
352 DataRow = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'fw_count'");
353
354 DataRow DataRow2;
355 DataRow2 = dbClient.ReadDataRow("SHOW COLUMNS FROM `items` WHERE field = 'extra_data'");
356
357 if (DataRow != null || DataRow2 != null)
358 {
359 if (DoYouWantContinue("Remember get backups before continue! Do you want continue? [Y/N]"))
360 {
361 if (DataRow != null)
362 {
363 Console.ForegroundColor = ConsoleColor.Red;
364 Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!");
365 Console.ForegroundColor = ConsoleColor.Gray;
366 Console.Write("Items werden geupdatet (Feuerwerke) ...");
367
368 dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_firework", int.MaxValue);
369 dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_firework` (`item_id` int(10) unsigned NOT NULL, `fw_count` int(10) NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;", int.MaxValue);
370 dbClient.ExecuteQuery("INSERT INTO items_firework SELECT Id, fw_count FROM items WHERE fw_count > 0;", int.MaxValue);
371 dbClient.ExecuteQuery("ALTER TABLE items DROP fw_count", int.MaxValue);
372
373 Console.WriteLine("Erfolgreich!");
374 }
375
376 if (DataRow2 != null)
377 {
378 Console.ForegroundColor = ConsoleColor.Red;
379 Console.WriteLine("UPDATING ITEMS POSSIBLY TAKE A LONG TIME! DONT SHUTDOWN EMULATOR! PLEASE WAIT!");
380 Console.ForegroundColor = ConsoleColor.Gray;
381 Console.Write("Items werden geupdatet (Extra data) ...");
382
383 dbClient.ExecuteQuery("DROP TABLE IF EXISTS items_extra_data", int.MaxValue);
384 dbClient.ExecuteQuery("CREATE TABLE IF NOT EXISTS `items_extra_data` (`item_id` int(10) unsigned NOT NULL, `extra_data` text NOT NULL, PRIMARY KEY (`item_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1;", int.MaxValue);
385 dbClient.ExecuteQuery("INSERT INTO items_extra_data SELECT Id, extra_data FROM items WHERE extra_data != '';", int.MaxValue);
386 dbClient.ExecuteQuery("ALTER TABLE items DROP extra_data", int.MaxValue);
387
388 Console.WriteLine("Erfolgreich!");
389 }
390
391 }
392 else
393 {
394 Console.BackgroundColor = ConsoleColor.White;
395 Logging.WriteLine("Press any key to shut down ...");
396 Console.ReadKey(true);
397 GoldTree.Destroy();
398 Logging.WriteLine("Press any key to close window ...");
399 Console.ReadKey(true);
400 Environment.Exit(0);
401 return;
402 }
403 }
404 }
405 //GoldTree.ConnectionManage.method_7();
406 GoldTree.Internal_Game.ContinueLoading();
407 }
408 catch { }
409 Console.BackgroundColor = ConsoleColor.White;
410
411 try
412 {
413 GoldTree.Internal_Game = new Game(int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]));
414 }
415 catch
416 {
417
418
419 Logging.WriteLine("Fehler bei den Permissions");
420 Logging.WriteLine("Press any key to shut down ...");
421 Console.ReadKey(true);
422 GoldTree.Destroy();
423
424 }
425
426 try
427 {
428 GoldTree.PacketManager = new PacketManager();
429
430 GoldTree.PacketManager.Handshake();
431
432 GoldTree.PacketManager.Messenger();
433
434 GoldTree.PacketManager.Navigator();
435
436 GoldTree.PacketManager.RoomsAction();
437 GoldTree.PacketManager.RoomsAvatar();
438 GoldTree.PacketManager.RoomsChat();
439 GoldTree.PacketManager.RoomsEngine();
440 GoldTree.PacketManager.RoomsFurniture();
441 GoldTree.PacketManager.RoomsPets();
442 GoldTree.PacketManager.RoomsPools();
443 GoldTree.PacketManager.RoomsSession();
444 GoldTree.PacketManager.RoomsSettings();
445
446 GoldTree.PacketManager.Catalog();
447 GoldTree.PacketManager.Marketplace();
448 GoldTree.PacketManager.Recycler();
449
450 GoldTree.PacketManager.Quest();
451
452 GoldTree.PacketManager.InventoryAchievements();
453 GoldTree.PacketManager.InventoryAvatarFX();
454 GoldTree.PacketManager.InventoryBadges();
455 GoldTree.PacketManager.InventoryFurni();
456 GoldTree.PacketManager.InventoryPurse();
457 GoldTree.PacketManager.InventoryTrading();
458
459 GoldTree.PacketManager.Avatar();
460 GoldTree.PacketManager.Users();
461 GoldTree.PacketManager.Register();
462
463 GoldTree.PacketManager.Help();
464
465 GoldTree.PacketManager.Sound();
466
467 GoldTree.PacketManager.Wired();
468
469 GoldTree.PacketManager.Jukebox();
470
471 GoldTree.PacketManager.FriendStream();
472
473 }
474 catch
475 {
476 Logging.WriteLine("Fehler bei wat weiß ich.");
477 Logging.WriteLine("Press any key to shut down ...");
478 Console.ReadKey(true);
479 GoldTree.Destroy();
480 }
481 try
482 {
483 GoldTree.webSocketManager = new WebSocketServerManager(GoldTree.GetConfig().data["websockets.url"]);
484 GoldTree.MusListener = new MusListener(GoldTree.GetConfig().data["mus.tcp.bindip"], int.Parse(GoldTree.GetConfig().data["mus.tcp.port"]), GoldTree.GetConfig().data["mus.tcp.allowedaddr"].Split(new char[] { ';' }), 20);
485 GoldTree.SocketsManager = new SocketsManager(GoldTree.GetConfig().data["game.tcp.bindip"], int.Parse(GoldTree.GetConfig().data["game.tcp.port"]), int.Parse(GoldTree.GetConfig().data["game.tcp.conlimit"]));
486 GoldTree.SocketsManager.method_3().method_0();
487 }
488 catch
489 {
490 Logging.WriteLine("MUS Verbindung fehlgeschlagen!");
491 Logging.WriteLine("Press any key to shut down ...");
492 Console.ReadKey(true);
493 GoldTree.Destroy();
494
495 }
496 TimeSpan timeSpan = DateTime.Now - now;
497 Logging.WriteLine(string.Concat(new object[]
498 {
499 "Unicorn -> BEREIT! (",
500 timeSpan.Seconds,
501 " s, ",
502 timeSpan.Milliseconds,
503 " ms)"
504 }));
505 Console.Beep();
506 }
507 catch (KeyNotFoundException KeyNotFoundException)
508 {
509 Logging.WriteLine("Failed to boot, key not found: " + KeyNotFoundException);
510 Logging.WriteLine("Press any key to shut down ...");
511 Console.ReadKey(true);
512 GoldTree.Destroy();
513 }
514
515 catch (InvalidOperationException ex)
516 {
517 Logging.WriteLine("Failed to initialize Unicorn: " + ex.Message);
518 Logging.WriteLine("Press any key to shut down ...");
519 Console.ReadKey(true);
520 GoldTree.Destroy();
521 }
522
523 // }
524 catch
525 {
526 Logging.WriteLine("Configuration not found ");
527 Logging.WriteLine("Press any key to shut down ...");
528 Console.ReadKey(true);
529 GoldTree.Destroy();
530 }
531 }
532
533 public static int StringToInt(string str)
534 {
535 return Convert.ToInt32(str);
536 }
537
538 public static bool StringToBoolean(string str)
539 {
540 return (str == "1" || str == "true");
541 }
542
543 public static string BooleanToString(bool b)
544 {
545 if (b)
546 return "1";
547 else
548 return "0";
549 }
550
551 public static int smethod_5(int int_3, int int_4)
552 {
553 RNGCryptoServiceProvider rNGCryptoServiceProvider = new RNGCryptoServiceProvider();
554 byte[] array = new byte[4];
555 rNGCryptoServiceProvider.GetBytes(array);
556 int seed = BitConverter.ToInt32(array, 0);
557 return new Random(seed).Next(int_3, int_4 + 1);
558 }
559
560 public static double GetUnixTimestamp()
561 {
562 return (DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds;
563 }
564
565 public static string FilterString(string str)
566 {
567 return DoFilter(str, false, false);
568 }
569
570 public static string DoFilter(string Input, bool bool_2, bool bool_3)
571 {
572 Input = Input.Replace(Convert.ToChar(1), ' ');
573 Input = Input.Replace(Convert.ToChar(2), ' ');
574 Input = Input.Replace(Convert.ToChar(9), ' ');
575 if (!bool_2)
576 {
577 Input = Input.Replace(Convert.ToChar(13), ' ');
578 }
579 if (bool_3)
580 {
581 Input = Input.Replace('\'', ' ');
582 }
583 return Input;
584 }
585
586 public static bool smethod_9(string string_8)
587 {
588 if (string.IsNullOrEmpty(string_8))
589 {
590 return false;
591 }
592 else
593 {
594 for (int i = 0; i < string_8.Length; i++)
595 {
596 if (!char.IsLetter(string_8[i]) && !char.IsNumber(string_8[i]))
597 {
598 return false;
599 }
600 }
601 return true;
602 }
603 }
604
605
606 public static void Destroy()
607 {
608 Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND);
609 Logging.WriteLine("Destroying Unicorn environment...");
610
611 if (GoldTree.GetGame() != null)
612 {
613 GoldTree.GetGame().ContinueLoading();
614 GoldTree.Internal_Game = null;
615 }
616
617 if (GoldTree.GetSocketsManager() != null)
618 {
619 Logging.WriteLine("Destroying connection manager.");
620 GoldTree.GetSocketsManager().method_3().method_2();
621 //GoldTree.smethod_14().Destroy();
622 GoldTree.GetSocketsManager().method_0();
623 GoldTree.SocketsManager = null;
624 }
625
626 if (GoldTree.GetDatabase() != null)
627 {
628 try
629 {
630 Logging.WriteLine("Destroying database manager.");
631 MySqlConnection.ClearAllPools();
632 GoldTree.DatabaseManager = null;
633 }
634 catch
635 {
636 }
637 }
638
639 Logging.WriteLine("Uninitialized successfully. Closing.");
640 }
641
642 internal static void smethod_17(string string_8)
643 {
644 try
645 {
646 ServerMessage Message = new ServerMessage(139u);
647 Message.AppendStringWithBreak(string_8);
648 GoldTree.GetGame().GetClientManager().BroadcastMessage(Message);
649 }
650 catch
651 {
652 }
653 }
654
655 internal static void Close()
656 {
657 GoldTree.Destroy("", true);
658 }
659
660 internal static void Destroy(string string_8, bool ExitWhenDone, bool waitExit = false)
661 {
662 Program.DeleteMenu(Program.GetSystemMenu(Program.GetConsoleWindow(), true), Program.SC_CLOSE, Program.MF_BYCOMMAND);
663
664 try
665 {
666 Internal_Game.StopGameLoop();
667 }
668 catch { }
669
670 try
671 {
672 if (GoldTree.GetPacketManager() != null)
673 {
674 GoldTree.GetPacketManager().Clear();
675 }
676 }
677 catch { }
678
679 if (string_8 != "")
680 {
681 if (GoldTree.bool_1)
682 {
683 return;
684 }
685 Console.WriteLine(string_8);
686 Logging.Disable();
687 GoldTree.smethod_17("ATTENTION:\r\nThe server is shutting down. All furniture placed in rooms/traded/bought after this message is on your own responsibillity.");
688 GoldTree.bool_1 = true;
689 Console.WriteLine("Server shutting down...");
690 try
691 {
692 GoldTree.Internal_Game.GetRoomManager().method_4();
693 }
694 catch
695 {
696 }
697 try
698 {
699 GoldTree.GetSocketsManager().method_3().method_1();
700 //GoldTree.smethod_14().Destroy();
701 GoldTree.GetGame().GetClientManager().CloseAll();
702 }
703 catch
704 {
705 }
706 try
707 {
708 Console.WriteLine("Destroying database manager.");
709 MySqlConnection.ClearAllPools();
710 GoldTree.DatabaseManager = null;
711 }
712 catch
713 {
714 }
715 Console.WriteLine("System disposed, goodbye!");
716 }
717 else
718 {
719 Logging.Disable();
720 GoldTree.bool_1 = true;
721 try
722 {
723 if (GoldTree.Internal_Game != null && GoldTree.Internal_Game.GetRoomManager() != null)
724 {
725 GoldTree.Internal_Game.GetRoomManager().UnloadAllRooms();
726 GoldTree.Internal_Game.GetRoomManager().method_4();
727 }
728 }
729 catch
730 {
731 }
732 try
733 {
734 if (GoldTree.GetSocketsManager() != null)
735 {
736 GoldTree.GetSocketsManager().method_3().method_1();
737 //GoldTree.smethod_14().Destroy();
738 GoldTree.GetGame().GetClientManager().CloseAll();
739 }
740 }
741 catch
742 {
743 }
744 if (SocketsManager != null)
745 {
746 //GoldTree.ConnectionManage.method_7();
747 }
748 if (GoldTree.Internal_Game != null)
749 {
750 GoldTree.Internal_Game.ContinueLoading();
751 }
752 Console.WriteLine(string_8);
753 }
754 if (ExitWhenDone)
755 {
756 if (waitExit)
757 {
758 Console.WriteLine("Press any key to exit..");
759 Console.ReadKey();
760 }
761
762 Environment.Exit(0);
763 }
764 }
765
766 public static bool CanBeDividedBy(int i, int j)
767 {
768 return i % j == 0;
769 }
770
771 public static DateTime TimestampToDate(double timestamp)
772 {
773 DateTime result = new DateTime(1970, 1, 1, 0, 0, 0, 0);
774
775 return result.AddSeconds(timestamp).ToLocalTime();
776 }
777
778
779 public static int[] IntToArray(string numbers)
780 {
781 string[] ColorList = numbers.Split(new char[]
782 {
783 '|'
784 });
785
786 var digits = new List<int>();
787
788 if (ColorList.Count() > 1)
789 {
790 for (int i = 0; i < ColorList.Count(); i++)
791 {
792 digits.Add(int.Parse(ColorList[i]));
793 }
794 }
795 else
796 {
797 digits.Add(int.Parse(ColorList[0]));
798 }
799
800 var arr = digits.ToArray();
801 Array.Reverse(arr);
802 return arr;
803 }
804
805 public static void RainbowText(string text, int[] colors, int color, int interval, int count, int maxcount, bool randomcolors, int lastcolor)
806 {
807 if (count > maxcount)
808 {
809 Console.ResetColor();
810 Console.BackgroundColor = ConsoleColor.White;
811 Console.Write("\r{0} ", text);
812 Console.WriteLine();
813 return;
814 }
815
816 count++;
817
818 if (randomcolors)
819 {
820 Random random = new Random();
821 int randomcolor = random.Next(1, 15);
822
823 while (lastcolor == randomcolor || randomcolor == 0)
824 {
825 randomcolor = random.Next(1, 15);
826 }
827
828 color = randomcolor;
829 }
830 else
831 {
832 if (colors.Count() > 1)
833 {
834 if (!(color >= 0 && color <= 15))
835 {
836 color = 0;
837 }
838
839 while (!colors.Contains(color) || lastcolor == color || (!(color >= 0 && color <= 15)))
840 {
841 color++;
842
843 if (!(color >= 0 && color <= 15))
844 {
845 color = 0;
846 }
847 }
848 }
849 else
850 {
851 color = colors[1];
852 }
853 }
854
855 if (color > 0 && color <= 15)
856 {
857 Console.ForegroundColor = (ConsoleColor)color;
858 Console.Write("\r{0} ", text);
859 Console.ResetColor();
860 Console.BackgroundColor = ConsoleColor.White;
861 lastcolor = color;
862 }
863
864 System.Threading.Thread.Sleep(interval);
865
866 RainbowText(text, colors, color, interval, count, maxcount, randomcolors, lastcolor);
867 }
868
869 public static bool DoYouWantContinue(string message)
870 {
871 Console.WriteLine(message);
872 ConsoleKeyInfo ConsoleKeyInfo = Console.ReadKey();
873 if (ConsoleKeyInfo.Key == ConsoleKey.Y)
874 {
875 return true;
876 }
877 else if (ConsoleKeyInfo.Key == ConsoleKey.N)
878 {
879 return false;
880 }
881 else
882 {
883 DoYouWantContinue(message);
884 }
885
886 return false;
887 }
888 public static WebSocketServerManager GetWebSocketManager()
889 {
890 return GoldTree.webSocketManager;
891 }
892
893
894 }
895}