mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-12 10:30:28 +00:00
Change: [Script] Use economy time for ScriptDate
This commit is contained in:
parent
704e871a0e
commit
02c00f3e3e
@ -9,7 +9,7 @@
|
||||
|
||||
#include "../../stdafx.h"
|
||||
#include "script_date.hpp"
|
||||
#include "../../timer/timer_game_calendar.h"
|
||||
#include "../../timer/timer_game_economy.h"
|
||||
|
||||
#include <time.h>
|
||||
|
||||
@ -22,14 +22,14 @@
|
||||
|
||||
/* static */ ScriptDate::Date ScriptDate::GetCurrentDate()
|
||||
{
|
||||
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);
|
||||
::TimerGameEconomy::YearMonthDay ymd = ::TimerGameEconomy::ConvertDateToYMD(date);
|
||||
return ymd.year.base();
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@
|
||||
{
|
||||
if (date < 0) return DATE_INVALID;
|
||||
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
::TimerGameEconomy::YearMonthDay ymd = ::TimerGameEconomy::ConvertDateToYMD(date);
|
||||
return ymd.month + 1;
|
||||
}
|
||||
|
||||
@ -45,7 +45,7 @@
|
||||
{
|
||||
if (date < 0) return DATE_INVALID;
|
||||
|
||||
::TimerGameCalendar::YearMonthDay ymd = ::TimerGameCalendar::ConvertDateToYMD(date);
|
||||
::TimerGameEconomy::YearMonthDay ymd = ::TimerGameEconomy::ConvertDateToYMD(date);
|
||||
return ymd.day;
|
||||
}
|
||||
|
||||
@ -53,9 +53,9 @@
|
||||
{
|
||||
if (month < 1 || month > 12) return DATE_INVALID;
|
||||
if (day_of_month < 1 || day_of_month > 31) return DATE_INVALID;
|
||||
if (year < 0 || year > CalendarTime::MAX_YEAR) return DATE_INVALID;
|
||||
if (year < 0 || year > EconomyTime::MAX_YEAR) return DATE_INVALID;
|
||||
|
||||
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()
|
||||
|
@ -11,7 +11,7 @@
|
||||
#define SCRIPT_DATE_HPP
|
||||
|
||||
#include "script_object.hpp"
|
||||
#include "../../timer/timer_game_calendar.h"
|
||||
#include "../../timer/timer_game_economy.h"
|
||||
|
||||
/**
|
||||
* Class that handles all date related (calculation) functions.
|
||||
@ -31,7 +31,7 @@ public:
|
||||
* compose valid date values for a known year, month and day.
|
||||
*/
|
||||
enum Date {
|
||||
DATE_INVALID = ::CalendarTime::INVALID_DATE.base(), ///< A value representing an invalid date.
|
||||
DATE_INVALID = ::EconomyTime::INVALID_DATE.base(), ///< A value representing an invalid date.
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user