public bool HandlePacket(PacketList.Server opcode, GameReader packet, GameData gameData, bool Handled, ExtensionHandler extensions) { InfoExt infoExt = (InfoExt)extensions.Get("InfoExt"); switch (opcode) { case PacketList.Server.CreatureSay: Character toon = new Character(); toon.ObjectID = packet.readD(); ChatType type = (ChatType)packet.readD(); toon.Name = packet.readS(); ChatReceived(type, toon, packet.readS(), packet, gameData, extensions); break; case PacketList.Server.Die: Character toon2 = new Character(); toon2.ObjectID = packet.readD(); bool hideout = (packet.readD() == 0x00) ? false : true; bool castle = (packet.readD() == 0x00) ? false : true; bool siege = (packet.readD() == 0x00) ? false : true; bool sweep = (packet.readD() == 0x00) ? false : true; bool fixedresp = (packet.readD() == 0x00) ? false : true; bool fortress = (packet.readD() == 0x00) ? false : true; if (toon2.ObjectID == infoExt.User.ObjectID) { SelfDie(hideout, castle, siege, fortress, packet, gameData, extensions); } else { OtherDie(hideout, castle, siege, fortress, sweep, fixedresp, packet, gameData, extensions); } break; } return(false); }
public bool HandlePacket(PacketList.Server opcode, GameReader packet, GameData gameData, bool Handled, ExtensionHandler extensions) { switch (opcode) { case PacketList.Server.UserInfo: User = Packets.UserInfo.parsePacket(packet); break; case PacketList.Server.CharInfo: Character temp = Packets.CharInfo.parsePacket(packet); if (!KnownUsers.ContainsKey(temp.ObjectID)) { KnownUsers.Add(temp.ObjectID, temp); } else { KnownUsers[temp.ObjectID] = temp; } break; case PacketList.Server.NpcInfo: Character temp2 = Packets.NPCInfo.parsePacket(packet); if (!KnownNPCs.ContainsKey(temp2.ObjectID)) { KnownNPCs.Add(temp2.ObjectID, temp2); } else { KnownNPCs[temp2.ObjectID] = temp2; } break; case PacketList.Server.TargetSelectedPacket: Int32 objectid = packet.readD(); if (KnownUsers.ContainsKey(objectid)) { Targeted = KnownUsers[objectid]; } else if (KnownNPCs.ContainsKey(objectid)) { Targeted = KnownNPCs[objectid]; } break; case PacketList.Server.TargetUnselectedPacket: if (Targeted != null && Targeted.ObjectID == packet.readD()) { Targeted = null; } break; } return(false); }
public bool CallPlugin_HandlePacket(PacketList.Server opcode, GameReader packet) { bool SimpleHandled = false; for (int i = 0; i < Plugins.Length; i++) { if (Plugins[i].HandlePacket(opcode, packet, gameData, SimpleHandled, extensions)) { SimpleHandled = true; } } return(SimpleHandled); }
public bool HandlePacket(PacketList.Server opcode, GameReader packet, GameData gameData, bool Handled, ExtensionHandler extensions) { InfoExt infoExt = (InfoExt)extensions.Get("InfoExt"); if (infoExt.HandlePacket(opcode, packet, gameData, Handled, extensions)) { Handled = true; } Events events = (Events)extensions.Get("Events"); if (events.HandlePacket(opcode, packet, gameData, Handled, extensions)) { Handled = true; } return(Handled); }
public void writeB(PacketList.Server data) { writeB((byte)data); }
public override void DataReceived(ref byte[] inputPacket) { if (gameData.CryptIn == null) { #region GameServer Auth stuff byte[] game_key = new byte[16]; game_key[0] = inputPacket[4]; game_key[1] = inputPacket[5]; game_key[2] = inputPacket[6]; game_key[3] = inputPacket[7]; game_key[4] = inputPacket[8]; game_key[5] = inputPacket[9]; game_key[6] = inputPacket[10]; game_key[7] = inputPacket[11]; game_key[8] = 0xc8; game_key[9] = 0x27; game_key[10] = 0x93; game_key[11] = 0x01; game_key[12] = 0xa1; game_key[13] = 0x6c; game_key[14] = 0x31; game_key[15] = 0x97; gameData.CryptIn = new GameCrypt(); gameData.CryptOut = new GameCrypt(); gameData.CryptIn.setKey(game_key); gameData.CryptOut.setKey(game_key); int offset = 0; byte[] buff = new byte[1024]; buff[offset++] = 0x2B; for (int i = 0; i < UserConfig.Username.Length; i++) { buff[offset++] = (byte)UserConfig.Username[i]; buff[offset++] = 0x00; } buff[offset++] = 0x00; buff[offset++] = 0x00; buff[offset++] = gameData.PlayOK[4]; buff[offset++] = gameData.PlayOK[5]; buff[offset++] = gameData.PlayOK[6]; buff[offset++] = gameData.PlayOK[7]; buff[offset++] = gameData.PlayOK[0]; buff[offset++] = gameData.PlayOK[1]; buff[offset++] = gameData.PlayOK[2]; buff[offset++] = gameData.PlayOK[3]; buff[offset++] = gameData.LoginOK[0]; buff[offset++] = gameData.LoginOK[1]; buff[offset++] = gameData.LoginOK[2]; buff[offset++] = gameData.LoginOK[3]; buff[offset++] = gameData.LoginOK[4]; buff[offset++] = gameData.LoginOK[5]; buff[offset++] = gameData.LoginOK[6]; buff[offset++] = gameData.LoginOK[7]; buff[offset++] = 0x01; buff[offset++] = 0x00; buff[offset++] = 0x00; buff[offset++] = 0x00; buff[offset++] = 0x30; buff[offset++] = 0x01; buff[offset++] = 0x00; buff[offset++] = 0x00; for (int x = 0; x < 10; x++) { buff[offset++] = 0x00; } byte[] realBuffer = new byte[offset]; for (int i = 0; i < realBuffer.Length; i++) { realBuffer[i] = buff[i]; } GameWriter pck = new GameWriter(realBuffer, gameData); pck.Encrypt(); byte[] bytes = pck.Finalize(); Send(bytes); Debug.Information("Authenticating with the GameServer."); #endregion } else { GameReader packet = new GameReader(inputPacket, gameData); packet.Decrypt(); PacketList.Server opcode = (PacketList.Server)packet.readB(); if (opcode == PacketList.Server.DummyPacket) { opcode = (PacketList.Server)BitConverter.ToUInt16(new byte[] { (byte)opcode, packet.readB() }, 0); } switch (opcode) { case PacketList.Server.CharacterSelectionInfo: if (!CallPlugin_HandlePacket(opcode, packet)) { Debug.Information("Selecting the character specified in the config."); GameWriter pw = new GameWriter(gameData); pw.writeB(PacketList.Client.CharacterSelect); pw.writeD(Int32.Parse(UserConfig.Toon) - 1); pw.writeB(General.Hex("00 00 00 00 00 00 00 00 00 00 00 00 00 00")); pw.Encrypt(); Send(pw.Finalize()); } else { Debug.Information("The 'CharacterSelectionInfo' packet was overridden by a plugin."); } break; case PacketList.Server.CharacterSelectedPacket: if (!CallPlugin_HandlePacket(opcode, packet)) { byte[] EnterWorldPacket = General.Hex(PacketList.EnterWorld); GameWriter gw = new GameWriter(EnterWorldPacket, gameData); gw.Encrypt(); Send(gw.Finalize()); Debug.Information("Character selected, entering world..."); CallPlugin_HandlePacket(opcode, packet); } else { Debug.Information("The 'CharacterSelectedPacket' packet was overridden by a plugin."); } break; default: CallPlugin_HandlePacket(opcode, packet); break; } } }