mirror of
https://forgejo.xatacraft.ru/Sunshine/mkxp-sunshine.git
synced 2026-08-19 13:29:54 +00:00
Watcher fix
This commit is contained in:
parent
868809bb5d
commit
98c153037c
3 changed files with 25 additions and 8 deletions
|
|
@ -1,17 +1,21 @@
|
||||||
|
// Custom Methods for time bcz Ruby bullshit
|
||||||
#include <ruby.h>
|
#include <ruby.h>
|
||||||
#include <time.h>
|
|
||||||
#include <SDL3/SDL_stdinc.h>
|
#include <SDL3/SDL_stdinc.h>
|
||||||
|
#include <SDL3/SDL_time.h>
|
||||||
|
#include "debugwriter.h"
|
||||||
|
static SDL_DateTime dt;
|
||||||
|
static SDL_Time ticks;
|
||||||
|
|
||||||
static VALUE get_month(VALUE self) {
|
static VALUE get_month(VALUE self) {
|
||||||
time_t now = time(NULL);
|
return INT2NUM(dt.month);
|
||||||
struct tm *ltm = localtime(&now);
|
|
||||||
return INT2NUM(1 + ltm->tm_mon);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE get_day(VALUE self) {
|
static VALUE get_day(VALUE self) {
|
||||||
time_t now = time(NULL);
|
return INT2NUM(dt.day);
|
||||||
struct tm *ltm = localtime(&now);
|
}
|
||||||
return INT2NUM(ltm->tm_mday);
|
|
||||||
|
static VALUE get_hours(VALUE self) {
|
||||||
|
return INT2NUM(dt.hour);
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE ctime_at(int argc, VALUE *argv, VALUE self){
|
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, "month", get_month, 0);
|
||||||
rb_define_module_function(m, "day", get_day, 0);
|
rb_define_module_function(m, "day", get_day, 0);
|
||||||
rb_define_singleton_method(m, "at", ctime_at, -1);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,3 +15,6 @@ Added "Stream Privacy"
|
||||||
Added a change to sub categories in the settings
|
Added a change to sub categories in the settings
|
||||||
Added way to set move panorama with custom speed value
|
Added way to set move panorama with custom speed value
|
||||||
Dynamic light configured in Tower
|
Dynamic light configured in Tower
|
||||||
|
Added SANITIZERS build option
|
||||||
|
"Watcher" time check function fixed
|
||||||
|
Ruby CTime.hour added
|
||||||
|
|
|
||||||
|
|
@ -767,7 +767,7 @@ end
|
||||||
|
|
||||||
# Misc
|
# Misc
|
||||||
def watcher_tell_time
|
def watcher_tell_time
|
||||||
hour = 0 #Time.now.hour
|
hour = CTime.hour
|
||||||
if hour >= 6 && hour < 12
|
if hour >= 6 && hour < 12
|
||||||
Script.tmp_v1 = 0
|
Script.tmp_v1 = 0
|
||||||
elsif hour >= 12 && hour < 17
|
elsif hour >= 12 && hour < 17
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue