public void Create(CharacterBase c, ClientConnection Client) { uint num; this.ObjectType = TYPE.PLAYER; this.ObjectTypeID = TYPEID.PLAYER; this.x = c.x; this.y = c.y; this.z = c.z; this.o = c.o; this.guid = c.guid; switch (c.PowerType) { case Powers.MANA: num = 0xee00; break; case Powers.RAGE: num = 0x1100ee00; break; case Powers.ENERGY: num = 0; break; default: num = 0; Console.WriteLine("Unknown PowerType"); break; } byte[] bytes = BitConverter.GetBytes(c.guid); this.mask.SetBit(0, BitConverter.ToUInt32(bytes, 0)); this.mask.SetBit(1, BitConverter.ToUInt32(bytes, 4)); if (c.race == Races.TAUREN) { this.mask.SetBit(4, (float)1.35f); } else { this.mask.SetBit(4, (float)1f); } this.mask.SetBit(0x81, (float)0.389f); this.mask.SetBit(130, (float)1.5f); this.mask.SetBit(0x83, c.displayid); this.mask.SetBit(0x84, c.displayid); this.mask.SetBit(0x24, new byte[] { (byte)c.race, (byte)c.class_, (byte)c.gender, (byte)c.PowerType }); this.mask.SetBit(0x8a, num); this.mask.SetBit(0xa4, (uint)0xeeeeee00); this.mask.SetBit(0x2e, (uint)0); this.mask.SetBit(0x8f, (uint)0x10); this.mask.SetBit(0xc1, new byte[] { c.skin, c.face, c.hairstyle, c.haircolor }); byte[] buffer3 = new byte[4]; buffer3[0] = c.facialhair; buffer3[1] = 0xee; buffer3[3] = 2; this.mask.SetBit(0xc2, buffer3); this.mask.SetBit(0xc3, (uint)c.gender); this.mask.SetBit(0x4c6, (uint)0xeee00000); this.mask.SetBit(0x22, (uint)c.level); this.mask.SetBit(0x23, c.GetFactionTemplate()); this.mask.SetBit(0x1c, (uint)0x3e8); this.mask.SetBit(0x16, (uint)200); if (Client.User.GMLevel > 0) { this.mask.SetBit(190, (uint)8); } byte[] buffer2 = BitConverter.GetBytes((ulong)100); }
public byte[] CreateCharacter(ByteArrayBuilderV2 data, ClientConnection Client, DatabaseManager DbManager) { byte num; byte num2; byte num3; byte num4; ByteArrayBuilderV2 rv = new ByteArrayBuilderV2(); if (Client.Characters.Count >= 10) { rv.Add((byte)0x34); return((byte[])rv); } CharacterBase base2 = new CharacterBase(); data.Get(out base2.name); this.Reader = DbManager.Read("SELECT guid FROM characters WHERE name='" + base2.name + "'"); if (this.Reader.Read()) { rv.Add((byte)0x31); this.Reader.Close(); return((byte[])rv); } this.Reader.Close(); data.Get(out num); data.Get(out num2); base2.class_ = (Classes)num2; base2.race = (Races)num; if ((Client.User.GMLevel < 1) && (Client.User.team != Side.NONE)) { if ((Client.User.team != base2.GetSide()) && (StaticCore.RealmType == 1)) { rv.Add((byte)0x33); return((byte[])rv); } if ((Client.User.team != base2.GetSide()) && (StaticCore.RealmType == 8)) { rv.Add((byte)0x33); return((byte[])rv); } } data.Get(out num3); base2.gender = (Gender)num3; data.Get(out base2.skin); data.Get(out base2.face); data.Get(out base2.hairstyle); data.Get(out base2.haircolor); data.Get(out base2.facialhair); data.Get(out num4); base2.level = 1; base2.displayid = base2.GetDisplayId(); string[] strArray = new string[] { "SELECT * FROM playercreateinfo WHERE race='", ((byte)base2.race).ToString(), "' AND class='", ((byte)base2.class_).ToString(), "'" }; this.Reader = DbManager.Read(string.Concat(strArray)); this.Reader.Read(); base2.map = this.Reader.GetUInt32(2); base2.zoneid = this.Reader.GetUInt32(3); base2.x = this.Reader.GetFloat(4); base2.y = this.Reader.GetFloat(5); base2.z = this.Reader.GetFloat(6); this.Reader.Close(); MySqlCommand command = new MySqlCommand(); command.Connection = DbManager.Connection; command.CommandText = "INSERT INTO characters (accname, name, race, class, gender, skin, face, hairstyle, haircolor, facialhair, level, zoneid, map, x, y, z, guildid, flags, rest, petinfoid, petlevel, petfamilyid, realmid, displayid, tutorialflags) VALUES(?accname, ?name, ?race, ?class, ?gender, ?skin, ?face, ?hairstyle, ?haircolor, ?facialhair, ?level, ?zoneid, ?map, ?x, ?y, ?z, ?guildid, ?flags, ?rest, ?petinfoid, ?petlevel, ?petfamilyid, ?realmid, ?displayid, ?tutorialflags)"; command.Parameters.Add("?accname", Client.User.Name); command.Parameters.Add("?name", base2.name); command.Parameters.Add("?race", base2.race); command.Parameters.Add("?class", base2.class_); command.Parameters.Add("?gender", base2.gender); command.Parameters.Add("?skin", base2.skin); command.Parameters.Add("?face", base2.face); command.Parameters.Add("?hairstyle", base2.hairstyle); command.Parameters.Add("?haircolor", base2.haircolor); command.Parameters.Add("?facialhair", base2.facialhair); command.Parameters.Add("?level", base2.level); command.Parameters.Add("?zoneid", base2.zoneid); command.Parameters.Add("?map", base2.map); command.Parameters.Add("?x", base2.x); command.Parameters.Add("?y", base2.y); command.Parameters.Add("?z", base2.z); command.Parameters.Add("?guildid", base2.guildid); command.Parameters.Add("?flags", base2.flags); command.Parameters.Add("?rest", base2.rest); command.Parameters.Add("?petinfoid", base2.petinfoid); command.Parameters.Add("?petlevel", base2.petlevel); command.Parameters.Add("?petfamilyid", base2.petfamilyid); command.Parameters.Add("?realmid", StaticCore.RealmID); command.Parameters.Add("?displayid", base2.displayid); command.Parameters.Add("?tutorialflags", base2.tutorialflags); if (command.ExecuteNonQuery() < 1) { rv.Add((byte)0x30); return((byte[])rv); } rv.Add((byte)0x2e); return((byte[])rv); }
public byte[] CreateList(ClientConnection Client, DatabaseManager DbManager) { Client.PlayerBase = null; ByteArrayBuilderV2 rv = new ByteArrayBuilderV2(); this.Reader = DbManager.Read("SELECT * FROM characters WHERE accname='" + Client.User.Name + "' AND realmid='" + StaticCore.RealmID.ToString() + "'"); Client.Characters = new ArrayList(); while (this.Reader.Read()) { CharacterBase base2 = new CharacterBase(); base2.guid = this.Reader.GetUInt64(0); base2.name = this.Reader[2].ToString(); byte @byte = this.Reader.GetByte(3); byte num2 = this.Reader.GetByte(4); byte num3 = this.Reader.GetByte(5); base2.gender = (Gender)num3; base2.race = (Races)@byte; base2.class_ = (Classes)num2; base2.skin = this.Reader.GetByte(6); base2.face = this.Reader.GetByte(7); base2.hairstyle = this.Reader.GetByte(8); base2.haircolor = this.Reader.GetByte(9); base2.facialhair = this.Reader.GetByte(10); base2.level = this.Reader.GetByte(11); base2.zoneid = this.Reader.GetUInt32(12); base2.map = this.Reader.GetUInt32(13); base2.x = this.Reader.GetFloat(14); base2.y = this.Reader.GetFloat(15); base2.z = this.Reader.GetFloat(0x10); base2.guildid = this.Reader.GetUInt32(0x11); base2.flags = this.Reader.GetByte(0x12); base2.rest = this.Reader.GetByte(0x13); base2.petinfoid = this.Reader.GetUInt32(20); base2.petlevel = this.Reader.GetUInt32(0x15); base2.petfamilyid = this.Reader.GetUInt32(0x16); base2.displayid = this.Reader.GetUInt32(0x18); base2.tutorialflags = this.Reader.GetUInt32(0x1a); Client.Characters.Add(base2); } Client.User.team = Side.NONE; rv.Add((byte)Client.Characters.Count); foreach (CharacterBase base3 in Client.Characters) { Client.User.team = base3.GetSide(); rv.Add(base3.guid); rv.Add(base3.name); rv.Add((byte)base3.race); rv.Add((byte)base3.class_); rv.Add((byte)base3.gender); rv.Add(base3.skin); rv.Add(base3.face); rv.Add(base3.hairstyle); rv.Add(base3.haircolor); rv.Add(base3.facialhair); rv.Add(base3.level); rv.Add(base3.zoneid); rv.Add(base3.map); rv.Add(base3.x); rv.Add(base3.y); rv.Add(base3.z); rv.Add(base3.guildid); rv.Add((uint)0); rv.Add(base3.rest); rv.Add(base3.petinfoid); rv.Add(base3.petlevel); rv.Add(base3.petfamilyid); Console.WriteLine("Guid:{0}", base3.guid); rv.Add(new byte[100]); } this.Reader.Close(); lock (StaticCore.RealmDbManager) { MySqlCommand command = new MySqlCommand(); command.Connection = StaticCore.RealmDbManager.Connection; command.CommandText = "REPLACE INTO realmcharacters (accname, realmid, charcount) VALUES(?accname, ?realmid, ?charcount)"; command.Parameters.Add("?accname", Client.User.Name); command.Parameters.Add("?realmid", StaticCore.RealmID); command.Parameters.Add("?charcount", Client.Characters.Count); command.ExecuteNonQuery(); } return((byte[])rv); }
private void PacketHandle(ClientConnection Client) { ArrayList list = new ArrayList(); lock (Client.Packets) { foreach (ByteArrayBuilderV2 rv in Client.Packets) { list.Add(rv); } Client.Packets.Clear(); } foreach (ByteArrayBuilderV2 rv2 in list) { ulong num5; this.Timer.Run(Client); OpCodes oP = Client.GetOP(rv2); Console.WriteLine(oP.ToString()); this.OutPacket.Clear(); rv2.pos = 6; switch (oP) { case OpCodes.CMSG_PLAYER_LOGOUT: this.logout = new LogoutHandler(); this.logout.LogoutRequest(0, Client); goto Label_0E44; case OpCodes.CMSG_LOGOUT_REQUEST: this.logout = new LogoutHandler(); this.logout.LogoutRequest(0x4e20, Client); goto Label_0E44; case OpCodes.CMSG_LOGOUT_CANCEL: this.logout.CancelLogout(Client); goto Label_0E44; case OpCodes.CMSG_NAME_QUERY: rv2.Get(out num5); Console.WriteLine("name guid:{0}", num5); if (num5 != Client.PlayerBase.guid) { break; } this.OutPacket.Add(Client.PlayerBase.guid); this.OutPacket.Add(Client.PlayerBase.name); this.OutPacket.Add((byte)0); this.OutPacket.Add((uint)Client.PlayerBase.race); this.OutPacket.Add((uint)Client.PlayerBase.gender); this.OutPacket.Add((uint)Client.PlayerBase.class_); Client.Send(OpCodes.SMSG_NAME_QUERY_RESPONSE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_ITEM_QUERY_SINGLE: ulong num9; uint num10; rv2.Get(out num10); rv2.Get(out num9); Console.WriteLine("\nitem entry: " + num10.ToString() + " guid: " + num9.ToString()); this.OutPacket.Add(num10); this.OutPacket.Add((uint)4); this.OutPacket.Add((uint)1); this.OutPacket.Add("Circle of Flame"); this.OutPacket.Add("qname"); this.OutPacket.Add("honorname"); this.OutPacket.Add("enchname"); this.OutPacket.Add((uint)0x6e6c); this.OutPacket.Add((uint)4); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)100); this.OutPacket.Add((uint)10); this.OutPacket.Add((uint)1); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0x3b); this.OutPacket.Add((uint)1); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)1); this.OutPacket.Add((uint)0); this.OutPacket.Add(new byte[0x48]); this.OutPacket.Add((uint)7); this.OutPacket.Add((uint)100); this.OutPacket.Add(new byte[60]); this.OutPacket.Add((uint)5); this.OutPacket.Add((uint)10); this.OutPacket.Add((uint)5); this.OutPacket.Add((uint)20); this.OutPacket.Add((uint)5); this.OutPacket.Add((uint)50); this.OutPacket.Add((uint)10); this.OutPacket.Add(new byte[120]); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_ITEM_QUERY_SINGLE_RESPONSE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_PLAYER_LOGIN: { ulong num4; EnterWorld world = new EnterWorld(); rv2.Get(out num4); Console.WriteLine("PlayerBase guid:{0}", num4); this.DbManager.Write("UPDATE characters SET online=1 WHERE guid='" + num4.ToString() + "'"); world.Login(Client, num4); goto Label_0E44; } case OpCodes.CMSG_CHAR_CREATE: { CHAR_CREATE_Handler handler2 = new CHAR_CREATE_Handler(); Client.Send(OpCodes.SMSG_CHAR_CREATE, handler2.CreateCharacter(rv2, Client, this.DbManager)); goto Label_0E44; } case OpCodes.CMSG_CHAR_ENUM: case OpCodes.CMSG_UNKNOWN_908: { CHAR_ENUM_Handler handler = new CHAR_ENUM_Handler(); Client.Send(OpCodes.SMSG_CHAR_ENUM, handler.CreateList(Client, this.DbManager)); goto Label_0E44; } case OpCodes.CMSG_CHAR_DELETE: { CHAR_DELETE_Handler handler3 = new CHAR_DELETE_Handler(); Client.Send(OpCodes.SMSG_CHAR_DELETE, handler3.DeleteCharacter(rv2, Client, this.DbManager)); goto Label_0E44; } case OpCodes.MSG_NULL_ACTION: Client.Disconnect(); goto Label_0E44; case OpCodes.MSG_MOVE_START_FORWARD: case OpCodes.MSG_MOVE_START_BACKWARD: case OpCodes.MSG_MOVE_STOP: case OpCodes.MSG_MOVE_START_STRAFE_LEFT: case OpCodes.MSG_MOVE_START_STRAFE_RIGHT: case OpCodes.MSG_MOVE_STOP_STRAFE: case OpCodes.MSG_MOVE_JUMP: case OpCodes.MSG_MOVE_START_TURN_LEFT: case OpCodes.MSG_MOVE_START_TURN_RIGHT: case OpCodes.MSG_MOVE_STOP_TURN: case OpCodes.MSG_MOVE_START_PITCH_UP: case OpCodes.MSG_MOVE_START_PITCH_DOWN: case OpCodes.MSG_MOVE_STOP_PITCH: case OpCodes.MSG_MOVE_SET_RUN_MODE: case OpCodes.MSG_MOVE_SET_WALK_MODE: case OpCodes.MSG_MOVE_START_SWIM: case OpCodes.MSG_MOVE_STOP_SWIM: case OpCodes.MSG_MOVE_SET_FACING: case OpCodes.MSG_MOVE_SET_PITCH: case OpCodes.MSG_MOVE_HEARTBEAT: this.Movement.Move(Client, rv2); goto Label_0E44; case OpCodes.CMSG_MESSAGECHAT: case OpCodes.CMSG_UPDATE_ACCOUNT_DATA: case OpCodes.CMSG_GMTICKET_GETTICKET: case OpCodes.CMSG_SET_ACTIVE_MOVER: case OpCodes.CMSG_MEETINGSTONE_INFO: case OpCodes.CMSG_MOVE_TIME_SKIPPED: case OpCodes.CMSG_BATTLEFIELD_STATUS: goto Label_0E44; case OpCodes.CMSG_TUTORIAL_FLAG: uint num6; rv2.Get(out num6); this.DbManager.Write("UPDATE characters SET tutorialflags='" + num6.ToString() + "' WHERE guid='" + Client.PlayerBase.guid.ToString() + "'"); goto Label_0E44; case OpCodes.CMSG_TUTORIAL_CLEAR: { string[] strArray = new string[] { "UPDATE characters SET tutorialflags='", uint.MaxValue.ToString(), "' WHERE guid='", Client.PlayerBase.guid.ToString(), "'" }; this.DbManager.Write(string.Concat(strArray)); goto Label_0E44; } case OpCodes.CMSG_TUTORIAL_RESET: this.DbManager.Write("UPDATE characters SET tutorialflags=0 WHERE guid='" + Client.PlayerBase.guid.ToString() + "'"); goto Label_0E44; case OpCodes.CMSG_PING: uint num3; rv2.Get(out num3); this.OutPacket.Add(num3); Client.Send(OpCodes.SMSG_PONG, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_AUTH_SESSION: { uint num; uint num2; DatabaseManager manager; rv2.Get(out num); rv2.Seek(4); rv2.Get(out Client.User.Name); Client.User.Name = Client.User.Name.ToLower(); Client.User.Hash = new byte[40]; rv2.Get(out num2); byte[] array = rv2.GetArray(20); lock ((manager = StaticCore.RealmDbManager)) { this.MySqlReader = StaticCore.RealmDbManager.Read("SELECT sessionkey, level, burning FROM accounts WHERE name='" + Client.User.Name + "'"); } if (!this.MySqlReader.Read()) { Client.Disconnect(); this.MySqlReader.Close(); } else { this.MySqlReader.GetBytes(0, (long)0, Client.User.Hash, 0, 40); Client.User.GMLevel = this.MySqlReader.GetInt32(1); Client.User.BCEnabled = this.MySqlReader.GetBoolean(2); this.MySqlReader.Close(); lock ((manager = StaticCore.RealmDbManager)) { StaticCore.RealmDbManager.Write("UPDATE accounts SET inworld=1, lastrealmid='" + StaticCore.RealmID.ToString() + "' WHERE name='" + Client.User.Name + "'"); } SHA1 sha = new SHA1CryptoServiceProvider(); ByteArrayBuilderV2 rv3 = new ByteArrayBuilderV2(); rv3.Add(Encoding.ASCII.GetBytes(Client.User.Name.ToUpper())); rv3.Add((uint)0); rv3.Add(num2); rv3.Add((uint)0xdeadbabe); rv3.Add(Client.User.Hash); if (!WorldServer.Utils.IsSameByteArray(sha.ComputeHash((byte[])rv3), array)) { this.OutPacket.Add((byte)13); Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } else if (num != 0x1992) { this.OutPacket.Add((byte)13); Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } else { this.OutPacket.Add((byte)12); this.OutPacket.Add((byte)0xb0); this.OutPacket.Add((byte)9); this.OutPacket.Add((byte)2); this.OutPacket.Add((byte)0); this.OutPacket.Add((byte)2); this.OutPacket.Add((uint)0); if (Client.User.BCEnabled) { this.OutPacket.Add((byte)1); } else { this.OutPacket.Add((byte)0); } Client.Send(OpCodes.SMSG_AUTH_RESPONSE, this.OutPacket); } } goto Label_0E44; } case OpCodes.CMSG_SWAP_INV_ITEM: byte num7; byte num8; rv2.Get(out num7); rv2.Get(out num8); Console.WriteLine("from: {0} to: {1}", num7, num8); this.OutPacket.Add((byte)4); this.OutPacket.Add((ulong)400); this.OutPacket.Add((ulong)0); this.OutPacket.Add((byte)0); Client.Send(OpCodes.SMSG_INVENTORY_CHANGE_FAILURE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_QUERY_TIME: this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_QUERY_TIME_RESPONSE, this.OutPacket); goto Label_0E44; case OpCodes.CMSG_REQUEST_RAID_INFO: this.OutPacket.Add((uint)0); Client.Send(OpCodes.SMSG_RAID_INSTANCE_INFO, this.OutPacket); goto Label_0E44; default: WorldServer.Utils.konzol((byte[])rv2); Console.WriteLine("unhandled OpCode (" + oP.ToString() + ")"); goto Label_0E44; } this.MySqlReader = this.DbManager.Read("SELECT name, race, class, gender FROM characters WHERE guid='" + num5.ToString() + "'"); if (!this.MySqlReader.Read()) { this.MySqlReader.Close(); } else { this.OutPacket.Add(num5); this.OutPacket.Add(this.MySqlReader[0].ToString()); this.OutPacket.Add((byte)0); this.OutPacket.Add((uint)this.MySqlReader.GetByte(1)); this.OutPacket.Add((uint)this.MySqlReader.GetByte(3)); this.OutPacket.Add((uint)this.MySqlReader.GetByte(2)); this.MySqlReader.Close(); Client.Send(OpCodes.SMSG_NAME_QUERY_RESPONSE, this.OutPacket); } Label_0E44 :; } }