fix: incorrect char slot
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 3s
Build, Package and Push Images / build (push) Successful in 28s
Build, Package and Push Images / sonarqube (push) Has been skipped
Build, Package and Push Images / sbom-scan (push) Successful in 31s
Build, Package and Push Images / container-build (push) Successful in 1m20s
Build, Package and Push Images / container-sbom-scan (push) Successful in 39s

This commit is contained in:
Timothy Schenk 2023-11-13 22:43:37 +01:00
parent 8bbd36eb89
commit 5381d78cfc
2 changed files with 49 additions and 6 deletions

View file

@ -41,7 +41,7 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
ChannelSelectionResponsePacket responsePacket;
var testingChars = true;
if (charactersOfAccount != null && testingChars)
if (charactersOfAccount != null && !testingChars)
{
responsePacket = new ChannelSelectionResponsePacket
{
@ -99,9 +99,9 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
{
new CharacterData
{
Name = "Test243",
Name = "1",
Job = new JobData { FirstJob = 1, SecondJob = 0, ThirdJob = 0, FourthJob = 0 },
Gender = Gender.None,
Gender = Gender.Female,
Level = ushort.MaxValue - 1,
Experience = 255,
Stats = new BaseStats
@ -116,8 +116,50 @@ public class ChannelSelectionHandler : IPacketHandler<ChannelSelectionPacket>
Health = int.MaxValue - 1,
Mana = int.MaxValue - 1,
EquippedItems = Enumerable.Repeat((ushort)25, 20).ToArray(),
EquippedCashItems = Enumerable.Repeat((ushort)25, 20).ToArray()
EquippedCashItems = Enumerable.Repeat((ushort)70, 20).ToArray()
},
new CharacterData
{
Name = "2",
Job = new JobData { FirstJob = 1, SecondJob = 0, ThirdJob = 0, FourthJob = 0 },
Gender = Gender.Female,
Level = ushort.MaxValue - 1,
Experience = 255,
Stats = new BaseStats
{
Strength = 5,
Dexterity = 5,
Intelligence = 5,
Vitality = 5,
Luck = 5,
Wisdom = 5
},
Health = int.MaxValue - 1,
Mana = int.MaxValue - 1,
EquippedItems = Enumerable.Repeat((ushort)25, 20).ToArray(),
EquippedCashItems = Enumerable.Repeat((ushort)70, 20).ToArray()
},
new CharacterData
{
Name = "3",
Job = new JobData { FirstJob = 1, SecondJob = 0, ThirdJob = 0, FourthJob = 0 },
Gender = Gender.Female,
Level = ushort.MaxValue - 1,
Experience = 255,
Stats = new BaseStats
{
Strength = 5,
Dexterity = 5,
Intelligence = 5,
Vitality = 5,
Luck = 5,
Wisdom = 5
},
Health = int.MaxValue - 1,
Mana = int.MaxValue - 1,
EquippedItems = Enumerable.Repeat((ushort)25, 20).ToArray(),
EquippedCashItems = Enumerable.Repeat((ushort)65, 20).ToArray()
}
},
};
}

View file

@ -18,7 +18,7 @@ public class ChannelSelectionResponsePacket : IPacket
public byte[] Serialize()
{
Span<byte> data = stackalloc byte[1 + 16 + 2 + 2 + 132 * this.Characters.Length + 20];
Span<byte> data = stackalloc byte[1 + 16 + 2 + 1 + 132 * this.Characters.Length];
data.Clear();
data[0] = this.ChannelIsFullFlag;
Encoding.ASCII.GetBytes(this.Endpoint, data.Slice(1, 16));
@ -29,7 +29,7 @@ public class ChannelSelectionResponsePacket : IPacket
for (var i = 0; i < Characters.Length; i++)
{
var character = Characters[i];
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(20, 4), i);
BinaryPrimitives.WriteInt32LittleEndian(data.Slice(20 + (i * 132), 4), i);
Encoding.ASCII.GetBytes(character.Name, data.Slice(24 + (i * 132), 20));
// Job Data
@ -64,6 +64,7 @@ public class ChannelSelectionResponsePacket : IPacket
character.EquippedCashItems.Length > j ? character.EquippedCashItems[j] : (ushort)0);
}
}
return data.ToArray();
}
}