Skip to content

Commit a67704f

Browse files
author
Rydan
authored
Fix Fluid Types (jo3bingham#21)
* Fix Fluid Types * Re-add Colors * Temporarily add Packet Data to Exception
1 parent 8ec4894 commit a67704f

3 files changed

Lines changed: 21 additions & 36 deletions

File tree

Apps/Extract/Program.cs

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,6 @@ class Program
1717
{
1818
private const int MapSizeW = 10;
1919

20-
private static readonly byte[] _reverseFluidMap =
21-
{
22-
(byte)FluidColor.Transparent,
23-
(byte)FluidType.Water,
24-
(byte)FluidType.Mana,
25-
(byte)FluidType.Beer,
26-
(byte)FluidColor.Transparent,
27-
(byte)FluidType.Blood,
28-
(byte)FluidType.Slime,
29-
(byte)FluidColor.Transparent,
30-
(byte)FluidType.Lemonade,
31-
(byte)FluidType.Milk
32-
};
33-
3420
private static readonly HashSet<ulong> _knownPositions = new HashSet<ulong>();
3521
private static readonly HashSet<uint> _knownMonsterIds = new HashSet<uint>();
3622
private static readonly HashSet<uint> _knownNpcIds = new HashSet<uint>();
@@ -721,9 +707,9 @@ static void ParseField((Field, Position) field)
721707
{
722708
_otbmFile.WriteByte(15);
723709
byte subType = 0;
724-
if (item.Data >= 0 && item.Data < _reverseFluidMap.Length)
710+
if (Enum.IsDefined(typeof(FluidType), (int)item.Data))
725711
{
726-
subType = _reverseFluidMap[item.Data];
712+
subType = (byte)item.Data;
727713
}
728714
WriteData(_otbmFile, new byte[] { subType });
729715
}

TibiaAPI/Constants/Enums.cs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -204,26 +204,24 @@ public enum MarketDetailField
204204

205205
public enum FluidType
206206
{
207-
None = FluidColor.Transparent,
208-
Water = FluidColor.Blue,
209-
Blood = FluidColor.Red,
210-
Beer = FluidColor.Brown,
211-
Slime = FluidColor.Green,
212-
Lemonade = FluidColor.Yellow,
213-
Milk = FluidColor.White,
214-
Mana = FluidColor.Purple,
215-
Life = FluidColor.Red + 8,
216-
Oil = FluidColor.Brown + 8,
217-
Urine = FluidColor.Yellow + 8,
218-
CoconutMilk = FluidColor.White + 8,
219-
Wine = FluidColor.Purple + 8,
220-
Mud = FluidColor.Brown + 16,
221-
FruitJuice = FluidColor.Yellow + 16,
222-
Lava = FluidColor.Red + 24,
223-
Rum = FluidColor.Brown + 24,
224-
Swamp = FluidColor.Green + 24,
225-
Tea = FluidColor.Brown + 32,
226-
Mead = FluidColor.Brown + 40
207+
None = 0,
208+
Water = 1,
209+
Wine = 2,
210+
Beer = 3,
211+
Mud = 4,
212+
Blood = 5,
213+
Slime = 6,
214+
Oil = 7,
215+
Urine = 8,
216+
Milk = 9,
217+
ManaFluid = 10,
218+
LifeFluid = 11,
219+
Lemonade = 12,
220+
Rum = 13,
221+
FruitJuice = 14,
222+
CoconutMilk = 15,
223+
Mead = 16,
224+
Tea = 17
227225
}
228226

229227
public enum MessageModeType

TibiaAPI/Network/NetworkMessage.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1300,6 +1300,7 @@ public void PrepareToParse(uint[] xteaKey, ZStream zStream = null)
13001300
var ret = zStream.inflate(zlibConst.Z_SYNC_FLUSH);
13011301
if (ret != zlibConst.Z_OK)
13021302
{
1303+
Console.WriteLine($"Data: {BitConverter.ToString(GetData()).Replace('-', ' ')}");
13031304
throw new Exception($"[NetworkMessage.PrepareToParse] zlib inflate failed: {ret}");
13041305
}
13051306

0 commit comments

Comments
 (0)