fix: Moves the rest of the Incoming packets (#1338)

This commit is contained in:
Marcelo Paez Sequeira 2023-02-11 03:59:36 -03:00 committed by GitHub
parent a8d8db8f59
commit b46544d752
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 71 additions and 25 deletions

View file

@ -1,3 +1,18 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: Gump.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;
using System.Collections.Generic;
using Server.Network;
@ -15,7 +30,20 @@ public partial class Gump
public static readonly byte[] NoDispose = StringToBuffer("{ nodispose }");
public static readonly byte[] NoResize = StringToBuffer("{ noresize }");
internal int m_TextEntries, m_Switches;
private int _switches;
private int _textEntries;
public int Switches
{
get => _switches;
set => _switches = value;
}
public int TextEntries
{
get => _textEntries;
set => _textEntries = value;
}
public Gump(int x, int y)
{
@ -250,7 +278,7 @@ public partial class Gump
public void SendTo(NetState state)
{
state.AddGump(this);
state.SendDisplayGump(this, out m_Switches, out m_TextEntries);
state.SendDisplayGump(this, out _switches, out _textEntries);
}
public static byte[] StringToBuffer(string str) => str.GetBytesAscii();

View file

@ -0,0 +1,37 @@
/*************************************************************************
* ModernUO *
* Copyright 2019-2023 - ModernUO Development Team *
* Email: hi@modernuo.com *
* File: MessageType.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;
[Flags]
public enum MessageType
{
Regular = 0x00,
System = 0x01,
Emote = 0x02,
Label = 0x06,
Focus = 0x07,
Whisper = 0x08,
Yell = 0x09,
Spell = 0x0A,
Guild = 0x0D,
Alliance = 0x0E,
Command = 0x0F,
Encoded = 0xC0
}

View file

@ -92,8 +92,8 @@ public static class IncomingItemPackets
if (item is BaseMulti multi && multi.AllowsRelativeDrop)
{
loc.m_X += multi.X;
loc.m_Y += multi.Y;
loc.X += multi.X;
loc.Y += multi.Y;
from.Drop(loc);
}
else

View file

@ -17,25 +17,6 @@ using System;
namespace Server.Network;
[Flags]
public enum MessageType
{
Regular = 0x00,
System = 0x01,
Emote = 0x02,
Label = 0x06,
Focus = 0x07,
Whisper = 0x08,
Yell = 0x09,
Spell = 0x0A,
Guild = 0x0D,
Alliance = 0x0E,
Command = 0x0F,
Encoded = 0xC0
}
public static class IncomingMessagePackets
{
private static readonly KeywordList m_KeywordList = new();

View file

@ -384,7 +384,7 @@ public static class IncomingPlayerPackets
var switchCount = reader.ReadInt32();
if (switchCount < 0 || switchCount > gump.m_Switches)
if (switchCount < 0 || switchCount > gump.Switches)
{
state.LogInfo("Invalid gump response, disconnecting...");
var exception = new InvalidGumpResponseException($"Bad switch count {switchCount}");
@ -405,7 +405,7 @@ public static class IncomingPlayerPackets
var textCount = reader.ReadInt32();
if (textCount < 0 || textCount > gump.m_TextEntries)
if (textCount < 0 || textCount > gump.TextEntries)
{
state.LogInfo("Invalid gump response, disconnecting...");
var exception = new InvalidGumpResponseException($"Bad text entry count {textCount}");