1 /// Transcription of steamtypes.h to D.
2 ///
3 /// Translated by hand, based on v1.3.0 6be41e3
4 ///
5 /// Copyright: Valve Corporation, all rights reserved
6 module steam_gns.stypes;
7 
8 extern (C++):
9 align(4):
10 
11 // probably unnecessary, i confused this with steamnetworkingtypes.h
12 
13 alias intp = ptrdiff_t;
14 alias uintp = size_t;
15 
16 alias AppId_t = uint;
17 enum AppId_t k_uAppIdInvalid = 0x0;
18 
19 // AppIds and DepotIDs also presently share the same namespace
20 alias DepotId_t = uint;
21 enum DepotId_t k_uDepotIdInvalid = 0x0;
22 
23 // RTime32.  Seconds elapsed since Jan 1 1970, i.e. unix timestamp.
24 // It's the same as time_t, but it is always 32-bit and unsigned.
25 alias RTime32 = uint;
26 
27 // handle to a Steam API call
28 alias SteamAPICall_t = ulong;
29 enum SteamAPICall_t k_uAPICallInvalid = 0x0;
30 
31 alias AccountID_t = uint;
32 
33 // Party Beacon ID
34 alias PartyBeaconID_t = ulong;
35 enum PartyBeaconID_t k_ulPartyBeaconIdInvalid = 0;
36 
37 enum ESteamIPType {
38     k_ESteamIPTypeIPv4 = 0,
39     k_ESteamIPTypeIPv6 = 1,
40 }
41 
42 struct SteamIPAddress_t {
43 
44     align(1):
45 
46     union {
47 
48         uint          m_unIPv4;       // Host order
49         ubyte[16]     m_rgubIPv6;     // Network order! Same as inaddr_in6.  (0011:2233:4455:6677:8899:aabb:ccdd:eeff)
50 
51         // Internal use only
52         ulong[2]         m_ipv6Qword; // big endian
53     };
54 
55     ESteamIPType m_eType;
56 
57     bool IsSet() const {
58         if (ESteamIPType.k_ESteamIPTypeIPv4 == m_eType) {
59             return m_unIPv4 != 0;
60         }
61         else {
62             return m_ipv6Qword[0] != 0 || m_ipv6Qword[1] != 0;
63         }
64     }
65 
66     static SteamIPAddress_t IPv4Any() {
67         SteamIPAddress_t ipOut;
68         ipOut.m_eType = ESteamIPType.k_ESteamIPTypeIPv4;
69         ipOut.m_unIPv4 = 0;
70 
71         return ipOut;
72     }
73 
74     static SteamIPAddress_t IPv6Any() {
75         SteamIPAddress_t ipOut;
76         ipOut.m_eType = ESteamIPType.k_ESteamIPTypeIPv6;
77         ipOut.m_ipv6Qword[0] = 0;
78         ipOut.m_ipv6Qword[1] = 0;
79 
80         return ipOut;
81     }
82 
83     static SteamIPAddress_t IPv4Loopback() {
84         SteamIPAddress_t ipOut;
85         ipOut.m_eType = ESteamIPType.k_ESteamIPTypeIPv4;
86         ipOut.m_unIPv4 = 0x7f000001;
87 
88         return ipOut;
89     }
90 
91     static SteamIPAddress_t IPv6Loopback() {
92         SteamIPAddress_t ipOut;
93         ipOut.m_eType = ESteamIPType.k_ESteamIPTypeIPv6;
94         ipOut.m_ipv6Qword[0] = 0;
95         ipOut.m_ipv6Qword[1] = 0;
96         ipOut.m_rgubIPv6[15] = 1;
97 
98         return ipOut;
99     }
100 }