From 07278187d0ca91a7fbd000f1f4b7781ff36b539b Mon Sep 17 00:00:00 2001 From: daneo1989 Date: Sat, 20 Dec 2025 15:34:54 +0000 Subject: [PATCH 1/2] #755 Hero Buffs Tried to replicate proposed issue, Could not replicate. If you shut down the server it would remove the Hero Buffs. Sorry @Suprcode included some more changes to this commit. 1. Hero buffs acts like Players buff on server restart/shutdown. (Retains the buffs) 2. Hero buff border to follow Official (Red border) 3. Hero Name to follow Official (Purple) 4. If you seal the Hero it will now remove the active buffs. --- Client/MirScenes/Dialogs/BuffDialog.cs | 12 ++++++------ Client/MirScenes/GameScene.cs | 7 +++++++ Server/MirDatabase/HeroInfo.cs | 18 ++++++++++++++++++ Server/MirEnvir/Envir.cs | 2 +- Server/MirObjects/HeroObject.cs | 2 ++ Server/MirObjects/PlayerObject.cs | 6 ++++++ Shared/ServerPackets.cs | 2 ++ 7 files changed, 42 insertions(+), 7 deletions(-) diff --git a/Client/MirScenes/Dialogs/BuffDialog.cs b/Client/MirScenes/Dialogs/BuffDialog.cs index efa5c19c2..5ffbdc4c9 100644 --- a/Client/MirScenes/Dialogs/BuffDialog.cs +++ b/Client/MirScenes/Dialogs/BuffDialog.cs @@ -29,7 +29,7 @@ public BuffDialog() { Index = 20; Library = Libraries.Prguse2; - Movable = false; + Movable = true; Size = new Size(44, 34); Location = new Point(Settings.ScreenWidth - 170, 0); Sort = true; @@ -214,7 +214,7 @@ private void UpdateWindow() { _buffCount = _buffList.Count; - var baseImage = 20; + var baseImage = (Index >= 40 && Index <= 53) ? 40 : 20; var heightOffset = Location.Y; //foreach (var dialog in GameScene.Scene.BuffDialogs) @@ -255,7 +255,7 @@ private void UpdateWindow() { var oldWidth = Size.Width; - Index = 20; + Index = baseImage; var newX = Location.X - Size.Width + oldWidth; var newY = heightOffset; @@ -560,7 +560,7 @@ public PoisonBuffDialog() { Index = 40; Library = Libraries.Prguse2; - Movable = false; + Movable = true; Size = new Size(44, 34); Location = new Point(Settings.ScreenWidth - 170, 0); Sort = true; @@ -836,7 +836,7 @@ private void UpdateWindow() { _buffCount = _buffList.Count; - var baseImage = 20; + var baseImage = 40; var heightOffset = 36; if (_buffCount > 0 && Settings.ExpandedBuffWindow) @@ -867,7 +867,7 @@ private void UpdateWindow() { var oldWidth = Size.Width; - Index = 20; + Index = 40; var newX = Location.X - Size.Width + oldWidth; var newY = heightOffset; diff --git a/Client/MirScenes/GameScene.cs b/Client/MirScenes/GameScene.cs index b71d7aebf..ed76773b7 100644 --- a/Client/MirScenes/GameScene.cs +++ b/Client/MirScenes/GameScene.cs @@ -5186,6 +5186,8 @@ private void AddBuff(S.AddBuff p) if (Hero != null && buff.ObjectID == Hero.ObjectID) { + if (HeroBuffsDialog.Index < 40 || HeroBuffsDialog.Index > 53) HeroBuffsDialog.Index = 40; + for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++) { if (HeroBuffsDialog.Buffs[i].Type != buff.Type) continue; @@ -5237,6 +5239,8 @@ private void RemoveBuff(S.RemoveBuff p) if (Hero != null && Hero.ObjectID == p.ObjectID) { + if (HeroBuffsDialog.Index < 40 || HeroBuffsDialog.Index > 53) HeroBuffsDialog.Index = 40; + for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++) { if (HeroBuffsDialog.Buffs[i].Type != p.Type) continue; @@ -5293,6 +5297,8 @@ private void PauseBuff(S.PauseBuff p) if (Hero != null && Hero.ObjectID == p.ObjectID) { + if (HeroBuffsDialog.Index < 40 || HeroBuffsDialog.Index > 53) HeroBuffsDialog.Index = 40; + for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++) { if (HeroBuffsDialog.Buffs[i].Type != p.Type) continue; @@ -6161,6 +6167,7 @@ private void HeroInformation(S.HeroInformation p) GetExpandedParameter = () => { return Settings.ExpandedHeroBuffWindow; }, SetExpandedParameter = (value) => { Settings.ExpandedHeroBuffWindow = value; } }; + HeroBuffsDialog.Index = 40; MainDialog.HeroInfoPanel.Update(); Hero.RefreshStats(); diff --git a/Server/MirDatabase/HeroInfo.cs b/Server/MirDatabase/HeroInfo.cs index f6bf47564..e794c541e 100644 --- a/Server/MirDatabase/HeroInfo.cs +++ b/Server/MirDatabase/HeroInfo.cs @@ -79,6 +79,17 @@ public override void Load(BinaryReader reader, int version, int customVersion) magic.CastTime = int.MinValue; Magics.Add(magic); } + + // Buff persistence (matches player CharacterInfo.Buffs) + if (version > 116) + { + count = reader.ReadInt32(); + for (int i = 0; i < count; i++) + { + Buff buff = new Buff(reader, version, customVersion); + Buffs.Add(buff); + } + } if (version > 99) { @@ -137,6 +148,13 @@ public override void Save(BinaryWriter writer) Magics[i].Save(writer); } + // Buff persistence (matches player CharacterInfo.Buffs) + writer.Write(Buffs.Count); + for (int i = 0; i < Buffs.Count; i++) + { + Buffs[i].Save(writer); + } + writer.Write(AutoPot); writer.Write(Grade); writer.Write(HPItemIndex); diff --git a/Server/MirEnvir/Envir.cs b/Server/MirEnvir/Envir.cs index 13e5f8a3d..9a3d6b7bf 100644 --- a/Server/MirEnvir/Envir.cs +++ b/Server/MirEnvir/Envir.cs @@ -53,7 +53,7 @@ public class Envir public static object LoadLock = new object(); public const int MinVersion = 60; - public const int Version = 116; + public const int Version = 117; public const int CustomVersion = 0; public static readonly string DatabasePath = Path.Combine(".", "Server.MirDB"); public static readonly string AccountPath = Path.Combine(".", "Server.MirADB"); diff --git a/Server/MirObjects/HeroObject.cs b/Server/MirObjects/HeroObject.cs index d8bec8a73..011beacf8 100644 --- a/Server/MirObjects/HeroObject.cs +++ b/Server/MirObjects/HeroObject.cs @@ -149,6 +149,7 @@ protected override void Load(CharacterInfo info, MirConnection connection) if (Level == 0) NewCharacter(); RefreshStats(); + RefreshNameColour(); SendInfo(); switch (HP) @@ -1201,6 +1202,7 @@ private void SendInfo() { ObjectID = ObjectID, Name = Name, + NameColour = NameColour, Class = Class, Gender = Gender, Level = Level, diff --git a/Server/MirObjects/PlayerObject.cs b/Server/MirObjects/PlayerObject.cs index 4f48b1471..44a54a5fe 100644 --- a/Server/MirObjects/PlayerObject.cs +++ b/Server/MirObjects/PlayerObject.cs @@ -1845,6 +1845,9 @@ public override Color GetNameColour(HumanObject human) { if (human == null) return NameColour; + // Heroes have a fixed, server-defined colour (do not apply PK/brown/warzone logic). + if (human is HeroObject hero) return hero.NameColour; + if (human is PlayerObject player) { if (player.PKPoints >= 200) @@ -14486,6 +14489,9 @@ public void SealHero() if (Hero != null) { + // Sealing (marbling) a hero should wipe all buffs so they can't be stored/traded with remaining durations. + CurrentHero.Buffs?.Clear(); + DespawnHero(); Info.HeroSpawned = false; Enqueue(new S.UpdateHeroSpawnState { State = HeroSpawnState.None }); diff --git a/Shared/ServerPackets.cs b/Shared/ServerPackets.cs index e6a4f4ff9..53bc344b6 100644 --- a/Shared/ServerPackets.cs +++ b/Shared/ServerPackets.cs @@ -4707,6 +4707,7 @@ protected override void ReadPacket(BinaryReader reader) { ObjectID = reader.ReadUInt32(); Name = reader.ReadString(); + NameColour = Color.FromArgb(reader.ReadInt32()); Class = (MirClass)reader.ReadByte(); Gender = (MirGender)reader.ReadByte(); Level = reader.ReadUInt16(); @@ -4756,6 +4757,7 @@ protected override void WritePacket(BinaryWriter writer) { writer.Write(ObjectID); writer.Write(Name); + writer.Write(NameColour.ToArgb()); writer.Write((byte)Class); writer.Write((byte)Gender); writer.Write(Level); From da4ed7f21a921224ba0debdf9f2cd8ca9f790fc3 Mon Sep 17 00:00:00 2001 From: daneo1989 Date: Thu, 15 Jan 2026 05:27:08 +0000 Subject: [PATCH 2/2] PR Update --- Client/MirScenes/Dialogs/BuffDialog.cs | 5 +++-- Client/MirScenes/GameScene.cs | 8 +------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/Client/MirScenes/Dialogs/BuffDialog.cs b/Client/MirScenes/Dialogs/BuffDialog.cs index 5ffbdc4c9..98a786298 100644 --- a/Client/MirScenes/Dialogs/BuffDialog.cs +++ b/Client/MirScenes/Dialogs/BuffDialog.cs @@ -1,4 +1,4 @@ -using Client.MirControls; +using Client.MirControls; using Client.MirGraphics; using Client.MirSounds; @@ -7,6 +7,7 @@ namespace Client.MirScenes.Dialogs public class BuffDialog : MirImageControl { public List Buffs = new List(); + public int BaseImageIndex { get; set; } = 20; protected MirButton _expandCollapseButton; protected MirLabel _buffCountLabel; @@ -214,7 +215,7 @@ private void UpdateWindow() { _buffCount = _buffList.Count; - var baseImage = (Index >= 40 && Index <= 53) ? 40 : 20; + var baseImage = BaseImageIndex; var heightOffset = Location.Y; //foreach (var dialog in GameScene.Scene.BuffDialogs) diff --git a/Client/MirScenes/GameScene.cs b/Client/MirScenes/GameScene.cs index ed76773b7..a838a852a 100644 --- a/Client/MirScenes/GameScene.cs +++ b/Client/MirScenes/GameScene.cs @@ -5186,8 +5186,6 @@ private void AddBuff(S.AddBuff p) if (Hero != null && buff.ObjectID == Hero.ObjectID) { - if (HeroBuffsDialog.Index < 40 || HeroBuffsDialog.Index > 53) HeroBuffsDialog.Index = 40; - for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++) { if (HeroBuffsDialog.Buffs[i].Type != buff.Type) continue; @@ -5239,8 +5237,6 @@ private void RemoveBuff(S.RemoveBuff p) if (Hero != null && Hero.ObjectID == p.ObjectID) { - if (HeroBuffsDialog.Index < 40 || HeroBuffsDialog.Index > 53) HeroBuffsDialog.Index = 40; - for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++) { if (HeroBuffsDialog.Buffs[i].Type != p.Type) continue; @@ -5297,8 +5293,6 @@ private void PauseBuff(S.PauseBuff p) if (Hero != null && Hero.ObjectID == p.ObjectID) { - if (HeroBuffsDialog.Index < 40 || HeroBuffsDialog.Index > 53) HeroBuffsDialog.Index = 40; - for (int i = 0; i < HeroBuffsDialog.Buffs.Count; i++) { if (HeroBuffsDialog.Buffs[i].Type != p.Type) continue; @@ -6164,10 +6158,10 @@ private void HeroInformation(S.HeroInformation p) Parent = this, Visible = true, Location = new Point(Settings.ScreenWidth - 170, 80), + BaseImageIndex = 40, GetExpandedParameter = () => { return Settings.ExpandedHeroBuffWindow; }, SetExpandedParameter = (value) => { Settings.ExpandedHeroBuffWindow = value; } }; - HeroBuffsDialog.Index = 40; MainDialog.HeroInfoPanel.Update(); Hero.RefreshStats();