Time in minutes is no longer scaled by day length.
Time in minutes now based on the existing date ticks * the day length, plus the tick skip counter, instead of just the date ticks. Change the format of the {DATE_WALLCLOCK_*} string params to use date ticks scaled by the day length, as above. Update status bar clock.
This commit is contained in:
@@ -16,6 +16,7 @@ typedef int32 Date; ///< The type to store our dates in
|
|||||||
typedef uint16 DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover
|
typedef uint16 DateFract; ///< The fraction of a date we're in, i.e. the number of ticks since the last date changeover
|
||||||
typedef int32 Ticks; ///< The type to store ticks in
|
typedef int32 Ticks; ///< The type to store ticks in
|
||||||
typedef int32 DateTicks; ///< The type to store dates in when tick-precision is required
|
typedef int32 DateTicks; ///< The type to store dates in when tick-precision is required
|
||||||
|
typedef int64 DateTicksScaled; ///< The type to store dates scaled by the day length factor in when tick-precision is required
|
||||||
typedef int32 Minutes; ///< The type to store minutes in
|
typedef int32 Minutes; ///< The type to store minutes in
|
||||||
|
|
||||||
typedef int32 Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0.
|
typedef int32 Year; ///< Type for the year, note: 0 based, i.e. starts at the year 0.
|
||||||
@@ -32,7 +33,9 @@ static const int DAY_TICKS = 74; ///< ticks per day
|
|||||||
static const int DAYS_IN_YEAR = 365; ///< days per year
|
static const int DAYS_IN_YEAR = 365; ///< days per year
|
||||||
static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
|
static const int DAYS_IN_LEAP_YEAR = 366; ///< sometimes, you need one day more...
|
||||||
|
|
||||||
#define DATE_UNIT_SIZE (_settings_client.gui.time_in_minutes ? _settings_client.gui.ticks_per_minute : DAY_TICKS)
|
#define CURRENT_SCALED_TICKS (((((DateTicksScaled)_date * DAY_TICKS) + _date_fract) * _settings_game.economy.day_length_factor) + _tick_skip_counter)
|
||||||
|
|
||||||
|
#define DATE_UNIT_SIZE (_settings_client.gui.time_in_minutes ? _settings_client.gui.ticks_per_minute : (DAY_TICKS * _settings_game.economy.day_length_factor))
|
||||||
|
|
||||||
static const int STATION_RATING_TICKS = 185; ///< cycle duration for updating station rating
|
static const int STATION_RATING_TICKS = 185; ///< cycle duration for updating station rating
|
||||||
static const int STATION_ACCEPTANCE_TICKS = 250; ///< cycle duration for updating station acceptance
|
static const int STATION_ACCEPTANCE_TICKS = 250; ///< cycle duration for updating station acceptance
|
||||||
@@ -111,7 +114,7 @@ static const Year MAX_YEAR = 5000000;
|
|||||||
#define MINUTES_DATE(day, hour, minute) ((day * 1440) + (hour * 60) + minute)
|
#define MINUTES_DATE(day, hour, minute) ((day * 1440) + (hour * 60) + minute)
|
||||||
|
|
||||||
/** Get the current date in minutes */
|
/** Get the current date in minutes */
|
||||||
#define CURRENT_MINUTE ((((DateTicks)_date * DAY_TICKS) + _date_fract) / _settings_client.gui.ticks_per_minute)
|
#define CURRENT_MINUTE (CURRENT_SCALED_TICKS / _settings_client.gui.ticks_per_minute)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data structure to convert between Date and triplet (year, month, and day).
|
* Data structure to convert between Date and triplet (year, month, and day).
|
||||||
|
@@ -139,7 +139,7 @@ struct StatusBarWindow : Window {
|
|||||||
switch (widget) {
|
switch (widget) {
|
||||||
case WID_S_LEFT:
|
case WID_S_LEFT:
|
||||||
/* Draw the date */
|
/* Draw the date */
|
||||||
SetDParam(0, ((DateTicks)_date * DAY_TICKS) + _date_fract);
|
SetDParam(0, CURRENT_SCALED_TICKS);
|
||||||
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, STR_WHITE_DATE_WALLCLOCK_LONG, TC_FROMSTRING, SA_HOR_CENTER);
|
DrawString(r.left + WD_FRAMERECT_LEFT, r.right - WD_FRAMERECT_RIGHT, r.top + WD_FRAMERECT_TOP, STR_WHITE_DATE_WALLCLOCK_LONG, TC_FROMSTRING, SA_HOR_CENTER);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -1229,7 +1229,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
|||||||
if (_settings_client.gui.time_in_minutes) {
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
||||||
} else {
|
} else {
|
||||||
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG) / DAY_TICKS, last, next_substr_case_index);
|
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_LONG) / (DAY_TICKS * _settings_game.economy.day_length_factor), last, next_substr_case_index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1238,7 +1238,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
|||||||
if (_settings_client.gui.time_in_minutes) {
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT), last, _settings_client.gui.date_with_time, next_substr_case_index);
|
||||||
} else {
|
} else {
|
||||||
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT) / DAY_TICKS, last, next_substr_case_index);
|
buff = FormatYmdString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_SHORT) / (DAY_TICKS * _settings_game.economy.day_length_factor), last, next_substr_case_index);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1247,7 +1247,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
|||||||
if (_settings_client.gui.time_in_minutes) {
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY), last, false, next_substr_case_index);
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY), last, false, next_substr_case_index);
|
||||||
} else {
|
} else {
|
||||||
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY) / DAY_TICKS, STR_FORMAT_DATE_TINY, last);
|
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_TINY) / (DAY_TICKS * _settings_game.economy.day_length_factor), STR_FORMAT_DATE_TINY, last);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1256,7 +1256,7 @@ static char *FormatString(char *buff, const char *str_arg, StringParameters *arg
|
|||||||
if (_settings_client.gui.time_in_minutes) {
|
if (_settings_client.gui.time_in_minutes) {
|
||||||
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO), last, false, next_substr_case_index);
|
buff = FormatWallClockString(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO), last, false, next_substr_case_index);
|
||||||
} else {
|
} else {
|
||||||
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO) / DAY_TICKS, STR_FORMAT_DATE_ISO, last);
|
buff = FormatTinyOrISODate(buff, args->GetInt64(SCC_DATE_WALLCLOCK_ISO) / (DAY_TICKS * _settings_game.economy.day_length_factor), STR_FORMAT_DATE_ISO, last);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user