]> git.jsancho.org Git - lugaru.git/blob - Source/WinDefs.h
First step at cleaning image loading.
[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 modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 Lugaru 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.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with Lugaru.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #ifndef _WINDEFS_H_
21 #define _WINDEFS_H_
22 #ifdef WIN32
23
24
25 #include <stdio.h>
26 #include <math.h>
27
28 // stuff to make Mac code compatable with Windows
29
30
31 // disable warnings about double to float conversions
32 #pragma warning(disable:4305)
33 #pragma warning(disable:4244)
34
35 // disable warnings about boolean to int conversions
36 #pragma warning(disable:4800)
37
38 // disable warning about unreferenced local variables
39 #pragma warning(disable:4101)
40
41 typedef bool Boolean;
42
43 struct Point {
44     short v;
45     short h;
46 };
47
48 typedef signed char SInt8;
49 typedef unsigned int UInt32;
50
51
52 #include "Random.h"
53
54
55 typedef struct AbsoluteTime {
56     unsigned long   hi;
57     unsigned long   lo;
58 } AbsoluteTime;
59
60 AbsoluteTime UpTime(); // NOTE: returns time since app started, not system start
61
62 typedef long Duration;
63
64 enum {
65     durationMicrosecond             = -1,
66     durationMillisecond             = 1,
67     durationSecond                  = 1000,
68     durationMinute                  = 1000 * 60,
69     durationHour                    = 1000 * 60 * 60,
70     durationDay                     = 1000 * 60 * 60 * 24,
71     durationForever                 = 0x7FFFFFFF,
72     durationImmediate               = 0,
73 };
74
75 Duration AbsoluteDeltaToDuration( AbsoluteTime& a, AbsoluteTime& b);
76
77
78 /*
79 inline bool isnormal( double x)
80 {
81     int ret = _fpclass( x);
82     return (ret == _FPCLASS_NN || ret == _FPCLASS_PN);
83 }
84 */
85
86
87 // fix file names to use '/' instead of ':'
88 char* ConvertFileName( const char* orgfilename);
89 char* ConvertFileName( const char* orgfilename, const char* junk);
90
91
92 #define fopen(a, b) fopen(ConvertFileName(a), b);
93
94 #ifndef __MINGW32__
95 inline float abs(float f)
96 {
97     if (f < 0)
98         return -f;
99     return f;
100 }
101
102 inline double abs(double f)
103 {
104     if (f < 0)
105         return -f;
106     return f;
107 }
108 #endif // __MINGW32__
109
110
111 #endif
112 #endif