Skip to content
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
12 changes: 10 additions & 2 deletions GenOnlineService/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ public static class Constants
}
public class RoomMember
{
public RoomMember(Int64 a_UserID, string strName, bool admin)
public RoomMember(Int64 a_UserID, string strName, bool admin, string platform = "")
{
UserID = a_UserID;
Name = strName;
IsAdmin = admin;
Platform = platform;
}

public Int64 UserID { get; set; } = -1;
public String Name { get; set; } = String.Empty;
public bool IsAdmin { get; set; } = false;
public String Platform { get; set; } = "";
}

public enum EPendingLoginState
Expand Down Expand Up @@ -765,7 +767,7 @@ public static async Task TickRoomMemberList()
}


memberListUpdate.members.Add(new RoomMember(sess.m_UserID, strDisplayName, sharedUserData.IsAdmin()));
memberListUpdate.members.Add(new RoomMember(sess.m_UserID, strDisplayName, sharedUserData.IsAdmin(), sess.Platform));

// also add to list of users who need this update, since they were in there
lstUsersToSend.Add(sess.m_UserID);
Expand Down Expand Up @@ -883,6 +885,7 @@ public class UserSession
private string m_strMiddlewareUserID = String.Empty;

public KnownClients.EKnownClients m_client_id = KnownClients.EKnownClients.unknown;
public string Platform { get; private set; } = "";
DateTime m_CreateTime = DateTime.Now;
public DateTime GetCreationTime()
{
Expand Down Expand Up @@ -937,6 +940,11 @@ public UserSession(Int64 ownerID, EUserSessionType sessionType, KnownClients.EKn
ACExeCRC = Helpers.g_dictInitialExeCRCs[ownerID].ToUpper();
Helpers.g_dictInitialExeCRCs.Remove(ownerID, out string removedCRC);
}

if (Helpers.g_dictPlayerPlatforms.TryRemove(ownerID, out string cachedPlatform))
{
Platform = cachedPlatform;
}
}

public void MarkAbandoned()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ public async Task<APIResult> Post_InternalHandler(string jsonData, string ipAddr
string exe_crc = data.ContainsKey("exe_crc") ? data["exe_crc"].ToString() : "NONE";
Helpers.RegisterInitialPlayerExeCRC(user_id, exe_crc);

string platform = data.ContainsKey("platform") ? data["platform"].ToString() : "";
Helpers.RegisterPlayerPlatform(user_id, platform);

var sessiontoken = Program.g_tokenGenerator.GenerateToken(strDisplayName, user_id, ipAddr, Program.JwtTokenGenerator.ETokenType.Session, knownClientID, sessionType, bIsAdmin);
var refreshtoken = Program.g_tokenGenerator.GenerateToken(strDisplayName, user_id, ipAddr, Program.JwtTokenGenerator.ETokenType.Refresh, knownClientID, sessionType, false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,9 @@ public async Task<APIResult> Post_InternalHandler(string jsonData, string ipAddr
string exe_crc = data.ContainsKey("exe_crc") ? data["exe_crc"].ToString() : "NONE";
Helpers.RegisterInitialPlayerExeCRC(user_id, exe_crc);

string platform = data.ContainsKey("platform") ? data["platform"].ToString() : "";
Helpers.RegisterPlayerPlatform(user_id, platform);

string strDisplayName = await Database.Users.GetDisplayName(db, user_id);
await SessionHelpers.SetUsedLoggedIn(user_id, clientID, sessionType);

Expand Down
6 changes: 6 additions & 0 deletions GenOnlineService/Discord.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ public static void RegisterInitialPlayerExeCRC(Int64 user_id, string exe_crc)
g_dictInitialExeCRCs[user_id] = exe_crc;
}

public static ConcurrentDictionary<Int64, string> g_dictPlayerPlatforms = new();
public static void RegisterPlayerPlatform(Int64 user_id, string platform)
{
g_dictPlayerPlatforms[user_id] = platform;
}

public static string ComputeMD5Hash(string input)
{
using (MD5 md5 = MD5.Create())
Expand Down
2 changes: 2 additions & 0 deletions GenOnlineService/LobbyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1105,6 +1105,7 @@ public void UpdateSlotIndex(UInt16 index)
public EPlayerType SlotState { get; private set; } = 0;
public UInt16 SlotIndex { get; private set; } = 0;
public string Region { get; private set; } = "Unknown";
public string Platform { get; private set; } = "";
public string MiddlewareUserID { get; private set; } = String.Empty;

[JsonIgnore] // cant serialize refs
Expand Down Expand Up @@ -1146,6 +1147,7 @@ public LobbyMember(Lobby owningLobby, UserSession? owningSession, Int64 UserID_i

IsReady = false;
Region = owningSession == null ? "Unknown" : owningSession.GetFullContinentName();
Platform = owningSession == null ? "" : owningSession.Platform;
}

public bool IsHuman() { return SlotState == EPlayerType.SLOT_PLAYER; }
Expand Down
Loading