Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for game server support (see commits) #111

Merged
merged 4 commits into from
Mar 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion EOLib/Domain/Login/LoginActions.cs
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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