diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp index 9a1b9db2bf..b8e90c0c4e 100644 --- a/src/build_vehicle_gui.cpp +++ b/src/build_vehicle_gui.cpp @@ -1128,8 +1128,7 @@ void TestedEngineDetails::FillDefaultCapacities(const Engine *e) int DrawVehiclePurchaseInfo(int left, int right, int y, EngineID engine_number, TestedEngineDetails &te) { const Engine *e = Engine::Get(engine_number); - YearMonthDay ymd; - ConvertDateToYMD(e->intro_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(e->intro_date); bool refittable = IsArticulatedVehicleRefittable(engine_number); bool articulated_cargo = false; diff --git a/src/cheat_gui.cpp b/src/cheat_gui.cpp index ff654e38b0..b9782d34f6 100644 --- a/src/cheat_gui.cpp +++ b/src/cheat_gui.cpp @@ -108,8 +108,7 @@ static int32 ClickChangeDateCheat(int32 p1, int32 p2) p1 = Clamp(p1, MIN_YEAR, MAX_YEAR); if (p1 == _cur_year) return _cur_year; - YearMonthDay ymd; - ConvertDateToYMD(_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(_date); Date new_date = ConvertYMDToDate(p1, ymd.month, ymd.day); /* Shift cached dates. */ diff --git a/src/command.cpp b/src/command.cpp index f006eea4af..517e63f023 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -665,8 +665,7 @@ static void DumpSubCommandLogEntry(char *&buffer, const char *last, const Comman return (entry.log_flags & CLEF_SCRIPT_ASYNC) ? 'A' : 'a'; }; - YearMonthDay ymd; - ConvertDateToYMD(entry.date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(entry.date); buffer += seprintf(buffer, last, "%4i-%02i-%02i, %2i, %3i", ymd.year, ymd.month + 1, ymd.day, entry.date_fract, entry.tick_skip_counter); if (_networking) { buffer += seprintf(buffer, last, ", %08X", entry.frame_counter); diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index ae02a92f69..2ce1bd52ce 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -1060,6 +1060,20 @@ CommandCost CmdSetCompanyManagerFace(TileIndex tile, DoCommandFlag flags, uint32 return CommandCost(); } +/** + * Update liveries for a company. This is called when the LS_DEFAULT scheme is changed, to update schemes with colours + * set to default. + * @param c Company to update. + */ +void UpdateCompanyLiveries(Company *c) +{ + for (int i = 1; i < LS_END; i++) { + if (!HasBit(c->livery[i].in_use, 0)) c->livery[i].colour1 = c->livery[LS_DEFAULT].colour1; + if (!HasBit(c->livery[i].in_use, 1)) c->livery[i].colour2 = c->livery[LS_DEFAULT].colour2; + } + UpdateCompanyGroupLiveries(c); +} + /** * Change the company's company-colour * @param tile unused @@ -1100,9 +1114,7 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, /* If setting the first colour of the default scheme, adjust the * original and cached company colours too. */ if (scheme == LS_DEFAULT) { - for (int i = 1; i < LS_END; i++) { - if (!HasBit(c->livery[i].in_use, 0)) c->livery[i].colour1 = colour; - } + UpdateCompanyLiveries(c); _company_colours[_current_company] = colour; c->colour = colour; CompanyAdminUpdate(c); @@ -1113,9 +1125,7 @@ CommandCost CmdSetCompanyColour(TileIndex tile, DoCommandFlag flags, uint32 p1, c->livery[scheme].colour2 = colour; if (scheme == LS_DEFAULT) { - for (int i = 1; i < LS_END; i++) { - if (!HasBit(c->livery[i].in_use, 1)) c->livery[i].colour2 = colour; - } + UpdateCompanyGroupLiveries(c); } } diff --git a/src/company_func.h b/src/company_func.h index a6dd57019d..5093ad92ab 100644 --- a/src/company_func.h +++ b/src/company_func.h @@ -24,6 +24,7 @@ void ShowBuyCompanyDialog(CompanyID company, bool hostile_takeover); void CompanyAdminUpdate(const Company *company); void CompanyAdminBankrupt(CompanyID company_id); void UpdateLandscapingLimits(); +void UpdateCompanyLiveries(Company *c); bool CheckCompanyHasMoney(CommandCost &cost); void SubtractMoneyFromCompany(const CommandCost& cost); diff --git a/src/company_gui.cpp b/src/company_gui.cpp index 89d903a0b4..44442d3264 100644 --- a/src/company_gui.cpp +++ b/src/company_gui.cpp @@ -931,18 +931,18 @@ public: int y = ir.top; /* Helper function to draw livery info. */ - auto draw_livery = [&](StringID str, const Livery &liv, bool sel, bool def, int indent) { + auto draw_livery = [&](StringID str, const Livery &livery, bool is_selected, bool is_default_scheme, int indent) { /* Livery Label. */ - DrawString(sch.left + (rtl ? 0 : indent), sch.right - (rtl ? indent : 0), y + text_offs, str, sel ? TC_WHITE : TC_BLACK); + DrawString(sch.left + (rtl ? 0 : indent), sch.right - (rtl ? indent : 0), y + text_offs, str, is_selected ? TC_WHITE : TC_BLACK); /* Text below the first dropdown. */ - DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour1), pri_squ.left, y + square_offs); - DrawString(pri.left, pri.right, y + text_offs, (def || HasBit(liv.in_use, 0)) ? STR_COLOUR_DARK_BLUE + liv.colour1 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD); + DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(livery.colour1), pri_squ.left, y + square_offs); + DrawString(pri.left, pri.right, y + text_offs, (is_default_scheme || HasBit(livery.in_use, 0)) ? STR_COLOUR_DARK_BLUE + livery.colour1 : STR_COLOUR_DEFAULT, is_selected ? TC_WHITE : TC_GOLD); /* Text below the second dropdown. */ if (sec.right > sec.left) { // Second dropdown has non-zero size. - DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(liv.colour2), sec_squ.left, y + square_offs); - DrawString(sec.left, sec.right, y + text_offs, (def || HasBit(liv.in_use, 1)) ? STR_COLOUR_DARK_BLUE + liv.colour2 : STR_COLOUR_DEFAULT, sel ? TC_WHITE : TC_GOLD); + DrawSprite(SPR_SQUARE, GENERAL_SPRITE_COLOUR(livery.colour2), sec_squ.left, y + square_offs); + DrawString(sec.left, sec.right, y + text_offs, (is_default_scheme || HasBit(livery.in_use, 1)) ? STR_COLOUR_DARK_BLUE + livery.colour2 : STR_COLOUR_DEFAULT, is_selected ? TC_WHITE : TC_GOLD); } y += this->line_height; @@ -962,9 +962,8 @@ public: uint max = static_cast(std::min(this->vscroll->GetPosition() + this->vscroll->GetCapacity(), this->groups.size())); for (uint i = this->vscroll->GetPosition(); i < max; ++i) { const Group *g = this->groups[i]; - const bool livery_set = HasBit(g->livery.in_use, 0); SetDParam(0, g->index); - draw_livery(STR_GROUP_NAME, livery_set ? g->livery : c->livery[LS_DEFAULT], this->sel == g->index, livery_set, this->indents[i] * WidgetDimensions::scaled.hsep_indent); + draw_livery(STR_GROUP_NAME, g->livery, this->sel == g->index, false, this->indents[i] * WidgetDimensions::scaled.hsep_indent); } if (this->vscroll->GetCount() == 0) { diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index b8337ec04f..2a58217cdd 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2738,10 +2738,8 @@ DEF_CONSOLE_CMD(ConDumpLinkgraphJobs) IConsolePrintF(CC_DEFAULT, PRINTF_SIZE " link graph jobs", LinkGraphJob::GetNumItems()); for (const LinkGraphJob *lgj : LinkGraphJob::Iterate()) { - YearMonthDay start_ymd; - ConvertDateToYMD(lgj->StartDateTicks().ToDate(), &start_ymd); - YearMonthDay join_ymd; - ConvertDateToYMD(lgj->JoinDateTicks().ToDate(), &join_ymd); + YearMonthDay start_ymd = ConvertDateToYMD(lgj->StartDateTicks().ToDate()); + YearMonthDay join_ymd = ConvertDateToYMD(lgj->JoinDateTicks().ToDate()); IConsolePrintF(CC_DEFAULT, " Job: %5u, nodes: %u, cost: " OTTD_PRINTF64U ", start: (%u, %4i-%02i-%02i, %i), end: (%u, %4i-%02i-%02i, %i), duration: %u", lgj->index, lgj->Graph().Size(), lgj->Graph().CalculateCostEstimate(), lgj->StartDateTicks().base(), start_ymd.year, start_ymd.month + 1, start_ymd.day, lgj->StartDateTicks().ToDateFractRemainder(), diff --git a/src/crashlog.cpp b/src/crashlog.cpp index c383cf919b..4015a5d9b1 100644 --- a/src/crashlog.cpp +++ b/src/crashlog.cpp @@ -484,8 +484,7 @@ char *CrashLog::LogRecentNews(char *buffer, const char *last) const int i = 0; for (NewsItem *news = _latest_news; i < 32 && news != nullptr; news = news->prev, i++) { - YearMonthDay ymd; - ConvertDateToYMD(news->date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(news->date); buffer += seprintf(buffer, last, "(%i-%02i-%02i) StringID: %u, Type: %u, Ref1: %u, %u, Ref2: %u, %u\n", ymd.year, ymd.month + 1, ymd.day, news->string_id, news->type, news->reftype1, news->ref1, news->reftype2, news->ref2); @@ -665,8 +664,7 @@ char *CrashLog::FillDesyncCrashLog(char *buffer, const char *last, const DesyncE extern uint8 _last_sync_tick_skip_counter; extern uint32 _last_sync_frame_counter; - YearMonthDay ymd; - ConvertDateToYMD(_last_sync_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(_last_sync_date); buffer += seprintf(buffer, last, "Last sync at: %i-%02i-%02i (%i, %i), %08X\n", ymd.year, ymd.month + 1, ymd.day, _last_sync_date_fract, _last_sync_tick_skip_counter, _last_sync_frame_counter); } @@ -731,8 +729,7 @@ char *CrashLog::FillInconsistencyLog(char *buffer, const char *last, const Incon extern uint8 _last_sync_tick_skip_counter; extern uint32 _last_sync_frame_counter; - YearMonthDay ymd; - ConvertDateToYMD(_last_sync_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(_last_sync_date); buffer += seprintf(buffer, last, "Last sync at: %i-%02i-%02i (%i, %i), %08X\n", ymd.year, ymd.month + 1, ymd.day, _last_sync_date_fract, _last_sync_tick_skip_counter, _last_sync_frame_counter); } diff --git a/src/date.cpp b/src/date.cpp index 1f4c628d12..34dd29dd36 100644 --- a/src/date.cpp +++ b/src/date.cpp @@ -90,11 +90,9 @@ void SetDate(Date date, DateFract fract, bool preserve_scaled_ticks) { assert(fract < DAY_TICKS); - YearMonthDay ymd; - _date = date; _date_fract = fract; - ConvertDateToYMD(date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(date); _cur_date_ymd = ymd; if (preserve_scaled_ticks) { RebaseScaledDateTicksBase(); @@ -153,7 +151,7 @@ static const uint16 _accum_days_for_month[] = { * @param date the date to convert from * @param ymd the year, month and day to write to */ -void ConvertDateToYMD(Date date, YearMonthDay *ymd) +YearMonthDay ConvertDateToYMD(Date date) { /* Year determination in multiple steps to account for leap * years. First do the large steps, then the smaller ones. @@ -195,11 +193,14 @@ void ConvertDateToYMD(Date date, YearMonthDay *ymd) /* Skip the 29th of February in non-leap years */ if (!IsLeapYear(yr) && rem >= ACCUM_MAR - 1) rem++; - ymd->year = yr; + YearMonthDay ymd; + ymd.year = yr; x = _month_date_from_year_day[rem]; - ymd->month = x >> 5; - ymd->day = x & 0x1F; + ymd.month = x >> 5; + ymd.day = x & 0x1F; + + return ymd; } /** @@ -345,8 +346,7 @@ void IncreaseDate() /* increase day counter */ _date++; - YearMonthDay ymd; - ConvertDateToYMD(_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(_date); /* check if we entered a new month? */ bool new_month = ymd.month != _cur_date_ymd.month; diff --git a/src/date_func.h b/src/date_func.h index 9e5a536868..ecfaea1523 100644 --- a/src/date_func.h +++ b/src/date_func.h @@ -29,7 +29,7 @@ extern DateFract _game_load_date_fract; extern uint8 _game_load_tick_skip_counter; void SetDate(Date date, DateFract fract, bool preserve_scaled_ticks = true); -void ConvertDateToYMD(Date date, YearMonthDay *ymd); +YearMonthDay ConvertDateToYMD(Date date); Date ConvertYMDToDate(Year year, Month month, Day day); void SetScaledTickVariables(); diff --git a/src/date_gui.cpp b/src/date_gui.cpp index 1353cb1697..efc9156010 100644 --- a/src/date_gui.cpp +++ b/src/date_gui.cpp @@ -57,7 +57,7 @@ struct SetDateWindow : Window { this->FinishInitNested(window_number); if (initial_date == 0) initial_date = _date; - ConvertDateToYMD(initial_date, &this->date); + this->date = ConvertDateToYMD(initial_date); this->date.year = Clamp(this->date.year, min_year, max_year); } diff --git a/src/debug.cpp b/src/debug.cpp index e83d3b8c8a..07d47313af 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -399,13 +399,11 @@ void ClearDesyncMsgLog() char *DumpDesyncMsgLog(char *buffer, const char *last) { buffer = _desync_msg_log.Dump(buffer, last, "Desync Msg Log", [](int display_num, char *buffer, const char *last, const DesyncMsgLogEntry &entry) -> int { - YearMonthDay ymd; - ConvertDateToYMD(entry.date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(entry.date); return seprintf(buffer, last, "%5u | %4i-%02i-%02i, %2i, %3i | %s\n", display_num, ymd.year, ymd.month + 1, ymd.day, entry.date_fract, entry.tick_skip_counter, entry.msg.c_str()); }); buffer = _remote_desync_msg_log.Dump(buffer, last, "Remote Client Desync Msg Log", [](int display_num, char *buffer, const char *last, const DesyncMsgLogEntry &entry) -> int { - YearMonthDay ymd; - ConvertDateToYMD(entry.date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(entry.date); return seprintf(buffer, last, "%5u | Client %5u | %4i-%02i-%02i, %2i, %3i | %s\n", display_num, entry.src_id, ymd.year, ymd.month + 1, ymd.day, entry.date_fract, entry.tick_skip_counter, entry.msg.c_str()); }); return buffer; diff --git a/src/engine.cpp b/src/engine.cpp index 5ec8e7a385..91a1973f4f 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -651,8 +651,7 @@ static void ClearLastVariant(EngineID engine_id, VehicleType type) static void RetireEngineIfPossible(Engine *e, int age_threshold) { if (_settings_game.vehicle.no_expire_vehicles_after > 0) { - YearMonthDay ymd; - ConvertDateToYMD(e->intro_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(e->intro_date); if ((ymd.year * 12) + ymd.month + age_threshold >= _settings_game.vehicle.no_expire_vehicles_after * 12) return; } @@ -725,8 +724,7 @@ void SetYearEngineAgingStops() if (e->type == VEH_TRAIN && e->u.rail.railveh_type == RAILVEH_WAGON) continue; /* Base year ending date on half the model life */ - YearMonthDay ymd; - ConvertDateToYMD(ei->base_intro + (static_cast(ei->lifelength) * DAYS_IN_LEAP_YEAR) / 2, &ymd); + YearMonthDay ymd = ConvertDateToYMD(ei->base_intro + (static_cast(ei->lifelength) * DAYS_IN_LEAP_YEAR) / 2); _year_engine_aging_stops = std::max(_year_engine_aging_stops, ymd.year); } @@ -779,14 +777,25 @@ void StartupOneEngine(Engine *e, Date aging_date, uint32 seed, Date no_introduce e->type ^ e->GetGRFID()); - r = Random(); - e->reliability_start = GB(r, 16, 14) + 0x7AE0; - e->reliability_max = GB(r, 0, 14) + 0xBFFF; + /* Base reliability defined as a percentage of UINT16_MAX. */ + const uint16_t RELIABILITY_START = UINT16_MAX * 48 / 100; + const uint16_t RELIABILITY_MAX = UINT16_MAX * 75 / 100; + const uint16_t RELIABILITY_FINAL = UINT16_MAX * 25 / 100; + + static_assert(RELIABILITY_START == 0x7AE0); + static_assert(RELIABILITY_MAX == 0xBFFF); + static_assert(RELIABILITY_FINAL == 0x3FFF); r = Random(); - e->reliability_final = GB(r, 16, 14) + 0x3FFF; + /* 14 bits gives a value between 0 and 16383, which is up to an additional 25%p reliability on top of the base reliability. */ + e->reliability_start = GB(r, 16, 14) + RELIABILITY_START; + e->reliability_max = GB(r, 0, 14) + RELIABILITY_MAX; + + r = Random(); + e->reliability_final = GB(r, 16, 14) + RELIABILITY_FINAL; + e->duration_phase_1 = GB(r, 0, 5) + 7; - e->duration_phase_2 = GB(r, 5, 4) + ei->base_life * 12 - 96; + e->duration_phase_2 = std::max(0, int(GB(r, 5, 4)) + ei->base_life * 12 - 96); e->duration_phase_3 = GB(r, 9, 7) + 120; RestoreRandomSeeds(saved_seeds); diff --git a/src/event_logs.cpp b/src/event_logs.cpp index 2b4bde0417..0a6399466b 100644 --- a/src/event_logs.cpp +++ b/src/event_logs.cpp @@ -90,8 +90,7 @@ char *DumpSpecialEventsLog(char *buffer, const char *last) } const SpecialEventLogEntry &entry = _special_event_log.log[log_index]; - YearMonthDay ymd; - ConvertDateToYMD(entry.date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(entry.date); buffer += seprintf(buffer, last, " %3u | %4i-%02i-%02i, %2i, %3i | cc: %3u, lc: %3u | %s\n", i, ymd.year, ymd.month + 1, ymd.day, entry.date_fract, entry.tick_skip_counter, (uint) entry.current_company, (uint) entry.local_company, entry.msg.c_str()); } diff --git a/src/group.h b/src/group.h index be019c6daf..9a44863c53 100644 --- a/src/group.h +++ b/src/group.h @@ -117,6 +117,7 @@ void SetTrainGroupID(Train *v, GroupID grp); void UpdateTrainGroupID(Train *v); void RemoveAllGroupsForCompany(const CompanyID company); bool GroupIsInGroup(GroupID search, GroupID group); +void UpdateCompanyGroupLiveries(const Company *c); std::string GenerateAutoNameForVehicleGroup(const Vehicle *v); diff --git a/src/group_cmd.cpp b/src/group_cmd.cpp index 5359f03fb7..badf6d72ad 100644 --- a/src/group_cmd.cpp +++ b/src/group_cmd.cpp @@ -320,26 +320,48 @@ void IterateDescendantsOfGroup(GroupID id_top, F func) /** * Propagate a livery change to a group's children. * @param g Group. + * Propagate a livery change to a group's children, and optionally update cached vehicle colourmaps. + * @param g Group to propagate colours to children. + * @param reset_cache Reset colourmap of vehicles in this group. */ -void PropagateChildLivery(const Group *g) +static void PropagateChildLivery(const Group *g, bool reset_cache) { - /* Company colour data is indirectly cached. */ - for (Vehicle *v : Vehicle::Iterate()) { - if (v->group_id == g->index && (!v->IsGroundVehicle() || v->IsFrontEngine())) { - for (Vehicle *u = v; u != nullptr; u = u->Next()) { - u->colourmap = PAL_NONE; - u->InvalidateNewGRFCache(); - u->InvalidateImageCache(); + if (reset_cache) { + /* Company colour data is indirectly cached. */ + for (Vehicle *v : Vehicle::Iterate()) { + if (v->group_id == g->index && (!v->IsGroundVehicle() || v->IsFrontEngine())) { + for (Vehicle *u = v; u != nullptr; u = u->Next()) { + u->colourmap = PAL_NONE; + u->InvalidateNewGRFCache(); + } } } } - IterateDescendantsOfGroup(g, [&](Group *cg) { - if (!HasBit(cg->livery.in_use, 0)) cg->livery.colour1 = g->livery.colour1; - if (!HasBit(cg->livery.in_use, 1)) cg->livery.colour2 = g->livery.colour2; - }); + for (Group *cg : Group::Iterate()) { + if (cg->parent == g->index) { + if (!HasBit(cg->livery.in_use, 0)) cg->livery.colour1 = g->livery.colour1; + if (!HasBit(cg->livery.in_use, 1)) cg->livery.colour2 = g->livery.colour2; + PropagateChildLivery(cg, reset_cache); + } + } } +/** + * Update group liveries for a company. This is called when the LS_DEFAULT scheme is changed, to update groups with + * colours set to default. + * @param c Company to update. + */ +void UpdateCompanyGroupLiveries(const Company *c) +{ + for (Group *g : Group::Iterate()) { + if (g->owner == c->index && g->parent == INVALID_GROUP) { + if (!HasBit(g->livery.in_use, 0)) g->livery.colour1 = c->livery[LS_DEFAULT].colour1; + if (!HasBit(g->livery.in_use, 1)) g->livery.colour2 = c->livery[LS_DEFAULT].colour2; + PropagateChildLivery(g, false); + } + } +} Group::Group(Owner owner) { @@ -509,12 +531,13 @@ CommandCost CmdAlterGroup(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 GroupStatistics::UpdateAutoreplace(g->owner); if (g->vehicle_type == VEH_TRAIN) ReindexTemplateReplacementsRecursive(); - if (g->livery.in_use == 0) { + if (!HasBit(g->livery.in_use, 0) || !HasBit(g->livery.in_use, 1)) { + /* Update livery with new parent's colours if either colour is default. */ const Livery *livery = GetParentLivery(g); - g->livery.colour1 = livery->colour1; - g->livery.colour2 = livery->colour2; + if (!HasBit(g->livery.in_use, 0)) g->livery.colour1 = livery->colour1; + if (!HasBit(g->livery.in_use, 1)) g->livery.colour2 = livery->colour2; - PropagateChildLivery(g); + PropagateChildLivery(g, true); MarkWholeScreenDirty(); } } @@ -852,7 +875,7 @@ CommandCost CmdSetGroupLivery(TileIndex tile, DoCommandFlag flags, uint32 p1, ui g->livery.colour2 = colour; } - PropagateChildLivery(g); + PropagateChildLivery(g, true); MarkWholeScreenDirty(); } diff --git a/src/lang/brazilian_portuguese.txt b/src/lang/brazilian_portuguese.txt index ae5ffeb53c..10e5f90af3 100644 --- a/src/lang/brazilian_portuguese.txt +++ b/src/lang/brazilian_portuguese.txt @@ -2197,9 +2197,17 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Exibe es STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Exibir os esquemas de cor de automóveis STR_LIVERY_SHIP_TOOLTIP :{BLACK}Exibir esquemas de cor de embarcação STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Exibir esquemas de cor de aviões +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de trens +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Exibir cores dos grupos de veículos +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Exibir cores de grupos de embarcações +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Exibir cores dos grupos de aeronaves STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Escolha a cor principal para o esquema selecionado. Ctrl+Clique seleciona essa cor para todos os esquemas STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Escolha a cor secundária para o esquema selecionado. Ctrl+Clique seleciona essa cor para todos os esquemas STR_LIVERY_PANEL_TOOLTIP :{BLACK}Selecionar um esquema de cores para mudar, ou múltiplos esquemas com CTRL+clique. Marque a opção para utilizar o esquema +STR_LIVERY_TRAIN_GROUP_EMPTY :Não há grupos de trens configurados +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Não há grupos de veículos configurados +STR_LIVERY_SHIP_GROUP_EMPTY :Não há grupos de embarcações configurados +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Não há grupos de aeronaves configurados ###length 23 STR_LIVERY_DEFAULT :Cores padrão @@ -4654,9 +4662,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Correspo STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Alternar correspondencia de "case" quando comparar mensagens de resgisto da IA contra a sequencia de falhas STR_AI_DEBUG_CONTINUE :{BLACK}Continuar STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Despausar e continuar o AI -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Ver a depuração produzida desta IA +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Ver saída de depuração desta IA STR_AI_GAME_SCRIPT :{BLACK}Game Script -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Checando o log do Game Script +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Verifique o registo do Script de jogo STR_ERROR_AI_NO_AI_FOUND :Nenhuma IA adequada encontrada para carregar.{} Esta IA é falsa e não irá fazer nada.{} Você pode pode baixar várias IA através do sistema de 'Conteúdo Online' STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}Um dos scripts em execução travou. Favor relatar isto ao autor do script com uma captura de tela da Janela de Depuração da I.A./Script do jogo diff --git a/src/lang/danish.txt b/src/lang/danish.txt index 6f51fc9060..af5f1af464 100644 --- a/src/lang/danish.txt +++ b/src/lang/danish.txt @@ -2194,12 +2194,19 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Vis farv STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Vis farveskemaer for køretøjer STR_LIVERY_SHIP_TOOLTIP :{BLACK}Vis farveskemaer for skibe STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Vis farveskemaer for fly +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Vis farver på toggrupper +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Vis farver på vejkøretøjsgrupper +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Vis farver på skibsgrupper +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Vis farverne på flygrupper STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Vælg den primære farve for det valgte farveskema. Ctrl+Click vil sætte denne farve for alle farveskemaer STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Vælg den sekundære farve for det valgte farveskema. Ctrl+Click vil sætte denne farve for alle farveskemaer STR_LIVERY_PANEL_TOOLTIP :{BLACK}Vælg et farveskema, som skal ændres, eller flere farveskemaer vha. CTRL+klik. Klik på boksen for at slå brug af farveskemaet til/fra +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :Der er ikke oprettet grupper af vejkøretøjer +STR_LIVERY_SHIP_GROUP_EMPTY :Der er ikke oprettet skibsgrupper +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :Der er ikke oprettet flygrupper ###length 23 -STR_LIVERY_DEFAULT :Standardfarver +STR_LIVERY_DEFAULT :Standard Livery STR_LIVERY_STEAM :Damplokomotiv STR_LIVERY_DIESEL :Diesellokomotiv STR_LIVERY_ELECTRIC :Elektrisk lokomotiv @@ -4651,7 +4658,7 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Match st STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Vis matchende stort/lille bogstav ved sammenligning af AI log beskeder messages mod teksten STR_AI_DEBUG_CONTINUE :{BLACK}Fortsæt STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Sæt spillet i gang, og start den kunstige intelligens igen -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Se debug output for denne AI +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}Se fejlretningsoutput af denne AI. Ctrl-klik for at åbne i et nyt vindue STR_AI_GAME_SCRIPT :{BLACK}Spil Script STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Tjek SpilScript-loggen diff --git a/src/lang/english_AU.txt b/src/lang/english_AU.txt index 0278f5a4ee..eb94bd140d 100644 --- a/src/lang/english_AU.txt +++ b/src/lang/english_AU.txt @@ -2196,12 +2196,20 @@ STR_LIVERY_TRAIN_TOOLTIP :{BLACK}Show tra STR_LIVERY_ROAD_VEHICLE_TOOLTIP :{BLACK}Show road vehicle colour schemes STR_LIVERY_SHIP_TOOLTIP :{BLACK}Show ship colour schemes STR_LIVERY_AIRCRAFT_TOOLTIP :{BLACK}Show aircraft colour schemes +STR_LIVERY_TRAIN_GROUP_TOOLTIP :{BLACK}Show colours of train groups +STR_LIVERY_ROAD_VEHICLE_GROUP_TOOLTIP :{BLACK}Show colours of road vehicle groups +STR_LIVERY_SHIP_GROUP_TOOLTIP :{BLACK}Show colours of ship groups +STR_LIVERY_AIRCRAFT_GROUP_TOOLTIP :{BLACK}Show colours of aircraft groups STR_LIVERY_PRIMARY_TOOLTIP :{BLACK}Choose the primary colour for the selected scheme. Ctrl+Click will set this colour for every scheme STR_LIVERY_SECONDARY_TOOLTIP :{BLACK}Choose the secondary colour for the selected scheme. Ctrl+Click will set this colour for every scheme STR_LIVERY_PANEL_TOOLTIP :{BLACK}Select a colour scheme to change, or multiple schemes with Ctrl+Click. Click on the box to toggle use of the scheme +STR_LIVERY_TRAIN_GROUP_EMPTY :No train groups are set up +STR_LIVERY_ROAD_VEHICLE_GROUP_EMPTY :No road vehicle groups are set up +STR_LIVERY_SHIP_GROUP_EMPTY :No ship groups are set up +STR_LIVERY_AIRCRAFT_GROUP_EMPTY :No aircraft groups are set up ###length 23 -STR_LIVERY_DEFAULT :Standard Livery +STR_LIVERY_DEFAULT :Default Livery STR_LIVERY_STEAM :Steam Engine STR_LIVERY_DIESEL :Diesel Engine STR_LIVERY_ELECTRIC :Electric Engine @@ -4653,9 +4661,9 @@ STR_AI_DEBUG_MATCH_CASE :{BLACK}Match ca STR_AI_DEBUG_MATCH_CASE_TOOLTIP :{BLACK}Toggle matching case when comparing AI log messages against the break string STR_AI_DEBUG_CONTINUE :{BLACK}Continue STR_AI_DEBUG_CONTINUE_TOOLTIP :{BLACK}Unpause and continue the AI -STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}View debug output of this AI +STR_AI_DEBUG_SELECT_AI_TOOLTIP :{BLACK}View debug output of this AI. Ctrl-Click to open in a new window STR_AI_GAME_SCRIPT :{BLACK}Game Script -STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Check the Game Script log +STR_AI_GAME_SCRIPT_TOOLTIP :{BLACK}Check the Game Script log. Ctrl-Click to open in a new window STR_ERROR_AI_NO_AI_FOUND :No suitable AI found to load.{}This AI is a dummy AI and won't do anything.{}You can download several AIs via the 'Online Content' system STR_ERROR_AI_PLEASE_REPORT_CRASH :{WHITE}One of the running scripts crashed. Please report this to the script author with a screenshot of the AI/Game Script Debug Window diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 1d240e5369..c234fe86e1 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -386,8 +386,7 @@ protected: if (const NWidgetBase *nwid = this->GetWidget(WID_NG_DATE); nwid->current_x != 0) { /* current date */ Rect date = nwid->GetCurrentRect(); - YearMonthDay ymd; - ConvertDateToYMD(cur_item->info.game_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(cur_item->info.game_date); SetDParam(0, ymd.year); DrawString(date.left, date.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER); } @@ -395,9 +394,8 @@ protected: if (const NWidgetBase *nwid = this->GetWidget(WID_NG_YEARS); nwid->current_x != 0) { /* number of years the game is running */ Rect years = nwid->GetCurrentRect(); - YearMonthDay ymd_cur, ymd_start; - ConvertDateToYMD(cur_item->info.game_date, &ymd_cur); - ConvertDateToYMD(cur_item->info.start_date, &ymd_start); + YearMonthDay ymd_cur = ConvertDateToYMD(cur_item->info.game_date); + YearMonthDay ymd_start = ConvertDateToYMD(cur_item->info.start_date); SetDParam(0, ymd_cur.year - ymd_start.year); DrawString(years.left, years.right, y + text_y_offset, STR_JUST_INT, TC_BLACK, SA_HOR_CENTER); } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 8df7e2763c..538785e956 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -2455,15 +2455,12 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) char *NetworkServerDumpClients(char *buffer, const char *last) { for (NetworkClientInfo *ci : NetworkClientInfo::Iterate()) { - YearMonthDay ymd; - ConvertDateToYMD(ci->join_date, &ymd); buffer += seprintf(buffer, last, " #%d: name: '%s', company: %u", ci->client_id, ci->client_name.c_str(), ci->client_playas); if (ci->join_date != 0) { - YearMonthDay ymd; - ConvertDateToYMD(ci->join_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(ci->join_date); buffer += seprintf(buffer, last, ", joined: %4i-%02i-%02i, %i, %i, frame: %08X", ymd.year, ymd.month + 1, ymd.day, ci->join_date_fract, ci->join_tick_skip_counter, ci->join_frame); } diff --git a/src/network/network_survey.cpp b/src/network/network_survey.cpp index 41c148e1fa..3b382f3178 100644 --- a/src/network/network_survey.cpp +++ b/src/network/network_survey.cpp @@ -237,9 +237,7 @@ static void SurveyTimers(nlohmann::json &survey) survey["ticks"] = _scaled_tick_counter; survey["seconds"] = std::chrono::duration_cast(std::chrono::steady_clock::now() - _switch_mode_time).count(); - YearMonthDay ymd; - ConvertDateToYMD(_date, &ymd); - survey["calendar"] = fmt::format("{:04}-{:02}-{:02} ({})", ymd.year, ymd.month + 1, ymd.day, _date_fract); + survey["calendar"] = fmt::format("{:04}-{:02}-{:02} ({})", _cur_date_ymd.year, _cur_date_ymd.month + 1, _cur_date_ymd.day, _date_fract); } /** diff --git a/src/saveload/afterload.cpp b/src/saveload/afterload.cpp index 4562b4d78a..c49c82aeb5 100644 --- a/src/saveload/afterload.cpp +++ b/src/saveload/afterload.cpp @@ -1792,7 +1792,7 @@ bool AfterLoadGame() if (IsSavegameVersionBefore(SLV_31)) { _date += DAYS_TILL_ORIGINAL_BASE_YEAR.AsDelta(); SetScaledTickVariables(); - ConvertDateToYMD(_date, &_cur_date_ymd); + _cur_date_ymd = ConvertDateToYMD(_date); UpdateCachedSnowLine(); for (Station *st : Station::Iterate()) st->build_date += DAYS_TILL_ORIGINAL_BASE_YEAR.AsDelta(); @@ -4299,6 +4299,10 @@ bool AfterLoadGame() } } + for (Company *c : Company::Iterate()) { + UpdateCompanyLiveries(c); + } + /* * The center of train vehicles was changed, fix up spacing. * Delay this until all train and track updates have been performed. diff --git a/src/script/api/script_date.cpp b/src/script/api/script_date.cpp index daf1180ba2..7d2f25596c 100644 --- a/src/script/api/script_date.cpp +++ b/src/script/api/script_date.cpp @@ -37,8 +37,7 @@ { if (date < 0) return DATE_INVALID; - ::YearMonthDay ymd; - ::ConvertDateToYMD(date, &ymd); + ::YearMonthDay ymd = ::ConvertDateToYMD(date); return ymd.year; } @@ -46,8 +45,7 @@ { if (date < 0) return DATE_INVALID; - ::YearMonthDay ymd; - ::ConvertDateToYMD(date, &ymd); + ::YearMonthDay ymd = ::ConvertDateToYMD(date); return ymd.month + 1; } @@ -55,8 +53,7 @@ { if (date < 0) return DATE_INVALID; - ::YearMonthDay ymd; - ::ConvertDateToYMD(date, &ymd); + ::YearMonthDay ymd = ::ConvertDateToYMD(date); return ymd.day; } diff --git a/src/strings.cpp b/src/strings.cpp index 2ed924958d..b497d29bca 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -462,8 +462,7 @@ static char *FormatWallClockString(char *buff, DateTicksScaled ticks, const char Date date = ScaledDateTicksToDate(ticks); int64 final_arg; if (_settings_client.gui.date_with_time == 1) { - YearMonthDay ymd; - ConvertDateToYMD(date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(date); final_arg = ymd.year; } else { final_arg = date.base(); @@ -487,8 +486,7 @@ static char *FormatTimeHHMMString(char *buff, uint time, const char *last, uint static char *FormatYmdString(char *buff, Date date, const char *last, uint case_index) { - YearMonthDay ymd; - ConvertDateToYMD(date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(date); auto tmp_params = MakeParameters(ymd.day + STR_DAY_NUMBER_1ST - 1, STR_MONTH_ABBREV_JAN + ymd.month, ymd.year); return FormatString(buff, GetStringPtr(STR_FORMAT_DATE_LONG), tmp_params, last, case_index); @@ -496,8 +494,7 @@ static char *FormatYmdString(char *buff, Date date, const char *last, uint case_ static char *FormatMonthAndYear(char *buff, Date date, const char *last, uint case_index) { - YearMonthDay ymd; - ConvertDateToYMD(date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(date); auto tmp_params = MakeParameters(STR_MONTH_JAN + ymd.month, ymd.year); return FormatString(buff, GetStringPtr(STR_FORMAT_DATE_SHORT), tmp_params, last, case_index); @@ -505,8 +502,7 @@ static char *FormatMonthAndYear(char *buff, Date date, const char *last, uint ca static char *FormatTinyOrISODate(char *buff, Date date, StringID str, const char *last) { - YearMonthDay ymd; - ConvertDateToYMD(date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(date); /* Day and month are zero-padded with ZEROFILL_NUM, hence the two 2s. */ auto tmp_params = MakeParameters(ymd.day, 2, ymd.month + 1, 2, ymd.year); diff --git a/src/table/newgrf_debug_data.h b/src/table/newgrf_debug_data.h index 6c76ff58d5..156c553b46 100644 --- a/src/table/newgrf_debug_data.h +++ b/src/table/newgrf_debug_data.h @@ -557,10 +557,8 @@ class NIHVehicle : public NIHelper { caps++; } } - YearMonthDay ymd; - ConvertDateToYMD(e->intro_date, &ymd); - YearMonthDay base_ymd; - ConvertDateToYMD(e->info.base_intro, &base_ymd); + YearMonthDay ymd = ConvertDateToYMD(e->intro_date); + YearMonthDay base_ymd = ConvertDateToYMD(e->info.base_intro); seprintf(buffer, lastof(buffer), " Intro: %4i-%02i-%02i (base: %4i-%02i-%02i), Age: %u, Base life: %u, Durations: %u %u %u (sum: %u)", ymd.year, ymd.month + 1, ymd.day, base_ymd.year, base_ymd.month + 1, base_ymd.day, e->age, e->info.base_life, e->duration_phase_1, e->duration_phase_2, e->duration_phase_3, @@ -1528,12 +1526,11 @@ class NIHObject : public NIHelper { output.print(buffer); { - YearMonthDay ymd; - ConvertDateToYMD(spec->introduction_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(spec->introduction_date); char *b = buffer + seprintf(buffer, lastof(buffer), " intro: %4i-%02i-%02i", ymd.year, ymd.month + 1, ymd.day); if (spec->end_of_life_date < MAX_DATE) { - ConvertDateToYMD(spec->end_of_life_date, &ymd); + ymd = ConvertDateToYMD(spec->end_of_life_date); seprintf(b, lastof(buffer), ", end of life: %4i-%02i-%02i", ymd.year, ymd.month + 1, ymd.day); } @@ -1679,8 +1676,7 @@ class NIHRailType : public NIHelper { seprintf(buffer, lastof(buffer), " Cost multiplier: %u/8, Maintenance multiplier: %u/8", info->cost_multiplier, info->maintenance_multiplier); output.print(buffer); - YearMonthDay ymd; - ConvertDateToYMD(info->introduction_date, &ymd); + YearMonthDay ymd = ConvertDateToYMD(info->introduction_date); seprintf(buffer, lastof(buffer), " Introduction date: %4i-%02i-%02i", ymd.year, ymd.month + 1, ymd.day); output.print(buffer); seprintf(buffer, lastof(buffer), " Intro required railtypes: 0x" OTTD_PRINTFHEX64, info->introduction_required_railtypes); diff --git a/src/tracerestrict.cpp b/src/tracerestrict.cpp index ada6aef001..762836b61a 100644 --- a/src/tracerestrict.cpp +++ b/src/tracerestrict.cpp @@ -2409,14 +2409,12 @@ int GetTraceRestrictTimeDateValueFromDate(TraceRestrictTimeDateValueField type, return minutes.ClockHHMM(); case TRTDVF_DAY: { - YearMonthDay ymd; - ConvertDateToYMD(ScaledDateTicksToDate(scaled_date_ticks), &ymd); + YearMonthDay ymd = ConvertDateToYMD(ScaledDateTicksToDate(scaled_date_ticks)); return ymd.day; } case TRTDVF_MONTH: { - YearMonthDay ymd; - ConvertDateToYMD(ScaledDateTicksToDate(scaled_date_ticks), &ymd); + YearMonthDay ymd = ConvertDateToYMD(ScaledDateTicksToDate(scaled_date_ticks)); return ymd.month + 1; }