]> git.jsancho.org Git - lugaru.git/blob - Source/WinDefs.h
mingw32: Fix issues with WIN32 not being defined
[lugaru.git] / Source / WinDefs.h
1 /*
2 Copyright (C) 2003, 2010 - Wolfire Games
3
4 This file is part of Lugaru.
5
6 Lugaru is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; either version 2
9 of the License, or (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
15 See the GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
20 */
21
22 #ifndef _WINDEFS_H_
23 #define _WINDEFS_H_
24 #ifdef WIN32
25
26
27 #include <stdio.h>
28 #include <math.h>
29
30 // stuff to make Mac code compatable with Windows
31
32
33 // disable warnings about double to float conversions
34 #pragma warning(disable:4305)
35 #pragma warning(disable:4244)
36
37 // disable warnings about boolean to int conversions
38 #pragma warning(disable:4800)
39
40 // disable warning about unreferenced local variables
41 #pragma warning(disable:4101)
42
43 typedef bool Boolean;
44
45 struct Point {
46     short v;
47     short h;
48 };
49
50 typedef signed char SInt8;
51 typedef unsigned int UInt32;
52
53
54 #include "Random.h"
55
56
57 void CopyCStringToPascal( const char* src, unsigned char dst[256]);
58 void CopyPascalStringToC( const unsigned char* src, char* dst);
59
60
61 typedef struct AbsoluteTime {
62     unsigned long   hi;
63     unsigned long   lo;
64 } AbsoluteTime;
65
66 AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
67
68 typedef long Duration;
69
70 enum {
71     durationMicrosecond             = -1,
72     durationMillisecond             = 1,
73     durationSecond                  = 1000,
74     durationMinute                  = 1000 * 60,
75     durationHour                    = 1000 * 60 * 60,
76     durationDay                     = 1000 * 60 * 60 * 24,
77     durationForever                 = 0x7FFFFFFF,
78     durationImmediate               = 0,
79 };
80
81 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
82
83
84 /*
85 inline bool isnormal( double x)
86 {
87     int ret = _fpclass( x);
88     return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
89 }
90 */
91
92 typedef unsigned int uintptr_t;
93
94
95 // fix file names to use '/' instead of ':'
96 char* ConvertFileName( const char* orgfilename);
97 char* ConvertFileName( const char* orgfilename, const char* junk);
98
99
100 #define fopen(a, b) fopen(ConvertFileName(a), b);
101
102 #ifndef __MINGW32__
103 inline float abs(float f)
104 {
105     if (f < 0)
106         return -f;
107     return f;
108 }
109
110 inline double abs(double f)
111 {
112     if (f < 0)
113         return -f;
114     return f;
115 }
116 #endif // __MINGW32__
117
118
119 #endif
120 #endif