我的SteamID格式为STEAM_0:1:21643603
。
如何将其翻译为:
43287207
; 76561198003552935
; 答案 0 :(得分:1)
// STEAM_X:Y:Z
func convertToSteam32ID(steamString: String) -> UInt64 {
let array = steamString.componentsSeparatedByString(":")
let Y = UInt64(array[1])!
let Z = UInt64(array[2])!
return (Z << 1) | Y
}
func convertToSteam64ID(accountID accountID: UInt64) -> UInt64 {
let Universe: UInt64 = 1
let AccountType: UInt64 = 1
let Instance: UInt64 = 1
return ((Universe << 56) | (AccountType << 52) | (Instance << 32) | accountID)
}
let steam32ID = convertToSteam32ID("STEAM_0:1:21643603")
let steam64ID = convertToSteam64ID(accountID: steam32ID)