Skip to content

Commit

Permalink
Merge pull request #111 from ethanmoffat/fixup
Browse files Browse the repository at this point in the history
Fixes for game server support (see commits)
  • Loading branch information
ethanmoffat committed Mar 4, 2022
2 parents db100eb + b80ff5c commit 8fb279f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 18 deletions.
2 changes: 1 addition & 1 deletion EOLib/Domain/Login/LoginActions.cs
Expand Up @@ -134,7 +134,7 @@ public async Task RequestCharacterLogin(ICharacter character)
public async Task<CharacterLoginReply> CompleteCharacterLogin()
{
var packet = new PacketBuilder(PacketFamily.Welcome, PacketAction.Message)
.AddThree(_playerInfoRepository.PlayerID)
.AddThree((ushort)_playerInfoRepository.PlayerID)
.AddInt(_characterRepository.MainCharacter.ID)
.Build();

Expand Down
12 changes: 4 additions & 8 deletions EOLib/Net/Translators/CharacterDisplayPacketTranslator.cs
Expand Up @@ -24,21 +24,17 @@ protected IEnumerable<ICharacter> GetCharacters(IPacket packet)

var numberOfCharacters = (int)packet.ReadChar();

// EOSERV sends this byte unconditionally for CHARACTER_REPLY, but GameServer appears
// to not send it on delete packets
if (packet.PeekByte() == 1)
packet.ReadByte();
// Optional AddByte call. EOSERV sends either 1 or 2, but GameServer appears
// to not send it on character delete
packet.ReadBreakString();

for (int i = 0; i < numberOfCharacters; ++i)
{
characters.Add(GetNextCharacter(packet));
if (packet.ReadByte() != 255)
throw new MalformedPacketException($"{packet.Family}_{packet.Action} packet missing character separator byte", packet);
characters.Add(GetNextCharacter(packet));
}

if (packet.ReadByte() != 255)
throw new MalformedPacketException($"{packet.Family}_{packet.Action} packet missing character separator byte", packet);

return characters;
}

Expand Down
8 changes: 0 additions & 8 deletions EOLib/Net/Translators/LoginRequestGrantedPacketTranslator.cs
Expand Up @@ -4,20 +4,12 @@
using EOLib.Domain.Character;
using EOLib.Domain.Login;
using EOLib.IO;
using EOLib.IO.Services;

namespace EOLib.Net.Translators
{
[AutoMappedType]
public class LoginRequestGrantedPacketTranslator : IPacketTranslator<ILoginRequestGrantedData>
{
private readonly INumberEncoderService _numberEncoderService;

public LoginRequestGrantedPacketTranslator(INumberEncoderService numberEncoderService)
{
_numberEncoderService = numberEncoderService;
}

public ILoginRequestGrantedData TranslatePacket(IPacket packet)
{
var reply = (CharacterLoginReply)packet.ReadShort();
Expand Down
2 changes: 1 addition & 1 deletion EndlessClient/Controllers/LoginController.cs
Expand Up @@ -177,8 +177,8 @@ public async Task LoginToCharacter(ICharacter character)
{
// https://discord.com/channels/723989119503696013/787685796055482368/946634672295784509
// Sausage: 'I have WELCOME_REPLY 3 as returning a "server is busy" message if you send it and then disconnect the client'
_errorDisplayAction.ShowLoginError(LoginReply.Busy);
_gameStateActions.ChangeToState(GameStates.Initial);
_errorDisplayAction.ShowLoginError(LoginReply.Busy);
return;
}

Expand Down

0 comments on commit 8fb279f

Please sign in to comment.