summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaximillian <maximillian.pol@gmail.com>2015-08-06 10:29:33 -0700
committerMaximillian <maximillian.pol@gmail.com>2015-08-06 10:29:33 -0700
commit6f9a084ac8a820450632f17384161c6a24da86d3 (patch)
treed4dbca6eb52f61d486dec7398db2a97945c5a8d4
parent9d185ccc30ad5fe7eb716390ca2e7f5c06574ce0 (diff)
Add OS.get_system_time_msec
-rw-r--r--core/bind/core_bind.cpp5
-rw-r--r--core/bind/core_bind.h1
-rw-r--r--core/os/os.cpp4
-rw-r--r--core/os/os.h1
-rw-r--r--drivers/unix/os_unix.cpp7
-rw-r--r--drivers/unix/os_unix.h1
-rw-r--r--platform/windows/os_windows.cpp6
-rw-r--r--platform/windows/os_windows.h3
8 files changed, 26 insertions, 2 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 6a3023cdb2..b4bf1ed4bd 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -494,6 +494,10 @@ uint64_t _OS::get_unix_time() const {
return OS::get_singleton()->get_unix_time();
};
+uint64_t _OS::get_system_time_msec() const {
+ return OS::get_singleton()->get_system_time_msec();
+}
+
void _OS::delay_usec(uint32_t p_usec) const {
OS::get_singleton()->delay_usec(p_usec);
@@ -801,6 +805,7 @@ void _OS::_bind_methods() {
ObjectTypeDB::bind_method(_MD("get_time","utc"),&_OS::get_time,DEFVAL(false));
ObjectTypeDB::bind_method(_MD("get_time_zone_info"),&_OS::get_time_zone_info);
ObjectTypeDB::bind_method(_MD("get_unix_time"),&_OS::get_unix_time);
+ ObjectTypeDB::bind_method(_MD("get_system_time_msec"), &_OS::get_system_time_msec);
ObjectTypeDB::bind_method(_MD("set_icon"),&_OS::set_icon);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 6b916a395e..ed3db29259 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -208,6 +208,7 @@ public:
Dictionary get_time(bool utc) const;
Dictionary get_time_zone_info() const;
uint64_t get_unix_time() const;
+ uint64_t get_system_time_msec() const;
int get_static_memory_usage() const;
int get_static_memory_peak_usage() const;
diff --git a/core/os/os.cpp b/core/os/os.cpp
index f292456079..efcd492230 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -50,7 +50,9 @@ uint64_t OS::get_unix_time() const {
return 0;
};
-
+uint64_t OS::get_system_time_msec() const {
+ return 0;
+}
void OS::debug_break() {
// something
diff --git a/core/os/os.h b/core/os/os.h
index 0230a75ca0..e8ecfa1054 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -254,6 +254,7 @@ public:
virtual Time get_time(bool local=false) const=0;
virtual TimeZoneInfo get_time_zone_info() const=0;
virtual uint64_t get_unix_time() const;
+ virtual uint64_t get_system_time_msec() const;
virtual void delay_usec(uint32_t p_usec) const=0;
virtual uint64_t get_ticks_usec() const=0;
diff --git a/drivers/unix/os_unix.cpp b/drivers/unix/os_unix.cpp
index f6d9e0fb4e..1afd0be61d 100644
--- a/drivers/unix/os_unix.cpp
+++ b/drivers/unix/os_unix.cpp
@@ -223,6 +223,13 @@ uint64_t OS_Unix::get_unix_time() const {
return time(NULL);
};
+uint64_t OS_Unix::get_system_time_msec() const {
+ struct timeval tv_now;
+ gettimeofday(&tv_now, null);
+ uint64_t msec = tv_now.tv_.sec / 1000;
+ return msec;
+}
+
OS::Date OS_Unix::get_date(bool utc) const {
diff --git a/drivers/unix/os_unix.h b/drivers/unix/os_unix.h
index 8bb57eda12..2ee6102164 100644
--- a/drivers/unix/os_unix.h
+++ b/drivers/unix/os_unix.h
@@ -93,6 +93,7 @@ public:
virtual TimeZoneInfo get_time_zone_info() const;
virtual uint64_t get_unix_time() const;
+ virtual uint64_t get_system_time_msec() const;
virtual void delay_usec(uint32_t p_usec) const;
virtual uint64_t get_ticks_usec() const;
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index ec9e17c4f0..87d9a43d8c 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -1899,6 +1899,12 @@ uint64_t OS_Windows::get_unix_time() const {
return (*(uint64_t*)&ft - *(uint64_t*)&fep) / 10000000;
};
+uint64_t OS_Windows::get_system_time_msec() const {
+ SYSTEMTIME st;
+ GetSystemTime(&st);
+ return st.wMilliseconds;
+}
+
void OS_Windows::delay_usec(uint32_t p_usec) const {
if (p_usec < 1000)
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index 31e030d02e..cce94f5b25 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -263,6 +263,7 @@ public:
virtual Time get_time(bool utc) const;
virtual TimeZoneInfo get_time_zone_info() const;
virtual uint64_t get_unix_time() const;
+ virtual uint64_t get_system_time_msec() const;
virtual bool can_draw() const;
virtual Error set_cwd(const String& p_cwd);
@@ -272,7 +273,7 @@ public:
virtual Error execute(const String& p_path, const List<String>& p_arguments,bool p_blocking,ProcessID *r_child_id=NULL,String* r_pipe=NULL,int *r_exitcode=NULL);
virtual Error kill(const ProcessID& p_pid);
-
+
virtual bool has_environment(const String& p_var) const;
virtual String get_environment(const String& p_var) const;