mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-03-06 06:15:04 +00:00
(svn r5918) -Cleanup: rename ConvertDayToYMD/ConvertYMDToDay as they really convert a Date to/from a YearMonthDay.
-Cleanup: swap ConvertDateToYMD's parameters to make the order consistent with the name of the function.
This commit is contained in:
parent
08fd0bed1f
commit
1cc6e186f0
@ -36,7 +36,7 @@ void DrawAircraftPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
const Engine *e = GetEngine(engine_number);
|
||||
CargoID cargo;
|
||||
YearMonthDay ymd;
|
||||
ConvertDayToYMD(&ymd, e->intro_date);
|
||||
ConvertDateToYMD(e->intro_date, &ymd);
|
||||
|
||||
/* Purchase cost - Max speed */
|
||||
SetDParam(0, avi->base_cost * (_price.aircraft_base>>3)>>5);
|
||||
|
10
date.c
10
date.c
@ -23,7 +23,7 @@ void SetDate(Date date)
|
||||
YearMonthDay ymd;
|
||||
|
||||
_date = date;
|
||||
ConvertDayToYMD(&ymd, date);
|
||||
ConvertDateToYMD(date, &ymd);
|
||||
_cur_year = ymd.year;
|
||||
_cur_month = ymd.month;
|
||||
#ifdef ENABLE_NETWORK
|
||||
@ -71,7 +71,7 @@ static const uint16 _accum_days_for_month[] = {
|
||||
};
|
||||
|
||||
|
||||
void ConvertDayToYMD(YearMonthDay *ymd, Date date)
|
||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd)
|
||||
{
|
||||
uint yr = date / (365 + 365 + 365 + 366);
|
||||
uint rem = date % (365 + 365 + 365 + 366);
|
||||
@ -101,7 +101,7 @@ void ConvertDayToYMD(YearMonthDay *ymd, Date date)
|
||||
* @param month is a number between 0..11
|
||||
* @param day is a number between 1..31
|
||||
*/
|
||||
uint ConvertYMDToDay(Year year, Month month, Day day)
|
||||
Date ConvertYMDToDate(Year year, Month month, Day day)
|
||||
{
|
||||
uint rem;
|
||||
|
||||
@ -147,7 +147,7 @@ Date ConvertIntDate(uint date)
|
||||
/* invalid ranges? */
|
||||
if (month >= 12 || !IS_INT_INSIDE(day, 1, 31 + 1)) return (Date)-1;
|
||||
|
||||
return ConvertYMDToDay(year, month, day);
|
||||
return ConvertYMDToDate(year, month, day);
|
||||
}
|
||||
|
||||
|
||||
@ -246,7 +246,7 @@ void IncreaseDate(void)
|
||||
}
|
||||
|
||||
/* check if we entered a new month? */
|
||||
ConvertDayToYMD(&ymd, _date);
|
||||
ConvertDateToYMD(_date, &ymd);
|
||||
if (ymd.month == _cur_month) return;
|
||||
_cur_month = ymd.month;
|
||||
|
||||
|
4
date.h
4
date.h
@ -30,6 +30,6 @@ extern DateFract _date_fract;
|
||||
|
||||
|
||||
void SetDate(Date date);
|
||||
void ConvertDayToYMD(YearMonthDay *ymd, Date date);
|
||||
uint ConvertYMDToDay(Year year, Month month, Day day);
|
||||
void ConvertDateToYMD(Date date, YearMonthDay *ymd);
|
||||
Date ConvertYMDToDate(Year year, Month month, Day day);
|
||||
Date ConvertIntDate(uint date);
|
||||
|
@ -1004,7 +1004,7 @@ static void ToolbarScenDateBackward(Window *w)
|
||||
HandleButtonClick(w, 6);
|
||||
InvalidateWidget(w, 5);
|
||||
|
||||
if (_date > MinDate) SetDate(ConvertYMDToDay(_cur_year - 1, 0, 1));
|
||||
if (_date > MinDate) SetDate(ConvertYMDToDate(_cur_year - 1, 0, 1));
|
||||
}
|
||||
_left_button_clicked = false;
|
||||
}
|
||||
@ -1016,7 +1016,7 @@ static void ToolbarScenDateForward(Window *w)
|
||||
HandleButtonClick(w, 7);
|
||||
InvalidateWidget(w, 5);
|
||||
|
||||
if (_date < MaxDate) SetDate(ConvertYMDToDay(_cur_year + 1, 0, 1));
|
||||
if (_date < MaxDate) SetDate(ConvertYMDToDate(_cur_year + 1, 0, 1));
|
||||
}
|
||||
_left_button_clicked = false;
|
||||
}
|
||||
|
@ -1675,11 +1675,11 @@ extern void EnginesMonthlyLoop(void);
|
||||
static int32 ClickChangeDateCheat(int32 p1, int32 p2)
|
||||
{
|
||||
YearMonthDay ymd;
|
||||
ConvertDayToYMD(&ymd, _date);
|
||||
ConvertDateToYMD(_date, &ymd);
|
||||
|
||||
if ((BASE_YEAR + ymd.year == MIN_YEAR && p2 == -1) || (BASE_YEAR + ymd.year == MAX_YEAR && p2 == 1)) return _cur_year;
|
||||
|
||||
SetDate(ConvertYMDToDay(_cur_year + p2, ymd.month, ymd.day));
|
||||
SetDate(ConvertYMDToDate(_cur_year + p2, ymd.month, ymd.day));
|
||||
EnginesMonthlyLoop();
|
||||
SetWindowDirty(FindWindowById(WC_STATUS_BAR, 0));
|
||||
return _cur_year;
|
||||
|
@ -33,7 +33,7 @@ void DrawRoadVehPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
const Engine *e = GetEngine(engine_number);
|
||||
bool refittable = (_engine_info[engine_number].refit_mask != 0);
|
||||
YearMonthDay ymd;
|
||||
ConvertDayToYMD(&ymd, e->intro_date);
|
||||
ConvertDateToYMD(e->intro_date, &ymd);
|
||||
|
||||
/* Purchase cost - Max speed */
|
||||
SetDParam(0, rvi->base_cost * (_price.roadveh_base>>3)>>5);
|
||||
|
@ -53,7 +53,7 @@ void DrawShipPurchaseInfo(int x, int y, EngineID engine_number)
|
||||
|
||||
/* Design date - Life length */
|
||||
e = GetEngine(engine_number);
|
||||
ConvertDayToYMD(&ymd, e->intro_date);
|
||||
ConvertDateToYMD(e->intro_date, &ymd);
|
||||
SetDParam(0, BASE_YEAR + ymd.year);
|
||||
SetDParam(1, e->lifelength);
|
||||
DrawString(x,y, STR_PURCHASE_INFO_DESIGNED_LIFE, 0);
|
||||
|
@ -331,7 +331,7 @@ static char *FormatYmdString(char *buff, uint16 number)
|
||||
const char *src;
|
||||
YearMonthDay ymd;
|
||||
|
||||
ConvertDayToYMD(&ymd, number);
|
||||
ConvertDateToYMD(number, &ymd);
|
||||
|
||||
for (src = GetStringPtr(ymd.day + STR_01AC_1ST - 1); (*buff++ = *src++) != '\0';) {}
|
||||
buff[-1] = ' ';
|
||||
@ -347,7 +347,7 @@ static char *FormatMonthAndYear(char *buff, uint16 number)
|
||||
const char *src;
|
||||
YearMonthDay ymd;
|
||||
|
||||
ConvertDayToYMD(&ymd, number);
|
||||
ConvertDateToYMD(number, &ymd);
|
||||
|
||||
for (src = GetStringPtr(STR_MONTH_JAN + ymd.month); (*buff++ = *src++) != '\0';) {}
|
||||
buff[-1] = ' ';
|
||||
@ -359,7 +359,7 @@ static char *FormatTinyDate(char *buff, uint16 number)
|
||||
{
|
||||
YearMonthDay ymd;
|
||||
|
||||
ConvertDayToYMD(&ymd, number);
|
||||
ConvertDateToYMD(number, &ymd);
|
||||
buff += sprintf(buff, " %02i-%02i-%04i", ymd.day, ymd.month + 1, BASE_YEAR + ymd.year);
|
||||
|
||||
return buff;
|
||||
|
@ -84,7 +84,7 @@ static void DrawSubsidiesWindow(const Window *w)
|
||||
|
||||
DrawWindowWidgets(w);
|
||||
|
||||
ConvertDayToYMD(&ymd, _date);
|
||||
ConvertDateToYMD(_date, &ymd);
|
||||
|
||||
y = 15;
|
||||
x = 1;
|
||||
|
@ -34,7 +34,7 @@ void DrawTrainEnginePurchaseInfo(int x, int y, EngineID engine_number)
|
||||
const Engine *e = GetEngine(engine_number);
|
||||
int multihead = (rvi->flags&RVI_MULTIHEAD?1:0);
|
||||
YearMonthDay ymd;
|
||||
ConvertDayToYMD(&ymd, e->intro_date);
|
||||
ConvertDateToYMD(e->intro_date, &ymd);
|
||||
|
||||
/* Purchase Cost - Engine weight */
|
||||
SetDParam(0, rvi->base_cost * (_price.build_railvehicle >> 3) >> 5);
|
||||
|
Loading…
Reference in New Issue
Block a user