-
Notifications
You must be signed in to change notification settings - Fork 338
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The old structure doesn't have enough space for the larger appearance data. I made it even larger than needed for future extensions.
- Loading branch information
Showing
7 changed files
with
401 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# C4 C7 - OpenLetterExtended (by server) | ||
|
||
## Is sent when | ||
|
||
After the player requested to read a letter. | ||
|
||
## Causes the following actions on the client side | ||
|
||
The letter is opened in a new dialog. | ||
|
||
## Structure | ||
|
||
| Index | Length | Data Type | Value | Description | | ||
|-------|--------|-----------|-------|-------------| | ||
| 0 | 1 | Byte | 0xC4 | [Packet type](PacketTypes.md) | | ||
| 1 | 2 | Short | | Packet header - length of the packet | | ||
| 3 | 1 | Byte | 0xC7 | Packet header - packet type identifier | | ||
| 4 | 2 | ShortLittleEndian | | LetterIndex | | ||
| 6 | 42 | Binary | | SenderAppearance | | ||
| 48 | 1 | Byte | | Rotation | | ||
| 49 | 1 | Byte | | Animation | | ||
| 50 | | String | | Message | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
src/GameServer/RemoteView/Messenger/ShowLetterExtendedPlugIn.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// <copyright file="ShowLetterExtendedPlugIn.cs" company="MUnique"> | ||
// Licensed under the MIT License. See LICENSE file in the project root for full license information. | ||
// </copyright> | ||
|
||
namespace MUnique.OpenMU.GameServer.RemoteView.Messenger; | ||
|
||
using System.Runtime.InteropServices; | ||
using MUnique.OpenMU.DataModel.Entities; | ||
using MUnique.OpenMU.GameLogic.Views.Messenger; | ||
using MUnique.OpenMU.Network; | ||
using MUnique.OpenMU.Network.Packets.ServerToClient; | ||
using MUnique.OpenMU.Network.PlugIns; | ||
using MUnique.OpenMU.PlugIns; | ||
|
||
/// <summary> | ||
/// The default implementation of the <see cref="IShowLetterPlugIn"/> which is forwarding everything to the game client with specific data packets. | ||
/// </summary> | ||
[PlugIn(nameof(ShowLetterExtendedPlugIn), "The extended implementation of the IShowLetterPlugIn which is forwarding everything to the game client with specific data packets.")] | ||
[Guid("9FC6D771-FCCE-4780-B68E-5FBFF3FE1EB0")] | ||
[MinimumClient(106, 3, ClientLanguage.Invariant)] | ||
public class ShowLetterExtendedPlugIn : IShowLetterPlugIn | ||
{ | ||
private readonly RemotePlayer _player; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="ShowLetterExtendedPlugIn"/> class. | ||
/// </summary> | ||
/// <param name="player">The player.</param> | ||
public ShowLetterExtendedPlugIn(RemotePlayer player) => this._player = player; | ||
|
||
/// <inheritdoc/> | ||
public async ValueTask ShowLetterAsync(LetterBody letter) | ||
{ | ||
var connection = this._player.Connection; | ||
if (connection is null || this._player.SelectedCharacter is null) | ||
{ | ||
return; | ||
} | ||
|
||
var appearanceSerializer = this._player.AppearanceSerializer; | ||
var letterIndex = this._player.SelectedCharacter.Letters.IndexOf(letter.Header!); | ||
int Write() | ||
{ | ||
var size = OpenLetterExtendedRef.GetRequiredSize(letter.Message); | ||
var span = connection.Output.GetSpan(size)[..size]; | ||
var result = new OpenLetterExtendedRef(span) | ||
{ | ||
LetterIndex = (ushort)letterIndex, | ||
Animation = letter.Animation, | ||
Rotation = letter.Rotation, | ||
Message = letter.Message, | ||
}; | ||
|
||
if (letter.SenderAppearance is not null) | ||
{ | ||
appearanceSerializer.WriteAppearanceData(result.SenderAppearance, letter.SenderAppearance, false); | ||
} | ||
|
||
return size; | ||
} | ||
|
||
await connection.SendAsync(Write).ConfigureAwait(false); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.