Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into kbatman/krec_support
- Loading branch information
Showing
37 changed files
with
1,224 additions
and
1,057 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,32 @@ | ||
namespace Server.Network | ||
{ | ||
public delegate void OnEncodedPacketReceive(NetState state, IEntity ent, EncodedReader reader); | ||
/************************************************************************* | ||
* ModernUO * | ||
* Copyright 2019-2022 - ModernUO Development Team * | ||
* Email: hi@modernuo.com * | ||
* File: EncodedPacketHandler.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/>. * | ||
*************************************************************************/ | ||
|
||
namespace Server.Network; | ||
|
||
public class EncodedPacketHandler | ||
public unsafe class EncodedPacketHandler | ||
{ | ||
public EncodedPacketHandler(int packetID, bool ingame, delegate*<NetState, IEntity, EncodedReader, void> onReceive) | ||
{ | ||
public EncodedPacketHandler(int packetID, bool ingame, OnEncodedPacketReceive onReceive) | ||
{ | ||
PacketID = packetID; | ||
Ingame = ingame; | ||
OnReceive = onReceive; | ||
} | ||
PacketID = packetID; | ||
Ingame = ingame; | ||
OnReceive = onReceive; | ||
} | ||
|
||
public int PacketID { get; } | ||
public int PacketID { get; } | ||
|
||
public OnEncodedPacketReceive OnReceive { get; } | ||
public delegate*<NetState, IEntity, EncodedReader, void> OnReceive { get; } | ||
|
||
public bool Ingame { get; } | ||
} | ||
public bool Ingame { get; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,37 @@ | ||
namespace Server.Network | ||
/************************************************************************* | ||
* ModernUO * | ||
* Copyright 2019-2022 - ModernUO Development Team * | ||
* Email: hi@modernuo.com * | ||
* File: EncodedReader.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/>. * | ||
*************************************************************************/ | ||
|
||
namespace Server.Network; | ||
|
||
public ref struct EncodedReader | ||
{ | ||
public ref struct EncodedReader | ||
{ | ||
private CircularBufferReader m_Reader; | ||
private CircularBufferReader _reader; | ||
|
||
public EncodedReader(CircularBufferReader reader) => m_Reader = reader; | ||
public EncodedReader(CircularBufferReader reader) => _reader = reader; | ||
|
||
public void Trace(NetState state) | ||
{ | ||
m_Reader.Trace(state); | ||
} | ||
public void Trace(NetState state) => _reader.Trace(state); | ||
|
||
public int ReadInt32() => m_Reader.ReadByte() != 0 ? 0 : m_Reader.ReadInt32(); | ||
public int ReadInt32() => _reader.ReadByte() != 0 ? 0 : _reader.ReadInt32(); | ||
|
||
public Point3D ReadPoint3D() => m_Reader.ReadByte() != 3 | ||
? Point3D.Zero | ||
: new Point3D(m_Reader.ReadInt16(), m_Reader.ReadInt16(), m_Reader.ReadByte()); | ||
public Point3D ReadPoint3D() => _reader.ReadByte() != 3 | ||
? Point3D.Zero | ||
: new Point3D(_reader.ReadInt16(), _reader.ReadInt16(), _reader.ReadByte()); | ||
|
||
public string ReadUnicodeStringSafe() => | ||
m_Reader.ReadByte() != 2 ? string.Empty : m_Reader.ReadBigUniSafe(m_Reader.ReadUInt16()); | ||
public string ReadUnicodeStringSafe() => | ||
_reader.ReadByte() != 2 ? string.Empty : _reader.ReadBigUniSafe(_reader.ReadUInt16()); | ||
|
||
public string ReadUnicodeString() => | ||
m_Reader.ReadByte() != 2 ? string.Empty : m_Reader.ReadBigUni(m_Reader.ReadUInt16()); | ||
} | ||
public string ReadUnicodeString() => | ||
_reader.ReadByte() != 2 ? string.Empty : _reader.ReadBigUni(_reader.ReadUInt16()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using Server.ContextMenus; | ||
using Server.Gumps; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
using ModernUO.Serialization; | ||
using Server.Targeting; | ||
using Server.Text; | ||
|
||
namespace Server.Items; | ||
|
||
|
97 changes: 45 additions & 52 deletions
97
Projects/UOContent/Items/Games/Mahjong/MahjongDealerIndicator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,69 +1,62 @@ | ||
namespace Server.Engines.Mahjong | ||
{ | ||
public class MahjongDealerIndicator | ||
{ | ||
public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind) | ||
{ | ||
Game = game; | ||
Position = position; | ||
Direction = direction; | ||
Wind = wind; | ||
} | ||
using ModernUO.Serialization; | ||
|
||
public MahjongDealerIndicator(MahjongGame game, IGenericReader reader) | ||
{ | ||
Game = game; | ||
namespace Server.Engines.Mahjong; | ||
|
||
var version = reader.ReadInt(); | ||
[SerializationGenerator(1, false)] | ||
public partial class MahjongDealerIndicator | ||
{ | ||
[DirtyTrackingEntity] | ||
private readonly MahjongGame _game; | ||
|
||
Position = reader.ReadPoint2D(); | ||
Direction = (MahjongPieceDirection)reader.ReadInt(); | ||
Wind = (MahjongWind)reader.ReadInt(); | ||
} | ||
[SerializableField(0, setter: "private")] | ||
private Point2D _position; | ||
|
||
public MahjongGame Game { get; } | ||
[SerializableField(1, setter: "private")] | ||
private MahjongPieceDirection _direction; | ||
|
||
public Point2D Position { get; private set; } | ||
[SerializableField(2, setter: "private")] | ||
private MahjongWind _wind; | ||
|
||
public MahjongPieceDirection Direction { get; private set; } | ||
public MahjongDealerIndicator(MahjongGame game) | ||
{ | ||
_game = game; | ||
} | ||
|
||
public MahjongWind Wind { get; private set; } | ||
public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind) | ||
{ | ||
_game = game; | ||
_position = position; | ||
_direction = direction; | ||
_wind = wind; | ||
} | ||
|
||
public MahjongPieceDim Dimensions => GetDimensions(Position, Direction); | ||
public MahjongPieceDim Dimensions => GetDimensions(_position, _direction); | ||
|
||
public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) | ||
{ | ||
if (direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down) | ||
{ | ||
return new MahjongPieceDim(position, 40, 20); | ||
} | ||
public static MahjongPieceDim GetDimensions(Point2D position, MahjongPieceDirection direction) => | ||
direction is MahjongPieceDirection.Up or MahjongPieceDirection.Down | ||
? new MahjongPieceDim(position, 40, 20) | ||
: new MahjongPieceDim(position, 20, 40); | ||
|
||
return new MahjongPieceDim(position, 20, 40); | ||
} | ||
public void Move(Point2D position, MahjongPieceDirection direction, MahjongWind wind) | ||
{ | ||
var dim = GetDimensions(position, direction); | ||
|
||
public void Move(Point2D position, MahjongPieceDirection direction, MahjongWind wind) | ||
if (!dim.IsValid()) | ||
{ | ||
var dim = GetDimensions(position, direction); | ||
|
||
if (!dim.IsValid()) | ||
{ | ||
return; | ||
} | ||
|
||
Position = position; | ||
Direction = direction; | ||
Wind = wind; | ||
|
||
Game.Players.SendGeneralPacket(true, true); | ||
return; | ||
} | ||
|
||
public void Save(IGenericWriter writer) | ||
{ | ||
writer.Write(0); // version | ||
_position = position; | ||
_direction = direction; | ||
_wind = wind; | ||
|
||
writer.Write(Position); | ||
writer.Write((int)Direction); | ||
writer.Write((int)Wind); | ||
} | ||
_game.Players.SendGeneralPacket(true, true); | ||
} | ||
|
||
private void Deserialize(IGenericReader reader, int version) | ||
{ | ||
_position = reader.ReadPoint2D(); | ||
_direction = (MahjongPieceDirection)reader.ReadInt(); | ||
_wind = (MahjongWind)reader.ReadInt(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,37 @@ | ||
namespace Server.Engines.Mahjong | ||
{ | ||
public class MahjongDices | ||
{ | ||
public MahjongDices(MahjongGame game) | ||
{ | ||
Game = game; | ||
First = Utility.Random(1, 6); | ||
Second = Utility.Random(1, 6); | ||
} | ||
using ModernUO.Serialization; | ||
|
||
public MahjongDices(MahjongGame game, IGenericReader reader) | ||
{ | ||
Game = game; | ||
namespace Server.Engines.Mahjong; | ||
|
||
var version = reader.ReadInt(); | ||
[SerializationGenerator(0, false)] | ||
public partial class MahjongDices | ||
{ | ||
[DirtyTrackingEntity] | ||
private readonly MahjongGame _game; | ||
|
||
First = reader.ReadInt(); | ||
Second = reader.ReadInt(); | ||
} | ||
[SerializableField(0, setter: "private")] | ||
private int _first; | ||
|
||
public MahjongGame Game { get; } | ||
[SerializableField(1, setter: "private")] | ||
private int _second; | ||
|
||
public int First { get; private set; } | ||
public MahjongDices(MahjongGame game) | ||
{ | ||
_game = game; | ||
_first = Utility.Random(1, 6); | ||
_second = Utility.Random(1, 6); | ||
} | ||
|
||
public int Second { get; private set; } | ||
public void RollDices(Mobile from) | ||
{ | ||
_first = Utility.Random(1, 6); | ||
_second = Utility.Random(1, 6); | ||
|
||
public void RollDices(Mobile from) | ||
{ | ||
First = Utility.Random(1, 6); | ||
Second = Utility.Random(1, 6); | ||
|
||
Game.Players.SendGeneralPacket(true, true); | ||
|
||
if (from != null) | ||
{ | ||
Game.Players.SendLocalizedMessage( | ||
1062695, | ||
$"{from.Name}\t{First}\t{Second}" | ||
); // ~1_name~ rolls the dice and gets a ~2_number~ and a ~3_number~! | ||
} | ||
} | ||
_game.Players.SendGeneralPacket(true, true); | ||
|
||
public void Save(IGenericWriter writer) | ||
if (from != null) | ||
{ | ||
writer.Write(0); // version | ||
|
||
writer.Write(First); | ||
writer.Write(Second); | ||
// ~1_name~ rolls the dice and gets a ~2_number~ and a ~3_number~! | ||
_game.Players.SendLocalizedMessage(1062695, $"{from.Name}\t{_first}\t{_second}"); | ||
} | ||
} | ||
} |
Oops, something went wrong.