static void Main(string[] args) { try { string mpath = string.Empty; if (args.Length > 0) { mpath = args[0]; } else { mpath = Files.GetMoviePath(); } file = new BynFile(mpath); file.Buffer.Position = 0; client = Client.OpenMC(Files.GetClientPath(file.TibiaVersion), null); } catch { System.Diagnostics.Process.GetCurrentProcess().Kill(); } client.WindowTitle = "BynaCam"; client.Exited += new EventHandler(client_Exited); StartServers(client); client.LoginCam("1", "1"); Timer titleTimer = new Timer(); titleTimer.Tick += new EventHandler(UpdateTitle); titleTimer.Interval = 500; titleTimer.Start(); Utilities.globalKeyboardHook gkh = new Utilities.globalKeyboardHook(); gkh.HookedKeys.Add(System.Windows.Forms.Keys.Up); gkh.HookedKeys.Add(System.Windows.Forms.Keys.Down); gkh.HookedKeys.Add(System.Windows.Forms.Keys.Left); gkh.HookedKeys.Add(System.Windows.Forms.Keys.Right); gkh.HookedKeys.Add(System.Windows.Forms.Keys.Pause); gkh.HookedKeys.Add(System.Windows.Forms.Keys.Back); gkh.KeyDown += new System.Windows.Forms.KeyEventHandler(delegate(object sender, KeyEventArgs e) { if (client.WindowHandle == WinApi.GetForegroundWindow()) //isactive { if (e.KeyCode == Keys.Right) { if (Player.speed == 50) { e.Handled = false; return; } Player.speed++; } if (e.KeyCode == Keys.Left) { if (Player.speed == 1) { e.Handled = false; return; } Player.speed--; } if (e.KeyCode == Keys.Up) { Player.speed = 50; e.Handled = false; } if (e.KeyCode == Keys.Down) { Player.speed = 1; e.Handled = false; } if (e.KeyCode == Keys.Pause && !Player.paused) { Player.paused = true; } else if (e.KeyCode == Keys.Pause && Player.paused) { Player.paused = false; } if (e.KeyCode == Keys.Back) { int ms = (int)Player.currentTime.TotalMilliseconds - (30 * 1000); if (ms <= 0) { ms = 0; } Player.GotoTime(TimeSpan.FromMilliseconds(ms)); } if (e.KeyCode == Keys.Left || e.KeyCode == Keys.Right || e.KeyCode == Keys.Down || e.KeyCode == Keys.Up || e.KeyCode == Keys.Pause) { UpdateTitle(null, null); } } e.Handled = true; }); System.Windows.Forms.Application.Run(); }
public static void ClientConnected(Server.GameServer stream) { BynFile file = Program.file; while (file.Buffer.Position < file.Buffer.Length) { if (makeFf && !ffReseted) { ffReseted = true; currentTime = TimeSpan.Zero; file.Buffer.Position = 0; } FileMessage msg = GetFileMessage(file.Buffer); switch (msg.id) { case MSG_ID.DELAY_ID: { int delay = BitConverter.ToInt32(msg.buffer, 0); if (makeFf) { currentTime += TimeSpan.FromMilliseconds(delay); if (ffTime > currentTime) { break; } else { makeFf = false; ffReseted = false; } } int newdelay = delay / (int)speed; int prevspeed = (int)speed; if (newdelay <= 2) { newdelay = 0; } while (prevspeed == speed) { if ((newdelay - 100) > 0) { newdelay -= 100; System.Threading.Thread.Sleep(100); } else { System.Threading.Thread.Sleep(newdelay); break; } } if (!makeFf) { currentTime += TimeSpan.FromMilliseconds(delay); } break; } case MSG_ID.PACKET_ID: { if (msg.buffer.Length == 0) { break; } while (paused) { System.Threading.Thread.Sleep(100); } try { stream.Send(msg.buffer); } catch { } break; } } } }