Advertisement
Guest User

Untitled

a guest
Mar 24th, 2016
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 15.79 KB | None | 0 0
  1. using Injection.Packets;
  2. using PlayUO;
  3. using PlayUO.Assets;
  4. using PlayUO.Profiles;
  5. using SallosLauncher;
  6. using SharpDX.Direct3D9;
  7. using System;
  8. using System.Collections;
  9. using System.Diagnostics;
  10. using System.Net;
  11. using System.Runtime.CompilerServices;
  12. using System.Threading;
  13. using System.Windows;
  14. using System.Windows.Forms;
  15. using Ultima.Data;
  16.  
  17. namespace Injection
  18. {
  19.     public sealed class Seed : Engine
  20.     {
  21.         public const uint Value = 3232235779;
  22.  
  23.         private static Injection.PacketHandlers Initializer
  24.         {
  25.             get;
  26.             set;
  27.         }
  28.  
  29.         internal static string Password
  30.         {
  31.             get;
  32.             set;
  33.         }
  34.  
  35.         internal static string Username
  36.         {
  37.             get;
  38.             set;
  39.         }
  40.  
  41.         static Seed()
  42.         {
  43.             Seed.Initializer = new Injection.PacketHandlers();
  44.         }
  45.  
  46.         public Seed()
  47.         {
  48.         }
  49.  
  50.         [STAThread]
  51.         private static void Initialize()
  52.         {
  53.             AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Engine.CurrentDomain_UnhandledException);
  54.             AppDomain.CurrentDomain.DomainUnload += new EventHandler((object o, EventArgs ea) => Music.Destroy());
  55.             try
  56.             {
  57.                 Engine.m_FileManager = new PlayUO.FileManager();
  58.                 if (Engine.m_FileManager.Error)
  59.                 {
  60.                     Engine.m_FileManager = null;
  61.                     GC.Collect();
  62.                     throw new InvalidOperationException("Unable to initialize file manager.");
  63.                 }
  64.                 Seed.MainA();
  65.             }
  66.             catch (Exception exception)
  67.             {
  68.                 Engine.HandleException(exception);
  69.                 throw;
  70.             }
  71.         }
  72.  
  73.         [STAThread]
  74.         public static new void Main(string[] args)
  75.         {
  76.             bool? nullable = (new MainWindow()).ShowDialog();
  77.             if ((nullable.GetValueOrDefault() ? false : nullable.HasValue))
  78.             {
  79.                 Environment.Exit(1);
  80.             }
  81.             string[] username = new string[] { "108.61.224.83", "2593", Seed.Username, Seed.Password };
  82.             args = username;
  83.             switch ((int)args.Length)
  84.             {
  85.                 case 0:
  86.                 {
  87.                     Seed.Print("Server address not set.");
  88.                     Seed.Print("Server port not set.");
  89.                     Seed.Print("Username not set.");
  90.                     Seed.Print("Password not set.", true);
  91.                     return;
  92.                 }
  93.                 case 1:
  94.                 {
  95.                     Seed.Print("Server port not set.");
  96.                     Seed.Print("Username not set.");
  97.                     Seed.Print("Password not set.", true);
  98.                     return;
  99.                 }
  100.                 case 2:
  101.                 {
  102.                     Seed.Print("Username not set.");
  103.                     Seed.Print("Password not set.", true);
  104.                     return;
  105.                 }
  106.                 case 3:
  107.                 {
  108.                     Seed.Print("Password not set.", true);
  109.                     return;
  110.                 }
  111.             }
  112.             string[] strArrays = new string[] { "-ticket", args[0], args[1], args[2], args[3] };
  113.             args = strArrays;
  114.             if (Seed.Verify(args))
  115.             {
  116.                 Seed.Parse(args);
  117.                 Seed.Initialize();
  118.             }
  119.         }
  120.  
  121.         private static void MainA()
  122.         {
  123.             if (Engine._ticket != null)
  124.             {
  125.                 uint num = 0;
  126.                 Engine.WantDirectory("data/");
  127.                 Engine.WantDirectory("data/ultima/");
  128.                 Engine.WantDirectory("data/ultima/logs/");
  129.                 PlayUO.Debug.Trace("Entered Main()");
  130.                 PlayUO.Debug.Block("Environment");
  131.                 PlayUO.Debug.Trace("Operating System = '{0}'", Environment.OSVersion);
  132.                 PlayUO.Debug.Trace(".NET Framework   = '{0}'", Environment.Version);
  133.                 PlayUO.Debug.Trace("Base Directory   = '{0}'", Engine.m_FileManager.BasePath(""));
  134.                 PlayUO.Debug.Trace("Data Directory   = '{0}'", Engine.m_FileManager.ResolveMUL(""));
  135.                 PlayUO.Debug.EndBlock();
  136.                 Engine.m_Timers = new ArrayList();
  137.                 Engine.m_Journal = new ArrayList();
  138.                 Engine.m_Pings = new Queue();
  139.                 Engine.m_LoadQueue = new Queue();
  140.                 Engine.m_MapLoadQueue = new Queue();
  141.                 MacroHandlers.Setup();
  142.                 PlayUO.Debug.Block("Main()");
  143.                 Engine.m_ClickTimer = new PlayUO.Timer(new OnTick(Engine.ClickTimer_OnTick), SystemInformation.DoubleClickTime);
  144.                 PlayUO.Debug.Try("Initializing Display");
  145.                 Engine.m_Display = new Display();
  146.                 Preferences.Current.Layout.Apply(false);
  147.                 Engine.m_Display.KeyPreview = true;
  148.                 Engine.m_Display.Show();
  149.                 Preferences.Current.Layout.Apply(false);
  150.                 Preferences.Current.Layout.Update();
  151.                 PlayUO.Debug.EndTry();
  152.                 System.Windows.Forms.Application.DoEvents();
  153.                 PlayUO.Debug.Block("Initializing DirectX");
  154.                 Engine.InitDX();
  155.                 PlayUO.Debug.EndBlock();
  156.                 Engine.m_Loading = true;
  157.                 Engine.m_Ingame = false;
  158.                 PlayUO.Cursor.Hourglass = true;
  159.                 Engine.DrawNow();
  160.                 PlayUO.Debug.TimeBlock("Initializing Animations");
  161.                 Engine.m_Animations = new Animations();
  162.                 PlayUO.Debug.EndBlock();
  163.                 Engine.m_Font = new PlayUO.Font[10];
  164.                 Engine.m_UniFont = new UnicodeFont[3];
  165.                 PlayUO.Debug.TimeBlock("Initializing Gumps");
  166.                 Engine.m_Gumps = new Gumps();
  167.                 PlayUO.Debug.EndBlock();
  168.                 Engine.m_DefaultFont = Engine.GetUniFont(3);
  169.                 Engine.m_DefaultHue = Hues.Load(946);
  170.                 Renderer.SetText("");
  171.                 Macros.Reset();
  172.                 Engine.LoadParticles();
  173.                 Renderer.FilterEnable = false;
  174.                 Renderer.SetTexture(Engine.m_Rain);
  175.                 try
  176.                 {
  177.                     Engine.m_Device.ValidateDevice(1);
  178.                 }
  179.                 catch (Exception exception1)
  180.                 {
  181.                     Exception exception = exception1;
  182.                     Engine.m_Rain.Dispose();
  183.                     Engine.m_Rain = PlayUO.Texture.Empty;
  184.                     Engine.m_SkillUp.Dispose();
  185.                     Engine.m_SkillUp = Hues.Default.GetGump(2435);
  186.                     Engine.m_SkillDown.Dispose();
  187.                     Engine.m_SkillDown = Hues.Default.GetGump(2437);
  188.                     Engine.m_SkillLocked.Dispose();
  189.                     Engine.m_SkillLocked = Hues.Default.GetGump(2092);
  190.                     Engine.m_Slider.Dispose();
  191.                     Engine.m_Slider = Hues.Default.GetGump(2117);
  192.                     for (int i = 0; i < (int)Engine.m_Snow.Length; i++)
  193.                     {
  194.                         Engine.m_Snow[i].Dispose();
  195.                         Engine.m_Snow[i] = PlayUO.Texture.Empty;
  196.                     }
  197.                     for (int j = 0; j < (int)Engine.m_Edge.Length; j++)
  198.                     {
  199.                         Engine.m_Edge[j].Dispose();
  200.                         Engine.m_Edge[j] = PlayUO.Texture.Empty;
  201.                     }
  202.                     PlayUO.Debug.Trace("ValidateDevice() failed on 32-bit textures");
  203.                     PlayUO.Debug.Error(exception);
  204.                 }
  205.                 Renderer.SetTexture(null);
  206.                 Engine.m_Effects = new PlayUO.Effects();
  207.                 Engine.m_Loading = false;
  208.                 PlayUO.Point client = Engine.m_Display.PointToClient(System.Windows.Forms.Cursor.Position);
  209.                 Engine.m_EventOk = true;
  210.                 Engine.MouseMove(Engine.m_Display, new MouseEventArgs(Control.MouseButtons, 0, client.X, client.Y, 0));
  211.                 Compression.CheckCache();
  212.                 Engine.Setup();
  213.                 Engine.MouseMoveQueue();
  214.                 Engine.m_EventOk = false;
  215.                 Preferences.Current.Layout.Update();
  216.                 Engine.DrawNow();
  217.                 Engine.m_MoveDelay = new TimeDelay(0f);
  218.                 Engine.m_LastOverCheck = new TimeDelay(0.1f);
  219.                 Engine.m_NewFrame = new TimeDelay(0.05f);
  220.                 Engine.m_SleepMode = new TimeDelay(7.5f);
  221.                 Engine.m_EventOk = true;
  222.                 bool flag = false;
  223.                 Animations.StartLoading();
  224.                 Engine.Unlock();
  225.                 DateTime now = DateTime.Now;
  226.                 int ticks = Engine.Ticks;
  227.                 bool flag1 = true;
  228.                 if (Animations.IsLoading)
  229.                 {
  230.                     do
  231.                     {
  232.                         Engine.DrawNow();
  233.                     }
  234.                     while (!Animations.WaitLoading());
  235.                 }
  236.                 PlayUO.Debug.Trace("Connecting to {0}:{1}", Engine._ticket._ipAddress, Engine._ticket._port);
  237.                 if (!Network.Connect(new LoginCrypto(num), new IPEndPoint(Engine._ticket._ipAddress, Engine._ticket._port)))
  238.                 {
  239.                     throw new InvalidOperationException("Unable to connect.");
  240.                 }
  241.                 Engine.m_ServerName = Engine._ticket._ipAddress.ToString();
  242.                 Network.Send(new PLoginSeedEx(Seed.Value));
  243.                 Network.Send(new Injection.Packets.PPE_Login(Seed.Username, Seed.Password));
  244.                 Engine.PingRequest(false);
  245.                 Compression.CheckCache();
  246.                 Stopwatch stopwatch = new Stopwatch();
  247.                 while (!Engine.exiting)
  248.                 {
  249.                     stopwatch.Start();
  250.                     Engine.m_SetTicks = false;
  251.                     int ticks1 = Engine.Ticks;
  252.                     Macros.Slice();
  253.                     ActionContext.InvokeQueue();
  254.                     if (Gumps.Invalidated)
  255.                     {
  256.                         if (Engine.m_LastMouseArgs != null)
  257.                         {
  258.                             Engine.MouseMove(Engine.m_Display, Engine.m_LastMouseArgs);
  259.                         }
  260.                         Gumps.Invalidated = false;
  261.                     }
  262.                     if (Engine.m_MouseMoved)
  263.                     {
  264.                         Engine.MouseMoveQueue();
  265.                     }
  266.                     if (Engine.m_NewFrame.ElapsedReset())
  267.                     {
  268.                         Renderer.m_Frames = Renderer.m_Frames + 1;
  269.                         Engine.m_Redraw = false;
  270.                         Renderer.Draw();
  271.                         stopwatch.Reset();
  272.                         stopwatch.Start();
  273.                     }
  274.                     else if (Engine.m_Redraw || Engine.m_PumpFPS || Engine.amMoving && Options.Current.SmoothWalk && Engine.IsMoving())
  275.                     {
  276.                         Engine.m_Redraw = false;
  277.                         Renderer.Draw();
  278.                         stopwatch.Reset();
  279.                         stopwatch.Start();
  280.                     }
  281.                     if (flag1 && Engine.m_Ingame && Party.State == PartyState.Joined && DateTime.Now >= now)
  282.                     {
  283.                         now = DateTime.Now + TimeSpan.FromSeconds(0.5);
  284.                         Network.Send(new Injection.Packets.PPE_QueryPartyLocs());
  285.                     }
  286.                     Thread.Sleep((World.Player == null || !World.Player.IsMoving ? 1 : 0));
  287.                     Engine.DoEvents();
  288.                     if (Engine.m_Ingame && !World.HasIdentified)
  289.                     {
  290.                         Mobile player = World.Player;
  291.                         if (player != null && !player.Flags[MobileFlag.Hidden])
  292.                         {
  293.                             player.OnSingleClick();
  294.                             World.HasIdentified = true;
  295.                         }
  296.                     }
  297.                     if (Network.Slice())
  298.                     {
  299.                         Network.Flush();
  300.                         Engine.TickTimers();
  301.                         if (Engine.amMoving && Engine.m_Ingame)
  302.                         {
  303.                             Engine.DoWalk(Engine.movingDir, false);
  304.                         }
  305.                         if (Engine.m_LoadQueue.Count > 0)
  306.                         {
  307.                             for (int k = 0; Engine.m_LoadQueue.Count > 0 && k < 6; k++)
  308.                             {
  309.                                 ((ILoader)Engine.m_LoadQueue.Dequeue()).Load();
  310.                             }
  311.                         }
  312.                         if (Engine.m_MapLoadQueue.Count <= 0)
  313.                         {
  314.                             continue;
  315.                         }
  316.                         Engine.Preload((Worker)Engine.m_MapLoadQueue.Dequeue());
  317.                     }
  318.                     else
  319.                     {
  320.                         flag = true;
  321.                         break;
  322.                     }
  323.                 }
  324.                 PlayUO.Profiles.Config.Current.Save();
  325.                 Thread.Sleep(5);
  326.                 if (Engine.m_Display != null && !Engine.m_Display.IsDisposed)
  327.                 {
  328.                     Engine.m_Display.Hide();
  329.                 }
  330.                 Thread.Sleep(5);
  331.                 System.Windows.Forms.Application.DoEvents();
  332.                 Thread.Sleep(5);
  333.                 System.Windows.Forms.Application.DoEvents();
  334.                 Engine.m_Animations.Dispose();
  335.                 if (Engine.m_ItemArt != null)
  336.                 {
  337.                     Engine.m_ItemArt.Dispose();
  338.                 }
  339.                 if (Engine.m_LandArt != null)
  340.                 {
  341.                     Engine.m_LandArt.Dispose();
  342.                 }
  343.                 if (Engine.m_TextureArt != null)
  344.                 {
  345.                     Engine.m_TextureArt.Dispose();
  346.                 }
  347.                 Engine.m_Gumps.Dispose();
  348.                 if (Engine.m_Sounds != null)
  349.                 {
  350.                     Engine.m_Sounds.Dispose();
  351.                 }
  352.                 if (Engine.m_Multis != null)
  353.                 {
  354.                     Engine.m_Multis.Dispose();
  355.                 }
  356.                 Engine.m_FileManager.Dispose();
  357.                 PlayUO.Cursor.Dispose();
  358.                 Music.Dispose();
  359.                 Hues.Dispose();
  360.                 GRadar.Dispose();
  361.                 if (Engine._imageCache != null)
  362.                 {
  363.                     Engine._imageCache.Dispose();
  364.                     Engine._imageCache = null;
  365.                 }
  366.                 if (Engine.m_Rain != null)
  367.                 {
  368.                     Engine.m_Rain.Dispose();
  369.                     Engine.m_Rain = null;
  370.                 }
  371.                 if (Engine.m_Slider != null)
  372.                 {
  373.                     Engine.m_Slider.Dispose();
  374.                     Engine.m_Slider = null;
  375.                 }
  376.                 if (Engine.m_SkillUp != null)
  377.                 {
  378.                     Engine.m_SkillUp.Dispose();
  379.                     Engine.m_SkillUp = null;
  380.                 }
  381.                 if (Engine.m_SkillDown != null)
  382.                 {
  383.                     Engine.m_SkillDown.Dispose();
  384.                     Engine.m_SkillDown = null;
  385.                 }
  386.                 if (Engine.m_SkillLocked != null)
  387.                 {
  388.                     Engine.m_SkillLocked.Dispose();
  389.                     Engine.m_SkillLocked = null;
  390.                 }
  391.                 if (Engine.m_Snow != null)
  392.                 {
  393.                     for (int l = 0; l < 12; l++)
  394.                     {
  395.                         if (Engine.m_Snow[l] != null)
  396.                         {
  397.                             Engine.m_Snow[l].Dispose();
  398.                             Engine.m_Snow[l] = null;
  399.                         }
  400.                     }
  401.                     Engine.m_Snow = null;
  402.                 }
  403.                 if (Engine.m_Edge != null)
  404.                 {
  405.                     for (int m = 0; m < 8; m++)
  406.                     {
  407.                         if (Engine.m_Edge[m] != null)
  408.                         {
  409.                             Engine.m_Edge[m].Dispose();
  410.                             Engine.m_Edge[m] = null;
  411.                         }
  412.                     }
  413.                     Engine.m_Edge = null;
  414.                 }
  415.                 if (Engine.m_WinScrolls != null)
  416.                 {
  417.                     for (int n = 0; n < (int)Engine.m_WinScrolls.Length; n++)
  418.                     {
  419.                         if (Engine.m_WinScrolls[n] != null)
  420.                         {
  421.                             Engine.m_WinScrolls[n].Dispose();
  422.                             Engine.m_WinScrolls[n] = null;
  423.                         }
  424.                     }
  425.                     Engine.m_WinScrolls = null;
  426.                 }
  427.                 if (Engine.m_FormX != null)
  428.                 {
  429.                     Engine.m_FormX.Dispose();
  430.                     Engine.m_FormX = null;
  431.                 }
  432.                 if (Engine.m_Font != null)
  433.                 {
  434.                     for (int o = 0; o < 10; o++)
  435.                     {
  436.                         if (Engine.m_Font[o] != null)
  437.                         {
  438.                             Engine.m_Font[o].Dispose();
  439.                             Engine.m_Font[o] = null;
  440.                         }
  441.                     }
  442.                     Engine.m_Font = null;
  443.                 }
  444.                 if (Engine.m_UniFont != null)
  445.                 {
  446.                     int length = (int)Engine.m_UniFont.Length;
  447.                     for (int p = 0; p < length; p++)
  448.                     {
  449.                         if (Engine.m_UniFont[p] != null)
  450.                         {
  451.                             Engine.m_UniFont[p].Dispose();
  452.                             Engine.m_UniFont[p] = null;
  453.                         }
  454.                     }
  455.                     Engine.m_UniFont = null;
  456.                 }
  457.                 if (Engine.m_MidiTable != null)
  458.                 {
  459.                     Engine.m_MidiTable.Dispose();
  460.                     Engine.m_MidiTable = null;
  461.                 }
  462.                 if (Engine.m_ContainerBoundsTable != null)
  463.                 {
  464.                     Engine.m_ContainerBoundsTable.Dispose();
  465.                     Engine.m_ContainerBoundsTable = null;
  466.                 }
  467.                 PlayUO.Texture.DisposeAll();
  468.                 PlayUO.Debug.EndBlock();
  469.                 if (flag)
  470.                 {
  471.                     PlayUO.Debug.Trace("Network error caused termination");
  472.                 }
  473.                 Network.Close();
  474.                 PlayUO.Debug.Dispose();
  475.                 Speech.Dispose();
  476.                 Map.Shutdown();
  477.                 Archives.Shutdown();
  478.                 Engine.m_LoadQueue = null;
  479.                 Engine.m_MapLoadQueue = null;
  480.                 Engine.m_DefaultFont = null;
  481.                 Engine.m_DefaultHue = null;
  482.                 Engine.m_Display = null;
  483.                 Engine.m_Encoder = null;
  484.                 Engine.m_Effects = null;
  485.                 Engine.m_Skills = null;
  486.                 Engine.m_Features = null;
  487.                 Engine.m_Animations = null;
  488.                 Engine.m_LandArt = null;
  489.                 Engine.m_TextureArt = null;
  490.                 Engine.m_ItemArt = null;
  491.                 Engine.m_Gumps = null;
  492.                 Engine.m_Sounds = null;
  493.                 Engine.m_Multis = null;
  494.                 Engine.m_FileManager = null;
  495.                 Engine.m_Display = null;
  496.                 Engine.m_Font = null;
  497.                 Engine.m_UniFont = null;
  498.                 Engine.m_Device = null;
  499.                 Engine.m_MoveDelay = null;
  500.                 Engine.m_Text = null;
  501.                 Engine.m_Font = null;
  502.                 Engine.m_UniFont = null;
  503.                 Engine.m_NewFrame = null;
  504.                 Engine.m_SleepMode = null;
  505.                 Engine.m_Timers = null;
  506.                 Engine.m_SkillsGump = null;
  507.                 Engine.m_JournalGump = null;
  508.                 Engine.m_Journal = null;
  509.                 Engine.m_FileManager = null;
  510.                 Engine.m_Encoder = null;
  511.                 Engine.m_DefaultFont = null;
  512.                 Engine.m_DefaultHue = null;
  513.                 Engine.m_Random = null;
  514.                 Engine._movementKeys = null;
  515.                 Engine.m_Prompt = null;
  516.                 Engine.m_Pings = null;
  517.                 Engine.m_PingTimer = null;
  518.                 Engine.m_MultiList = null;
  519.                 Engine.m_AllNames = null;
  520.                 Engine.m_LastOverCheck = null;
  521.                 Engine.m_LastMouseArgs = null;
  522.                 Engine.m_LastAttacker = null;
  523.             }
  524.         }
  525.  
  526.         private static void Parse(string[] args)
  527.         {
  528.             int length = (int)args.Length;
  529.             int num = 0;
  530.             while (num < length)
  531.             {
  532.                 int num1 = num;
  533.                 num = num1 + 1;
  534.                 if (!string.Equals(args[num1], "-ticket", StringComparison.OrdinalIgnoreCase))
  535.                 {
  536.                     continue;
  537.                 }
  538.                 if (Engine._ticket != null)
  539.                 {
  540.                     throw new InvalidOperationException("Authentication ticket already specified.");
  541.                 }
  542.                 if (num + 4 > (int)args.Length)
  543.                 {
  544.                     throw new InvalidOperationException("Malformed authentication ticket specified.");
  545.                 }
  546.                 Engine._ticket = new AuthenticationTicket();
  547.                 int num2 = num;
  548.                 num = num2 + 1;
  549.                 Engine._ticket._ipAddress = IPAddress.Parse(args[num2]);
  550.                 int num3 = num;
  551.                 num = num3 + 1;
  552.                 Engine._ticket._port = int.Parse(args[num3]);
  553.                 int num4 = num;
  554.                 num = num4 + 1;
  555.                 Seed.Username = args[num4];
  556.                 int num5 = num;
  557.                 num = num5 + 1;
  558.                 Seed.Password = args[num5];
  559.             }
  560.         }
  561.  
  562.         private static void Print(string message)
  563.         {
  564.             Seed.Print(message, false);
  565.         }
  566.  
  567.         private static void Print(string message, bool readKey)
  568.         {
  569.             Console.WriteLine("* {0}", message);
  570.             if (readKey)
  571.             {
  572.                 Console.ReadKey();
  573.             }
  574.         }
  575.  
  576.         private static bool Verify(string[] args)
  577.         {
  578.             if (args == null || (int)args.Length != 5)
  579.             {
  580.                 throw new ArgumentException("Invalid Arguments");
  581.             }
  582.             return true;
  583.         }
  584.     }
  585. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement