Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

0x02 Attribute is possibly unsigned. Made all Signed Ints are now Unsigned. #44

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/PFire.Core/Models/FriendRequestModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class FriendRequestModel
{
public int Id { get; set; }
public uint Id { get; set; }
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's keep these as int since it interacts with the database. We may need to add casting in places between our database and the protocol though.

public string Username { get; set; }
public string Nickname { get; set; }
public string Message { get; set; }
Expand Down
6 changes: 3 additions & 3 deletions src/PFire.Core/Models/GameModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ namespace PFire.Core.Models
{
public class GameModel
{
public int Id { get; set; }
public int Ip { get; set; }
public int Port { get; set; }
public uint Id { get; set; }
public uint Ip { get; set; }
public uint Port { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/PFire.Core/Models/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class UserModel
{
public int Id { get; set; }
public uint Id { get; set; }
public string Username { get; set; }
public string Password { get; set; }
public string Nickname { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ internal sealed class ChatContent : XFireMessage
public ChatContent() : base(XFireMessageType.ServerChatMessage) {}

[XMessageField("imindex")]
public int MessageOrderIndex { get; set; }
public uint MessageOrderIndex { get; set; }

[XMessageField("im")]
public string MessageContent { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private ChatMessage BuildAckResponse(Guid sessionId)
MessagePayload = new Dictionary<string, dynamic>
{
{"msgtyp", (byte)ChatMessageType.Acknowledgement},
{"imindex", (int)MessagePayload["imindex"]}
{"imindex", (uint)MessagePayload["imindex"]}
}
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ internal sealed class ChatTypingNotification : XFireMessage
public ChatTypingNotification() : base(XFireMessageType.ServerChatMessage) {}

[XMessageField("imindex")]
public int OrderIndex { get; set; }
public uint OrderIndex { get; set; }

[XMessageField("typing")]
public int Typing { get; set; }
public uint Typing { get; set; }
}
}
4 changes: 2 additions & 2 deletions src/PFire.Core/Protocol/Messages/Inbound/ClientVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ internal sealed class ClientVersion : XFireMessage
public ClientVersion() : base(XFireMessageType.ClientVersion) {}

[XMessageField("version")]
public int Version { get; set; }
public uint Version { get; set; }

[XMessageField("major_version")]
public int MajorVersion { get; set; }
public uint MajorVersion { get; set; }

public override async Task Process(IXFireClient context)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ internal sealed class ConnectionInformation : XFireMessage
public ConnectionInformation() : base(XFireMessageType.ConnectionInformation) {}

[XMessageField("conn")]
public int Connection { get; set; }
public uint Connection { get; set; }

[XMessageField("nat")]
public int Nat { get; set; }
public uint Nat { get; set; }

[XMessageField("naterr")]
public int NatError { get; set; }
public uint NatError { get; set; }

[XMessageField("sec")]
public int Sec { get; set; }
public uint Sec { get; set; }

[XMessageField("clientip")]
public int ClientIp { get; set; }
public uint ClientIp { get; set; }

[XMessageField("upnpinfo")]
public string UpnpInfo { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion src/PFire.Core/Protocol/Messages/Inbound/FriendRemoval.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ internal sealed class FriendRemoval : XFireMessage
public FriendRemoval() : base(XFireMessageType.FriendRemoval) { }

[XMessageField("userid")]
public int UserId { get; set; }
public uint UserId { get; set; }

public override async Task Process(IXFireClient context)
{
Expand Down
6 changes: 3 additions & 3 deletions src/PFire.Core/Protocol/Messages/Inbound/GameInformation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ internal sealed class GameInformation : XFireMessage
public GameInformation() : base(XFireMessageType.GameInformation) {}

[XMessageField("gameid")]
public int GameId { get; set; }
public uint GameId { get; set; }

[XMessageField("gip")]
public int GameIP { get; set; }
public uint GameIP { get; set; }

[XMessageField("gport")]
public int GamePort { get; set; }
public uint GamePort { get; set; }

public override async Task Process(IXFireClient context)
{
Expand Down
2 changes: 1 addition & 1 deletion src/PFire.Core/Protocol/Messages/Inbound/LoginRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public LoginRequest() : base(XFireMessageType.LoginRequest) {}
public string Password { get; set; }

[XMessageField("flags")]
public int Flags { get; set; }
public uint Flags { get; set; }

public override async Task Process(IXFireClient context)
{
Expand Down
4 changes: 2 additions & 2 deletions src/PFire.Core/Protocol/Messages/Outbound/ChatRooms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ internal sealed class ChatRooms : XFireMessage
{
public ChatRooms() : base(XFireMessageType.ChatRooms)
{
ChatIds = new List<int>();
ChatIds = new List<uint>();
}

[XMessageField(0x04)]
public List<int> ChatIds { get; }
public List<uint> ChatIds { get; }
}
}
4 changes: 2 additions & 2 deletions src/PFire.Core/Protocol/Messages/Outbound/FriendRemoved.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ namespace PFire.Core.Protocol.Messages.Outbound
{
internal sealed class FriendRemoved : XFireMessage
{
public FriendRemoved(int userId) : base(XFireMessageType.FriendRemoved)
public FriendRemoved(uint userId) : base(XFireMessageType.FriendRemoved)
{
UserId = userId;
}

[XMessageField("userid")]
public int UserId { get; set; }
public uint UserId { get; set; }
}
}
12 changes: 6 additions & 6 deletions src/PFire.Core/Protocol/Messages/Outbound/FriendsGameInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ public FriendsGamesInfo(UserModel owner) : base(XFireMessageType.FriendsGameInfo
{
_ownerUser = owner;
SessionIds = new List<Guid>();
GameID = new List<int>();
GameIP = new List<int>();
GamePort = new List<int>();
GameID = new List<uint>();
GameIP = new List<uint>();
GamePort = new List<uint>();
}

[XMessageField("sid")]
public List<Guid> SessionIds { get; set; }

[XMessageField("gameid")]
public List<int> GameID { get; set; }
public List<uint> GameID { get; set; }

[XMessageField("gip")]
public List<int> GameIP { get; set; }
public List<uint> GameIP { get; set; }

[XMessageField("gport")]
public List<int> GamePort { get; set; }
public List<uint> GamePort { get; set; }

public override Task Process(IXFireClient client)
{
Expand Down
4 changes: 2 additions & 2 deletions src/PFire.Core/Protocol/Messages/Outbound/FriendsList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ public FriendsList(UserModel owner) : base(XFireMessageType.FriendsList)
{
_ownerUser = owner;

UserIds = new List<int>();
UserIds = new List<uint>();
Usernames = new List<string>();
Nicks = new List<string>();
}

[XMessageField("userid")]
public List<int> UserIds { get; }
public List<uint> UserIds { get; }

[XMessageField("friends")]
public List<string> Usernames { get; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ internal sealed class FriendsSessionAssign : XFireMessage
public FriendsSessionAssign(UserModel owner) : base(XFireMessageType.FriendsSessionAssign)
{
_ownerUser = owner;
UserIds = new List<int>();
UserIds = new List<uint>();
SessionIds = new List<Guid>();
}

[XMessageField("userid")]
public List<int> UserIds { get; }
public List<uint> UserIds { get; }

[XMessageField("sid")]
public List<Guid> SessionIds { get; }
Expand Down
4 changes: 2 additions & 2 deletions src/PFire.Core/Protocol/Messages/Outbound/Groups.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ internal sealed class Groups : XFireMessage
public Groups() : base(XFireMessageType.Groups) {}

[XMessageField(0x19)]
public List<int> GroupIds { get; set; }
public List<uint> GroupIds { get; set; }

[XMessageField(0x1a)]
public List<string> GroupNames { get; set; }

public override Task Process(IXFireClient context)
{
GroupIds = new List<int>();
GroupIds = new List<uint>();
GroupNames = new List<string>();

return Task.CompletedTask;
Expand Down
8 changes: 4 additions & 4 deletions src/PFire.Core/Protocol/Messages/Outbound/GroupsFriends.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ internal sealed class GroupsFriends : XFireMessage
{
public GroupsFriends() : base(XFireMessageType.GroupsFriends)
{
UserIds = new List<int>();
GroupIds = new List<int>();
UserIds = new List<uint>();
GroupIds = new List<uint>();
}

[XMessageField(0x01)]
public List<int> UserIds { get; }
public List<uint> UserIds { get; }

[XMessageField(0x19)]
public List<int> GroupIds { get; }
public List<uint> GroupIds { get; }
}
}
2 changes: 1 addition & 1 deletion src/PFire.Core/Protocol/Messages/Outbound/LoginFailure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ internal sealed class LoginFailure : XFireMessage
public LoginFailure() : base(XFireMessageType.LoginFailure) {}

[XMessageField("reason")]
public int Reason { get; set; }
public uint Reason { get; set; }
}
}
20 changes: 10 additions & 10 deletions src/PFire.Core/Protocol/Messages/Outbound/LoginSuccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ internal sealed class LoginSuccess : XFireMessage
public LoginSuccess() : base(XFireMessageType.LoginSuccess) {}

[XMessageField("userid")]
public int UserId { get; set; }
public uint UserId { get; set; }

[XMessageField("sid")]
public Guid SessionId { get; set; }
Expand All @@ -20,7 +20,7 @@ public LoginSuccess() : base(XFireMessageType.LoginSuccess) {}
public string Nickname { get; set; }

[XMessageField("status")]
public int Status { get; set; }
public uint Status { get; set; }

[XMessageField("dlset")]
public string DlSet { get; set; }
Expand All @@ -32,25 +32,25 @@ public LoginSuccess() : base(XFireMessageType.LoginSuccess) {}
public string ClientSet { get; set; }

[XMessageField("minrect")]
public int MinRect { get; set; }
public uint MinRect { get; set; }

[XMessageField("maxrect")]
public int MaxRect { get; set; }
public uint MaxRect { get; set; }

[XMessageField("ctry")]
public int Country { get; set; }
public uint Country { get; set; }

[XMessageField("n1")]
public int N1 { get; set; }
public uint N1 { get; set; }

[XMessageField("n2")]
public int N2 { get; set; }
public uint N2 { get; set; }

[XMessageField("n3")]
public int N3 { get; set; }
public uint N3 { get; set; }

[XMessageField("pip")]
public int PublicIp { get; set; }
public uint PublicIp { get; set; }

[XMessageField("salt")]
public string Salt { get; set; }
Expand All @@ -67,7 +67,7 @@ public override Task Process(IXFireClient context)
MinRect = 1;
MaxRect = 164867;
var ipAddress = StripPortFromIpAddress(context.RemoteEndPoint.ToString());
PublicIp = BitConverter.ToInt32(IPAddress.Parse(ipAddress).GetAddressBytes(), 0);
PublicIp = BitConverter.ToUInt32(IPAddress.Parse(ipAddress).GetAddressBytes(), 0);
Salt = context.Salt;
Reason = "Mq_P8Ad3aMEUvFinw0ceu6FITnZTWXxg46XU8xHW";

Expand Down
14 changes: 7 additions & 7 deletions src/PFire.Core/Protocol/Messages/Outbound/ServerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,21 @@ internal sealed class ServerList : XFireMessage
{
public ServerList() : base(XFireMessageType.ServerList)
{
GameIds = new List<int>();
GameIPs = new List<int>();
GamePorts = new List<int>();
GameIds = new List<uint>();
GameIPs = new List<uint>();
GamePorts = new List<uint>();
}

[XMessageField("max")]
public int MaximumFavorites { get; set; }
public uint MaximumFavorites { get; set; }

[XMessageField("gameid")]
public List<int> GameIds { get; }
public List<uint> GameIds { get; }

[XMessageField("gip")]
public List<int> GameIPs { get; }
public List<uint> GameIPs { get; }

[XMessageField("gport")]
public List<int> GamePorts { get; }
public List<uint> GamePorts { get; }
}
}
2 changes: 1 addition & 1 deletion src/PFire.Core/Protocol/Messages/Outbound/ServerPong.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal sealed class ServerPong : XFireMessage
public ServerPong() : base(XFireMessageType.ServerPong) { }

[XMessageField("value")]
public int Value { get; set; } = 0;
public uint Value { get; set; } = 0;

public override Task Process(IXFireClient context)
{
Expand Down
3 changes: 2 additions & 1 deletion src/PFire.Core/Protocol/XFireAttributeFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class XFireAttributeFactory
private XFireAttributeFactory()
{
Add(new StringAttribute());
Add(new Int32Attribute());
//Add(new Int32Attribute());
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
//Add(new Int32Attribute());

Let's just delete this

Add(new UInt32Attribute());
Add(new SessionIdAttribute());
Add(new ListAttribute());
Add(new DidAttribute());
Expand Down
6 changes: 3 additions & 3 deletions src/PFire.Core/Protocol/XFireAttributes/MessageAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ namespace PFire.Core.Protocol.XFireAttributes
{
public class MessageAttribute : XFireAttribute
{
private static readonly Dictionary<int, IMessage> MESSAGE_TYPES = new Dictionary<int, IMessage>
private static readonly Dictionary<uint, IMessage> MESSAGE_TYPES = new Dictionary<uint, IMessage>
{
{ 0, new ChatMessage() },
{ 1, new ChatAcknowledgement() }
};

private IMessage CreateMessage(short type)
private IMessage CreateMessage(uint type)
{
if(!MESSAGE_TYPES.ContainsKey(type))
{
Expand Down Expand Up @@ -55,4 +55,4 @@ private string ReadInt8String(BinaryReader reader)
return Encoding.UTF8.GetString(reader.ReadBytes(length));
}
}
}
}
Loading
Loading