Exemplo n.º 1
0
 internal void Start(SocketConnection.RouteReceivedDataCallback dataRouter)
 {
     this.mDataBuffer = new byte[1024];
     this.mDataReceivedCallback = new AsyncCallback(this.DataReceived);
     this.mDataSentCallback = new AsyncCallback(this.DataSent);
     this.mRouteReceivedDataCallback = dataRouter;
     this.WaitForData();
 }
Exemplo n.º 2
0
 internal void AddClient(uint uint_0, ref SocketConnection Message1_0)
 {
     this.Clients[(int)((UIntPtr)uint_0)] = new GameClient(uint_0, ref Message1_0);
     this.Clients[(int)((UIntPtr)uint_0)].GetSocketConnection();
 }
Exemplo n.º 3
0
 internal void DisposeConnection(SocketConnection connection)
 {
     if (!this.DisposeQueue.Contains(connection))
     {
         this.DisposeQueue.Add(connection);
     }
 }
Exemplo n.º 4
0
        public static void HandleRequest(string furniname, SocketConnection sConnection)
        {
            //This shit doesn't work.
            if (furniname.Contains("*"))
                furniname = furniname.Remove(furniname.IndexOf("*"));

            bool isHandled = false;
            if (!Directory.Exists("API\\" + furniname))
                Directory.CreateDirectory("API\\" + furniname);
            else if (File.Exists("API\\" + furniname + "\\" + furniname + ".png"))
            {
                sConnection.SendFile("API\\" + furniname + "\\" + furniname + ".png");
                return;
            }

            if (DownloadFurni(furniname))
            {
                try
                {
                    ProcessStartInfo startInfo2 = new ProcessStartInfo("swfdump.exe", "API\\" + furniname + "\\" + furniname + ".swf")
                    {
                        WindowStyle = ProcessWindowStyle.Hidden,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    };
                    bool isEnding = false;
                    Dictionary<string, string> fiiList = new Dictionary<string, string>();
                    Process process2 = Process.Start(startInfo2);
                    process2.OutputDataReceived += (sender, e) => ReadLine(e.Data, process2, fiiList, ref isEnding);
                    process2.BeginOutputReadLine();
                    process2.Start();
                    //Thread.Sleep(1000);
                    while (!isEnding)
                    {

                    }
                    process2.Close();
                    startInfo2 = new ProcessStartInfo("swfbinexport.exe", "API\\" + furniname + "\\" + furniname + ".swf")
                    {
                        WindowStyle = ProcessWindowStyle.Hidden,
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    };
                    process2 = Process.Start(startInfo2);
                    process2.BeginOutputReadLine();
                    process2.Start();
                    process2.WaitForExit();
                    process2.Close();
                    List<FurniImageAsset> fiaList = new List<FurniImageAsset>();
                    foreach (KeyValuePair<string, string> kvp in fiiList.ToList<KeyValuePair<string, string>>())
                    {
                        string fileend = ".png";

                        string kchar = "p";
                        if (kvp.Value.Contains("_assets"))// || kvp.Value.Contains("_visualization"))
                        {
                            XmlTextReader reader = new XmlTextReader("API\\" + furniname + "\\" + furniname + "-" + int.Parse(kvp.Key) + ".bin");
                            while (reader.Read())
                            {
                                if (reader.Name == "asset" && reader.NodeType == XmlNodeType.Element)
                                {

                                    FurniImageAsset fia = new FurniImageAsset("", 0, 0, furniname);
                                    while (reader.MoveToNextAttribute()) // Read the attributes.
                                    {
                                        if (reader.Name == "name")
                                            fia.Name = reader.Value;
                                        else if (reader.Name == "x")
                                            fia.X = int.Parse(reader.Value);
                                        else if (reader.Name == "y")
                                            fia.Y = int.Parse(reader.Value);
                                    }
                                    if (fia.Name != "" && fia.Name.Contains(furniname + "_64")&& File.Exists("API\\" + furniname +"\\" + furniname + "_" + fia.Name + ".png"))
                                        fiaList.Add(fia);
                                }
                            }
                        }
                        else if (kvp.Value.Contains("_" + furniname + "_64"))
                        {
                            startInfo2 = new ProcessStartInfo("swfextract.exe", "-" + kchar + " " + kvp.Key + " -o " + "API\\" + furniname + "\\" + kvp.Value + fileend + " API\\" + furniname + "\\" + furniname + ".swf")
                            {
                                WindowStyle = ProcessWindowStyle.Hidden,
                                UseShellExecute = false,
                                RedirectStandardOutput = true,
                                CreateNoWindow = true
                            };
                            process2 = Process.Start(startInfo2);
                            process2.BeginOutputReadLine();
                            process2.Start();
                            process2.WaitForExit();
                            process2.Close();
                        }
                    }
                    string direction = "0";
                    FurniImageAsset first = fiaList.First();
                    direction = first.Name.Substring(first.Name.LastIndexOf("_") - 1, 1);
                    FurniImageAsset biggest = fiaList.OrderByDescending(o=>o.Height).First();
                    
                    Bitmap bmp = new Bitmap(biggest.Width+  200, biggest.Height +200);
                    using (Graphics g = Graphics.FromImage(bmp))
                    {

                        //g.DrawImage(biggest.Image, 0, 0);
                        foreach (FurniImageAsset furniImageAsset in fiaList)
                        {
                            try
                            {
                                /*if(furniImageAsset.X == 30 && furniImageAsset.Y == 80)
                                    g.DrawImage(furniImageAsset.Image, new Rectangle(0, 0, furniImageAsset.Width, furniImageAsset.Height));
                                else*/
                                furniImageAsset.X = furniImageAsset.X == 30 ? 0 : furniImageAsset.X;
                                furniImageAsset.Y = furniImageAsset.Y == 80 ? 0 : furniImageAsset.Y;
                                if(furniImageAsset.Name.Substring(furniImageAsset.Name.LastIndexOf("_") -1,1) == direction)
                                    g.DrawImage(furniImageAsset.Image, new Rectangle(biggest.Width / 2 - furniImageAsset.Width / 2, furniImageAsset.X - (furniImageAsset.Y / 2), furniImageAsset.Width, furniImageAsset.Height));
                            }
                            catch { }
                        }
                    }
                    bmp.Save("API\\"+furniname + "\\"+furniname +".png", ImageFormat.Png);
                    sConnection.SendFile("API\\" + furniname + "\\" + furniname + ".png");
                }catch(Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                }
            }
            sConnection.SendFile("API//placeholder.png");
        }
Exemplo n.º 5
0
 public GameClient(uint id, ref SocketConnection connection)
 {
     this.Id = id;
     this.Connection = connection;
     this.CreateClientMessageHandler();
 }
Exemplo n.º 6
0
		public void Dispose()
		{
			if (this.Connection != null)
			{
				this.Connection.Close();
				this.Connection = null;
			}
			if (this.GetHabbo() != null)
			{
				this.Habbo.Dispose();
				this.Habbo = null;
			}
			if (this.GetClientMessageHandler() != null)
			{
				this.ClientMessageHandler.Destroy();
				this.ClientMessageHandler = null;
			}
		}