diff --git a/binding-mri/time-binding.cpp b/binding-mri/time-binding.cpp index 453e43e..cb1d77a 100644 --- a/binding-mri/time-binding.cpp +++ b/binding-mri/time-binding.cpp @@ -1,17 +1,21 @@ +// Custom Methods for time bcz Ruby bullshit #include -#include #include +#include +#include "debugwriter.h" +static SDL_DateTime dt; +static SDL_Time ticks; static VALUE get_month(VALUE self) { - time_t now = time(NULL); - struct tm *ltm = localtime(&now); - return INT2NUM(1 + ltm->tm_mon); + return INT2NUM(dt.month); } static VALUE get_day(VALUE self) { - time_t now = time(NULL); - struct tm *ltm = localtime(&now); - return INT2NUM(ltm->tm_mday); + return INT2NUM(dt.day); +} + +static VALUE get_hours(VALUE self) { + return INT2NUM(dt.hour); } static VALUE ctime_at(int argc, VALUE *argv, VALUE self){ @@ -55,4 +59,14 @@ void TimeBindingInit() { rb_define_module_function(m, "month", get_month, 0); rb_define_module_function(m, "day", get_day, 0); rb_define_singleton_method(m, "at", ctime_at, -1); + rb_define_singleton_method(m, "hour", get_hours, 0); + if (!SDL_GetCurrentTime(&ticks)) { + Debug() << "SDL_GetCurrentTime failed: " << SDL_GetError(); + return; + } + + if (!SDL_TimeToDateTime(ticks, &dt, true)) { + Debug() << "SDL_TimeToDateTime failed: " << SDL_GetError(); + return; + } } diff --git a/changelogs/0.1.2.txt b/changelogs/0.1.2.txt index e21e01d..9c736a5 100644 --- a/changelogs/0.1.2.txt +++ b/changelogs/0.1.2.txt @@ -15,3 +15,6 @@ Added "Stream Privacy" Added a change to sub categories in the settings Added way to set move panorama with custom speed value Dynamic light configured in Tower +Added SANITIZERS build option +"Watcher" time check function fixed +Ruby CTime.hour added diff --git a/scripts/Script.rb b/scripts/Script.rb index 4853c06..7c418b5 100644 --- a/scripts/Script.rb +++ b/scripts/Script.rb @@ -767,7 +767,7 @@ end # Misc def watcher_tell_time - hour = 0 #Time.now.hour + hour = CTime.hour if hour >= 6 && hour < 12 Script.tmp_v1 = 0 elsif hour >= 12 && hour < 17