stdafx.h
author glx
Mon, 24 Sep 2007 03:08:47 +0000
branch0.5
changeset 5545 f42dc59a45f5
parent 5472 16f71955fc3b
permissions -rw-r--r--
(svn r11153) [0.5] -Fix [FS#1251]: incorrect usage of {G} tag in slovak translation
2186
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2125
diff changeset
     1
/* $Id$ */
461a2aff3486 (svn r2701) Insert Id tags into all source files
tron
parents: 2125
diff changeset
     2
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2225
diff changeset
     3
#ifndef STDAFX_H
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2225
diff changeset
     4
#define STDAFX_H
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     5
3624
bfd51a1e20bd (svn r4522) -Fix: include stdio before stddef; some targets don't like the other way around.
truelight
parents: 3584
diff changeset
     6
#include <stdio.h>
3584
005b6170f15c (svn r4470) -Fix: FS#97 ? Possible bug in Win64 versions (by michi_cc)
KUDr
parents: 3582
diff changeset
     7
#include <stddef.h>
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     8
#include <string.h>
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
     9
#include <stdlib.h>
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    10
2223
29d61b962cb0 (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2186
diff changeset
    11
// MacOS X will use an NSAlert to display failed assertaions since they're lost unless running from a terminal
2225
e60b20805e4d (svn r2745) -Fix: [OSX] removed the assert window introduced in 2741 from strgen
bjarni
parents: 2223
diff changeset
    12
// strgen always runs from terminal and don't need a window for asserts
2731
97a409a62741 (svn r3276) reverted the last two commits. OSX 10.2 kept finding new stuff to prevent it from running OpenTTD, so now it's not supported anymore
bjarni
parents: 2730
diff changeset
    13
#if !defined(__APPLE__) || defined(STRGEN)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    14
# include <assert.h>
2223
29d61b962cb0 (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2186
diff changeset
    15
#else
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    16
# include "os/macosx/macos.h"
2223
29d61b962cb0 (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2186
diff changeset
    17
#endif
29d61b962cb0 (svn r2741) -Feature: [OSX] added a window to display asserts on OSX (Tobin)
bjarni
parents: 2186
diff changeset
    18
858
329ff519fb45 (svn r1339) -Fix: compilation with networking works on MinGW32 again (thx orudge).
darkvater
parents: 796
diff changeset
    19
#if defined(UNIX) || defined(__MINGW32__)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    20
# include <sys/types.h>
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    21
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    22
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    23
#if defined(__OS2__)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    24
# include <types.h>
4216
c403fc7b6e10 (svn r5760) - Codechange: Use a define for case-string comparison in OS/2 instead of function.
Darkvater
parents: 4000
diff changeset
    25
# define strcasecmp stricmp
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    26
#endif
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    27
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    28
#ifdef __BEOS__
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    29
# include <SupportDefs.h>
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    30
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    31
446
20304ea8e94e (svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents: 425
diff changeset
    32
#ifdef SUNOS
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    33
# include <alloca.h>
446
20304ea8e94e (svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents: 425
diff changeset
    34
#endif
20304ea8e94e (svn r655) Add the necessary bits to make building on SunOS/Solaris work
tron
parents: 425
diff changeset
    35
770
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
    36
#ifdef __MORPHOS__
915
013cb2d74800 (svn r1402) Trim trailing whitespace
tron
parents: 858
diff changeset
    37
// morphos defines certain amiga defines per default, we undefine them
770
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
    38
// here to make the rest of source less messy and more clear what is
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
    39
// required for morphos and what for amigaos
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    40
# ifdef amigaos
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    41
#  undef amigaos
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    42
# endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    43
# ifdef __amigaos__
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    44
#  undef __amigaos__
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    45
# endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    46
# ifdef __AMIGA__
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    47
#  undef __AMIGA__
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    48
# endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    49
# ifdef AMIGA
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    50
#  undef AMIGA
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    51
# endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    52
# ifdef amiga
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    53
#  undef amiga
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    54
# endif
770
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
    55
#endif /* __MORPHOS__ */
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
    56
3016
c63fb93fa1a0 (svn r3596) -Codechange: [OSX] changed to use Apple's macros instead of OTTD macros for endian conversion
bjarni
parents: 2984
diff changeset
    57
#ifdef __APPLE__
3289
8c0707257253 (svn r4003) - Minor codebeautifier@work
Darkvater
parents: 3016
diff changeset
    58
# include "os/macosx/osx_stdafx.h"
3016
c63fb93fa1a0 (svn r3596) -Codechange: [OSX] changed to use Apple's macros instead of OTTD macros for endian conversion
bjarni
parents: 2984
diff changeset
    59
// make endian swapping use Apple's macros to increase speed
3289
8c0707257253 (svn r4003) - Minor codebeautifier@work
Darkvater
parents: 3016
diff changeset
    60
# define BSWAP32(x) Endian32_Swap(x)
8c0707257253 (svn r4003) - Minor codebeautifier@work
Darkvater
parents: 3016
diff changeset
    61
# define BSWAP16(x) Endian16_Swap(x)
3016
c63fb93fa1a0 (svn r3596) -Codechange: [OSX] changed to use Apple's macros instead of OTTD macros for endian conversion
bjarni
parents: 2984
diff changeset
    62
#else
3289
8c0707257253 (svn r4003) - Minor codebeautifier@work
Darkvater
parents: 3016
diff changeset
    63
# define BSWAP32(x) ((((x) >> 24) & 0xFF) | (((x) >> 8) & 0xFF00) | (((x) << 8) & 0xFF0000) | (((x) << 24) & 0xFF000000))
8c0707257253 (svn r4003) - Minor codebeautifier@work
Darkvater
parents: 3016
diff changeset
    64
# define BSWAP16(x) ((x) >> 8 | (x) << 8)
8c0707257253 (svn r4003) - Minor codebeautifier@work
Darkvater
parents: 3016
diff changeset
    65
#endif /* __APPLE__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    66
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    67
// by default we use [] var arrays
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    68
#define VARARRAY_SIZE
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    69
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    70
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    71
// Stuff for GCC
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    72
#if defined(__GNUC__)
4000
bab1ebc37da0 (svn r5210) Many small changes which piled up: const, unsigned, variable scope, CSE for readability, DeMorgan, if cascades -> switch, whitespace, parentheses, bracing, misc.
tron
parents: 3900
diff changeset
    73
# define NORETURN __attribute__ ((noreturn))
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    74
# define FORCEINLINE inline
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    75
# define CDECL
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    76
# define __int64 long long
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1812
diff changeset
    77
# define NOT_REACHED() assert(0)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    78
# define GCC_PACK __attribute__((packed))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    79
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    80
# if (__GNUC__ == 2)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    81
#  undef VARARRAY_SIZE
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    82
#  define VARARRAY_SIZE 0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    83
# endif
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    84
#endif /* __GNUC__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    85
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    86
#if defined(__WATCOMC__)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    87
# define NORETURN
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    88
# define FORCEINLINE inline
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    89
# define CDECL
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    90
# define NOT_REACHED() assert(0)
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    91
# define GCC_PACK
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    92
# include <malloc.h>
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    93
#endif /* __WATCOMC__ */
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
    94
796
42a3669a939f (svn r1266) -Fix: fix some cygwin/mingw warnings
darkvater
parents: 781
diff changeset
    95
#if defined(__MINGW32__) || defined(__CYGWIN__)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
    96
# include <malloc.h> // alloca()
796
42a3669a939f (svn r1266) -Fix: fix some cygwin/mingw warnings
darkvater
parents: 781
diff changeset
    97
#endif
42a3669a939f (svn r1266) -Fix: fix some cygwin/mingw warnings
darkvater
parents: 781
diff changeset
    98
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
    99
// Stuff for MSVC
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   100
#if defined(_MSC_VER)
2695
395110265c87 (svn r3237) - CodeChange: remove silencing of some warnings. MSVC6 once again has some issues with enums, and other things as usual, so silence those still.
Darkvater
parents: 2694
diff changeset
   101
# pragma once
5465
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   102
/* Define a win32 target platform, to override defaults of the SDK
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   103
 * We need to define NTDDI version for Vista SDK, but win2k is minimum */
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   104
# define NTDDI_VERSION NTDDI_WIN2K // Windows 2000
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   105
# define _WIN32_WINNT 0x0500       // Windows 2000
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   106
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   107
# define _WIN32_WINDOWS 0x400      // Windows 95
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   108
# define WINVER 0x0400             // Windows NT 4.0 / Windows 95
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   109
# define _WIN32_IE_ 0x0401         // 4.01 (win98 and NT4SP5+)
30426b385cde (svn r9348) [0.5] -Backport from trunk (r8974, r8994, r9074):
rubidium
parents: 5412
diff changeset
   110
2695
395110265c87 (svn r3237) - CodeChange: remove silencing of some warnings. MSVC6 once again has some issues with enums, and other things as usual, so silence those still.
Darkvater
parents: 2694
diff changeset
   111
# define WIN32_LEAN_AND_MEAN     // Exclude rarely-used stuff from Windows headers
395110265c87 (svn r3237) - CodeChange: remove silencing of some warnings. MSVC6 once again has some issues with enums, and other things as usual, so silence those still.
Darkvater
parents: 2694
diff changeset
   112
# pragma warning(disable: 4244)  // 'conversion' conversion from 'type1' to 'type2', possible loss of data
395110265c87 (svn r3237) - CodeChange: remove silencing of some warnings. MSVC6 once again has some issues with enums, and other things as usual, so silence those still.
Darkvater
parents: 2694
diff changeset
   113
# pragma warning(disable: 4761)  // integral size mismatch in argument : conversion supplied
5120
e12dfc67761f (svn r7200) -Codechange: remove unneeded redraw (console.c), coding style, use FindWindowById
Darkvater
parents: 5082
diff changeset
   114
2976
a89ead6e2247 (svn r3551) Add directives to allow Visual Studio 2005 compilation.
peter1138
parents: 2974
diff changeset
   115
# if _MSC_VER >= 1400              // MSVC 2005 safety checks
a89ead6e2247 (svn r3551) Add directives to allow Visual Studio 2005 compilation.
peter1138
parents: 2974
diff changeset
   116
#  pragma warning(disable: 4996)   // 'strdup' was declared deprecated
a89ead6e2247 (svn r3551) Add directives to allow Visual Studio 2005 compilation.
peter1138
parents: 2974
diff changeset
   117
#  define _CRT_SECURE_NO_DEPRECATE // all deprecated 'unsafe string functions
a89ead6e2247 (svn r3551) Add directives to allow Visual Studio 2005 compilation.
peter1138
parents: 2974
diff changeset
   118
# endif /* _MSC_VER >= 1400 */
2695
395110265c87 (svn r3237) - CodeChange: remove silencing of some warnings. MSVC6 once again has some issues with enums, and other things as usual, so silence those still.
Darkvater
parents: 2694
diff changeset
   119
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   120
# include <malloc.h> // alloca()
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   121
# define NORETURN __declspec(noreturn)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   122
# define FORCEINLINE __forceinline
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   123
# define inline _inline
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   124
# define CDECL _cdecl
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1812
diff changeset
   125
# if defined(_DEBUG)
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1812
diff changeset
   126
#  define NOT_REACHED() assert(0)
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1812
diff changeset
   127
# else
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1812
diff changeset
   128
#  define NOT_REACHED() _assume(0)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   129
# endif /* _DEBUG */
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   130
  int CDECL snprintf(char *str, size_t size, const char *format, ...);
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   131
# if _MSC_VER < 1400
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   132
   int CDECL vsnprintf(char *str, size_t size, const char *format, va_list ap);
1881
023a134a4b12 (svn r2387) - CodeChange: made the saveload code more readable and also removed the 'byte' saveload arrays which means you can save an array of more than 255 elements, or bigger structs than 255 bytes. This doesn't yet solve the problem that a chunk can be a maximum of 16384 big.
Darkvater
parents: 1812
diff changeset
   133
# endif
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   134
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   135
# if defined(WIN32) && !defined(_WIN64) && !defined(WIN64)
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   136
#  ifndef _W64
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   137
#   define _W64
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   138
#  endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   139
   typedef _W64 int INT_PTR, *PINT_PTR;
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   140
   typedef _W64 unsigned int UINT_PTR, *PUINT_PTR;
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   141
# endif /* WIN32 && !_WIN64 && !WIN64 */
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   142
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   143
# if _MSC_VER < 1300 // VC6 and lower
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   144
#  ifdef  _WIN64
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   145
    typedef __int64 intptr_t;
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   146
#  else
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   147
    typedef _W64 int intptr_t;
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   148
#  endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   149
# endif /* _MSC_VER < 1300 */
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   150
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   151
# define GCC_PACK
2694
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   152
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   153
// This is needed to zlib uses the stdcall calling convention on visual studio, also used with libpng (VS6 warning)
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   154
# if defined(WITH_ZLIB) || defined(WITH_PNG)
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   155
#  ifndef ZLIB_WINAPI
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   156
#   define ZLIB_WINAPI
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   157
#  endif
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   158
# endif
99d88a9d5337 (svn r3236) - Fix: warnings about 'CDECL must be used with ...' on VS6
Darkvater
parents: 2639
diff changeset
   159
2889
ac841003c51e (svn r3442) - Fix: Only windows has stricmp. So define strcasecmp to stricmp when using MSVC
Darkvater
parents: 2731
diff changeset
   160
# define strcasecmp stricmp
4316
aa8116c33774 (svn r5969) -Fix r5968: windows doesn't know strncasecmp, but called it strnicmp (michi_cc)
truelight
parents: 4221
diff changeset
   161
# define strncasecmp strnicmp
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   162
// suppress: warning C4005: 'offsetof' : macro redefinition (VC8)
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   163
# include <stddef.h>
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   164
#endif /* defined(_MSC_VER) */
2483
ee0517ddfa92 (svn r3009) DIEEEEEEEEEEE VS6 (you good-for-nothing compiler)
Darkvater
parents: 2482
diff changeset
   165
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   166
/* NOTE: the string returned by these functions is only valid until the next
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   167
 * call to the same function and is not thread- or reentrancy-safe */
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   168
#if !defined(STRGEN)
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   169
# if defined(WIN32) || defined(WIN64)
5472
16f71955fc3b (svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):
glx
parents: 5465
diff changeset
   170
#  include <tchar.h>
16f71955fc3b (svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):
glx
parents: 5465
diff changeset
   171
#  define fopen(file, mode) _tfopen(OTTD2FS(file), _T(mode))
16f71955fc3b (svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):
glx
parents: 5465
diff changeset
   172
   const char *FS2OTTD(const TCHAR *name);
16f71955fc3b (svn r9358) [0.5] -Backport from trunk (r9055, r9082, r9083, r9084, r9085, r9086):
glx
parents: 5465
diff changeset
   173
   const TCHAR *OTTD2FS(const char *name);
5167
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   174
# else
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   175
#  define fopen(file, mode) fopen(OTTD2FS(file), mode)
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   176
   const char *FS2OTTD(const char *name);
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   177
   const char *OTTD2FS(const char *name);
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   178
# endif /* WIN32 */
2b9d61386688 (svn r7274) -Codechange [utf8]: Add input/output unicode support. This actually only changes win32
Darkvater
parents: 5138
diff changeset
   179
#endif /* STRGEN */
2482
dffcca243dbc (svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Darkvater
parents: 2436
diff changeset
   180
157
dd017fa3bad8 (svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents: 0
diff changeset
   181
// Windows has always LITTLE_ENDIAN
2482
dffcca243dbc (svn r3008) [ 1247535 ] Native Support for Win64 (compile&run only) (michi_cc)
Darkvater
parents: 2436
diff changeset
   182
#if defined(WIN32) || defined(__OS2__) || defined(WIN64)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   183
# define TTD_LITTLE_ENDIAN
157
dd017fa3bad8 (svn r158) -Fix: make endianess check 100% accurate (hopefully ;))
truelight
parents: 0
diff changeset
   184
#else
1721
64d59b181596 (svn r2225) -Fix: split the endian-detection to target/host. Now cross-compiling
truelight
parents: 1317
diff changeset
   185
// Else include endian[target/host].h, which has the endian-type, autodetected by the Makefile
4563
f25cb91c5f14 (svn r6411) -Fix(r6410): forgot to update openttd*.sln (thx Darkvater and michi_cc :) )
glx
parents: 4379
diff changeset
   186
# if defined(STRGEN)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   187
#  include "endian_host.h"
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   188
# else
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   189
#  include "endian_target.h"
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   190
# endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   191
#endif /* WIN32 || __OS2__ || WIN64 */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   192
5412
3c79dfcb9082 (svn r8176) -Backport from trunk (r8042, r8089, r8090, r8112):
Darkvater
parents: 5365
diff changeset
   193
#if defined(WIN32) || defined(WIN64) || defined(__OS2__) && !defined(__INNOTEK_LIBC__)
4379
2866185c1377 (svn r6117) -Fix r6097: on mingw it is normal that both / as \ are accepted as input
truelight
parents: 4316
diff changeset
   194
# define PATHSEP "\\"
2866185c1377 (svn r6117) -Fix r6097: on mingw it is normal that both / as \ are accepted as input
truelight
parents: 4316
diff changeset
   195
# define PATHSEPCHAR '\\'
2866185c1377 (svn r6117) -Fix r6097: on mingw it is normal that both / as \ are accepted as input
truelight
parents: 4316
diff changeset
   196
#else
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   197
# define PATHSEP "/"
4221
bb06fe8dcce2 (svn r5765) - Codechange: Fully unify the OS-specific FiosGet...List functions into fios.c, as well as FiosGetSavegameList and FiosGetScenarioList functions with the help of some callbacks.
Darkvater
parents: 4216
diff changeset
   198
# define PATHSEPCHAR '/'
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   199
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   200
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   201
typedef unsigned char byte;
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   202
#ifndef __BEOS__ // already defined
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   203
  typedef unsigned char uint8;
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   204
  typedef unsigned short uint16;
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   205
  typedef unsigned int uint32;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   206
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   207
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   208
// This is already defined in unix
5365
81e1c8f97973 (svn r7666) -Backport from trunk (r7548):
Darkvater
parents: 5167
diff changeset
   209
#if !defined(UNIX) && !defined(__CYGWIN__) && !defined(__BEOS__) && !defined(__MORPHOS__)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   210
  typedef unsigned int uint;
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   211
#endif
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   212
// Not defined in QNX Neutrino (6.x)
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   213
#if defined(__QNXNTO__)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   214
  typedef unsigned int uint;
543
e3b43338096b (svn r942) -Merged branch/network back into the trunk
truelight
parents: 536
diff changeset
   215
#endif
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   216
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   217
#ifndef __BEOS__
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   218
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   219
// some platforms use 4 bytes bool in C++
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   220
// C bool has to be the same
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   221
#	ifndef __cplusplus
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   222
#		ifdef FOUR_BYTE_BOOL
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   223
			typedef unsigned long bool;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   224
#		else /* FOUR_BYTE_BOOL */
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   225
			typedef unsigned char bool;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   226
#		endif /* FOUR_BYTE_BOOL */
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   227
#	endif /* __cplusplus */
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   228
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   229
	typedef signed char int8;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   230
	typedef signed short int16;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   231
	typedef signed int int32;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   232
	typedef signed __int64 int64;
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   233
	typedef unsigned __int64 uint64;
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   234
#endif /* __BEOS__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   235
2978
1a04b74b61ae (svn r3553) - Revert r3549 "Change the behaviour of OTTD_ALIGNMENT". Some tests showed that forcing aligned reads slowed down the code (drawing smallmap) by 14%. Change back to the old behaviour.
Darkvater
parents: 2976
diff changeset
   236
#if defined(ARM) || defined(__arm__) || defined(__alpha__)
1a04b74b61ae (svn r3553) - Revert r3549 "Change the behaviour of OTTD_ALIGNMENT". Some tests showed that forcing aligned reads slowed down the code (drawing smallmap) by 14%. Change back to the old behaviour.
Darkvater
parents: 2976
diff changeset
   237
# define OTTD_ALIGNMENT
1a04b74b61ae (svn r3553) - Revert r3549 "Change the behaviour of OTTD_ALIGNMENT". Some tests showed that forcing aligned reads slowed down the code (drawing smallmap) by 14%. Change back to the old behaviour.
Darkvater
parents: 2976
diff changeset
   238
#endif
1a04b74b61ae (svn r3553) - Revert r3549 "Change the behaviour of OTTD_ALIGNMENT". Some tests showed that forcing aligned reads slowed down the code (drawing smallmap) by 14%. Change back to the old behaviour.
Darkvater
parents: 2976
diff changeset
   239
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   240
// Setup alignment and conversion macros
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   241
#if defined(TTD_BIG_ENDIAN)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   242
  static inline uint32 TO_LE32(uint32 x) { return BSWAP32(x); }
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   243
  static inline uint16 TO_LE16(uint16 x) { return BSWAP16(x); }
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   244
  static inline uint32 FROM_LE32(uint32 x) { return BSWAP32(x); }
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   245
  static inline uint16 FROM_LE16(uint16 x) { return BSWAP16(x); }
2984
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   246
# define TO_BE32(x)   (x)
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   247
# define TO_BE16(x)   (x)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2485
diff changeset
   248
# define FROM_BE32(x) (x)
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2485
diff changeset
   249
# define FROM_BE16(x) (x)
2984
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   250
# define TO_LE32X(x)  BSWAP32(x)
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   251
# define TO_BE32X(x)  (x)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   252
#else
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   253
  static inline uint32 TO_BE32(uint32 x) { return BSWAP32(x); }
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   254
  static inline uint16 TO_BE16(uint16 x) { return BSWAP16(x); }
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   255
  static inline uint32 FROM_BE32(uint32 x) { return BSWAP32(x); }
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   256
  static inline uint16 FROM_BE16(uint16 x) { return BSWAP16(x); }
2984
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   257
# define TO_LE32(x)   (x)
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   258
# define TO_LE16(x)   (x)
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2485
diff changeset
   259
# define FROM_LE32(x) (x)
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2485
diff changeset
   260
# define FROM_LE16(x) (x)
2984
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   261
# define TO_LE32X(x)  (x)
225bffc79071 (svn r3559) - CodeChange: simplify MKCOLOR(x) macro for smallmap_gui.c by adding a TO_LE32X() macro next to TO_BE32X(). The 'X' signifies them as macros and not-inline functions so they can be used in variable declarations.
Darkvater
parents: 2980
diff changeset
   262
# define TO_BE32X(x)  BSWAP32(x)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   263
#endif /* TTD_BIG_ENDIAN */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   264
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   265
#if !defined(GAME_DATA_DIR)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   266
# define GAME_DATA_DIR ""
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   267
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   268
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   269
#if !defined(PERSONAL_DIR)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   270
# define PERSONAL_DIR ""
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   271
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   272
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   273
#ifndef __cplusplus
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   274
# ifndef __BEOS__
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   275
   enum {
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   276
    false = 0,
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   277
    true = 1,
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   278
   };
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   279
# endif
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   280
#endif /* __cplusplus */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   281
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   282
// Compile time assertions
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
   283
#ifdef __OS2__
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   284
# define assert_compile(expr)
781
9717ff353c17 (svn r1248) -Add: initial OS/2 support (read docs/ReadMe_OS2.txt) (orudge)
truelight
parents: 770
diff changeset
   285
#else
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   286
# ifdef __cplusplus
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   287
#  define assert_compile(expr) extern "C" void __ct_assert__(int a[1 - 2 * !(expr)])
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   288
# else /* __cplusplus */
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   289
#  define assert_compile(expr) void __ct_assert__(int a[1 - 2 * !(expr)])
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   290
# endif /* !__cplusplus */
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   291
#endif /* __OS2__ */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   292
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   293
assert_compile(sizeof(uint32) == 4);
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   294
assert_compile(sizeof(uint16) == 2);
2639
8a7342eb3a78 (svn r3181) -Bracing
tron
parents: 2485
diff changeset
   295
assert_compile(sizeof(uint8)  == 1);
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   296
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   297
#define lengthof(x) (sizeof(x)/sizeof(x[0]))
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   298
#define endof(x) (&x[lengthof(x)])
1317
f382f1b439c7 (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
   299
#define lastof(x) (&x[lengthof(x) - 1])
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   300
#ifndef offsetof
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   301
# define offsetof(s,m)   (size_t)&(((s *)0)->m)
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   302
#endif
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   303
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   304
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   305
// take care of some name clashes on macos
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   306
#if defined(__APPLE__)
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   307
# define GetString OTTD_GetString
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   308
# define DrawString OTTD_DrawString
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   309
# define Random OTTD_Random
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   310
# define CloseConnection OTTD_CloseConnection
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   311
#endif /* __APPLE */
0
29654efe3188 (svn r1) Import of revision 975 of old (crashed) SVN
truelight
parents:
diff changeset
   312
770
89dab23f04ca (svn r1236) MorphOS: added make release like in OSX (tokai)
bjarni
parents: 569
diff changeset
   313
#ifdef __AMIGA__
569
2e86ae517874 (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
   314
// it seems AmigaOS already have a Point declared
2485
fd92a70a064a (svn r3011) Refix last revision's fix of VS6 which broke compilation on MinGW. Also beautify stdafx.h with nice indentation and comments after big #ifdef blocks. Hope it didn't break compilation on any OS's.
Darkvater
parents: 2483
diff changeset
   315
# define Point OTTD_AMIGA_POINT
569
2e86ae517874 (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
   316
#endif
2e86ae517874 (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
   317
3900
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   318
#define EXTERN_C_BEGIN extern "C" {
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   319
#define EXTERN_C_END   }
4984308f9125 (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents: 3624
diff changeset
   320
2436
177cb6a8339f (svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents: 2225
diff changeset
   321
#endif /* STDAFX_H */