Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/jo3bingham/TibiaAPI
Browse files Browse the repository at this point in the history
  • Loading branch information
jo3bingham committed Sep 22, 2020
2 parents babbec1 + e71077e commit 3ca46a3
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 7 deletions.
6 changes: 4 additions & 2 deletions TibiaAPI/Constants/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public enum PreyActionType
{
ListReroll = 0,
BonusReroll = 1,
MonsterSelection = 2
MonsterSelection = 2,
Option = 5
}

public enum ReportType
Expand Down Expand Up @@ -119,7 +120,8 @@ public enum GraphicalEffectsType
Delay = 2,
Effect = 3,
MissileXY = 4,
MissileYX = 5
MissileYX = 5,
Unknown = 0x83
}

public enum PreyDataState
Expand Down
9 changes: 9 additions & 0 deletions TibiaAPI/Network/ClientPackets/PreyAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public class PreyAction : ClientPacket
public PreyActionType ActionType { get; set; }

public byte MonsterIndex { get; set; }
public byte Option { get; set; }
public byte PreyId { get; set; }

public PreyAction(Client client)
Expand All @@ -23,6 +24,10 @@ public override void ParseFromNetworkMessage(NetworkMessage message)
{
MonsterIndex = message.ReadByte();
}
else if (ActionType == PreyActionType.Option)
{
Option = message.ReadByte(); // 0 = None, 1 = Automatic Bonus Reroll, 2 = Lock Prey
}
}

public override void AppendToNetworkMessage(NetworkMessage message)
Expand All @@ -34,6 +39,10 @@ public override void AppendToNetworkMessage(NetworkMessage message)
{
message.Write(MonsterIndex);
}
else if (ActionType == PreyActionType.Option)
{
message.Write(Option);
}
}
}
}
12 changes: 12 additions & 0 deletions TibiaAPI/Network/ServerPackets/GraphicalEffects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,15 @@ public override void ParseFromNetworkMessage(NetworkMessage message)
var distanceAxisX = message.ReadSByte();
Effects.Add((type, 0, 0, missileId, distanceAxisX, distanceAxisY));
}
else if (type == GraphicalEffectsType.Unknown)
{
// This is "unknown" because a) it seems to have existed for a single
// client update but no longer exist as of client update 12.51.10194
// (or I can't reproduce it) and b) it seems to indicate a new
// GraphicalEffects packet without the position at the beginning
// (it jumps straight to the effect type). Either way, treating it
// as a type without any data fixes any existing parser errors.
}
else
{
throw new System.Exception($"[ServerPackets.GraphicalEffects] Unknown type: {type}");
Expand Down Expand Up @@ -111,6 +120,9 @@ public override void AppendToNetworkMessage(NetworkMessage message)
message.Write(DistanceY);
message.Write(DistanceX);
}
else if (Type == GraphicalEffectsType.Unknown)
{
}
}
message.Write((byte)GraphicalEffectsType.None);
}
Expand Down
23 changes: 18 additions & 5 deletions TibiaAPI/Network/ServerPackets/PreyData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ public class PreyData : ServerPacket

public string Name { get; set; }

public uint TimeLeftUntilFreeListReroll { get; set; }

public ushort BonusPercentage { get; set; }
public ushort TimeLeft { get; set; }
public ushort TimeLeftUntilFreeListReroll { get; set; }

public byte BonusRarity { get; set; }
public byte BonusType { get; set; }
Expand All @@ -37,7 +38,6 @@ public PreyData(Client client)
public override void ParseFromNetworkMessage(NetworkMessage message)
{
Index = message.ReadByte();

State = (PreyDataState)message.ReadByte();
switch (State)
{
Expand Down Expand Up @@ -111,8 +111,14 @@ public override void ParseFromNetworkMessage(NetworkMessage message)
throw new Exception($"[PreyData.ParseFromNetworkMessage] Unknown state: {State}");
}
}

TimeLeftUntilFreeListReroll = message.ReadUInt16();
if (Client.VersionNumber >= 125110194)
{
TimeLeftUntilFreeListReroll = message.ReadUInt32();
}
else
{
TimeLeftUntilFreeListReroll = message.ReadUInt16();
}
if (Client.VersionNumber > 11606457)
{
Option = message.ReadByte(); // 0 = none, 1 = automatic reroll, 2 = locked
Expand Down Expand Up @@ -224,7 +230,14 @@ public override void AppendToNetworkMessage(NetworkMessage message)
throw new Exception($"[PreyData.AppendToNetworkMessage] Unknown state: {State}");
}
}
message.Write(TimeLeftUntilFreeListReroll);
if (Client.VersionNumber >= 125110194)
{
message.Write(TimeLeftUntilFreeListReroll);
}
else
{
message.Write((ushort)TimeLeftUntilFreeListReroll);
}
if (Client.VersionNumber > 11606457)
{
message.Write(Option);
Expand Down
6 changes: 6 additions & 0 deletions TibiaAPI/Network/ServerPackets/PreyHuntingTaskData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public class PreyHuntingTaskData : ServerPacket
public List<(ushort RaceId, bool IsUnlocked)> ListSelection { get; } =
new List<(ushort RaceId, bool IsUnlocked)>();

public uint TimeLeftUntilFreeReroll { get; set; }

public ushort CurrentKills { get; set; }
public ushort RaceId { get; set; }
public ushort RequiredKills { get; set; }
Expand Down Expand Up @@ -86,6 +88,10 @@ public override void ParseFromNetworkMessage(NetworkMessage message)
throw new Exception($"[PreyHuntingTaskData.ParseFromNetworkMessage] Unknown state: {State}");
}
}
if (Client.VersionNumber >= 125110194)
{
TimeLeftUntilFreeReroll = message.ReadUInt32();
}
}

public override void AppendToNetworkMessage(NetworkMessage message)
Expand Down

0 comments on commit 3ca46a3

Please sign in to comment.