Skip to content

Commit

Permalink
fixed build
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n committed Sep 24, 2024
1 parent 94b44e8 commit c4770eb
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/Packets/C3-16-ExperienceGainedExtended_by-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Defines the result and type of experience which is added.

| Value | Name | Description |
|-------|------|-------------|
| 0 | Undefined | Undefined, no experience is added. |
| 1 | Normal | The normal experience is added. |
| 2 | Master | The master experience is added. |
| 0x10 | MaxLevelReached | The maximum level has been reached, no experience is added. |
Expand Down
26 changes: 22 additions & 4 deletions src/GameServer/RemoteView/Character/AddExperienceExtendedPlugIn.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
using System.Runtime.InteropServices;
// <copyright file="AddExperienceExtendedPlugIn.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.Character;

using System.Runtime.InteropServices;
using MUnique.OpenMU.GameLogic;
using MUnique.OpenMU.GameLogic.Views;
using MUnique.OpenMU.GameLogic.Views.Character;
using MUnique.OpenMU.Network.Packets.ServerToClient;
using MUnique.OpenMU.Network.PlugIns;
using MUnique.OpenMU.PlugIns;

namespace MUnique.OpenMU.GameServer.RemoteView.Character;

/// <summary>
/// The extended implementation of the <see cref="IAddExperiencePlugIn"/> which is forwarding everything to the game client with specific data packets.
/// </summary>
Expand Down Expand Up @@ -41,11 +45,25 @@ public async ValueTask AddExperienceAsync(int exp, IAttackable? obj, ExperienceT
killerId = ViewExtensions.ConstantPlayerId;
}

await this._player.Connection.SendExperienceGainedExtendedAsync((byte)experienceType,
await this._player.Connection.SendExperienceGainedExtendedAsync(
Convert(experienceType),
(uint)exp,
(uint)damage,
killedId,
killerId)
.ConfigureAwait(false);
}

private static ExperienceGainedExtended.AddResult Convert(ExperienceType experienceType)
{
return experienceType switch
{
ExperienceType.Normal => ExperienceGainedExtended.AddResult.Normal,
ExperienceType.Master => ExperienceGainedExtended.AddResult.Master,
ExperienceType.MaxLevelReached => ExperienceGainedExtended.AddResult.MaxLevelReached,
ExperienceType.MaxMasterLevelReached => ExperienceGainedExtended.AddResult.MaxMasterLevelReached,
ExperienceType.MonsterLevelTooLowForMasterExperience => ExperienceGainedExtended.AddResult.MonsterLevelTooLowForMasterExperience,
_ => ExperienceGainedExtended.AddResult.Undefined
};
}
}
5 changes: 5 additions & 0 deletions src/Network/Packets/ServerToClient/ServerToClientPackets.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6579,6 +6579,11 @@ public readonly struct ExperienceGainedExtended
/// </summary>
public enum AddResult
{
/// <summary>
/// Undefined, no experience is added.
/// </summary>
Undefined = 0,

/// <summary>
/// The normal experience is added.
/// </summary>
Expand Down
5 changes: 5 additions & 0 deletions src/Network/Packets/ServerToClient/ServerToClientPackets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2392,6 +2392,11 @@
<Name>AddResult</Name>
<Description>Defines the result and type of experience which is added.</Description>
<Values>
<EnumValue>
<Name>Undefined</Name>
<Description>Undefined, no experience is added.</Description>
<Value>0</Value>
</EnumValue>
<EnumValue>
<Name>Normal</Name>
<Description>The normal experience is added.</Description>
Expand Down

0 comments on commit c4770eb

Please sign in to comment.