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()); }
public void QueryName(WoWGuid guid) { WoWWriter wr = new WoWWriter(OpCode.CMSG_NAME_QUERY); wr.Write(guid.GetOldGuid()); Send(wr.ToArray()); }
public void QueryName(UInt64 guid) { WoWWriter wr = new WoWWriter(OpCode.CMSG_NAME_QUERY); wr.Write(guid); Send(wr.ToArray()); }
public void LoginChar(UInt64 guid) { foreach (Character c in characterList) { if (c.GUID == guid) { BoogieCore.World.setPlayer(c.MapID, new WoWGuid(guid)); BoogieCore.Player.setPlayer(c); } } characterList = null; // No longer needed! WoWWriter ww = new WoWWriter(OpCode.CMSG_PLAYER_LOGIN); ww.Write(guid); Send(ww.ToArray()); ww = new WoWWriter(OpCode.CMSG_UPDATE_ACCOUNT_DATA); ww.Write((UInt32)7); ww.Write((UInt32)5144); ww.Write(account_data); Send(ww.ToArray()); ww = new WoWWriter(OpCode.CMSG_NAME_QUERY); ww.Write(guid); Send(ww.ToArray()); ww = new WoWWriter(OpCode.CMSG_SET_ACTIVE_MOVER); ww.Write(guid); Send(ww.ToArray()); //MoveUpdateTimer.Enabled = true; }
public void Query_GetMailList(WoWGuid mailbox_guid) { WoWWriter wr = new WoWWriter(OpCode.CMSG_GET_MAIL_LIST); wr.Write(mailbox_guid.GetOldGuid()); Send(wr.ToArray()); }
private void Query_Item_Single(UInt32 id) { WoWWriter ww = new WoWWriter(OpCode.CMSG_ITEM_QUERY_SINGLE); ww.Write(id); ww.Write((UInt64)0); Send(ww.ToArray()); }
public void SendEmoteMsg(ChatMsg Type, Languages Language, string Message, string To) { WoWWriter wr = new WoWWriter(OpCode.CMSG_TEXT_EMOTE); wr.Write((UInt32)Type); wr.Write((UInt32)Languages.LANG_ORCISH); wr.Write(Message); Send(wr.ToArray()); }
public void PartChannel(string channel) { WoWWriter wr = new WoWWriter(OpCode.CMSG_LEAVE_CHANNEL); wr.Write((UInt32)0); wr.Write(channel); Send(wr.ToArray()); ChannelList.Remove(channel); BoogieCore.Event(new Event(EventType.EVENT_CHANNEL_LEFT, Time.GetTime(), channel)); }
public void SendChatMsg(ChatMsg Type, Languages Language, string Message, string To) { WoWWriter wr = new WoWWriter(OpCode.CMSG_MESSAGECHAT); wr.Write((UInt32)Type); wr.Write((UInt32)Languages.LANG_ORCISH); if ((Type == ChatMsg.CHAT_MSG_WHISPER || Type == ChatMsg.CHAT_MSG_CHANNEL) && To != "") { wr.Write(To); } wr.Write(Message); Send(wr.ToArray()); }
public void JoinChannel(string channel, string password) { WoWWriter wr = new WoWWriter(OpCode.CMSG_JOIN_CHANNEL); wr.Write((UInt32)0); // dbc id?? wr.Write((UInt16)0); // crap as ascent put it wr.Write(channel); wr.Write((byte)0); Send(wr.ToArray()); ChannelList.Add(channel); BoogieCore.Event(new Event(EventType.EVENT_CHANNEL_JOINED, Time.GetTime(), channel)); }
private void Handle_CreatureQuery(WoWReader wr) { Entry entry = new Entry(); entry.entry = wr.ReadUInt32(); entry.name = wr.ReadString(); entry.blarg = wr.ReadBytes(3); entry.subname = wr.ReadString(); entry.flags = wr.ReadUInt32(); entry.subtype = wr.ReadUInt32(); entry.family = wr.ReadUInt32(); entry.rank = wr.ReadUInt32(); BoogieCore.Log(LogType.NeworkComms, "Got CreatureQuery Response - Entry: {0} - Name: {1} - SubName {2}", entry.entry, entry.name, entry.subname); if (EntryList.ContainsKey(entry.entry) == false) { EntryList.Add(entry.entry, entry); } if (EntryQueue.ContainsKey(entry.entry)) { EntryQueue.Remove(entry.entry); } foreach (Object obj in BoogieCore.world.getObjectList()) { if (obj.Fields != null) { if (obj.Fields[(int)UpdateFields.OBJECT_FIELD_ENTRY] == entry.entry) { if (entry.name.Contains("Auctioneer") && SentHello == false) { WoWWriter ww = new WoWWriter(OpCode.MSG_AUCTION_HELLO); ww.Write(obj.GUID.GetOldGuid()); Send(ww.ToArray()); BoogieCore.Log(LogType.SystemDebug, "Sent AH Hello!"); SentHello = true; } obj.Name = entry.name; obj.SubName = entry.subname; obj.SubType = entry.subtype; obj.Family = entry.family; obj.Rank = entry.rank; } } } }
private void Query_AH(UInt32 entry) { WoWWriter wr = new WoWWriter(OpCode.CMSG_AUCTION_LIST_ITEMS); wr.Write(entry); wr.Write((byte)0); // "message" wr.Write((byte)0); // minlevel wr.Write((byte)0); // maxlevel wr.Write(0xFFFFFFFF); // unk wr.Write(0xFFFFFFFF); // item class wr.Write(0xFFFFFFFF); // item subclass wr.Write(0xFFFFFFFF); // rarity wr.Write((byte)0); // usable Send(wr.ToArray()); AHEntry = entry + 50; }
private void BuildMovePacket(OpCode op, float x, float y, float z, float o) { WoWWriter ww = new WoWWriter(op); ww.Write((UInt32)MoveFlags); ww.Write((byte)255); ww.Write((UInt32)MM_GetTime()); ww.Write(x); ww.Write(y); ww.Write(z); ww.Write(o); ww.Write((UInt32)0); Send(ww.ToArray()); }
private void Handle_NewWorld(WoWReader wr) { Object obj = BoogieCore.world.getPlayerObject(); WorldZone(obj.GUID.GetOldGuid()); UInt32 mapid = wr.ReadUInt32(); BoogieCore.world.zoned(mapid); // Tell World we zoned, and give new mapid obj.coord = new Coordinate(wr.ReadSingle(), wr.ReadSingle(), wr.ReadSingle(), wr.ReadSingle()); WoWWriter ww = new WoWWriter(OpCode.MSG_MOVE_WORLDPORT_ACK); //ww.Write(BoogieCore.world.getPlayerObject().GUID.GetOldGuid()); Send(ww.ToArray()); SendMoveHeartBeat(obj.coord); BoogieCore.Log(LogType.System, "Got worldport for mapid: {0} xyz: {1} {2} {3}", mapid, obj.coord.X, obj.coord.Y, obj.coord.Z); BoogieCore.world.updatePlayerLocationUI(); }
private void Ping(object source, ElapsedEventArgs e) { if (!mSocket.Connected) { PingTimer.Enabled = false; PingTimer.Stop(); return; } Ping_Req_Time = MM_GetTime(); BoogieCore.Log(LogType.NeworkComms, "Ping!"); WoWWriter ww = new WoWWriter(OpCode.CMSG_PING); ww.Write(Ping_Seq); ww.Write(Latency); Send(ww.ToArray()); }
private void Handle_AuthResponse(WoWReader wr) { byte error = wr.ReadByte(); if (error != 0x0C) { BoogieCore.Log(LogType.Error, "WS: Authentication Failed: Error = {0}", error); return; } BoogieCore.Log(LogType.System, "WS: Authentication Successful!"); BoogieCore.Log(LogType.System, "WS: Requesting Character List..."); WoWWriter ww = new WoWWriter(OpCode.CMSG_CHAR_ENUM); Send(ww.ToArray()); PingTimer.Enabled = true; }
public void WorldZone(UInt64 guid) { WoWWriter ww = new WoWWriter(OpCode.CMSG_PLAYER_LOGIN); ww.Write(guid); Send(ww.ToArray()); ww = new WoWWriter(OpCode.CMSG_UPDATE_ACCOUNT_DATA); ww.Write((UInt32)7); ww.Write((UInt32)5144); ww.Write(account_data); Send(ww.ToArray()); ww = new WoWWriter(OpCode.CMSG_NAME_QUERY); ww.Write(guid); Send(ww.ToArray()); ww = new WoWWriter(OpCode.CMSG_SET_ACTIVE_MOVER); ww.Write(guid); Send(ww.ToArray()); }
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); } }
public void Send(WoWWriter wr) { Send(wr.ToArray()); }
private void Handle_ObjUpdate(WoWReader wr, bool Compressed) { if (Compressed) { Int32 size = wr.ReadInt32(); byte[] decomped = Foole.Utils.Compression.Decompress(size, wr.ReadRemaining()); wr = new WoWReader(decomped); } WoWGuid guid; UInt32 blockCount; byte unk1; byte blockType; byte objTypeId; blockCount = wr.ReadUInt32(); unk1 = wr.ReadByte(); BoogieCore.Log(LogType.Error, "Got obj update with {0} blocks", blockCount); for (UInt32 i = 0; i < blockCount; i++) { blockType = wr.ReadByte(); #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "Block #{0}/{1} Type: {2}", i + 1, blockCount, blockType); #endif switch (blockType) { case 0: // Fields update { byte mask = wr.ReadByte(); if (mask == 0x00) { break; } guid = new WoWGuid(mask, wr.ReadBytes(WoWGuid.BitCount8(mask))); UpdateMask UpdateMask = new UpdateMask(); byte bc = wr.ReadByte(); // Block Count UpdateMask.SetCount((ushort)(bc * 32)); UpdateMask.SetMask(wr.ReadBytes(bc * 4), bc); #if (DEBUG) BoogieCore.Log(LogType.Error, "Field Update! FieldCount: {0}", UpdateMask.GetCount()); #endif UInt32[] Fields = new UInt32[UpdateMask.GetCount()]; Object obj = BoogieCore.World.getObject(guid); if (obj == null) { BoogieCore.Log(LogType.Error, "Object with the guid {0} not recognized in field update.", guid.GetOldGuid()); } for (ushort x = 0; x < UpdateMask.GetCount(); x++) { if (UpdateMask.GetBit(x)) { if (obj == null) // FixMe { wr.ReadUInt32(); } else { obj.Fields[x] = wr.ReadUInt32(); } } } // Update Player Class if these are Player Fields being changed. if (obj != null) { if (obj.GUID.GetOldGuid() == BoogieCore.Player.Character.GUID) { BoogieCore.Player.updatePlayer(obj); } } break; } case 1: // Movement Update { byte mask = wr.ReadByte(); if (mask == 0x00) { break; } guid = new WoWGuid(mask, wr.ReadBytes(WoWGuid.BitCount8(mask))); #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "Got Movement update for GUID {0}", BitConverter.ToUInt64(guid.GetNewGuid(), 0)); #endif UInt32 flags2 = 0, unk3; float posX = 0; float posY = 0; float posZ = 0; float facing = 0; float walkSpeed, runSpeed, backWalkSpeed, swimSpeed, backSwimSpeed, turnRate = 0; byte flags = wr.ReadByte(); if ((flags & 0x20) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 20)"); #endif flags2 = wr.ReadUInt32(); wr.ReadByte(); // 2.3.3 unk3 = wr.ReadUInt32(); } if ((flags & 0x40) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 40)"); #endif posX = wr.ReadSingle(); posY = wr.ReadSingle(); posZ = wr.ReadSingle(); facing = wr.ReadSingle(); #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "Position - X: {0} Y: {1} Z: {2} Orient: {3} ", posX, posY, posZ, facing); #endif if ((flags2 & 0x02000000) >= 1) // player being transported { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags2 & 0x02000000)"); #endif wr.ReadUInt32(); //guidlow wr.ReadUInt32(); //guidhigh wr.ReadSingle(); //x wr.ReadSingle(); //y wr.ReadSingle(); //z wr.ReadSingle(); //o wr.ReadSingle(); // unk } } if ((flags & 0x20) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 20)"); #endif wr.ReadSingle(); //unk if ((flags2 & 0x2000) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 2000)"); #endif wr.ReadSingle(); // pos unk1 wr.ReadSingle(); // pos unk1 wr.ReadSingle(); // pos unk1 wr.ReadSingle(); // pos unk1 //BoogieCore.Log(LogType.NeworkComms, "Position 2 - X: {0} Y: {1} Z: {2} Orient: {3} ", punk1, punk2, punk3, punk1); } } if ((flags & 0x20) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 20)"); #endif walkSpeed = wr.ReadSingle(); runSpeed = wr.ReadSingle(); backWalkSpeed = wr.ReadSingle(); swimSpeed = wr.ReadSingle(); backSwimSpeed = wr.ReadSingle(); wr.ReadSingle(); //unk1 wr.ReadSingle(); //unk2 turnRate = wr.ReadSingle(); //BoogieCore.Log(LogType.NeworkComms, "Speed - (flags & 0x20)"); } if ((flags & 0x20) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 0x20)"); if ((flags2 & 0x00400000) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags2 & 0x00400000)"); UInt32 splineFlags; splineFlags = wr.ReadUInt32(); if ((splineFlags & 0x00010000) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(splineFlags & 0x00010000)"); posX = wr.ReadSingle(); posY = wr.ReadSingle(); posZ = wr.ReadSingle(); //BoogieCore.Log(LogType.NeworkComms, "Position 3 - X: {0} Y: {1} Z: {2} Orient: {3} ", posX, posY, posZ, facing); } if ((splineFlags & 0x00020000) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(splineFlags & 0x00020000)"); wr.ReadUInt64(); } if ((splineFlags & 0x00040000) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(splineFlags & 0x00040000)"); float f; f = wr.ReadSingle(); } UInt32 time1, time2, splineCount, unk4; //1.8 time1 = wr.ReadUInt32(); time2 = wr.ReadUInt32(); unk4 = wr.ReadUInt32(); splineCount = wr.ReadUInt32(); //BoogieCore.Log(LogType.NeworkComms, "splineCount = {0}", splineCount); for (UInt32 j = 0; j < splineCount + 1; j++) { posX = wr.ReadSingle(); posY = wr.ReadSingle(); posZ = wr.ReadSingle(); //BoogieCore.Log(LogType.NeworkComms, "Position 4 - X: {0} Y: {1} Z: {2} Orient: {3} ", posX, posY, posZ, facing); } } } if ((flags & 0x8) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 8)"); #endif wr.ReadUInt32(); if ((flags & 0x10) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 10)"); #endif wr.ReadUInt32(); } } else if ((flags & 0x10) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 10)"); #endif wr.ReadUInt32(); } if ((flags & 0x2) >= 1) { #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "(flags & 0x2)"); #endif wr.ReadUInt32(); } break; } case 2: // ObjCreate case 3: // ObjCreate { byte mask = wr.ReadByte(); guid = new WoWGuid(mask, wr.ReadBytes(WoWGuid.BitCount8(mask))); objTypeId = wr.ReadByte(); #if (DEBUG) BoogieCore.Log(LogType.NeworkComms, "Got Object Create Mask: 0x{0:x2} GUID: {1} ObjTypeID: {2} ", mask, BitConverter.ToUInt64(guid.GetNewGuid(), 0), objTypeId); #endif UInt32 flags2 = 0, unk3; float posX = 0; float posY = 0; float posZ = 0; float facing = 0; float walkSpeed = 0, runSpeed = 0, backWalkSpeed = 0, swimSpeed = 0, backSwimSpeed = 0, turnRate = 0; byte flags = wr.ReadByte(); if ((flags & 0x20) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 20)"); flags2 = wr.ReadUInt32(); wr.ReadByte(); // 2.3.3 unk3 = wr.ReadUInt32(); } if ((flags & 0x40) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 40)"); posX = wr.ReadSingle(); posY = wr.ReadSingle(); posZ = wr.ReadSingle(); facing = wr.ReadSingle(); //BoogieCore.Log(LogType.NeworkComms, "Position - X: {0} Y: {1} Z: {2} Orient: {3} ", posX, posY, posZ, facing); if (((flags & 0x20) >= 1 && (flags2 & 0x0200) >= 1)) // player being transported { //BoogieCore.Log(LogType.NeworkComms, "(flags & 0x20 && flags2 & 0x0200)"); wr.ReadUInt32(); //guidlow wr.ReadUInt32(); //guidhigh wr.ReadSingle(); //x wr.ReadSingle(); //y wr.ReadSingle(); //z wr.ReadSingle(); //o wr.ReadSingle(); // unk } } if ((flags & 0x20) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 20)"); wr.ReadSingle(); //unk if ((flags2 & 0x2000) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 2000)"); wr.ReadSingle(); // pos unk1 wr.ReadSingle(); // pos unk1 wr.ReadSingle(); // pos unk1 wr.ReadSingle(); // pos unk1 //BoogieCore.Log(LogType.NeworkComms, "Position 2 - X: {0} Y: {1} Z: {2} Orient: {3} ", punk1, punk2, punk3, punk1); } } if ((flags & 0x20) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 20)"); walkSpeed = wr.ReadSingle(); runSpeed = wr.ReadSingle(); backWalkSpeed = wr.ReadSingle(); swimSpeed = wr.ReadSingle(); backSwimSpeed = wr.ReadSingle(); wr.ReadSingle(); //unk1 wr.ReadSingle(); //unk2 turnRate = wr.ReadSingle(); //BoogieCore.Log(LogType.NeworkComms, "Speed - (flags & 0x20)"); } if ((flags & 0x20) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 0x20)"); if ((flags2 & 0x08000000) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags2 & 0x00400000)"); UInt32 splineFlags; splineFlags = wr.ReadUInt32(); if ((splineFlags & 0x00010000) >= 1) { BoogieCore.Log(LogType.NeworkComms, "(splineFlags & 0x00010000)"); posX = wr.ReadSingle(); posY = wr.ReadSingle(); posZ = wr.ReadSingle(); BoogieCore.Log(LogType.NeworkComms, "Position 3 - X: {0} Y: {1} Z: {2} Orient: {3} ", posX, posY, posZ, facing); } if ((splineFlags & 0x00020000) >= 1) { BoogieCore.Log(LogType.NeworkComms, "(splineFlags & 0x00020000)"); wr.ReadUInt64(); } if ((splineFlags & 0x00040000) >= 1) { BoogieCore.Log(LogType.NeworkComms, "(splineFlags & 0x00040000)"); float f; f = wr.ReadSingle(); } UInt32 time1, time2, splineCount, unk4; //1.8 time1 = wr.ReadUInt32(); time2 = wr.ReadUInt32(); unk4 = wr.ReadUInt32(); splineCount = wr.ReadUInt32(); BoogieCore.Log(LogType.NeworkComms, "splineCount = {0}", splineCount); for (UInt32 j = 0; j < splineCount + 1; j++) { posX = wr.ReadSingle(); posY = wr.ReadSingle(); posZ = wr.ReadSingle(); //BoogieCore.Log(LogType.NeworkComms, "Position 4 - X: {0} Y: {1} Z: {2} Orient: {3} ", posX, posY, posZ, facing); } } } if ((flags & 0x8) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 8)"); wr.ReadUInt32(); if ((flags & 0x10) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 10)"); wr.ReadUInt32(); } } else if ((flags & 0x10) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 10)"); wr.ReadUInt32(); } if ((flags & 0x2) >= 1) { //BoogieCore.Log(LogType.NeworkComms, "(flags & 0x2)"); wr.ReadUInt32(); } UpdateMask UpdateMask = new UpdateMask(); byte bc = wr.ReadByte(); // Block Count //BoogieCore.Log(LogType.Error, "Block Count = {0}, Mask = {1}, flags = {2}, flags2 = {3}", bc * 32, mask, flags, flags2); UpdateMask.SetCount((ushort)(bc * 32)); UpdateMask.SetMask(wr.ReadBytes(bc * 4), bc); if (UpdateMask.GetCount() > 2500) { int count = UpdateMask.GetCount(); BoogieCore.Log(LogType.Error, "Bad mask count = {0} ! aborting parse", count); return; } //BoogieCore.Log(LogType.NeworkComms, "(ObjCreate) FieldCount: {0}", UpdateMask.GetCount()); UInt32[] Fields = new UInt32[UpdateMask.GetCount()]; for (ushort x = 0; x < UpdateMask.GetCount(); x++) { if (UpdateMask.GetBit(x)) { Fields[x] = wr.ReadUInt32(); } } if (!BoogieCore.world.objectExists(guid)) // Add new Object { UInt32 entryid = Fields[(int)UpdateFields.OBJECT_FIELD_ENTRY]; Object NewObj = new Object(); NewObj.GUID = guid; NewObj.coord = new Coordinate(posX, posY, posZ, facing); NewObj.Type = flags; NewObj.Fields = Fields; NewObj.walkSpeed = walkSpeed; NewObj.runSpeed = runSpeed; NewObj.backWalkSpeed = backWalkSpeed; NewObj.swimSpeed = swimSpeed; NewObj.backSwimSpeed = backSwimSpeed; NewObj.turnRate = turnRate; BoogieCore.world.newObject(NewObj, false); //MoveUpdateTimer.Enabled = true; if (objTypeId == 4) { QueryName(guid); BoogieCore.Log(LogType.NeworkComms, "Adding new Player {0}", BitConverter.ToUInt64(guid.GetNewGuid(), 0)); } if (objTypeId == 3 || objTypeId == 5) { BoogieCore.Log(LogType.System, "Querying for name of object with an entry of {0} and type of {1}", entryid, objTypeId); if (EntryList.ContainsKey(entryid) == false && EntryQueue.ContainsKey(entryid) == false) { EntryQueue.Add(entryid, true); if (objTypeId == 3) { WoWWriter wr2 = CreatureQuery(guid, entryid); Send(wr2.ToArray()); BoogieCore.Log(LogType.NeworkComms, "Adding new Unit {0}", BitConverter.ToUInt64(guid.GetNewGuid(), 0)); } if (objTypeId == 5) { WoWWriter wr2 = GameObjectQuery(guid, entryid); Send(wr2.ToArray()); BoogieCore.Log(LogType.NeworkComms, "Adding new GameObject {0}", BitConverter.ToUInt64(guid.GetNewGuid(), 0)); } } } } else // Update Existing Object { Object updateObj = BoogieCore.world.getObject(guid); updateObj.coord = new Coordinate(posX, posY, posZ, facing); updateObj.Type = flags; updateObj.Fields = Fields; BoogieCore.world.updateObject(updateObj); } break; } case 4: // Out Of Range update { UInt32 count = wr.ReadUInt32(); for (UInt32 j = 0; j < count; j++) { byte mask = wr.ReadByte(); guid = new WoWGuid(mask, wr.ReadBytes(WoWGuid.BitCount8(mask))); BoogieCore.world.delObject(guid); } break; } } } }
private void Handle_AuthRequest(WoWReader wr) { BoogieCore.Log(LogType.System, "WS: Recieved Authentication Challenge: Sending out response"); ServerSeed = wr.ReadUInt32(); ClientSeed = (UInt32)random.Next(); Sha1Hash sha = new Sha1Hash(); sha.Update(mUsername); sha.Update(0); // t sha.Update(ClientSeed); sha.Update(ServerSeed); sha.Update(Key); byte[] Digest = sha.Final(); WoWWriter ww = new WoWWriter(OpCode.CMSG_AUTH_SESSION); ww.Write(BoogieCore.configFile.ReadInteger("WoW", "Build")); ww.Write((UInt32)0); ww.Write(mUsername); ww.Write(ClientSeed); ww.Write(Digest); StreamReader SR; WoWWriter buffer = new WoWWriter(); SR = File.OpenText("Addons.txt"); string Line = SR.ReadLine(); while (Line != null) { string[] Fields = new string[3]; string Name = null; UInt64 Checksum = 0; byte unk = 0x0; Fields = Line.Split(':'); Name = Fields[0]; Checksum = UInt64.Parse(Fields[1]); //unk = (Fields[2].ToCharArray())[0]; if (Name != null && Checksum > 0) { buffer.Write(Name); buffer.Write(Checksum); buffer.Write(unk); //BoogieCore.Log("Adding addon {0} with the checksum {1}", Name, Checksum); } Line = SR.ReadLine(); } SR.Close(); byte[] buffer2 = Foole.Utils.Compression.Compress(buffer.ToArray()); UInt32 Size = (UInt32)buffer.ToArray().Length; ww.Write(Size); ww.Write(buffer2); Send(ww); mCrypt.Init(Key); }
private void Handle_CharEnum(WoWReader wr) { BoogieCore.Log(LogType.NeworkComms, "WS: Recieved Character List.."); byte count = wr.ReadByte(); characterList = new Character[count]; for (int i = 0; i < count; i++) { characterList[i].GUID = wr.ReadUInt64(); characterList[i].Name = wr.ReadString(); characterList[i].Race = wr.ReadByte(); characterList[i].Class = wr.ReadByte(); characterList[i].Gender = wr.ReadByte(); characterList[i].Skin = wr.ReadByte(); characterList[i].Face = wr.ReadByte(); characterList[i].HairStyle = wr.ReadByte(); characterList[i].HairColor = wr.ReadByte(); characterList[i].FacialHair = wr.ReadByte(); characterList[i].Level = wr.ReadByte(); characterList[i].ZoneID = wr.ReadUInt32(); characterList[i].MapID = wr.ReadUInt32(); characterList[i].X = wr.ReadFloat(); characterList[i].Y = wr.ReadFloat(); characterList[i].Z = wr.ReadFloat(); characterList[i].Guild = wr.ReadUInt32(); characterList[i].Unk = wr.ReadUInt32(); characterList[i].RestState = wr.ReadByte(); characterList[i].PetInfoID = wr.ReadUInt32(); characterList[i].PetLevel = wr.ReadUInt32(); characterList[i].PetFamilyID = wr.ReadUInt32(); CharEquipment[] equip = new CharEquipment[20]; for (int x = 0; x < 20; x++) { equip[x].EntryID = wr.ReadUInt32(); equip[x].Type = wr.ReadByte(); wr.ReadUInt32(); // enchant (2.4 patch) } characterList[i].Equipment = equip; } BoogieCore.Log(LogType.NeworkComms, "{0} characters in total.", characterList.Length); String defaultChar = BoogieCore.configFile.ReadString("Connection", "DefaultChar"); if (defaultChar != "") { foreach (Character c in characterList) { if (c.Name.ToLower() == defaultChar.ToLower()) { BoogieCore.Log(LogType.System, "Defaulting to Character {0}", defaultChar); BoogieCore.WorldServerClient.LoginChar(c.GUID); return; } } } if (count < 1) { string name = RandomString(6, false); BoogieCore.Log(LogType.System, "Auto-Generating Human Character with the name {0}", name); WoWWriter ww = new WoWWriter(OpCode.CMSG_CHAR_CREATE); ww.Write(name); ww.Write((byte)1); // race - human ww.Write((byte)1); // class - warrior ww.Write((byte)0); // gender - male ww.Write((byte)1); // skin ww.Write((byte)1); // face ww.Write((byte)1); // hair style ww.Write((byte)1); // hair color ww.Write((byte)1); // facial hair ww.Write((byte)1); // outfit id Send(ww.ToArray()); ww = new WoWWriter(OpCode.CMSG_CHAR_ENUM); Send(ww.ToArray()); return; } if (count == 1) { BoogieCore.Log(LogType.System, "Defaulting to Character {0}", characterList[0].Name); BoogieCore.WorldServerClient.LoginChar(characterList[0].GUID); return; } BoogieCore.Event(new Event(EventType.EVENT_CHAR_LIST, Time.GetTime(), characterList)); }