From a806e7f2b021afe9d0582b486e2a7becb6b10535 Mon Sep 17 00:00:00 2001 From: Zin <62830952+Zintixx@users.noreply.github.com> Date: Sun, 22 Sep 2024 12:54:12 -0700 Subject: [PATCH] fixes --- Maple2.Database/Model/Item/ItemSubType.cs | 2 +- Maple2.Model/Enum/Instrument.cs | 44 +++++++++++++++++++ .../Game/Item/ItemCustomMusicScore.cs | 9 ++-- .../PacketHandlers/InstrumentHandler.cs | 4 +- 4 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 Maple2.Model/Enum/Instrument.cs diff --git a/Maple2.Database/Model/Item/ItemSubType.cs b/Maple2.Database/Model/Item/ItemSubType.cs index a63a2e9aa..eece4516a 100644 --- a/Maple2.Database/Model/Item/ItemSubType.cs +++ b/Maple2.Database/Model/Item/ItemSubType.cs @@ -94,7 +94,7 @@ internal record ItemPet(string Name, long Exp, int EvolvePoints, short Level, sh internal record ItemCustomMusicScore( int Length, - int Instrument, + Instrument Instrument, string Title, string Author, long AuthorId, diff --git a/Maple2.Model/Enum/Instrument.cs b/Maple2.Model/Enum/Instrument.cs new file mode 100644 index 000000000..54d99bd9a --- /dev/null +++ b/Maple2.Model/Enum/Instrument.cs @@ -0,0 +1,44 @@ +namespace Maple2.Model.Enum; + +public enum Instrument { + Piano = 1, + Misc = 2, + Clarinet = 3, + Harp = 4, + Timapni = 5, + ElectricGuitar = 6, + Bass = 7, + Tomtam = 8, + Violin = 9, + Cello = 10, + PanFlute = 11, + Saxophone = 12, + Trombone = 13, + Trumpet = 14, + Ocarina = 15, + AcousticBass = 16, + Vibraphone = 17, + ElectricPiano = 18, + SteelDrum = 19, + PickBassGuitar = 20, + Oboe = 21, + Pizzicato = 22, + Harpsichord = 23, + Harmonica = 24, + Xylophone = 25, + Recorder = 26, + Celesta = 27, + Cymbal = 28, + BassDrum = 29, + SnareDrum = 30, + Shamisen = 31, + Koto = 32, + Shakuhachi = 33, + TaikoDrum = 34, + FretlessBass = 35, + Marimba = 36, + Flute = 37, + HonkyTonkPiano = 38, + FrenchHorn = 39, + PipeOrgan = 40, +} diff --git a/Maple2.Model/Game/Item/ItemCustomMusicScore.cs b/Maple2.Model/Game/Item/ItemCustomMusicScore.cs index c7847b57e..0c9126b6e 100644 --- a/Maple2.Model/Game/Item/ItemCustomMusicScore.cs +++ b/Maple2.Model/Game/Item/ItemCustomMusicScore.cs @@ -1,11 +1,12 @@ -using Maple2.PacketLib.Tools; +using Maple2.Model.Enum; +using Maple2.PacketLib.Tools; using Maple2.Tools; namespace Maple2.Model.Game; public sealed class ItemCustomMusicScore : IByteSerializable, IByteDeserializable { public int Length; - public int Instrument; + public Instrument Instrument; public string Title; public string Author; public long AuthorId; // AccountId @@ -24,7 +25,7 @@ public ItemCustomMusicScore Clone() { public void WriteTo(IByteWriter writer) { writer.WriteInt(Length); - writer.WriteInt(Instrument); + writer.Write(Instrument); writer.WriteUnicodeString(Title); writer.WriteUnicodeString(Author); writer.WriteInt(1); @@ -36,7 +37,7 @@ public void WriteTo(IByteWriter writer) { public void ReadFrom(IByteReader reader) { Length = reader.ReadInt(); - Instrument = reader.ReadInt(); + Instrument = reader.Read(); Title = reader.ReadUnicodeString(); Author = reader.ReadUnicodeString(); reader.ReadInt(); diff --git a/Maple2.Server.Game/PacketHandlers/InstrumentHandler.cs b/Maple2.Server.Game/PacketHandlers/InstrumentHandler.cs index cc5ba75ea..b5a421c33 100644 --- a/Maple2.Server.Game/PacketHandlers/InstrumentHandler.cs +++ b/Maple2.Server.Game/PacketHandlers/InstrumentHandler.cs @@ -237,7 +237,7 @@ private void HandleComposeScore(GameSession session, IByteReader packet) { } int length = packet.ReadInt(); - int instrument = packet.ReadInt(); + var instrument = packet.Read(); string title = packet.ReadUnicodeString(); string mml = packet.ReadString(); @@ -245,7 +245,7 @@ private void HandleComposeScore(GameSession session, IByteReader packet) { score.Music.Instrument = instrument; score.Music.Title = title; score.Music.Author = session.PlayerName; - score.Music.AuthorId = session.CharacterId; + score.Music.AuthorId = session.AccountId; score.Music.Mml = mml; session.Send(InstrumentPacket.ComposeScore(score));