-
Notifications
You must be signed in to change notification settings - Fork 629
/
steamtypes.h
182 lines (143 loc) · 4.04 KB
/
steamtypes.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
//========= Copyright 1996-2022, Valve LLC, All rights reserved. ============
#ifndef STEAMTYPES_H
#define STEAMTYPES_H
#define S_CALLTYPE __cdecl
// WARNING: __cdecl is potentially #defined away in steam_api_common.h
// Steam-specific types. Defined here so this header file can be included in other code bases.
#ifndef WCHARTYPES_H
typedef unsigned char uint8;
#endif
#ifdef __GNUC__
#if __GNUC__ < 4
#error "Steamworks requires GCC 4.X (4.2 or 4.4 have been tested)"
#endif
#endif
#if defined(__LP64__) || defined(__x86_64__) || defined(_WIN64) || defined(__aarch64__) || defined(__s390x__)
#define X64BITS
#endif
#if !defined(VALVE_BIG_ENDIAN)
#if defined(_PS3)
// Make sure VALVE_BIG_ENDIAN gets set on PS3, may already be set previously in Valve internal code.
#define VALVE_BIG_ENDIAN 1
#endif
#if defined( __GNUC__ ) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
#define VALVE_BIG_ENDIAN 1
#endif
#endif
typedef unsigned char uint8;
typedef signed char int8;
#if defined( _WIN32 ) && !defined( __GNUC__ )
typedef __int16 int16;
typedef unsigned __int16 uint16;
typedef __int32 int32;
typedef unsigned __int32 uint32;
typedef __int64 int64;
typedef unsigned __int64 uint64;
typedef int64 lint64;
typedef uint64 ulint64;
#ifdef X64BITS
typedef __int64 intp; // intp is an integer that can accomodate a pointer
typedef unsigned __int64 uintp; // (ie, sizeof(intp) >= sizeof(int) && sizeof(intp) >= sizeof(void *)
#else
typedef __int32 intp;
typedef unsigned __int32 uintp;
#endif
#else // _WIN32
typedef short int16;
typedef unsigned short uint16;
typedef int int32;
typedef unsigned int uint32;
typedef long long int64;
typedef unsigned long long uint64;
// [u]int64 are actually defined as 'long long' and gcc 64-bit
// doesn't automatically consider them the same as 'long int'.
// Changing the types for [u]int64 is complicated by
// there being many definitions, so we just
// define a 'long int' here and use it in places that would
// otherwise confuse the compiler.
typedef long int lint64;
typedef unsigned long int ulint64;
#ifdef X64BITS
typedef long long intp;
typedef unsigned long long uintp;
#else
typedef int intp;
typedef unsigned int uintp;
#endif
#endif // else _WIN32
typedef uint32 AppId_t;
const AppId_t k_uAppIdInvalid = 0x0;
// AppIds and DepotIDs also presently share the same namespace
typedef uint32 DepotId_t;
const DepotId_t k_uDepotIdInvalid = 0x0;
// RTime32. Seconds elapsed since Jan 1 1970, i.e. unix timestamp.
// It's the same as time_t, but it is always 32-bit and unsigned.
typedef uint32 RTime32;
// handle to a Steam API call
typedef uint64 SteamAPICall_t;
const SteamAPICall_t k_uAPICallInvalid = 0x0;
typedef uint32 AccountID_t;
const AccountID_t k_uAccountIdInvalid = 0;
// Party Beacon ID
typedef uint64 PartyBeaconID_t;
const PartyBeaconID_t k_ulPartyBeaconIdInvalid = 0;
enum ESteamIPType
{
k_ESteamIPTypeIPv4 = 0,
k_ESteamIPTypeIPv6 = 1,
};
#pragma pack( push, 1 )
struct SteamIPAddress_t
{
union {
uint32 m_unIPv4; // Host order
uint8 m_rgubIPv6[16]; // Network order! Same as inaddr_in6. (0011:2233:4455:6677:8899:aabb:ccdd:eeff)
// Internal use only
uint64 m_ipv6Qword[2]; // big endian
};
ESteamIPType m_eType;
bool IsSet() const
{
if ( k_ESteamIPTypeIPv4 == m_eType )
{
return m_unIPv4 != 0;
}
else
{
return m_ipv6Qword[0] !=0 || m_ipv6Qword[1] != 0;
}
}
static SteamIPAddress_t IPv4Any()
{
SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv4;
ipOut.m_unIPv4 = 0;
return ipOut;
}
static SteamIPAddress_t IPv6Any()
{
SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv6;
ipOut.m_ipv6Qword[0] = 0;
ipOut.m_ipv6Qword[1] = 0;
return ipOut;
}
static SteamIPAddress_t IPv4Loopback()
{
SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv4;
ipOut.m_unIPv4 = 0x7f000001;
return ipOut;
}
static SteamIPAddress_t IPv6Loopback()
{
SteamIPAddress_t ipOut;
ipOut.m_eType = k_ESteamIPTypeIPv6;
ipOut.m_ipv6Qword[0] = 0;
ipOut.m_ipv6Qword[1] = 0;
ipOut.m_rgubIPv6[15] = 1;
return ipOut;
}
};
#pragma pack( pop )
#endif // STEAMTYPES_H