-Removed OS.get_system_time_msec(), this is undoable on Windows and also unusable from GDscript due to precision.
-Added, instead an OS.get_system_time_secs(), which is 32 bits friendly, fixes #3143
This commit is contained in:
parent
5b088b41b3
commit
a120c66f98
|
@ -494,8 +494,8 @@ 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();
|
||||
uint64_t _OS::get_system_time_secs() const {
|
||||
return OS::get_singleton()->get_system_time_secs();
|
||||
}
|
||||
|
||||
void _OS::delay_usec(uint32_t p_usec) const {
|
||||
|
@ -810,7 +810,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("get_system_time_secs"), &_OS::get_system_time_secs);
|
||||
|
||||
ObjectTypeDB::bind_method(_MD("set_icon","icon"),&_OS::set_icon);
|
||||
|
||||
|
|
|
@ -208,7 +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;
|
||||
uint64_t get_system_time_secs() const;
|
||||
|
||||
int get_static_memory_usage() const;
|
||||
int get_static_memory_peak_usage() const;
|
||||
|
|
|
@ -50,7 +50,7 @@ uint64_t OS::get_unix_time() const {
|
|||
|
||||
return 0;
|
||||
};
|
||||
uint64_t OS::get_system_time_msec() const {
|
||||
uint64_t OS::get_system_time_secs() const {
|
||||
return 0;
|
||||
}
|
||||
void OS::debug_break() {
|
||||
|
|
|
@ -256,7 +256,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 uint64_t get_system_time_secs() const;
|
||||
|
||||
virtual void delay_usec(uint32_t p_usec) const=0;
|
||||
virtual uint64_t get_ticks_usec() const=0;
|
||||
|
|
|
@ -233,13 +233,12 @@ uint64_t OS_Unix::get_unix_time() const {
|
|||
return time(NULL);
|
||||
};
|
||||
|
||||
uint64_t OS_Unix::get_system_time_msec() const {
|
||||
uint64_t OS_Unix::get_system_time_secs() const {
|
||||
struct timeval tv_now;
|
||||
gettimeofday(&tv_now, NULL);
|
||||
//localtime(&tv_now.tv_usec);
|
||||
//localtime((const long *)&tv_now.tv_usec);
|
||||
uint64_t msec = uint64_t(tv_now.tv_sec)*1000+tv_now.tv_usec/1000;
|
||||
return msec;
|
||||
return uint64_t(tv_now.tv_sec);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -95,7 +95,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 uint64_t get_system_time_secs() const;
|
||||
|
||||
virtual void delay_usec(uint32_t p_usec) const;
|
||||
virtual uint64_t get_ticks_usec() const;
|
||||
|
|
|
@ -1681,10 +1681,16 @@ 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 {
|
||||
uint64_t OS_Windows::get_system_time_secs() const {
|
||||
SYSTEMTIME st;
|
||||
GetSystemTime(&st);
|
||||
return st.wMilliseconds;
|
||||
FILETIME ft;
|
||||
SystemTimeToFileTime(&st,&ft);
|
||||
uint64_t ret;
|
||||
ret=ft.dwHighDateTime;
|
||||
ret<<=32;
|
||||
ret|=ft.dwLowDateTime;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void OS_Windows::delay_usec(uint32_t p_usec) const {
|
||||
|
|
|
@ -231,7 +231,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 uint64_t get_system_time_secs() const;
|
||||
|
||||
virtual bool can_draw() const;
|
||||
virtual Error set_cwd(const String& p_cwd);
|
||||
|
|
Loading…
Reference in New Issue