mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Don't allow negative values for OS.delay_usec()/OS.delay_msec()
This closes #46190.
(cherry picked from commit 76f1f9b3c5)
This commit is contained in:
committed by
Rémi Verschelde
parent
2fb221e79a
commit
9f236d48e6
@@ -942,13 +942,19 @@ uint64_t _OS::get_system_time_msecs() const {
|
||||
return OS::get_singleton()->get_system_time_msecs();
|
||||
}
|
||||
|
||||
void _OS::delay_usec(uint32_t p_usec) const {
|
||||
|
||||
/** This method uses a signed argument for better error reporting as it's used from the scripting API. */
|
||||
void _OS::delay_usec(int p_usec) const {
|
||||
ERR_FAIL_COND_MSG(
|
||||
p_usec < 0,
|
||||
vformat("Can't sleep for %d microseconds. The delay provided must be greater than or equal to 0 microseconds.", p_usec));
|
||||
OS::get_singleton()->delay_usec(p_usec);
|
||||
}
|
||||
|
||||
void _OS::delay_msec(uint32_t p_msec) const {
|
||||
|
||||
/** This method uses a signed argument for better error reporting as it's used from the scripting API. */
|
||||
void _OS::delay_msec(int p_msec) const {
|
||||
ERR_FAIL_COND_MSG(
|
||||
p_msec < 0,
|
||||
vformat("Can't sleep for %d milliseconds. The delay provided must be greater than or equal to 0 milliseconds.", p_msec));
|
||||
OS::get_singleton()->delay_usec(int64_t(p_msec) * 1000);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user