private void RetrieveRealmList() { Realm[] Realms; byte op = win.ReadByte(); UInt16 Length = win.ReadUInt16(); UInt32 Request = win.ReadUInt32(); UInt16 NumOfRealms = win.ReadUInt16(); Realms = new Realm[NumOfRealms]; for (int i = 0; i < NumOfRealms; i++) { if ((i + 1) % 10 == 0) { BoogieCore.Log(LogType.SystemDebug, "Retrieved realm {0} of {1}.", i + 1, NumOfRealms); } Realms[i].Type = win.ReadByte(); Realms[i].Color = win.ReadByte(); win.ReadByte(); // unk Realms[i].Name = win.ReadString(); Realms[i].Address = win.ReadString(); Realms[i].Population = win.ReadFloat(); Realms[i].NumChars = win.ReadByte(); Realms[i].Language = win.ReadByte(); Realms[i].Unk = win.ReadByte(); } byte Unk1 = win.ReadByte(); byte Unk2 = win.ReadByte(); BoogieCore.Log(LogType.SystemDebug, "Done."); String defaultRealm = BoogieCore.configFile.ReadString("Connection", "DefaultRealm"); if (defaultRealm != "") { foreach (Realm r in Realms) { if (r.Name.ToLower() == defaultRealm.ToLower()) { BoogieCore.Log(LogType.System, "Defaulting to realm {0}", defaultRealm); string[] address = r.Address.Split(':'); BoogieCore.Log(LogType.System, "Defaulting to realm {0} IP: {1} port: {2}", defaultRealm, address[0], address[1]); IPAddress WSAddr = IPAddress.Parse(address[0]);//Dns.GetHostEntry(address[0]).AddressList[0]; BoogieCore.Log(LogType.System, "IP: {0}", WSAddr.ToString()); int WSPort = Int32.Parse(address[1]); BoogieCore.ConnectToWorldServer(new IPEndPoint(WSAddr, WSPort)); return; } } } BoogieCore.Event(new Event(EventType.EVENT_REALMLIST, Time.GetTime(), Realms)); }
private void TeleportHandler(WoWReader wr) { float x, y, z, orient; byte mask = wr.ReadByte(); WoWGuid guid = new WoWGuid(mask, wr.ReadBytes(WoWGuid.BitCount8(mask))); wr.ReadUInt32(); // flags wr.ReadUInt32(); // time? wr.ReadByte(); // unk 2.3.0 wr.ReadSingle(); // unk2 x = wr.ReadSingle(); y = wr.ReadSingle(); z = wr.ReadSingle(); orient = wr.ReadSingle(); wr.ReadUInt16(); // unk3 wr.ReadByte(); // unk4 BoogieCore.Log(LogType.SystemDebug, "Got teleport to: {0} {1} {2} {3}", x, y, z, orient); BoogieCore.world.getPlayerObject().SetCoordinates(new Coordinate(x, y, z, orient)); WoWWriter ww = new WoWWriter(OpCode.MSG_MOVE_TELEPORT_ACK); ww.Write(BoogieCore.world.getPlayerObject().GUID.GetOldGuid()); Send(ww.ToArray()); SendMoveHeartBeat(BoogieCore.world.getPlayerObject().GetCoordinates()); }
private void Handle_InitialSpells(WoWReader wr) { byte unknown = wr.ReadByte(); // Dunno. wowd sends a 0. UInt16 count = wr.ReadUInt16(); SpellItem[] spellList = new SpellItem[count]; for (int i = 0; i < count; i++) { spellList[i].spellID = wr.ReadUInt16(); spellList[i].unknown = wr.ReadUInt16(); // 0xeeee } wr.ReadUInt16(); // Another 0 according to wowd. BoogieCore.Player.setSpells(spellList); }
private void Handle_ActionButtons(WoWReader wr) { ActionButton[] actionButtonList = new ActionButton[ActionBars.MaxButtons]; for (int i = 0; i < ActionBars.MaxButtons; i++) { actionButtonList[i].action = wr.ReadUInt16(); actionButtonList[i].type = wr.ReadByte(); actionButtonList[i].misc = wr.ReadByte(); } BoogieCore.Player.setActionBars(actionButtonList); }
private void decryptData(byte[] Data) { mCrypt.Decrypt(Data, mRecvCryptSize); #if (LOG) WoWReader wr = new WoWReader(Data); UInt16 Op2 = wr.ReadUInt16(); OpCode Op = (OpCode)Op2; int left = wr.Remaining; tw.Write("{"); tw.Write("SERVER"); tw.Write("}"); tw.WriteLine(" Packet: (0x{2:x4}) {1} PacketSize = {0} TimeStamp = 0", Data.Length, Op, Op2); tw.WriteLine("|------------------------------------------------|----------------|"); tw.WriteLine("|00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF|"); tw.WriteLine("|------------------------------------------------|----------------|"); Debug.DumpBuffer(wr.ReadRemaining(), left, tw); tw.WriteLine("-------------------------------------------------------------------"); tw.WriteLine(); tw.Flush(); #endif }
public void Send(byte[] Data) { #if (LOG) WoWReader wr = new WoWReader(Data); UInt16 Op2 = wr.ReadUInt16(); OpCode Op = (OpCode)Op2; int left = wr.Remaining; tw.Write("{"); tw.Write("CLIENT"); tw.Write("}"); tw.WriteLine(" Packet: (0x{2:x4}) {1} PacketSize = {0} TimeStamp = 0", Data.Length, Op, Op2); tw.WriteLine("|------------------------------------------------|----------------|"); tw.WriteLine("|00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F |0123456789ABCDEF|"); tw.WriteLine("|------------------------------------------------|----------------|"); Debug.DumpBuffer(wr.ReadRemaining(), left, tw); tw.WriteLine("-------------------------------------------------------------------"); tw.WriteLine(); tw.Flush(); #endif int Length = Data.Length; byte[] Packet = new byte[2 + Length]; Packet[0] = (byte)(Length >> 8); Packet[1] = (byte)(Length & 0xff); Data.CopyTo(Packet, 2); mCrypt.Encrypt(Packet, mSendCryptSize); try { mSocket.Send(Packet); } catch (SocketException e) { BoogieCore.Log(LogType.Error, "Unable to send packet! Error: {0}", e.Message); isRunning = false; } }
protected void processData(byte[] Data) { WoWReader wr = new WoWReader(Data); OpCode Op = (OpCode)wr.ReadUInt16(); BoogieCore.Log(LogType.NeworkComms, "Debugging packet for opcode: {0}", Op); SMSG_Debug(new WoWReader(Data)); try { switch (Op) { case OpCode.SMSG_AUTH_CHALLENGE: Handle_AuthRequest(wr); break; case OpCode.SMSG_AUTH_RESPONSE: Handle_AuthResponse(wr); break; case OpCode.SMSG_CHAR_ENUM: Handle_CharEnum(wr); break; case OpCode.SMSG_WARDEN_DATA: // Warden was figured out. but I won't give it out. GL break; case OpCode.SMSG_ACCOUNT_DATA_MD5: WoWWriter ww = new WoWWriter(OpCode.CMSG_UPDATE_ACCOUNT_DATA); ww.Write(0x00000002); ww.Write((UInt32)0); Send(ww.ToArray()); break; case OpCode.SMSG_PONG: { UInt32 Server_Seq = wr.ReadUInt32(); if (Server_Seq == Ping_Seq) { Ping_Res_Time = MM_GetTime(); Latency = Ping_Res_Time - Ping_Req_Time; Ping_Seq += 1; //BoogieCore.Log(LogType.NeworkComms, "Got pong'd with a latency of: {0} sequence: {1}", Latency, Server_Seq); } else { BoogieCore.Log(LogType.Error, "Server pong'd bad sequence! Ours: {0} Theirs: {1}", Ping_Seq, Server_Seq); } break; } case OpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE: BoogieCore.Log(LogType.NeworkComms, "Got Item Response"); break; case OpCode.SMSG_SET_PROFICIENCY: break; case OpCode.MSG_MOVE_HEARTBEAT: case OpCode.MSG_MOVE_START_TURN_RIGHT: case OpCode.MSG_MOVE_STOP: case OpCode.MSG_MOVE_START_TURN_LEFT: case OpCode.MSG_MOVE_START_FORWARD: case OpCode.MSG_MOVE_START_BACKWARD: case OpCode.MSG_MOVE_STOP_TURN: case OpCode.MSG_MOVE_START_STRAFE_LEFT: case OpCode.MSG_MOVE_START_STRAFE_RIGHT: case OpCode.MSG_MOVE_STOP_STRAFE: case OpCode.MSG_MOVE_FALL_LAND: case OpCode.MSG_MOVE_JUMP: case OpCode.MSG_MOVE_SET_FACING: MovementHandler(wr); break; case OpCode.SMSG_EMOTE: break; case OpCode.SMSG_WEATHER: break; case OpCode.MSG_MOVE_TELEPORT_ACK: TeleportHandler(wr); break; case OpCode.SMSG_NEW_WORLD: Handle_NewWorld(wr); break; case OpCode.SMSG_FORCE_MOVE_UNROOT: SendMoveHeartBeat(BoogieCore.world.getPlayerObject().GetCoordinates()); break; case OpCode.SMSG_UPDATE_OBJECT: Handle_ObjUpdate(wr, false); break; case OpCode.SMSG_DESTROY_OBJECT: Handle_ObjDestroy(wr); break; case OpCode.SMSG_COMPRESSED_UPDATE_OBJECT: Handle_ObjUpdate(wr, true); break; case OpCode.SMSG_SPELL_START: break; case OpCode.SMSG_SPELL_GO: break; case OpCode.SMSG_CAST_RESULT: break; case OpCode.SMSG_MESSAGECHAT: Handle_MessageChat(wr); break; case OpCode.SMSG_CHANNEL_NOTIFY: break; case OpCode.SMSG_NAME_QUERY_RESPONSE: Handle_NameQuery(wr); break; case OpCode.SMSG_CREATURE_QUERY_RESPONSE: Handle_CreatureQuery(wr); break; case OpCode.SMSG_GAMEOBJECT_QUERY_RESPONSE: SMSG_Debug(wr); break; case OpCode.MSG_AUCTION_HELLO: BoogieCore.Log(LogType.NeworkComms, "Got ah Hello!"); Query_AH(AHEntry); break; case OpCode.SMSG_AUCTION_LIST_RESULT: BoogieCore.Log(LogType.NeworkComms, "Got ah response!"); Query_AH(AHEntry); break; case OpCode.SMSG_FRIEND_LIST: Handle_FriendsList(wr); break; case OpCode.SMSG_FRIEND_STATUS: Handle_FriendStatus(wr); break; //case OpCode.SMSG_IGNORE_LIST: // Handle_IgnoreList(wr); // break; case OpCode.SMSG_INIT_WORLD_STATES: Handle_InitWorldStates(wr); break; case OpCode.SMSG_INITIAL_SPELLS: Handle_InitialSpells(wr); break; case OpCode.SMSG_LEARNED_SPELL: Handle_LearntSpell(wr); break; case OpCode.SMSG_SUPERCEDED_SPELL: Handle_SupercededSpell(wr); break; case OpCode.SMSG_INITIALIZE_FACTIONS: Handle_InitializeFactions(wr); break; case OpCode.SMSG_LOGIN_SETTIMESPEED: Handle_LoginSetTimeSpeed(wr); break; case OpCode.SMSG_SPELLLOGEXECUTE: Handle_SpellLogExecute(wr); break; case OpCode.SMSG_MAIL_LIST_RESULT: Handle_MailList(wr); break; case OpCode.SMSG_SEND_MAIL_RESULT: // We don't send mail (yet). break; case OpCode.SMSG_RECEIVED_MAIL: // You've got MAIL! break; case OpCode.SMSG_LIST_INVENTORY: Handle_VendorInventoryList(wr); break; case OpCode.SMSG_ACTION_BUTTONS: Handle_ActionButtons(wr); break; case OpCode.SMSG_LEVELUP_INFO: Handle_LevelUp(wr); break; case OpCode.SMSG_LOG_XPGAIN: Handle_XpGain(wr); break; default: BoogieCore.Log(LogType.NeworkComms, "Got unknown opcode: {0} length: {1}", Op, wr.Remaining); break; } } catch (Exception ex) { BoogieCore.Log(LogType.Error, "Caught Exception while processing packet with opcode of {0}: Exception is: {1}", Op, ex.Message); //BoogieCore.Log(LogType.Error, "{0}", ex.StackTrace); } }