public static AutoWalkPacket Parse(NetworkMessage message) { AutoWalkPacket packet = new AutoWalkPacket(); packet.Directions = new Queue<Direction>(); byte count = message.GetByte(); for (int i = 0; i < count; i++) { Direction direction; byte dir = message.GetByte(); switch (dir) { case 1: direction = Direction.East; break; case 2: direction = Direction.NorthEast; break; case 3: direction = Direction.North; break; case 4: direction = Direction.NorthWest; break; case 5: direction = Direction.West; break; case 6: direction = Direction.SouthWest; break; case 7: direction = Direction.South; break; case 8: direction = Direction.SouthEast; break; default: continue; } packet.Directions.Enqueue(direction); } return packet; }
public static LoginPacket Parse(NetworkMessage message) { LoginPacket packet = new LoginPacket(); packet.Os = message.GetUInt16(); // OS packet.Version = message.GetUInt16(); // version message.RSADecrypt(); message.GetByte(); // should be zero packet.XteaKey = new uint[4]; packet.XteaKey[0] = message.GetUInt32(); packet.XteaKey[1] = message.GetUInt32(); packet.XteaKey[2] = message.GetUInt32(); packet.XteaKey[3] = message.GetUInt32(); packet.GmMode = message.GetByte(); packet.AccountName = message.GetString(); packet.CharacterName = message.GetString(); packet.Password = message.GetString(); message.SkipBytes(6); // 841 specific (according to OT) return packet; }
public static PlayerSpeechPacket Parse(NetworkMessage message) { PlayerSpeechPacket packet = new PlayerSpeechPacket(); packet.Speech = new Speech(); packet.Speech.Type = (SpeechType)message.GetByte(); switch (packet.Speech.Type) { case SpeechType.Private: case SpeechType.PrivateRed: case SpeechType.RuleViolationAnswer: packet.Speech.Receiver = message.GetString(); break; case SpeechType.ChannelYellow: case SpeechType.ChannelRed: case SpeechType.ChannelRedAnonymous: case SpeechType.ChannelWhite: packet.Speech.ChannelId = (ChatChannel)message.GetUInt16(); break; default: break; } packet.Speech.Message = message.GetString(); return packet; }
public static void Add(NetworkMessage message, Location location, TextColor color, string text) { message.AddByte((byte)ServerPacketType.AnimatedText); message.AddLocation(location); message.AddByte((byte)color); message.AddString(text); }
public static void AddMapDescription(Connection connection, NetworkMessage message, int x, int y, int z, ushort width, ushort height) { int MAP_MAX_LAYERS = 16; int skip = -1; int startZ, endZ, zStep = 0; if (z > 7) { startZ = z - 2; endZ = Math.Min(MAP_MAX_LAYERS - 1, z + 2); zStep = 1; } else { startZ = 7; endZ = 0; zStep = -1; } for (int nz = startZ; nz != endZ + zStep; nz += zStep) { skip = AddFloorDescription(connection, message, x, y, nz, width, height, z - nz, skip); } if (skip >= 0) { message.AddByte((byte)skip); message.AddByte(0xFF); } }
public static int AddFloorDescription(Connection connection, NetworkMessage message, int x, int y, int z, int width, int height, int offset, int skip) { Tile tile; for (int nx = 0; nx < width; nx++) { for (int ny = 0; ny < height; ny++) { tile = connection.Game.Map.GetTile(x + nx + offset, y + ny + offset, z); if (tile != null) { if (skip >= 0) { message.AddByte((byte)skip); message.AddByte(0xFF); } skip = 0; AddTileDescription(connection, message, tile); } else { skip++; if (skip == 0xFF) { message.AddByte(0xFF); message.AddByte(0xFF); skip = -1; } } } } return skip; }
// TODO: map debug public static void AddTileDescription(Connection connection, NetworkMessage message, Tile tile) { if (tile != null) { int count = 0; if (tile.Ground != null) { message.AddItem(tile.Ground); ++count; } foreach (Item item in tile.GetTopItems()) { message.AddItem(item); ++count; } foreach (Creature creature in tile.Creatures) { if (true)// (player->canSeeCreature(*cit)) { uint removeKnown; bool known = connection.IsCreatureKnown(creature.Id, out removeKnown); message.AddCreature(creature, known, removeKnown); count++; } } foreach (Item item in tile.GetDownItems()) { message.AddItem(item); ++count; } } }
public static void Add(NetworkMessage message, Location fromLocation, Location toLocation, ProjectileType projectile) { message.AddByte((byte)ServerPacketType.Projectile); message.AddLocation(fromLocation); message.AddLocation(toLocation); message.AddByte((byte)projectile); }
public static void Add( Connection connection, NetworkMessage outMessage, Location fromLocation, Location toLocation ) { if (fromLocation.Y > toLocation.Y) { // north, for old x outMessage.AddByte((byte)ServerPacketType.MapSliceNorth); AddMapDescription(connection, outMessage, fromLocation.X - 8, toLocation.Y - 6, toLocation.Z, 18, 1); } else if (fromLocation.Y < toLocation.Y) { // south, for old x outMessage.AddByte((byte)ServerPacketType.MapSliceSouth); AddMapDescription(connection, outMessage, fromLocation.X - 8, toLocation.Y + 7, toLocation.Z, 18, 1); } if (fromLocation.X < toLocation.X) { // east, [with new y] outMessage.AddByte((byte)ServerPacketType.MapSliceEast); AddMapDescription(connection, outMessage, toLocation.X + 9, toLocation.Y - 6, toLocation.Z, 1, 14); } else if (fromLocation.X > toLocation.X) { // west, [with new y] outMessage.AddByte((byte)ServerPacketType.MapSliceWest); AddMapDescription(connection, outMessage, toLocation.X - 8, toLocation.Y - 6, toLocation.Z, 1, 14); } }
public static void Add(NetworkMessage message, uint creatureId, byte lightLevel, byte lightColor) { message.AddByte((byte)ServerPacketType.CreatureLight); message.AddUInt32(creatureId); message.AddByte(lightLevel); message.AddByte(lightColor); }
public static void Add(NetworkMessage message, uint playerId, bool canReportBugs) { message.AddByte((byte)ServerPacketType.SelfAppear); message.AddUInt32(playerId); message.AddByte(0x32); message.AddByte(0); message.AddByte(Convert.ToByte(canReportBugs)); }
public static VipAddPacket Parse(NetworkMessage message) { VipAddPacket p = new VipAddPacket(); p.Name = message.GetString(); return p; }
public static void Add(NetworkMessage message) { message.AddByte(0x1F); // type message.AddUInt32(0x1337); // time in seconds since server start message.AddByte(0x10); // fractional time? }
public static void Add( NetworkMessage message, byte containerId ) { message.AddByte((byte)ServerPacketType.ContainerClose); message.AddByte(containerId); }
public static void Add(NetworkMessage message, Location fromLocation, byte fromStackPosition) { if (fromStackPosition < 10) { message.AddByte((byte)ServerPacketType.TileRemoveThing); message.AddLocation(fromLocation); message.AddByte(fromStackPosition); } }
public static LookAtPacket Parse(NetworkMessage message) { LookAtPacket packet = new LookAtPacket(); packet.Location = message.GetLocation(); packet.Id = message.GetUInt16(); packet.StackPosition = message.GetByte(); return packet; }
public static void Add(NetworkMessage message, List<Channel> channels) { message.AddByte((byte)ServerPacketType.ChannelList); message.AddByte((byte)channels.Count); foreach (var c in channels) { message.AddUInt16((ushort)c.Id); message.AddString(c.Name); } }
public static void Add( Connection connection, NetworkMessage message, Tile tile ) { message.AddByte((byte)ServerPacketType.TileUpdate); message.AddLocation(tile.Location); MapPacket.AddTileDescription(connection, message, tile); }
public static ItemUsePacket Parse(NetworkMessage message) { ItemUsePacket packet = new ItemUsePacket(); packet.FromLocation = message.GetLocation(); packet.SpriteId = message.GetUInt16(); packet.FromStackPosition = message.GetByte(); packet.Index = message.GetByte(); return packet; }
public static void Add( NetworkMessage message, uint creatureID, byte newHealth ) { message.AddByte((byte)ServerPacketType.CreatureHealth); message.AddUInt32(creatureID); message.AddByte(newHealth); }
public static void Add( NetworkMessage message, byte containerIndex, byte containerPosition ) { message.AddByte((byte)ServerPacketType.ContainerRemoveItem); message.AddByte(containerIndex); message.AddByte(containerPosition); }
public static void Add( NetworkMessage message, Location fromLocation, byte fromStackPosition, Location toLocation ) { message.AddByte((byte)ServerPacketType.CreatureMove); message.AddLocation(fromLocation); message.AddByte(fromStackPosition); message.AddLocation(toLocation); }
public static void Add( NetworkMessage message, Creature creature ) { message.AddByte((byte)ServerPacketType.TileTransformThing); message.AddLocation(creature.Tile.Location); message.AddByte(creature.Tile.GetStackPosition(creature)); message.AddUInt16(0x63); message.AddUInt32(creature.Id); message.AddByte((byte)creature.Direction); }
public static void Add( NetworkMessage message, Location location, byte stackPosition, Item item ) { message.AddByte((byte)ServerPacketType.TileAddThing); message.AddLocation(location); message.AddByte(stackPosition); message.AddItem(item); }
public static void Add( Connection connection, NetworkMessage outMessage, Location fromLocation, byte fromStackPosition, Location toLocation ) { //floor change up outMessage.AddByte((byte)ServerPacketType.FloorChangeUp); //going to surface if (toLocation.Z == 7) { int skip = -1; skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, 5, 18, 14, 3, skip); //(floor 7 and 6 already set) skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, 4, 18, 14, 4, skip); skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, 3, 18, 14, 5, skip); skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, 2, 18, 14, 6, skip); skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, 1, 18, 14, 7, skip); skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, 0, 18, 14, 8, skip); if (skip >= 0) { outMessage.AddByte((byte)skip); outMessage.AddByte(0xFF); } } //underground, going one floor up (still underground) else if (toLocation.Z > 7) { int skip = -1; skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, fromLocation.Z - 3, 18, 14, 3, skip); if (skip >= 0) { outMessage.AddByte((byte)skip); outMessage.AddByte(0xFF); } } //moving up a floor up makes us out of sync //west outMessage.AddByte((byte)ServerPacketType.MapSliceWest); AddMapDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y + 1 - 6, toLocation.Z, 1, 14); //north outMessage.AddByte((byte)ServerPacketType.MapSliceNorth); AddMapDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, toLocation.Z, 18, 1); }
public static void Add(NetworkMessage message, Player player, IEnumerable<Outfit> outfits) { message.AddByte((byte)ServerPacketType.OutfitWindow); message.AddOutfit(player.Outfit); message.AddByte((byte)outfits.Count()); foreach (Outfit outfit in outfits) { message.AddUInt16((ushort)outfit.LookType); message.AddString(outfit.Name); message.AddByte(outfit.Addons); } }
public static void Add( NetworkMessage message, Location location, byte stackPosition, Creature creature, bool known, uint removeKnown ) { message.AddByte((byte)ServerPacketType.TileAddThing); message.AddLocation(location); message.AddByte(stackPosition); message.AddCreature(creature, known, removeKnown); }
public static void Add( Connection connection, NetworkMessage outMessage, Location fromLocation, byte fromStackPosition, Location toLocation ) { //floor change down outMessage.AddByte((byte)ServerPacketType.FloorChangeDown); //going from surface to underground if (toLocation.Z == 8) { int skip = -1; skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, toLocation.Z, 18, 14, -1, skip); skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, toLocation.Z + 1, 18, 14, -2, skip); skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, toLocation.Z + 2, 18, 14, -3, skip); if (skip >= 0) { outMessage.AddByte((byte)skip); outMessage.AddByte(0xFF); } } //going further down else if (toLocation.Z > fromLocation.Z && toLocation.Z > 8 && toLocation.Z < 14) { int skip = -1; skip = AddFloorDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y - 6, toLocation.Z + 2, 18, 14, -3, skip); if (skip >= 0) { outMessage.AddByte((byte)skip); outMessage.AddByte(0xFF); } } //moving down a floor makes us out of sync //east outMessage.AddByte((byte)ServerPacketType.MapSliceEast); AddMapDescription(connection, outMessage, fromLocation.X + 9, fromLocation.Y - 1 - 6, toLocation.Z, 1, 14); //south outMessage.AddByte((byte)ServerPacketType.MapSliceSouth); AddMapDescription(connection, outMessage, fromLocation.X - 8, fromLocation.Y + 7, toLocation.Z, 18, 1); }
public static void Add( NetworkMessage message, string senderName, ushort senderLevel, SpeechType speechType, string text, Location location, ChatChannel channelId, uint time ) { message.AddByte((byte)ServerPacketType.CreatureSpeech); message.AddUInt32(0x00000000); message.AddString(senderName); message.AddUInt16(senderLevel); message.AddByte((byte)speechType); switch (speechType) { case SpeechType.Say: case SpeechType.Whisper: case SpeechType.Yell: case SpeechType.MonsterSay: case SpeechType.MonsterYell: case SpeechType.PrivateNPCToPlayer: message.AddLocation(location); break; case SpeechType.ChannelRed: case SpeechType.ChannelRedAnonymous: case SpeechType.ChannelOrange: case SpeechType.ChannelYellow: case SpeechType.ChannelWhite: message.AddUInt16((ushort)channelId); break; case SpeechType.RuleViolationReport: message.AddUInt32(time); break; default: break; } message.AddString(text); }
public static void Add( NetworkMessage message, ushort health, ushort maxHealth, uint capacity, uint experience, ushort level, byte levelPercent, ushort mana, ushort maxMana, byte magicLevel, byte magicLevelPercent, byte soul, ushort stamina ) { message.AddByte((byte)ServerPacketType.PlayerStatus); message.AddUInt16(health); message.AddUInt16(maxHealth); message.AddUInt32(capacity); message.AddUInt32(experience); message.AddUInt16(level); message.AddByte(levelPercent); message.AddUInt16(mana); message.AddUInt16(maxMana); message.AddByte(magicLevel); message.AddByte(magicLevelPercent); message.AddByte(soul); message.AddUInt16(stamina); }
public CharacterListPacket Parse(NetworkMessage message) { return(new CharacterListPacket()); }
public GameServerConnectPacket Parse(NetworkMessage message) { return(new GameServerConnectPacket()); }
public static void Add(NetworkMessage message, Creature creature) { message.AddByte((byte)ServerPacketType.CreatureOutfit); message.AddUInt32(creature.Id); message.AddOutfit(creature.Outfit); }
public static void Add(NetworkMessage message, uint id) { message.AddByte((byte)ServerPacketType.VipLogout); message.AddUInt32(id); }
public static void Add(NetworkMessage message, SlotType slot, Item item) { message.AddByte((byte)ServerPacketType.InventorySetSlot); message.AddByte((byte)slot); message.AddItem(item); }
public MessageOfTheDayPacket Parse(NetworkMessage message) { return(new MessageOfTheDayPacket()); }
public static void Add(NetworkMessage message, string messageOfTheDay) { message.AddByte((byte)ServerPacketType.MessageOfTheDay); message.AddString("1\n" + messageOfTheDay); }
public static void Add(NetworkMessage message, Direction direction) { message.AddByte((byte)ServerPacketType.PlayerWalkCancel); message.AddByte((byte)direction); }