fix: Optimizes gump relay info (Prep for Static Gumps) (#1698)
This commit is contained in:
parent
50fcee12dc
commit
cfe9e04c78
220 changed files with 364 additions and 402 deletions
|
|
@ -291,7 +291,7 @@ public partial class Gump
|
|||
|
||||
public static byte[] StringToBuffer(string str) => str.GetBytesAscii();
|
||||
|
||||
public virtual void OnResponse(NetState sender, RelayInfo info)
|
||||
public virtual void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,36 @@
|
|||
/*************************************************************************
|
||||
* ModernUO *
|
||||
* Copyright 2019-2024 - ModernUO Development Team *
|
||||
* Email: hi@modernuo.com *
|
||||
* File: RelayInfo.cs *
|
||||
* *
|
||||
* This program is free software: you can redistribute it and/or modify *
|
||||
* it under the terms of the GNU General Public License as published by *
|
||||
* the Free Software Foundation, either version 3 of the License, or *
|
||||
* (at your option) any later version. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License *
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
|
||||
*************************************************************************/
|
||||
|
||||
using System;
|
||||
|
||||
namespace Server.Gumps;
|
||||
|
||||
public class TextRelay
|
||||
public readonly struct TextRelay
|
||||
{
|
||||
public TextRelay(int entryID, string text)
|
||||
public TextRelay(int entryId, string text)
|
||||
{
|
||||
EntryID = entryID;
|
||||
EntryId = entryId;
|
||||
Text = text;
|
||||
}
|
||||
|
||||
public int EntryID { get; }
|
||||
public int EntryId { get; }
|
||||
|
||||
public string Text { get; }
|
||||
}
|
||||
|
||||
public class RelayInfo
|
||||
public ref struct RelayInfo
|
||||
{
|
||||
public RelayInfo(int buttonID, int[] switches, TextRelay[] textEntries)
|
||||
{
|
||||
|
|
@ -24,9 +41,9 @@ public class RelayInfo
|
|||
|
||||
public int ButtonID { get; }
|
||||
|
||||
public int[] Switches { get; }
|
||||
public ReadOnlySpan<int> Switches { get; }
|
||||
|
||||
public TextRelay[] TextEntries { get; }
|
||||
public ReadOnlySpan<TextRelay> TextEntries { get; }
|
||||
|
||||
public bool IsSwitched(int switchID)
|
||||
{
|
||||
|
|
@ -41,16 +58,16 @@ public class RelayInfo
|
|||
return false;
|
||||
}
|
||||
|
||||
public TextRelay GetTextEntry(int entryID)
|
||||
public string GetTextEntry(int entryId)
|
||||
{
|
||||
for (var i = 0; i < TextEntries.Length; ++i)
|
||||
{
|
||||
if (TextEntries[i].EntryID == entryID)
|
||||
if (TextEntries[i].EntryId == entryId)
|
||||
{
|
||||
return TextEntries[i];
|
||||
return TextEntries[i].Text;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ public sealed partial class VirtualCheck : Item
|
|||
AddButton(305, 128, 12000, 12002, (int)Buttons.Accept);
|
||||
}
|
||||
|
||||
public override void OnResponse(NetState sender, RelayInfo info)
|
||||
public override void OnResponse(NetState sender, in RelayInfo info)
|
||||
{
|
||||
if (Check?.Deleted != false || sender.Mobile != User)
|
||||
{
|
||||
|
|
@ -324,8 +324,8 @@ public sealed partial class VirtualCheck : Item
|
|||
}
|
||||
case Buttons.Accept:
|
||||
{
|
||||
var platText = info.GetTextEntry(0).Text;
|
||||
var goldText = info.GetTextEntry(1).Text;
|
||||
var platText = info.GetTextEntry(0);
|
||||
var goldText = info.GetTextEntry(1);
|
||||
|
||||
if (!int.TryParse(platText, out _plat))
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue