Skip to content

Commit

Permalink
create overload for AddShort that accepts ushort
Browse files Browse the repository at this point in the history
  • Loading branch information
sorokya committed Mar 27, 2022
1 parent c7fe494 commit 763a76c
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion EOLib/Domain/Account/AccountActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public async Task<AccountReply> CheckAccountNameWithServer(string accountName)
public async Task<AccountReply> CreateAccount(ICreateAccountParameters parameters)
{
var createAccountPacket = new PacketBuilder(PacketFamily.Account, PacketAction.Create)
.AddShort(_playerInfoRepository.SessionID)
.AddShort((ushort)_playerInfoRepository.SessionID)
.AddByte(255)
.AddBreakString(parameters.AccountName)
.AddBreakString(parameters.Password)
Expand Down
2 changes: 1 addition & 1 deletion EOLib/Net/Connection/NetworkConnectionActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public void CompleteHandshake(IInitializationData initializationData)
var packet = new PacketBuilder(PacketFamily.Connection, PacketAction.Accept)
.AddShort((short)initializationData[InitializationDataKey.SendMultiple])
.AddShort((short)initializationData[InitializationDataKey.ReceiveMultiple])
.AddShort(_playerInfoRepository.PlayerID)
.AddShort((ushort)_playerInfoRepository.PlayerID)
.Build();

_packetSendService.SendPacket(packet);
Expand Down
6 changes: 3 additions & 3 deletions EOLib/Net/FileTransfer/FileRequestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<IMapFile> RequestMapFile(short mapID, short sessionID)
{
var request = new PacketBuilder(PacketFamily.Welcome, PacketAction.Agree)
.AddChar((byte)InitFileType.Map)
.AddShort(sessionID)
.AddShort((ushort)sessionID)
.AddShort(mapID)
.Build();

Expand All @@ -41,7 +41,7 @@ public async Task<IMapFile> RequestMapFileForWarp(short mapID, short sessionID)
{
var request = new PacketBuilder(PacketFamily.Warp, PacketAction.Take)
.AddShort(mapID)
.AddShort(sessionID)
.AddShort((ushort)sessionID)
.Build();

return await GetMapFile(request, mapID);
Expand All @@ -52,7 +52,7 @@ public async Task<IPubFile<TRecord>> RequestFile<TRecord>(InitFileType fileType,
{
var request = new PacketBuilder(PacketFamily.Welcome, PacketAction.Agree)
.AddChar((byte)fileType)
.AddShort(sessionID)
.AddShort((ushort)sessionID)
.AddChar(1) // file id (for chunking oversize pub files)
.Build();

Expand Down
2 changes: 2 additions & 0 deletions EOLib/Net/IPacketBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public interface IPacketBuilder

IPacketBuilder AddShort(short s);

IPacketBuilder AddShort(ushort s);

IPacketBuilder AddThree(int t);

IPacketBuilder AddInt(int i);
Expand Down
7 changes: 6 additions & 1 deletion EOLib/Net/PacketBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,12 @@ public IPacketBuilder AddChar(byte b)

public IPacketBuilder AddShort(short s)
{
return AddBytes(_encoderService.EncodeNumber((ushort)s, 2));
return AddBytes(_encoderService.EncodeNumber(s, 2));
}

public IPacketBuilder AddShort(ushort s)
{
return AddBytes(_encoderService.EncodeNumber(s, 2));
}

public IPacketBuilder AddThree(int t)
Expand Down
2 changes: 1 addition & 1 deletion EOLib/PacketHandlers/BeginPlayerWarpHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void SendWarpAcceptToServer(short mapID, short sessionID)
{
var response = new PacketBuilder(PacketFamily.Warp, PacketAction.Accept)
.AddShort(mapID)
.AddShort(sessionID)
.AddShort((ushort)sessionID)
.Build();
_packetSendService.SendPacket(response);
}
Expand Down

0 comments on commit 763a76c

Please sign in to comment.