fix: Warn when sending empty gumps (#2563)

### Summary

Generates a console warning when users receive an empty gump. This will help prevent client side leaks.
This commit is contained in:
Guflly 2026-08-08 00:55:12 -07:00 • committed by GitHub
parent b2c59191bd
commit 64e6fe5da8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 114 additions and 0 deletions

View file

@ -13,6 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
*************************************************************************/
using Server.Logging;
using Server.Network;
using System;
using System.Buffers;
@ -23,10 +24,12 @@ namespace Server.Gumps;
public abstract class BaseGump
{
private static readonly byte[] _packetBuffer = GC.AllocateUninitializedArray<byte>(0x10000);
private static readonly ILogger _logger = LogFactory.GetLogger(typeof(BaseGump));
private static Serial nextSerial = (Serial)1;
public int TypeID { get; protected set; }
public Serial Serial { get; protected set; }
protected bool HasVisualElements { get; set; }
public abstract int Switches { get; }
public abstract int TextEntries { get; }
@ -56,6 +59,11 @@ public abstract class BaseGump
var writer = new SpanWriter(_packetBuffer);
Compile(ref writer);
if (!HasVisualElements)
{
_logger.Warning("Sending empty gump {GumpType}", GetType().FullName);
}
ns.Send(writer.Span);
writer.Dispose();