3 Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 Random portability stuff
24 #ifndef PORTING_HEADER
25 #define PORTING_HEADER
28 // Included for u64 and such
29 #include "common_irrlicht.h"
31 #include "constants.h"
34 #define SWPRINTF_CHARSTRING L"%S"
36 #define SWPRINTF_CHARSTRING L"%s"
41 #define sleep_ms(x) Sleep(x)
44 #define sleep_ms(x) usleep(x*1000)
51 Path of static data directory.
53 extern std::string path_data;
56 Directory for storing user data. Examples:
57 Windows: "C:\Documents and Settings\user\Application Data\<APPNAME>"
59 Mac: "~/Library/Application Support/<APPNAME>"
61 extern std::string path_userdata;
64 Get full path of stuff in data directory.
65 Example: "stone.png" -> "../data/stone.png"
67 inline std::string getDataPath(const char *subpath)
69 return path_data + "/" + subpath;
73 Initialize path_data and path_userdata.
75 void initializePaths();
78 Resolution is 10-20ms.
79 Remember to check for overflows.
80 Overflow can occur at any value higher than 10000000.
82 #ifdef _WIN32 // Windows
84 inline u32 getTimeMs()
86 return GetTickCount();
90 inline u32 getTimeMs()
93 gettimeofday(&tv, NULL);
94 return tv.tv_sec * 1000 + tv.tv_usec / 1000;
96 /*#include <sys/timeb.h>
97 inline u32 getTimeMs()
101 return tb.time * 1000 + tb.millitm;
105 } // namespace porting
107 #endif // PORTING_HEADER