Skip to content

Commit

Permalink
Fix: [Script] ScriptSubsidy::GetExpireDate should return an economy-d…
Browse files Browse the repository at this point in the history
…ate (#12372)
  • Loading branch information
frosch123 committed Mar 28, 2024
1 parent 8fb7d74 commit 907cb4f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/script/api/script_subsidy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,13 @@
{
if (!IsValidSubsidy(subsidy_id)) return ScriptDate::DATE_INVALID;

int year = ScriptDate::GetYear(ScriptDate::GetCurrentDate());
int month = ScriptDate::GetMonth(ScriptDate::GetCurrentDate());
TimerGameEconomy::YearMonthDay ymd = TimerGameEconomy::ConvertDateToYMD(TimerGameEconomy::date);
ymd.day = 1;
auto m = ymd.month + ::Subsidy::Get(subsidy_id)->remaining;
ymd.month = (m - 1) % 12 + 1;
ymd.year += (m - 1) / 12;

month += ::Subsidy::Get(subsidy_id)->remaining;

year += (month - 1) / 12;
month = ((month - 1) % 12) + 1;

return ScriptDate::GetDate(year, month, 1);
return (ScriptDate::Date)TimerGameEconomy::ConvertYMDToDate(ymd.year, ymd.month, ymd.day).base();
}

/* static */ CargoID ScriptSubsidy::GetCargoType(SubsidyID subsidy_id)
Expand Down

0 comments on commit 907cb4f

Please sign in to comment.