mirror of https://github.com/OpenRCT2/OpenRCT2.git
commit
a236e567fe
|
@ -33,6 +33,7 @@
|
||||||
#include "../config.h"
|
#include "../config.h"
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
// The name of the mutex used to prevent multiple instances of the game from running
|
// The name of the mutex used to prevent multiple instances of the game from running
|
||||||
#define SINGLE_INSTANCE_MUTEX_NAME "RollerCoaster Tycoon 2_GSKMUTEX"
|
#define SINGLE_INSTANCE_MUTEX_NAME "RollerCoaster Tycoon 2_GSKMUTEX"
|
||||||
|
@ -57,6 +58,31 @@ int main(int argc, const char **argv)
|
||||||
return gExitCode;
|
return gExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void platform_get_date(rct2_date *out_date)
|
||||||
|
{
|
||||||
|
assert(out_date != NULL);
|
||||||
|
time_t rawtime;
|
||||||
|
struct tm * timeinfo;
|
||||||
|
time(&rawtime);
|
||||||
|
timeinfo = gmtime(&rawtime);
|
||||||
|
out_date->day = timeinfo->tm_mday;
|
||||||
|
out_date->month = timeinfo->tm_mon;
|
||||||
|
out_date->year = timeinfo->tm_year;
|
||||||
|
out_date->day_of_week = timeinfo->tm_wday;
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform_get_time(rct2_time *out_time)
|
||||||
|
{
|
||||||
|
assert(out_time != NULL);
|
||||||
|
time_t rawtime;
|
||||||
|
struct tm * timeinfo;
|
||||||
|
time(&rawtime);
|
||||||
|
timeinfo = gmtime(&rawtime);
|
||||||
|
out_time->second = timeinfo->tm_sec;
|
||||||
|
out_time->minute = timeinfo->tm_min;
|
||||||
|
out_time->hour = timeinfo->tm_hour;
|
||||||
|
}
|
||||||
|
|
||||||
char platform_get_path_separator()
|
char platform_get_path_separator()
|
||||||
{
|
{
|
||||||
return '/';
|
return '/';
|
||||||
|
|
|
@ -45,6 +45,19 @@ typedef struct {
|
||||||
uint64 last_modified;
|
uint64 last_modified;
|
||||||
} file_info;
|
} file_info;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
sint16 day;
|
||||||
|
sint16 month;
|
||||||
|
sint16 year;
|
||||||
|
sint16 day_of_week;
|
||||||
|
} rct2_date;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
sint16 hour;
|
||||||
|
sint16 minute;
|
||||||
|
sint16 second;
|
||||||
|
} rct2_time;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int x, y;
|
int x, y;
|
||||||
unsigned char left, middle, right, any;
|
unsigned char left, middle, right, any;
|
||||||
|
@ -91,6 +104,8 @@ void platform_process_messages();
|
||||||
int platform_scancode_to_rct_keycode(int sdl_key);
|
int platform_scancode_to_rct_keycode(int sdl_key);
|
||||||
void platform_start_text_input(utf8 *buffer, int max_length);
|
void platform_start_text_input(utf8 *buffer, int max_length);
|
||||||
void platform_stop_text_input();
|
void platform_stop_text_input();
|
||||||
|
void platform_get_date(rct2_date *out_date);
|
||||||
|
void platform_get_time(rct2_time *out_time);
|
||||||
|
|
||||||
// Platform specific definitions
|
// Platform specific definitions
|
||||||
char platform_get_path_separator();
|
char platform_get_path_separator();
|
||||||
|
|
|
@ -85,6 +85,28 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta
|
||||||
return gExitCode;
|
return gExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void platform_get_date(rct2_date *out_date)
|
||||||
|
{
|
||||||
|
assert(out_date != NULL);
|
||||||
|
SYSTEMTIME systime;
|
||||||
|
|
||||||
|
GetSystemTime(&systime);
|
||||||
|
out_date->day = systime.wDay;
|
||||||
|
out_date->month = systime.wMonth;
|
||||||
|
out_date->year = systime.wYear;
|
||||||
|
out_date->day_of_week = systime.wDayOfWeek;
|
||||||
|
}
|
||||||
|
|
||||||
|
void platform_get_time(rct2_time *out_time)
|
||||||
|
{
|
||||||
|
assert(out_time != NULL);
|
||||||
|
SYSTEMTIME systime;
|
||||||
|
GetLocalTime(&systime);
|
||||||
|
out_time->hour = systime.wHour;
|
||||||
|
out_time->minute = systime.wMinute;
|
||||||
|
out_time->second = systime.wSecond;
|
||||||
|
}
|
||||||
|
|
||||||
char platform_get_path_separator()
|
char platform_get_path_separator()
|
||||||
{
|
{
|
||||||
return '\\';
|
return '\\';
|
||||||
|
|
30
src/rct2.c
30
src/rct2.c
|
@ -530,17 +530,12 @@ void get_system_info()
|
||||||
*/
|
*/
|
||||||
void get_system_time()
|
void get_system_time()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
rct2_date date;
|
||||||
SYSTEMTIME systime;
|
platform_get_date(&date);
|
||||||
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, sint16) = date.day;
|
||||||
GetSystemTime(&systime);
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MONTH, sint16) = date.month;
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAY, sint16) = systime.wDay;
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_YEAR, sint16) = date.year;
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MONTH, sint16) = systime.wMonth;
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAYOFWEEK, sint16) = date.day_of_week;
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_YEAR, sint16) = systime.wYear;
|
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_DAYOFWEEK, sint16) = systime.wDayOfWeek;
|
|
||||||
#else
|
|
||||||
STUB();
|
|
||||||
#endif // _WIN32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -549,15 +544,10 @@ void get_system_time()
|
||||||
*/
|
*/
|
||||||
void get_local_time()
|
void get_local_time()
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
rct2_time t;
|
||||||
SYSTEMTIME systime;
|
platform_get_time(&t);
|
||||||
GetLocalTime(&systime);
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_HOUR, sint16) = t.hour;
|
||||||
|
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MINUTE, sint16) = t.minute;
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_HOUR, sint16) = systime.wHour;
|
|
||||||
RCT2_GLOBAL(RCT2_ADDRESS_OS_TIME_MINUTE, sint16) = systime.wMinute;
|
|
||||||
#else
|
|
||||||
STUB();
|
|
||||||
#endif // _WIN32
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue