1
0

UserDataExt.cs 805 B

123456789101112131415161718192021222324
  1. using Content.Shared.Database;
  2. using Robust.Shared.Network;
  3. namespace Content.Server.Connection;
  4. /// <summary>
  5. /// Helper functions for working with <see cref="NetUserData"/>.
  6. /// </summary>
  7. public static class UserDataExt
  8. {
  9. /// <summary>
  10. /// Get the preferred HWID that should be used for new records related to a player.
  11. /// </summary>
  12. /// <remarks>
  13. /// Players can have zero or more HWIDs, but for logging things like connection logs we generally
  14. /// only want a single one. This method returns a nullable method.
  15. /// </remarks>
  16. public static ImmutableTypedHwid? GetModernHwid(this NetUserData userData)
  17. {
  18. return userData.ModernHWIds.Length == 0
  19. ? null
  20. : new ImmutableTypedHwid(userData.ModernHWIds[0], HwidType.Modern);
  21. }
  22. }