Add: AI/GS Time Mode to choose between economy (default) and calendar time (#11603)
This commit is contained in:
@@ -9,7 +9,9 @@
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_date.hpp"
|
||||
#include "script_timemode.hpp"
|
||||
#include "../../timer/timer_game_calendar.h"
|
||||
#include "../../timer/timer_game_economy.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
@@ -22,14 +24,21 @@
|
||||
|
||||
/* static */ ScriptDate::Date ScriptDate::GetCurrentDate()
|
||||
{
|
||||
return (ScriptDate::Date)TimerGameCalendar::date.base();
|
||||
if (ScriptTimeMode::IsCalendarMode()) return (ScriptDate::Date)TimerGameCalendar::date.base();
|
||||
|
||||
return (ScriptDate::Date)TimerGameEconomy::date.base();
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptDate::GetYear(ScriptDate::Date date)
|
||||
{
|
||||
if (date < 0) return DATE_INVALID;
|
||||
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
if (ScriptTimeMode::IsCalendarMode()) {
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
return ymd.year.base();
|
||||
}
|
||||
|
||||
::TimerGameEconomy::YearMonthDay ymd = ::TimerGameEconomy::ConvertDateToYMD(date);
|
||||
return ymd.year.base();
|
||||
}
|
||||
|
||||
@@ -37,7 +46,12 @@
|
||||
{
|
||||
if (date < 0) return DATE_INVALID;
|
||||
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
if (ScriptTimeMode::IsCalendarMode()) {
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
return ymd.month + 1;
|
||||
}
|
||||
|
||||
::TimerGameEconomy::YearMonthDay ymd = ::TimerGameEconomy::ConvertDateToYMD(date);
|
||||
return ymd.month + 1;
|
||||
}
|
||||
|
||||
@@ -45,7 +59,12 @@
|
||||
{
|
||||
if (date < 0) return DATE_INVALID;
|
||||
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
if (ScriptTimeMode::IsCalendarMode()) {
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
return ymd.day;
|
||||
}
|
||||
|
||||
::TimerGameEconomy::YearMonthDay ymd = ::TimerGameEconomy::ConvertDateToYMD(date);
|
||||
return ymd.day;
|
||||
}
|
||||
|
||||
@@ -55,7 +74,9 @@
|
||||
if (day_of_month < 1 || day_of_month > 31) return DATE_INVALID;
|
||||
if (year < 0 || year > CalendarTime::MAX_YEAR) return DATE_INVALID;
|
||||
|
||||
return (ScriptDate::Date)::TimerGameCalendar::ConvertYMDToDate(year, month - 1, day_of_month).base();
|
||||
if (ScriptTimeMode::IsCalendarMode()) return (ScriptDate::Date)::TimerGameCalendar::ConvertYMDToDate(year, month - 1, day_of_month).base();
|
||||
|
||||
return (ScriptDate::Date)::TimerGameEconomy::ConvertYMDToDate(year, month - 1, day_of_month).base();
|
||||
}
|
||||
|
||||
/* static */ SQInteger ScriptDate::GetSystemTime()
|
||||
|
||||
Reference in New Issue
Block a user