]> git.lizzy.rs Git - minetest.git/blobdiff - src/porting.h
Fix client profiler print interval
[minetest.git] / src / porting.h
index 19ac5c6bb920f7ff8c69b163e7e62b46e02ed550..3f9486b63fb1fda9b14afafe5e8e2347e99f17a1 100644 (file)
@@ -24,10 +24,13 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #ifndef PORTING_HEADER
 #define PORTING_HEADER
 
-// Included for u64 and such
+#include <string>
+// Included for u32 and such
 #include "common_irrlicht.h"
+#include "debug.h"
+#include "constants.h"
 
-#ifdef _WIN32
+#ifdef _MSC_VER
        #define SWPRINTF_CHARSTRING L"%S"
 #else
        #define SWPRINTF_CHARSTRING L"%s"
@@ -44,6 +47,42 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 namespace porting
 {
 
+/*
+       Signal handler (grabs Ctrl-C on POSIX systems)
+*/
+
+void signal_handler_init(void);
+// Returns a pointer to a bool.
+// When the bool is true, program should quit.
+bool * signal_handler_killstatus(void);
+
+/*
+       Path of static data directory.
+*/
+extern std::string path_data;
+
+/*
+       Directory for storing user data. Examples:
+       Windows: "C:\Documents and Settings\user\Application Data\<PROJECT_NAME>"
+       Linux: "~/.<PROJECT_NAME>"
+       Mac: "~/Library/Application Support/<PROJECT_NAME>"
+*/
+extern std::string path_userdata;
+
+/*
+       Get full path of stuff in data directory.
+       Example: "stone.png" -> "../data/stone.png"
+*/
+inline std::string getDataPath(const char *subpath)
+{
+       return path_data + "/" + subpath;
+}
+
+/*
+       Initialize path_data and path_userdata.
+*/
+void initializePaths();
+
 /*
        Resolution is 10-20ms.
        Remember to check for overflows.
@@ -56,16 +95,23 @@ namespace porting
                return GetTickCount();
        }
 #else // Posix
-       #include <sys/timeb.h>
+       #include <sys/time.h>
+       inline u32 getTimeMs()
+       {
+               struct timeval tv;
+               gettimeofday(&tv, NULL);
+               return tv.tv_sec * 1000 + tv.tv_usec / 1000;
+       }
+       /*#include <sys/timeb.h>
        inline u32 getTimeMs()
        {
                struct timeb tb;
                ftime(&tb);
                return tb.time * 1000 + tb.millitm;
-       }
+       }*/
 #endif
 
 } // namespace porting
 
-#endif
+#endif // PORTING_HEADER