private void ParseServerCreatureSpeak(InMessage message) { var statementId = message.ReadUInt(); var name = message.ReadString(); var level = message.ReadUShort(); var type = (MessageClasses)message.ReadByte(); Location location = null; switch (type) { case MessageClasses.SPEAK_SAY: case MessageClasses.SPEAK_WHISPER: case MessageClasses.SPEAK_YELL: case MessageClasses.SPEAK_MONSTER_SAY: case MessageClasses.SPEAK_MONSTER_YELL: case MessageClasses.SPEAK_SPELL: case MessageClasses.NPC_FROM: location = message.ReadLocation(); break; case MessageClasses.CHANNEL: case MessageClasses.CHANNEL_HIGHLIGHT: case MessageClasses.GAMEMASTER_CHANNEL: var channelId = message.ReadUShort(); break; default: break; } var text = message.ReadString(); client.Chat.OnCreatureSpeak(statementId, name, level, type, location, text); }
private void ParseServerFloorDescription(InMessage message, List <Tile> tiles, int x, int y, int z, int width, int height, int offset, ref int skipTiles) { for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { if (skipTiles == 0) { var tileOpt = message.PeekUShort(); // Decide if we have to skip tiles // or if it is a real tile if (tileOpt >= 0xFF00) { skipTiles = (short)(message.ReadUShort() & 0xFF); } else { //real tile so read tile tiles.Add(ParseServerTileDescription(message, new Location(x + nx + offset, y + ny + offset, z))); skipTiles = (short)(message.ReadUShort() & 0xFF); } } else { skipTiles--; } } } }
private void ParseServerCreatePrivateChannel(InMessage message) { var channelId = message.ReadUShort(); var name = message.ReadString(); message.ReadUShort(); message.ReadString(); message.ReadUShort(); }
private void ParseServerItemTextWindow(InMessage message) { var windowID = message.ReadUInt(); var itemID = message.ReadUShort(); var maxlen = message.ReadUShort(); var text = message.ReadString(); var writter = message.ReadString(); var date = message.ReadString(); }
private void ParseServerPlayerStats(InMessage message) { var health = message.ReadUShort(); var healthMax = message.ReadUShort(); var freeCapacity = message.ReadUInt(); var capacity = message.ReadUInt(); var experience = message.ReadULong(); var level = message.ReadUShort(); var levelPercent = message.ReadByte(); var mana = message.ReadUShort(); var manaMax = message.ReadUShort(); var magicLevel = message.ReadByte(); var baseMagicLevel = message.ReadByte(); var magicLevelPercent = message.ReadByte(); var soul = message.ReadByte(); var stamina = message.ReadUShort(); var speed = message.ReadUShort(); var regeneration = message.ReadUShort(); var offlineTranning = message.ReadUShort(); }
private void ParseServerQuestList(InMessage message) { var nQuests = message.ReadUShort(); for (uint i = 0; i < nQuests; ++i) { var questsID = message.ReadUShort(); var questsName = message.ReadString(); var questsState = message.ReadByte(); } }
private void ParseClientSay(InMessage message) { string receiver = null; ushort channelId = 0; MessageClasses type = (MessageClasses)message.ReadByte(); switch (type) { case MessageClasses.PRIVATE_TO: case MessageClasses.GAMEMASTER_PRIVATE_TO: receiver = message.ReadString(); break; case MessageClasses.CHANNEL: case MessageClasses.CHANNEL_HIGHLIGHT: case MessageClasses.GAMEMASTER_CHANNEL: channelId = message.ReadUShort(); break; default: break; } string text = message.ReadString(); client.Chat.OnPlayerSpeak(receiver, channelId, type, text); }
private void ParseClientSay(InMessage message) { string receiver = null; ushort channelId = 0; MessageClasses type = (MessageClasses)message.ReadByte(); switch (type) { case MessageClasses.PRIVATE_TO: case MessageClasses.GAMEMASTER_PRIVATE_TO: receiver = message.ReadString(); break; case MessageClasses.CHANNEL: case MessageClasses.CHANNEL_HIGHLIGHT: case MessageClasses.GAMEMASTER_CHANNEL: channelId = message.ReadUShort(); break; default: break; } string text = message.ReadString(); client.Chat.OnPlayerSpeak(receiver, channelId, type, text); }
private Item GetItem(InMessage message, ushort itemid) { if (itemid == ushort.MaxValue) { itemid = message.ReadUShort(); } ItemType type = client.Items.Get(itemid); if (type == null) { throw new Exception("[GetItem] (" + itemid + ") Can't find the item type."); } byte count = 0; byte subtype = 0; if (type.IsStackable) { count = message.ReadByte(); } else if (type.IsSplash || type.IsFluidContainer) { subtype = message.ReadByte(); } if (type.IsAnimation) { message.ReadByte(); // Desconhecido } return(new Item(type, count, subtype)); }
private void ParseServerOpenChannel(InMessage message) { var channelId = message.ReadUShort(); var name = message.ReadString(); var num = message.ReadUShort(); for (int i = 0; i < num; i++) { message.ReadString(); } num = message.ReadUShort(); for (int i = 0; i < num; i++) { message.ReadString(); } }
private void ParseServerSelfAppear(InMessage message) { client.BattleList.Clear(); client.Map.Clear(); client.PlayerId = message.ReadUInt(); message.ReadUShort(); client.PlayerCanReportBugs = message.ReadByte() != 0; }
private void ParseServerBasicData(InMessage message) { var isPremmium = message.ReadByte(); var vocation = message.ReadByte(); var knowSpells = message.ReadUShort(); message.ReadBytes(knowSpells); }
private void ParseServerChannelList(InMessage message) { var count = message.ReadByte(); for (uint i = 0; i < count; ++i) { var channelId = message.ReadUShort(); var name = message.ReadString(); } }
private void ParseServerMarketEnter(InMessage message) { message.ReadUInt(); message.ReadByte(); var num = message.ReadUShort(); for (int i = 0; i < num; i++) { message.ReadUInt(); } }
private void ParseServerOpenShopWindow(InMessage message) { var shop = new Shop(message.ReadString()); var size = message.ReadUShort(); for (uint i = 0; i < size; ++i) { var shopItem = new ShopItem(); shopItem.Id = message.ReadUShort(); shopItem.SubType = message.ReadByte(); shopItem.Name = message.ReadString(); shopItem.Weight = message.ReadUInt(); shopItem.BuyPrice = message.ReadUInt(); shopItem.SellPrice = message.ReadUInt(); shop.Items.Add(shopItem); } client.OnOpenShopWindow(shop); }
private void ParseServerQuestPartList(InMessage message) { var questsID = message.ReadUShort(); var nMission = message.ReadByte(); for (uint i = 0; i < nMission; ++i) { var questsName = message.ReadString(); var questsDesc = message.ReadString(); } }
private void ParseServerOutfitWindow(InMessage message) { message.ReadOutfit(); var nOutfits = message.ReadByte(); for (uint i = 0; i < nOutfits; ++i) { var outfitID = message.ReadUShort(); var name = message.ReadString(); var addons = message.ReadByte(); } int mountCount = message.ReadByte(); for (int i = 0; i < mountCount; ++i) { int mountId = message.ReadUShort(); // mount type string mountName = message.ReadString(); // mount name } }
private void ParseServerUpdateTile(InMessage message) { Location location = message.ReadLocation(); var thingId = message.PeekUShort(); if (thingId == 0xFF01) { message.ReadUShort(); Tile tile = client.Map.GetTile(location); if (tile == null) { throw new Exception("[ParseServerUpdateTile] Tile not found."); } tile.Clear(); } else { ParseServerTileDescription(message, location); message.ReadUShort(); } }
private Tile ParseServerTileDescription(InMessage message, Location location) { Tile tile = new Tile(location); if (message.PeekUShort() < 0xFF00) { message.ReadUShort(); } while (message.PeekUShort() < 0xFF00) { tile.AddThing(GetThing(message)); } client.Map.SetTile(tile); return(tile); }
private void ParseServerMarketDetail(InMessage message) { message.ReadUShort(); for (int i = 0; i < 15; i++) { message.ReadString(); } var num2 = message.ReadByte(); if (num2 > 0) { message.ReadBytes(num2 * 16); } num2 = message.ReadByte(); if (num2 > 0) { message.ReadBytes(num2 * 16); } }
private void ParseServerUpdateTile(InMessage message) { Location location = message.ReadLocation(); var thingId = message.PeekUShort(); if (thingId == 0xFF01) { message.ReadUShort(); Tile tile = client.Map.GetTile(location); if (tile == null) throw new Exception("[ParseServerUpdateTile] Tile not found."); tile.Clear(); } else { ParseServerTileDescription(message, location); message.ReadUShort(); } }
private void ParseServerPlayerIcons(InMessage message) { message.ReadUShort(); }
private Item GetItem(InMessage message, ushort itemid) { if (itemid == ushort.MaxValue) itemid = message.ReadUShort(); ItemType type = client.Items.Get(itemid); if (type == null) throw new Exception("[GetItem] (" + itemid + ") Can't find the item type."); byte count = 0; byte subtype = 0; if (type.IsStackable) count = message.ReadByte(); else if (type.IsSplash || type.IsFluidContainer) subtype = message.ReadByte(); if (type.IsAnimation) message.ReadByte(); // Desconhecido return new Item(type, count, subtype); }
private Thing GetThing(InMessage message) { //get thing type var thingId = message.ReadUShort(); if (thingId == 0x0061 || thingId == 0x0062) { //creatures Creature creature = null; if (thingId == 0x0062) { creature = client.BattleList.GetCreature(message.ReadUInt()); if (creature == null) throw new Exception("[GetThing] (0x0062) Can't find the creature in the battle list."); creature.Health = message.ReadByte(); } else if (thingId == 0x0061) { //creature is not known client.BattleList.RemoveCreature(message.ReadUInt()); creature = new Creature(message.ReadUInt()); client.BattleList.AddCreature(creature); creature.Type = (CreatureType)message.ReadByte(); creature.Name = message.ReadString(); creature.Health = message.ReadByte(); } var direction = (Direction)message.ReadByte(); creature.LookDirection = direction; creature.TurnDirection = direction; creature.Outfit = message.ReadOutfit(); creature.LightLevel = message.ReadByte(); creature.LightColor = message.ReadByte(); creature.Speed = message.ReadUShort(); creature.Skull = message.ReadByte(); creature.Shield = message.ReadByte(); if (thingId == 0x0061) // emblem is sent only in packet type 0x61 creature.Emblem = message.ReadByte(); creature.IsImpassable = message.ReadBool(); return creature; } else if (thingId == 0x0063) { Creature creature = client.BattleList.GetCreature(message.ReadUInt()); if (creature == null) throw new Exception("[GetThing] (0x0063) Can't find the creature in the battle list."); creature.TurnDirection = (Direction)message.ReadByte(); creature.IsImpassable = message.ReadBool(); return creature; } else return GetItem(message, thingId); }
private void ParseServerChannelEvent(InMessage message) { var channelId = message.ReadUShort(); var playerName = message.ReadString(); var channelEvent = message.ReadByte(); }
private void ParseServerOpenChannel(InMessage message) { var channelId = message.ReadUShort(); var name = message.ReadString(); var num = message.ReadUShort(); for (int i = 0; i < num; i++) message.ReadString(); num = message.ReadUShort(); for (int i = 0; i < num; i++) message.ReadString(); }
private void ParseInitialize(InMessage message) { if (minorVersion >= 10) message.ReadByte(); //? int count = message.ReadUShort(); for (int i = 0; i < count; i++) { var creature = new Creature(message.ReadUInt()); creature.Type = (CreatureType)message.ReadByte(); creature.Name = message.ReadString(); //Trace.WriteLine(String.Format("Creature[{0}]: {1}", i, creature.Name)); creature.Health = message.ReadByte(); var direction = (Direction)message.ReadByte(); creature.LookDirection = direction; creature.TurnDirection = direction; //Outfit creature.Outfit = message.ReadOutfit(); creature.LightLevel = message.ReadByte(); creature.LightColor = message.ReadByte(); creature.Speed = message.ReadUShort(); creature.Skull = message.ReadByte(); creature.Shield = message.ReadByte(); creature.Emblem = message.ReadByte(); creature.IsImpassable = message.ReadByte() == 0x01; //10.20+ includes an extra 4 bytes per creature //These bytes could alter the read order, but since I don't know what they are for yet, I'll read them out of the way. message.ReadUInt(); //speech category? if (client.Version.Number >= ClientVersion.Version1036.Number) message.ReadByte(); client.BattleList.AddCreature(creature); } ParseTibiaPackets(message); }
private void ParseServerMarketDetail(InMessage message) { message.ReadUShort(); for (int i = 0; i < 15; i++) message.ReadString(); var num2 = message.ReadByte(); if (num2 > 0) message.ReadBytes(num2 * 16); num2 = message.ReadByte(); if (num2 > 0) message.ReadBytes(num2 * 16); }
private void ParseServerMarketEnter(InMessage message) { message.ReadUInt(); message.ReadByte(); var num = message.ReadUShort(); for (int i = 0; i < num; i++) message.ReadUInt(); }
private void ParseServerMarketBrowser(InMessage message) { ushort num = message.ReadUShort(); if (num == 65535) { var count = message.ReadUInt(); for (int i = 0; i < count; i++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadByte(); } count = message.ReadUInt(); for (int j = 0; j <= count; j++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadByte(); } } else if (num == 65534) { var count = message.ReadUInt(); for (int k = 0; k <= count; k++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); } count = message.ReadUInt(); for (int l = 0; l <= count; l++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); } } else { var count = message.ReadUInt(); for (int m = 0; m < count; m++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadString(); } count = message.ReadUInt(); for (int n = 0; n < count; n++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadString(); } } }
private void ParseServerItemTextWindow(InMessage message) { var windowID = message.ReadUInt(); var itemID = message.ReadUShort(); var maxlen = message.ReadUShort(); var text = message.ReadString(); var writter = message.ReadString(); var date = message.ReadString(); }
private void ParseServerFloorDescription(InMessage message, List<Tile> tiles, int x, int y, int z, int width, int height, int offset, ref int skipTiles) { for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { if (skipTiles == 0) { var tileOpt = message.PeekUShort(); // Decide if we have to skip tiles // or if it is a real tile if (tileOpt >= 0xFF00) skipTiles = (short)(message.ReadUShort() & 0xFF); else { //real tile so read tile tiles.Add(ParseServerTileDescription(message, new Location(x + nx + offset, y + ny + offset, z))); skipTiles = (short)(message.ReadUShort() & 0xFF); } } else skipTiles--; } } }
private Tile ParseServerTileDescription(InMessage message, Location location) { Tile tile = new Tile(location); if (message.PeekUShort() < 0xFF00) message.ReadUShort(); while (message.PeekUShort() < 0xFF00) tile.AddThing(GetThing(message)); client.Map.SetTile(tile); return tile; }
private void ParseInitialize(InMessage message) { int count = message.ReadUShort(); for (int i = 0; i < count; i++) { var creature = new Creature(message.ReadUInt()); creature.Type = (CreatureType)message.ReadByte(); creature.Name = message.ReadString(); //Trace.WriteLine(String.Format("Creature[{0}]: {1}", i, creature.Name)); creature.Health = message.ReadByte(); var direction = (Direction)message.ReadByte(); creature.LookDirection = direction; creature.TurnDirection = direction; //Outfit creature.Outfit = message.ReadOutfit(); creature.LightLevel = message.ReadByte(); creature.LightColor = message.ReadByte(); creature.Speed = message.ReadUShort(); creature.Skull = message.ReadByte(); creature.Shield = message.ReadByte(); creature.Emblem = message.ReadByte(); creature.IsImpassable = message.ReadByte() == 0x01; client.BattleList.AddCreature(creature); } ParseTibiaPackets(message); }
private void ParseServerOpenShopWindow(InMessage message) { var shop = new Shop(message.ReadString()); var size = message.ReadUShort(); for (uint i = 0; i < size; ++i) { var shopItem = new ShopItem(); shopItem.Id = message.ReadUShort(); shopItem.SubType = message.ReadByte(); shopItem.Name = message.ReadString(); shopItem.Weight = message.ReadUInt(); shopItem.BuyPrice = message.ReadUInt(); shopItem.SellPrice = message.ReadUInt(); shop.Items.Add(shopItem); } client.OnOpenShopWindow(shop); }
private void ParseServerQuestList(InMessage message) { var nQuests = message.ReadUShort(); for (uint i = 0; i < nQuests; ++i) { var questsID = message.ReadUShort(); var questsName = message.ReadString(); var questsState = message.ReadByte(); } }
private void ParseServerCreatureSpeed(InMessage message) { var creatureID = message.ReadUInt(); var speed = message.ReadUShort(); }
private void ParseServerCreatePrivateChannel(InMessage message) { var channelId = message.ReadUShort(); var name = message.ReadString(); message.ReadUShort(); message.ReadString(); message.ReadUShort(); }
private void ParseServerMarketBrowser(InMessage message) { ushort num = message.ReadUShort(); if (num == 65535) { var count = message.ReadUInt(); for (int i = 0; i < count; i++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadByte(); } count = message.ReadUInt(); for (int j = 0; j <= count; j++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadByte(); } } else if (num == 65534) { var count = message.ReadUInt(); for (int k = 0; k <= count; k++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); } count = message.ReadUInt(); for (int l = 0; l <= count; l++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); } } else { var count = message.ReadUInt(); for (int m = 0; m < count; m++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadString(); } count = message.ReadUInt(); for (int n = 0; n < count; n++) { message.ReadUInt(); message.ReadUShort(); message.ReadUShort(); message.ReadUInt(); message.ReadString(); } } }
//private void ParseServerRuleViolationB1(InMessage message) //{ // message.ReadUShort(); //} //private void ParseServerRuleViolationB0(InMessage message) //{ // message.ReadUShort(); //} //private void ParseServerRuleViolationAF(InMessage message) //{ // message.ReadUShort(); //} private void ParseServerOpenRuleViolation(InMessage message) { message.ReadUShort(); }
private void ParseServerBasicData(InMessage message) { var isPremmium = message.ReadByte(); var vocation = message.ReadByte(); var knowSpells = message.ReadUShort(); message.ReadBytes(knowSpells); }
private void ParseServerLoginMessage() { #if DEBUG_PROXY Trace.WriteLine("[DEBUG] Proxy [ParseServerLoginMessage]"); #endif serverInMessage.ReadPosition = 2; if (Adler.Generate(serverInMessage) != serverInMessage.ReadChecksum()) { throw new Exception("Wrong checksum."); } Xtea.Decrypt(serverInMessage, xteaKey); serverInMessage.Size = serverInMessage.ReadInternalHead() + 8; serverInMessage.ReadPosition = 8; clientOutMessage.Reset(); Array.Copy(serverInMessage.Buffer, clientOutMessage.Buffer, serverInMessage.Size); clientOutMessage.Size = serverInMessage.Size; while (serverInMessage.ReadPosition < serverInMessage.Size) { byte cmd = serverInMessage.ReadByte(); switch (cmd) { case 0x0A: //Error message var msg = serverInMessage.ReadString(); break; case 0x0B: //For your information serverInMessage.ReadString(); break; case 0x14: //MOTD serverInMessage.ReadString(); break; case 0x1E: //Patching exe/dat/spr messages case 0x1F: case 0x20: //DisconnectClient(0x0A, "A new client is avalible, please download it first!"); break; case 0x28: //Select other login server //selectedLoginServer = random.Next(0, loginServers.Length - 1); break; case 0x64: //character list int nChar = (int)serverInMessage.ReadByte(); charList = new CharacterLoginInfo[nChar]; for (int i = 0; i < nChar; i++) { charList[i].CharName = serverInMessage.ReadString(); charList[i].WorldName = serverInMessage.ReadString(); clientOutMessage.WriteAt(new byte[] { 127, 0, 0, 1 }, serverInMessage.ReadPosition); charList[i].WorldIP = serverInMessage.ReadUInt(); clientOutMessage.WriteAt(BitConverter.GetBytes((ushort)worldClientPort), serverInMessage.ReadPosition); charList[i].WorldPort = serverInMessage.ReadUShort(); } break; default: break; } } clientOutMessage.WriteInternalHead(); Xtea.Encrypt(clientOutMessage, xteaKey); Adler.Generate(clientOutMessage, true); clientOutMessage.WriteHead(); SendToClient(clientOutMessage); }
private void ParseServerPlayerStats(InMessage message) { var health = message.ReadUShort(); var healthMax = message.ReadUShort(); var freeCapacity = message.ReadUInt(); var capacity = message.ReadUInt(); var experience = message.ReadULong(); var level = message.ReadUShort(); var levelPercent = message.ReadByte(); var mana = message.ReadUShort(); var manaMax = message.ReadUShort(); var magicLevel = message.ReadByte(); var baseMagicLevel = message.ReadByte(); var magicLevelPercent = message.ReadByte(); var soul = message.ReadByte(); var stamina = message.ReadUShort(); var speed = message.ReadUShort(); var regeneration = message.ReadUShort(); var offlineTranning = message.ReadUShort(); }
private void ParseServerLoginMessage() { #if DEBUG_PROXY Trace.WriteLine("[DEBUG] Proxy [ParseServerLoginMessage]"); #endif serverInMessage.ReadPosition = 2; if (Adler.Generate(serverInMessage) != serverInMessage.ReadChecksum()) { throw new Exception("Wrong checksum."); } Xtea.Decrypt(serverInMessage, xteaKey); serverInMessage.Size = serverInMessage.ReadInternalHead() + 8; serverInMessage.ReadPosition = 8; clientOutMessage.Reset(); Array.Copy(serverInMessage.Buffer, clientOutMessage.Buffer, serverInMessage.Size); clientOutMessage.Size = serverInMessage.Size; while (serverInMessage.ReadPosition < serverInMessage.Size) { byte cmd = serverInMessage.ReadByte(); switch (cmd) { case 0x0A: //Error message var msg = serverInMessage.ReadString(); break; case 0x0B: //For your information serverInMessage.ReadString(); break; case 0x14: //MOTD serverInMessage.ReadString(); break; case 0x1E: //Patching exe/dat/spr messages case 0x1F: case 0x20: //DisconnectClient(0x0A, "A new client is avalible, please download it first!"); break; case 0x28: //Select other login server //selectedLoginServer = random.Next(0, loginServers.Length - 1); break; case 0x64: //character list if (client.Version.Number <= ClientVersion.Version1011.Number) { int nChar = (int)serverInMessage.ReadByte(); charList = new CharacterLoginInfo[nChar]; for (int i = 0; i < nChar; i++) { charList[i].CharName = serverInMessage.ReadString(); charList[i].WorldName = serverInMessage.ReadString(); clientOutMessage.WriteAt(new byte[] { 127, 0, 0, 1 }, serverInMessage.ReadPosition); charList[i].WorldIP = serverInMessage.ReadUInt(); clientOutMessage.WriteAt(BitConverter.GetBytes((ushort)worldClientPort), serverInMessage.ReadPosition); charList[i].WorldPort = serverInMessage.ReadUShort(); if (client.Version.Number >= ClientVersion.Version981.Number) { serverInMessage.ReadByte(); //isPreviewWorld } } if (client.Version.Number >= ClientVersion.Version1011.Number) { serverInMessage.ReadUShort(); //PremiumTime } } else if (client.Version.Number >= ClientVersion.Version1012.Number) { clientOutMessage.WritePosition = serverInMessage.ReadPosition; byte nWorlds = serverInMessage.ReadByte(); clientOutMessage.WriteByte(nWorlds); WorldLoginInfo[] worldList = new WorldLoginInfo[nWorlds]; for (byte i = 0; i < nWorlds; i++) { worldList[i].ID = serverInMessage.ReadByte(); clientOutMessage.WriteByte(worldList[i].ID); worldList[i].Name = serverInMessage.ReadString(); clientOutMessage.WriteString(worldList[i].Name); worldList[i].Hostname = serverInMessage.ReadString(); clientOutMessage.WriteString("127.0.0.1"); worldList[i].Port = serverInMessage.ReadUShort(); clientOutMessage.WriteUShort((ushort)worldClientPort); worldList[i].IsPreviewWorld = serverInMessage.ReadBool(); clientOutMessage.WriteByte(Convert.ToByte(worldList[i].IsPreviewWorld)); } byte nChars = serverInMessage.ReadByte(); clientOutMessage.WriteByte(nChars); charList = new CharacterLoginInfo[nChars]; for (byte j = 0; j < nChars; j++) { byte WorldID = serverInMessage.ReadByte(); clientOutMessage.WriteByte(WorldID); charList[j].CharName = serverInMessage.ReadString(); clientOutMessage.WriteString(charList[j].CharName); charList[j].WorldName = worldList[WorldID].Name; charList[j].WorldIP = BitConverter.ToUInt32(Dns.GetHostAddresses(worldList[WorldID].Hostname)[0].GetAddressBytes(), 0); charList[j].WorldPort = worldList[WorldID].Port; charList[j].WorldIPString = worldList[WorldID].Hostname; } ushort PremiumTime = serverInMessage.ReadUShort(); clientOutMessage.WriteUShort(PremiumTime); clientOutMessage.Size = clientOutMessage.WritePosition; } break; default: break; } } clientOutMessage.WriteInternalHead(); Xtea.Encrypt(clientOutMessage, xteaKey); Adler.Generate(clientOutMessage, true); clientOutMessage.WriteHead(); SendToClient(clientOutMessage); }
private void ParseServerClosePrivateChannel(InMessage message) { var channelId = message.ReadUShort(); }
private void ParseServerSelfAppear(InMessage message) { client.BattleList.Clear(); client.Map.Clear(); client.PlayerId = message.ReadUInt(); message.ReadUShort(); client.PlayerCanReportBugs = message.ReadByte() != 0; }
//private void ParseServerRuleViolationB1(InMessage message) //{ // message.ReadUShort(); //} //private void ParseServerRuleViolationB0(InMessage message) //{ // message.ReadUShort(); //} //private void ParseServerRuleViolationAF(InMessage message) //{ // message.ReadUShort(); //} private void ParseServerOpenRuleViolation(InMessage message) { message.ReadUShort(); }
public void ParseServerMessage(InMessage message) { var packets = new List<byte>(); var packetStart = 0; try { while (message.ReadPosition < message.Size) { packetStart = message.ReadPosition; byte cmd = message.ReadByte(); packets.Add(cmd); switch (cmd) { case 0x0A: ParseServerSelfAppear(message); break; case 0x0B: ParseServerGMActions(message); break; case 0x14: ParseServerErrorMessage(message); break; case 0x15: ParseServerFYIMessage(message); break; case 0x16: ParseServerWaitingList(message); break; case 0x1D: ParseServerPing(message); break; case 0x1E: ParseServerPingBack(message); break; case 0x28: ParseServerDeath(message); break; case 0x32: ParseServerCanReportBugs(message); break; case 0x64: ParseServerMapDescription(message); break; case 0x65: ParseServerMoveNorth(message); break; case 0x66: ParseServerMoveEast(message); break; case 0x67: ParseServerMoveSouth(message); break; case 0x68: ParseServerMoveWest(message); break; case 0x69: ParseServerUpdateTile(message); break; case 0x6A: ParseServerTileAddThing(message); break; case 0x6B: ParseServerTileTransformThing(message); break; case 0x6C: ParseServerTileRemoveThing(message); break; case 0x6D: ParseServerCreatureMove(message); break; case 0x6E: ParseServerOpenContainer(message); break; case 0x6F: ParseServerCloseContainer(message); break; case 0x70: ParseServerContainerAddItem(message); break; case 0x71: ParseServerContainerUpdateItem(message); break; case 0x72: ParseServerContainerRemoveItem(message); break; case 0x78: ParseServerInventorySetSlot(message); break; case 0x79: ParseServerInventoryResetSlot(message); break; case 0x7D: ParseServerSafeTradeRequestAck(message); break; case 0x7E: ParseServerSafeTradeRequestNoAck(message); break; case 0x7F: ParseServerSafeTradeClose(message); break; case 0x82: ParseServerWorldLight(message); break; case 0x83: ParseServerMagicEffect(message); break; case 0x84: ParseServerAnimatedText(message); break; case 0x85: ParseServerDistanceShot(message); break; case 0x86: ParseServerCreatureSquare(message); break; case 0x87: byte b = message.ReadByte(); if (b > 0) message.ReadBytes(b * 4); break; case 0x8C: ParseServerCreatureHealth(message); break; case 0x8D: ParseServerCreatureLight(message); break; case 0x8E: ParseServerCreatureOutfit(message); break; case 0x8F: ParseServerCreatureSpeed(message); break; case 0x90: ParseServerCreatureSkulls(message); break; case 0x91: ParseServerCreatureShields(message); break; case 0x92: ParseServerCreaturePassable(message); break; case 0x96: ParseServerItemTextWindow(message); break; case 0x97: ParseServerHouseTextWindow(message); break; case 0xA0: ParseServerPlayerStats(message); break; case 0xA1: ParseServerPlayerSkills(message); break; case 0xA2: ParseServerPlayerIcons(message); break; case 0xA3: ParseServerPlayerCancelAttack(message); break; case 0xA4: ParseServerSpellCooldown(message); break; case 0xA5: ParseServerSpellGroupCooldown(message); break; case 0xA6: //desconhecido message.ReadUInt(); break; case 0xAA: ParseServerCreatureSpeak(message); break; case 0xAB: ParseServerChannelList(message); break; case 0xAC: ParseServerOpenChannel(message); break; case 0xAD: ParseServerOpenPrivatePlayerChat(message); break; case 0xAE: ParseServerOpenRuleViolation(message); break; case 0xB2: ParseServerCreatePrivateChannel(message); break; case 0xB3: ParseServerClosePrivateChannel(message); break; case 0xB4: ParseServerTextMessage(message); break; case 0xB5: ParseServerPlayerCancelWalk(message); break; case 0xB6: message.ReadUShort(); break; case 0xBE: ParseServerFloorChangeUp(message); break; case 0xBF: ParseServerFloorChangeDown(message); break; case 0xC8: ParseServerOutfitWindow(message); break; case 0xD2: ParseServerVipState(message); break; case 0xD3: ParseServerVipLogin(message); break; case 0xD4: ParseServerVipLogout(message); break; case 0xF0: ParseServerQuestList(message); break; case 0xF1: ParseServerQuestPartList(message); break; case 0x7A: ParseServerOpenShopWindow(message); break; case 0x7B: ParseServerPlayerCash(message); break; case 0x7C: ParseServerCloseShopWindow(message); break; case 0x9F: ParseServerBasicData(message); break; case 0xDC: ParseServerShowTutorial(message); break; case 0xDD: ParseServerAddMapMarker(message); break; case 0xF3: ParseServerChannelEvent(message); break; case 0xF6: ParseServerMarketEnter(message); break; case 0xF7: ParseServerMarketLeave(message); break; case 0xF8: ParseServerMarketDetail(message); break; case 0xF9: ParseServerMarketBrowser(message); break; default: throw new Exception("ProtocolWorld [ParseServerMessage]: Unkonw packet type " + cmd.ToString("X2")); } } } catch (Exception ex) { Trace.TraceWarning(ex.Message + "\nLast Packets: " + packets.ToArray().ToHexString() + "\nPacket Bytes: " + message.Buffer.ToHexString(packetStart, message.ReadPosition - packetStart)); } }
public void ParseServerMessage(InMessage message) { var packets = new List <byte>(); var packetStart = 0; try { while (message.ReadPosition < message.Size) { packetStart = message.ReadPosition; byte cmd = message.ReadByte(); packets.Add(cmd); switch (cmd) { case 0x0A: ParseServerSelfAppear(message); break; case 0x0B: ParseServerGMActions(message); break; case 0x14: ParseServerErrorMessage(message); break; case 0x15: ParseServerFYIMessage(message); break; case 0x16: ParseServerWaitingList(message); break; case 0x1D: ParseServerPing(message); break; case 0x1E: ParseServerPingBack(message); break; case 0x28: ParseServerDeath(message); break; case 0x32: ParseServerCanReportBugs(message); break; case 0x64: ParseServerMapDescription(message); break; case 0x65: ParseServerMoveNorth(message); break; case 0x66: ParseServerMoveEast(message); break; case 0x67: ParseServerMoveSouth(message); break; case 0x68: ParseServerMoveWest(message); break; case 0x69: ParseServerUpdateTile(message); break; case 0x6A: ParseServerTileAddThing(message); break; case 0x6B: ParseServerTileTransformThing(message); break; case 0x6C: ParseServerTileRemoveThing(message); break; case 0x6D: ParseServerCreatureMove(message); break; case 0x6E: ParseServerOpenContainer(message); break; case 0x6F: ParseServerCloseContainer(message); break; case 0x70: ParseServerContainerAddItem(message); break; case 0x71: ParseServerContainerUpdateItem(message); break; case 0x72: ParseServerContainerRemoveItem(message); break; case 0x78: ParseServerInventorySetSlot(message); break; case 0x79: ParseServerInventoryResetSlot(message); break; case 0x7D: ParseServerSafeTradeRequestAck(message); break; case 0x7E: ParseServerSafeTradeRequestNoAck(message); break; case 0x7F: ParseServerSafeTradeClose(message); break; case 0x82: ParseServerWorldLight(message); break; case 0x83: ParseServerMagicEffect(message); break; case 0x84: ParseServerAnimatedText(message); break; case 0x85: ParseServerDistanceShot(message); break; case 0x86: ParseServerCreatureSquare(message); break; case 0x87: byte b = message.ReadByte(); if (b > 0) { message.ReadBytes(b * 4); } break; case 0x8C: ParseServerCreatureHealth(message); break; case 0x8D: ParseServerCreatureLight(message); break; case 0x8E: ParseServerCreatureOutfit(message); break; case 0x8F: ParseServerCreatureSpeed(message); break; case 0x90: ParseServerCreatureSkulls(message); break; case 0x91: ParseServerCreatureShields(message); break; case 0x92: ParseServerCreaturePassable(message); break; case 0x96: ParseServerItemTextWindow(message); break; case 0x97: ParseServerHouseTextWindow(message); break; case 0xA0: ParseServerPlayerStats(message); break; case 0xA1: ParseServerPlayerSkills(message); break; case 0xA2: ParseServerPlayerIcons(message); break; case 0xA3: ParseServerPlayerCancelAttack(message); break; case 0xA4: ParseServerSpellCooldown(message); break; case 0xA5: ParseServerSpellGroupCooldown(message); break; case 0xA6: //desconhecido message.ReadUInt(); break; case 0xAA: ParseServerCreatureSpeak(message); break; case 0xAB: ParseServerChannelList(message); break; case 0xAC: ParseServerOpenChannel(message); break; case 0xAD: ParseServerOpenPrivatePlayerChat(message); break; case 0xAE: ParseServerOpenRuleViolation(message); break; case 0xB2: ParseServerCreatePrivateChannel(message); break; case 0xB3: ParseServerClosePrivateChannel(message); break; case 0xB4: ParseServerTextMessage(message); break; case 0xB5: ParseServerPlayerCancelWalk(message); break; case 0xB6: message.ReadUShort(); break; case 0xBE: ParseServerFloorChangeUp(message); break; case 0xBF: ParseServerFloorChangeDown(message); break; case 0xC8: ParseServerOutfitWindow(message); break; case 0xD2: ParseServerVipState(message); break; case 0xD3: ParseServerVipLogin(message); break; case 0xD4: ParseServerVipLogout(message); break; case 0xF0: ParseServerQuestList(message); break; case 0xF1: ParseServerQuestPartList(message); break; case 0x7A: ParseServerOpenShopWindow(message); break; case 0x7B: ParseServerPlayerCash(message); break; case 0x7C: ParseServerCloseShopWindow(message); break; case 0x9F: ParseServerBasicData(message); break; case 0xDC: ParseServerShowTutorial(message); break; case 0xDD: ParseServerAddMapMarker(message); break; case 0xF3: ParseServerChannelEvent(message); break; case 0xF6: ParseServerMarketEnter(message); break; case 0xF7: ParseServerMarketLeave(message); break; case 0xF8: ParseServerMarketDetail(message); break; case 0xF9: ParseServerMarketBrowser(message); break; default: throw new Exception("ProtocolWorld [ParseServerMessage]: Unkonw packet type " + cmd.ToString("X2")); } } } catch (Exception ex) { Trace.TraceWarning(ex.Message + "\nLast Packets: " + packets.ToArray().ToHexString() + "\nPacket Bytes: " + message.Buffer.ToHexString(packetStart, message.ReadPosition - packetStart)); } }
private void ParseServerClosePrivateChannel(InMessage message) { var channelId = message.ReadUShort(); }
private void ParseServerOutfitWindow(InMessage message) { message.ReadOutfit(); var nOutfits = message.ReadByte(); for (uint i = 0; i < nOutfits; ++i) { var outfitID = message.ReadUShort(); var name = message.ReadString(); var addons = message.ReadByte(); } int mountCount = message.ReadByte(); for (int i = 0; i < mountCount; ++i) { int mountId = message.ReadUShort(); // mount type string mountName = message.ReadString(); // mount name } }
private void ParseServerChannelEvent(InMessage message) { var channelId = message.ReadUShort(); var playerName = message.ReadString(); var channelEvent = message.ReadByte(); }
private void ParseServerCreatureSpeed(InMessage message) { var creatureID = message.ReadUInt(); var speed = message.ReadUShort(); }
private void ParseServerChannelList(InMessage message) { var count = message.ReadByte(); for (uint i = 0; i < count; ++i) { var channelId = message.ReadUShort(); var name = message.ReadString(); } }
private void ParseTibiaPackets(InMessage message) { var packetCount = message.ReadUShort(); for (int j = 0; j < packetCount; j++) { var packetSize = message.ReadUShort(); var packet = message.ReadBytes(packetSize); var packetMessage = new InMessage(packet, packetSize); ParseTibiaPacket(packetMessage); } }
private void ParseServerCreatureSpeak(InMessage message) { var statementId = message.ReadUInt(); var name = message.ReadString(); var level = message.ReadUShort(); var type = (MessageClasses)message.ReadByte(); Location location = null; switch (type) { case MessageClasses.SPEAK_SAY: case MessageClasses.SPEAK_WHISPER: case MessageClasses.SPEAK_YELL: case MessageClasses.SPEAK_MONSTER_SAY: case MessageClasses.SPEAK_MONSTER_YELL: case MessageClasses.SPEAK_SPELL: case MessageClasses.NPC_FROM: location = message.ReadLocation(); break; case MessageClasses.CHANNEL: case MessageClasses.CHANNEL_HIGHLIGHT: case MessageClasses.GAMEMASTER_CHANNEL: var channelId = message.ReadUShort(); break; default: break; } var text = message.ReadString(); client.Chat.OnCreatureSpeak(statementId, name, level, type, location, text); }
private void ParseServerLoginMessage() { #if DEBUG_PROXY Trace.WriteLine("[DEBUG] Proxy [ParseServerLoginMessage]"); #endif serverInMessage.ReadPosition = 2; if (Adler.Generate(serverInMessage) != serverInMessage.ReadChecksum()) { throw new Exception("Wrong checksum."); } Xtea.Decrypt(serverInMessage, xteaKey); serverInMessage.Size = serverInMessage.ReadInternalHead() + 8; serverInMessage.ReadPosition = 8; clientOutMessage.Reset(); Array.Copy(serverInMessage.Buffer, clientOutMessage.Buffer, serverInMessage.Size); clientOutMessage.Size = serverInMessage.Size; while (serverInMessage.ReadPosition < serverInMessage.Size) { byte cmd = serverInMessage.ReadByte(); switch (cmd) { case 0x0A: //Error message var msg = serverInMessage.ReadString(); break; case 0x0B: //For your information serverInMessage.ReadString(); break; case 0x0C: //token succes case 0x0D: //token error serverInMessage.ReadByte(); break; case 0x11: //update serverInMessage.ReadString(); break; case 0x14: //MOTD serverInMessage.ReadString(); break; case 0x1E: //Patching exe/dat/spr messages case 0x1F: case 0x20: //DisconnectClient(0x0A, "A new client is avalible, please download it first!"); break; case 0x28: //session key serverInMessage.ReadString(); break; case 0x64: //character list if (client.Version.Number <= ClientVersion.Version1011.Number) { int nChar = (int)serverInMessage.ReadByte(); charList = new CharacterLoginInfo[nChar]; for (int i = 0; i < nChar; i++) { charList[i].CharName = serverInMessage.ReadString(); charList[i].WorldName = serverInMessage.ReadString(); clientOutMessage.WriteAt(new byte[] { 127, 0, 0, 1 }, serverInMessage.ReadPosition); charList[i].WorldIP = serverInMessage.ReadUInt(); clientOutMessage.WriteAt(BitConverter.GetBytes((ushort)worldClientPort), serverInMessage.ReadPosition); charList[i].WorldPort = serverInMessage.ReadUShort(); if (client.Version.Number >= ClientVersion.Version981.Number) { serverInMessage.ReadByte(); //isPreviewWorld } } if (client.Version.Number >= ClientVersion.Version1011.Number) { serverInMessage.ReadUShort(); //PremiumTime } } else if (client.Version.Number >= ClientVersion.Version1012.Number) { clientOutMessage.WritePosition = serverInMessage.ReadPosition; byte nWorlds = serverInMessage.ReadByte(); clientOutMessage.WriteByte(nWorlds); WorldLoginInfo[] worldList = new WorldLoginInfo[nWorlds]; for (byte i = 0; i < nWorlds; i++) { worldList[i].ID = serverInMessage.ReadByte(); clientOutMessage.WriteByte(worldList[i].ID); worldList[i].Name = serverInMessage.ReadString(); clientOutMessage.WriteString(worldList[i].Name); worldList[i].Hostname = serverInMessage.ReadString(); clientOutMessage.WriteString("127.0.0.1"); worldList[i].Port = serverInMessage.ReadUShort(); clientOutMessage.WriteUShort((ushort)worldClientPort); worldList[i].IsPreviewWorld = serverInMessage.ReadBool(); clientOutMessage.WriteByte(Convert.ToByte(worldList[i].IsPreviewWorld)); } byte nChars = serverInMessage.ReadByte(); clientOutMessage.WriteByte(nChars); charList = new CharacterLoginInfo[nChars]; for (byte j = 0; j < nChars; j++) { byte WorldID = serverInMessage.ReadByte(); clientOutMessage.WriteByte(WorldID); charList[j].CharName = serverInMessage.ReadString(); clientOutMessage.WriteString(charList[j].CharName); charList[j].WorldName = worldList[WorldID].Name; charList[j].WorldIP = BitConverter.ToUInt32(Dns.GetHostAddresses(worldList[WorldID].Hostname)[0].GetAddressBytes(), 0); charList[j].WorldPort = worldList[WorldID].Port; charList[j].WorldIPString = worldList[WorldID].Hostname; } /** * Not very accurately named variables, but I'll settle for some pseudocode in case of futher implementations * * if version < 10.80: * ushort PremiumTime * else if version < 10.82 * bool isPremium * uint PremiumTime (In seconds from epoch - don't quote me on this :D) * else if version >= 10.82 * byte AccountStatus (0 = normal, 1 = frozen, 2 = suspended) * bool isPremium * uint PremiumTime */ ushort PremiumTime = serverInMessage.ReadUShort(); clientOutMessage.WriteUShort(PremiumTime); if (client.Version.Number >= ClientVersion.Version1090.Number) // From 10.80 - but haven't added 10.80 support. { uint PremiumSeconds = serverInMessage.ReadUInt(); // Not sure about this name. clientOutMessage.WriteUInt(PremiumSeconds); } clientOutMessage.Size = clientOutMessage.WritePosition; } break; default: break; } } clientOutMessage.WriteInternalHead(); Xtea.Encrypt(clientOutMessage, xteaKey); Adler.Generate(clientOutMessage, true); clientOutMessage.WriteHead(); SendToClient(clientOutMessage); }
private Thing GetThing(InMessage message) { //get thing type var thingId = message.ReadUShort(); if (thingId == 0x0061 || thingId == 0x0062) { //creatures Creature creature = null; if (thingId == 0x0062) { creature = client.BattleList.GetCreature(message.ReadUInt()); if (creature == null) { throw new Exception("[GetThing] (0x0062) Can't find the creature in the battle list."); } creature.Health = message.ReadByte(); } else if (thingId == 0x0061) { //creature is not known client.BattleList.RemoveCreature(message.ReadUInt()); creature = new Creature(message.ReadUInt()); client.BattleList.AddCreature(creature); creature.Type = (CreatureType)message.ReadByte(); creature.Name = message.ReadString(); creature.Health = message.ReadByte(); } var direction = (Direction)message.ReadByte(); creature.LookDirection = direction; creature.TurnDirection = direction; creature.Outfit = message.ReadOutfit(); creature.LightLevel = message.ReadByte(); creature.LightColor = message.ReadByte(); creature.Speed = message.ReadUShort(); creature.Skull = message.ReadByte(); creature.Shield = message.ReadByte(); if (thingId == 0x0061) // emblem is sent only in packet type 0x61 { creature.Emblem = message.ReadByte(); } creature.IsImpassable = message.ReadBool(); return(creature); } else if (thingId == 0x0063) { Creature creature = client.BattleList.GetCreature(message.ReadUInt()); if (creature == null) { throw new Exception("[GetThing] (0x0063) Can't find the creature in the battle list."); } creature.TurnDirection = (Direction)message.ReadByte(); creature.IsImpassable = message.ReadBool(); return(creature); } else { return(GetItem(message, thingId)); } }
private void ParseFirstClientMessage() { #if DEBUG_PROXY Trace.WriteLine("[DEBUG] Proxy [ParseFirstClientMessage]"); #endif clientInMessage.ReadPosition = 2; clientInMessage.Encrypted = false; if (Adler.Generate(clientInMessage) != clientInMessage.ReadUInt()) { throw new Exception("Wrong checksum."); } byte protocolId = clientInMessage.ReadByte(); if (protocolId == 0x01) //Login { protocol = Protocol.Login; ushort clientType = clientInMessage.ReadUShort(); ushort protocolVersion = clientInMessage.ReadUShort(); if (client.Version.Number >= ClientVersion.Version981.Number) { uint clientVersion = clientInMessage.ReadUInt(); } uint datSignature = clientInMessage.ReadUInt(); uint sprSignature = clientInMessage.ReadUInt(); uint picSignature = clientInMessage.ReadUInt(); if (client.Version.Number >= ClientVersion.Version981.Number) { byte clientPreviewState = clientInMessage.ReadByte(); } Rsa.OpenTibiaDecrypt(clientInMessage); Array.Copy(clientInMessage.Buffer, serverOutMessage.Buffer, clientInMessage.Size); serverOutMessage.Size = clientInMessage.Size; serverOutMessage.WritePosition = clientInMessage.ReadPosition - 1; //the first byte is zero xteaKey = new uint[4]; xteaKey[0] = clientInMessage.ReadUInt(); xteaKey[1] = clientInMessage.ReadUInt(); xteaKey[2] = clientInMessage.ReadUInt(); xteaKey[3] = clientInMessage.ReadUInt(); var acc = clientInMessage.ReadString(); //account name var pass = clientInMessage.ReadString(); //password if (client.IsOpenTibiaServer) { Rsa.OpenTibiaEncrypt(serverOutMessage); } else { Rsa.RealTibiaEncrypt(serverOutMessage); } Adler.Generate(serverOutMessage, true); serverOutMessage.WriteHead(); serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); serverSocket.Connect(loginServers[0].Server, loginServers[0].Port); serverSocket.Send(serverOutMessage.Buffer, 0, serverOutMessage.Size, SocketFlags.None); serverInMessage.Reset(); serverSocket.BeginReceive(serverInMessage.Buffer, 0, 2, SocketFlags.None, ServerReceiveCallback, null); } else if (protocolId == 0x0A) //Game { protocol = Protocol.World; ushort clientType = clientInMessage.ReadUShort(); ushort protocolVersion = clientInMessage.ReadUShort(); if (client.Version.Number >= ClientVersion.Version981.Number) { uint clientVersion = clientInMessage.ReadUInt(); byte clientPreviewState = clientInMessage.ReadByte(); } Rsa.OpenTibiaDecrypt(clientInMessage); Array.Copy(clientInMessage.Buffer, serverOutMessage.Buffer, clientInMessage.Size); serverOutMessage.Size = clientInMessage.Size; serverOutMessage.WritePosition = clientInMessage.ReadPosition - 1; //the first byte is zero xteaKey = new uint[4]; xteaKey[0] = clientInMessage.ReadUInt(); xteaKey[1] = clientInMessage.ReadUInt(); xteaKey[2] = clientInMessage.ReadUInt(); xteaKey[3] = clientInMessage.ReadUInt(); clientInMessage.ReadByte(); var accountName = clientInMessage.ReadString(); var characterName = clientInMessage.ReadString(); var password = clientInMessage.ReadString(); if (client.IsOpenTibiaServer) { Rsa.OpenTibiaEncrypt(serverOutMessage); } else { Rsa.RealTibiaEncrypt(serverOutMessage); } Adler.Generate(serverOutMessage, true); serverOutMessage.WriteHead(); serverSocket.Send(serverOutMessage.Buffer, 0, serverOutMessage.Size, SocketFlags.None); } else { throw new Exception("Invalid protocol " + protocolId.ToString("X2")); } }
private void ParseServerQuestPartList(InMessage message) { var questsID = message.ReadUShort(); var nMission = message.ReadByte(); for (uint i = 0; i < nMission; ++i) { var questsName = message.ReadString(); var questsDesc = message.ReadString(); } }