author | truelight |
Thu, 24 Mar 2005 14:43:40 +0000 | |
changeset 1540 | 6eef12dab5bf |
parent 1317 | 3c90086ff34f |
child 1721 | e2887b445ac0 |
permissions | -rw-r--r-- |
0 | 1 |
#if !defined(_STDAFX_H) |
2 |
#define _STDAFX_H |
|
3 |
||
4 |
#if defined(_MSC_VER) |
|
5 |
#pragma once |
|
6 |
||
7 |
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers |
|
8 |
#pragma warning(disable: 4100) // parameter not used |
|
9 |
#pragma warning(disable: 4244) // conversion |
|
10 |
#pragma warning(disable: 4245) // conversion |
|
11 |
#pragma warning(disable: 4201) // nameless union |
|
12 |
#pragma warning(disable: 4514) // removed unref inline |
|
13 |
#pragma warning(disable: 4127) // constant conditional expression |
|
14 |
#pragma warning(disable: 4276) // MSVC BUG??? Complains about function body not declared when using function pointers |
|
15 |
#pragma warning(disable: 4761) // warning C4761: integral size mismatch in argument; conversion supplied |
|
16 |
#endif |
|
17 |
||
18 |
#include <stdio.h> |
|
19 |
#include <assert.h> |
|
20 |
#include <string.h> |
|
21 |
#include <stdlib.h> |
|
22 |
||
858
9a3254670831
(svn r1339) -Fix: compilation with networking works on MinGW32 again (thx orudge).
darkvater
parents:
796
diff
changeset
|
23 |
#if defined(UNIX) || defined(__MINGW32__) |
0 | 24 |
# include <sys/types.h> |
25 |
#endif |
|
26 |
||
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
27 |
#if defined(__OS2__) |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
28 |
# include <types.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
29 |
#endif |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
30 |
|
0 | 31 |
#ifdef __BEOS__ |
32 |
#include <SupportDefs.h> |
|
33 |
#endif |
|
34 |
||
446
7a92ca9738e2
(svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents:
425
diff
changeset
|
35 |
#ifdef SUNOS |
7a92ca9738e2
(svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents:
425
diff
changeset
|
36 |
#include <alloca.h> |
7a92ca9738e2
(svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents:
425
diff
changeset
|
37 |
#endif |
7a92ca9738e2
(svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents:
425
diff
changeset
|
38 |
|
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
39 |
#ifdef __MORPHOS__ |
915 | 40 |
// morphos defines certain amiga defines per default, we undefine them |
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
41 |
// here to make the rest of source less messy and more clear what is |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
42 |
// required for morphos and what for amigaos |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
43 |
# ifdef amigaos |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
44 |
# undef amigaos |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
45 |
# endif |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
46 |
# ifdef __amigaos__ |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
47 |
# undef __amigaos__ |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
48 |
# endif |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
49 |
# ifdef __AMIGA__ |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
50 |
# undef __AMIGA__ |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
51 |
# endif |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
52 |
# ifdef AMIGA |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
53 |
# undef AMIGA |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
54 |
# endif |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
55 |
# ifdef amiga |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
56 |
# undef amiga |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
57 |
# endif |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
58 |
#endif /* __MORPHOS__ */ |
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
59 |
|
0 | 60 |
#define BSWAP32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) << 8) & 0xFF0000) | (((x) << 24) & 0xFF000000)) |
61 |
#define BSWAP16(x) ((x) >> 8 | (x) << 8) |
|
62 |
||
63 |
// by default we use [] var arrays |
|
64 |
#define VARARRAY_SIZE |
|
65 |
||
66 |
||
67 |
// Stuff for GCC |
|
68 |
#if defined(__GNUC__) |
|
69 |
# define NORETURN |
|
70 |
# define FORCEINLINE inline |
|
71 |
# define CDECL |
|
72 |
//#include <alloca.h> |
|
73 |
//#include <malloc.h> |
|
74 |
# define __int64 long long |
|
75 |
# define NOT_REACHED() |
|
76 |
# define GCC_PACK __attribute__((packed)) |
|
77 |
||
78 |
# if (__GNUC__ == 2) |
|
79 |
# undef VARARRAY_SIZE |
|
80 |
# define VARARRAY_SIZE 0 |
|
81 |
# endif |
|
82 |
#endif |
|
83 |
||
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
84 |
#if defined(__WATCOMC__) |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
85 |
# define NORETURN |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
86 |
# define FORCEINLINE inline |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
87 |
# define CDECL |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
88 |
# define NOT_REACHED() |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
89 |
# define GCC_PACK |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
90 |
# undef TTD_ALIGNMENT_4 |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
91 |
# undef TTD_ALIGNMENT_2 |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
92 |
|
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
93 |
# include <malloc.h> |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
94 |
#endif |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
95 |
|
796 | 96 |
#if defined(__MINGW32__) || defined(__CYGWIN__) |
97 |
#include <malloc.h> // alloca() |
|
98 |
#endif |
|
99 |
||
0 | 100 |
// Stuff for MSVC |
101 |
#if defined(_MSC_VER) |
|
102 |
# include <malloc.h> // alloca() |
|
103 |
# define NORETURN __declspec(noreturn) |
|
104 |
# define FORCEINLINE __forceinline |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
446
diff
changeset
|
105 |
# define inline _inline |
0 | 106 |
# define CDECL _cdecl |
107 |
# define NOT_REACHED() _assume(0) |
|
1022
d5ec3467d2a4
(svn r1523) -Fix: somehow mousewheel was disabled on windows using SDL; reenabled again
darkvater
parents:
915
diff
changeset
|
108 |
int CDECL snprintf(char *str, size_t size, const char *format, ...); |
d5ec3467d2a4
(svn r1523) -Fix: somehow mousewheel was disabled on windows using SDL; reenabled again
darkvater
parents:
915
diff
changeset
|
109 |
int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap); |
0 | 110 |
# undef TTD_ALIGNMENT_4 |
111 |
# undef TTD_ALIGNMENT_2 |
|
112 |
# define GCC_PACK |
|
113 |
#endif |
|
114 |
||
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
0
diff
changeset
|
115 |
// Windows has always LITTLE_ENDIAN |
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
116 |
#if defined(WIN32) || defined(__OS2__) |
157
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
0
diff
changeset
|
117 |
#define TTD_LITTLE_ENDIAN |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
0
diff
changeset
|
118 |
#else |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
0
diff
changeset
|
119 |
// Else include endian.h, which has the endian-type, autodetected by the Makefile |
dd017fa3bad8
(svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents:
0
diff
changeset
|
120 |
#include "endian.h" |
0 | 121 |
#endif |
122 |
||
123 |
#if defined(UNIX) |
|
124 |
#define PATHSEP "/" |
|
125 |
#else |
|
126 |
#define PATHSEP "\\" |
|
127 |
#endif |
|
128 |
||
129 |
||
130 |
typedef unsigned char byte; |
|
131 |
#ifndef __BEOS__ // already defined |
|
132 |
typedef unsigned char uint8; |
|
133 |
typedef unsigned short uint16; |
|
134 |
typedef unsigned int uint32; |
|
135 |
#endif |
|
136 |
||
137 |
// This is already defined in unix |
|
138 |
#if !defined(UNIX) && !defined(__CYGWIN__) |
|
139 |
typedef unsigned int uint; |
|
140 |
#endif |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
141 |
// Not defined in QNX Neutrino (6.x) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
142 |
#if defined(__QNXNTO__) |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
143 |
typedef unsigned int uint; |
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
144 |
#endif |
0 | 145 |
|
146 |
#ifndef __BEOS__ |
|
147 |
typedef signed char int8; |
|
148 |
typedef signed short int16; |
|
149 |
typedef signed int int32; |
|
150 |
#ifndef __cplusplus |
|
151 |
typedef unsigned char bool; |
|
152 |
#endif |
|
153 |
typedef signed __int64 int64; |
|
154 |
typedef unsigned __int64 uint64; |
|
155 |
#endif |
|
156 |
||
157 |
// Setup alignment and conversion macros |
|
158 |
#if defined(TTD_BIG_ENDIAN) |
|
275
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
159 |
|
0 | 160 |
# define TTD_ALIGNMENT_2 |
161 |
# define TTD_ALIGNMENT_4 |
|
275
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
162 |
|
500
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
446
diff
changeset
|
163 |
static inline uint32 TO_LE32(uint32 x) { return BSWAP32(x); } |
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
446
diff
changeset
|
164 |
static inline uint16 TO_LE16(uint16 x) { return BSWAP16(x); } |
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
446
diff
changeset
|
165 |
static inline uint32 FROM_LE32(uint32 x) { return BSWAP32(x); } |
8e52f7797b48
(svn r793) Merge INLINE -> inline replacement (revision 376)
tron
parents:
446
diff
changeset
|
166 |
static inline uint16 FROM_LE16(uint16 x) { return BSWAP16(x); } |
275
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
167 |
#define TO_BE32(x) x |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
168 |
#define TO_BE16(x) x |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
169 |
#define FROM_BE32(x) x |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
170 |
#define FROM_BE16(x) x |
193
0a7025304867
(svn r194) -Codechange: stripping trailing-spaces. Please keep this that way!
truelight
parents:
157
diff
changeset
|
171 |
#define TO_BE32X(x) x |
275
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
172 |
|
0 | 173 |
#else |
275
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
174 |
|
536 | 175 |
static inline uint32 TO_BE32(uint32 x) { return BSWAP32(x); } |
176 |
static inline uint16 TO_BE16(uint16 x) { return BSWAP16(x); } |
|
177 |
static inline uint32 FROM_BE32(uint32 x) { return BSWAP32(x); } |
|
178 |
static inline uint16 FROM_BE16(uint16 x) { return BSWAP16(x); } |
|
275
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
179 |
#define TO_LE32(x) x |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
180 |
#define TO_LE16(x) x |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
181 |
#define TO_BE32X(x) BSWAP32(x) |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
182 |
#define FROM_LE32(x) x |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
183 |
#define FROM_LE16(x) x |
9f810ad00b60
(svn r281) -Fix: some endian issues fixed in network code
signde
parents:
193
diff
changeset
|
184 |
|
0 | 185 |
#endif |
186 |
||
187 |
#if !defined(GAME_DATA_DIR) |
|
188 |
#define GAME_DATA_DIR "" |
|
189 |
#endif |
|
190 |
||
191 |
#if !defined(PERSONAL_DIR) |
|
192 |
#define PERSONAL_DIR "" |
|
193 |
#endif |
|
194 |
||
195 |
#ifndef __cplusplus |
|
196 |
#ifndef __BEOS__ |
|
197 |
enum { |
|
198 |
false = 0, |
|
199 |
true = 1, |
|
200 |
}; |
|
201 |
#endif |
|
202 |
#endif |
|
203 |
||
204 |
// Compile time assertions |
|
781
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
205 |
#ifdef __OS2__ |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
206 |
# define assert_compile(expr) |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
207 |
#else |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
208 |
# define assert_compile(expr) void __ct_assert__(int a[1 - 2 * !(expr)]) |
4c9177888196
(svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents:
770
diff
changeset
|
209 |
#endif |
0 | 210 |
|
211 |
assert_compile(sizeof(uint32) == 4); |
|
212 |
assert_compile(sizeof(uint16) == 2); |
|
213 |
assert_compile(sizeof(uint8) == 1); |
|
214 |
||
215 |
#define lengthof(x) (sizeof(x)/sizeof(x[0])) |
|
216 |
#define endof(x) (&x[lengthof(x)]) |
|
1317
3c90086ff34f
(svn r1821) Move generic string handling functions to string.[ch] and introduce stre{cpy,cat}, see string.h for their semantics
tron
parents:
1022
diff
changeset
|
217 |
#define lastof(x) (&x[lengthof(x) - 1]) |
0 | 218 |
#ifndef offsetof |
219 |
#define offsetof(s,m) (size_t)&(((s *)0)->m) |
|
220 |
#endif |
|
221 |
||
222 |
||
223 |
// take care of some name clashes on macos |
|
224 |
#if defined(__APPLE__) |
|
225 |
#define GetString OTTD_GetString |
|
226 |
#define DrawString OTTD_DrawString |
|
227 |
#define Random OTTD_Random |
|
543
946badd71033
(svn r942) -Merged branch/network back into the trunk
truelight
parents:
536
diff
changeset
|
228 |
#define CloseConnection OTTD_CloseConnection |
0 | 229 |
#endif |
230 |
||
770
c2eacca29601
(svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents:
569
diff
changeset
|
231 |
#ifdef __AMIGA__ |
569
1e1755ba1572
(svn r980) Fixed issues where MorphOS would get problems if AmigaOS would get a port, since MorphOS also have the flag __AMIGA__ defined (Tokai)
bjarni
parents:
543
diff
changeset
|
232 |
// it seems AmigaOS already have a Point declared |
1e1755ba1572
(svn r980) Fixed issues where MorphOS would get problems if AmigaOS would get a port, since MorphOS also have the flag __AMIGA__ defined (Tokai)
bjarni
parents:
543
diff
changeset
|
233 |
#define Point OTTD_AMIGA_POINT |
1e1755ba1572
(svn r980) Fixed issues where MorphOS would get problems if AmigaOS would get a port, since MorphOS also have the flag __AMIGA__ defined (Tokai)
bjarni
parents:
543
diff
changeset
|
234 |
#endif |
1e1755ba1572
(svn r980) Fixed issues where MorphOS would get problems if AmigaOS would get a port, since MorphOS also have the flag __AMIGA__ defined (Tokai)
bjarni
parents:
543
diff
changeset
|
235 |
|
0 | 236 |
#endif // !defined(_STDAFX_H) |