1
0
Fork 0

Compare commits

..

No commits in common. "1071acb4831be15b1e671bec15bee058b5bef6f9" and "9f90ab7b04e9bc675ae13357c00ab7621daf0776" have entirely different histories.

35 changed files with 59 additions and 118 deletions

View File

@ -106,19 +106,19 @@ struct BaseSet {
* @param isocode the isocode to search for * @param isocode the isocode to search for
* @return the description * @return the description
*/ */
const std::string &GetDescription(const std::string &isocode) const const char *GetDescription(const std::string &isocode) const
{ {
if (!isocode.empty()) { if (!isocode.empty()) {
/* First the full ISO code */ /* First the full ISO code */
auto desc = this->description.find(isocode); auto desc = this->description.find(isocode);
if (desc != this->description.end()) return desc->second; if (desc != this->description.end()) return desc->second.c_str();
/* Then the first two characters */ /* Then the first two characters */
desc = this->description.find(isocode.substr(0, 2)); desc = this->description.find(isocode.substr(0, 2));
if (desc != this->description.end()) return desc->second; if (desc != this->description.end()) return desc->second.c_str();
} }
/* Then fall back */ /* Then fall back */
return this->description.at(std::string{}); return this->description.at(std::string{}).c_str();
} }
/** /**

View File

@ -125,11 +125,11 @@ struct BaseStation : StationPool::PoolItem<&_station_pool> {
*/ */
virtual void UpdateVirtCoord() = 0; virtual void UpdateVirtCoord() = 0;
inline const std::string &GetCachedName() const inline const char *GetCachedName() const
{ {
if (!this->name.empty()) return this->name; if (!this->name.empty()) return this->name.c_str();
if (this->cached_name.empty()) this->FillCachedName(); if (this->cached_name.empty()) this->FillCachedName();
return this->cached_name; return this->cached_name.c_str();
} }
virtual void MoveSign(TileIndex new_xy) virtual void MoveSign(TileIndex new_xy)

View File

@ -18,13 +18,11 @@ struct fmt::formatter<E, Char, std::enable_if_t<std::is_enum<E>::value>> : fmt::
using underlying_type = typename std::underlying_type<E>::type; using underlying_type = typename std::underlying_type<E>::type;
using parent = typename fmt::formatter<underlying_type>; using parent = typename fmt::formatter<underlying_type>;
constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) {
{
return parent::parse(ctx); return parent::parse(ctx);
} }
fmt::format_context::iterator format(const E &e, format_context &ctx) const fmt::format_context::iterator format(const E &e, format_context &ctx) const {
{
return parent::format(underlying_type(e), ctx); return parent::format(underlying_type(e), ctx);
} }
}; };
@ -34,13 +32,11 @@ struct fmt::formatter<T, Char, std::enable_if_t<std::is_base_of<StrongTypedefBas
using underlying_type = typename T::BaseType; using underlying_type = typename T::BaseType;
using parent = typename fmt::formatter<underlying_type>; using parent = typename fmt::formatter<underlying_type>;
constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) constexpr fmt::format_parse_context::iterator parse(fmt::format_parse_context &ctx) {
{
return parent::parse(ctx); return parent::parse(ctx);
} }
fmt::format_context::iterator format(const T &t, format_context &ctx) const fmt::format_context::iterator format(const T &t, format_context &ctx) const {
{
return parent::format(t.base(), ctx); return parent::format(t.base(), ctx);
} }
}; };

View File

@ -444,8 +444,7 @@ void ShowErrorMessage(StringID summary_msg, StringID detailed_msg, WarningLevel
* Close active error message window * Close active error message window
* @return true if a window was closed. * @return true if a window was closed.
*/ */
bool HideActiveErrorMessage() bool HideActiveErrorMessage() {
{
ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0); ErrmsgWindow *w = (ErrmsgWindow*)FindWindowById(WC_ERRMSG, 0);
if (w == nullptr) return false; if (w == nullptr) return false;
w->Close(); w->Close();

View File

@ -154,8 +154,7 @@ ICUParagraphLayout::ICUVisualRun::ICUVisualRun(const ICURun &run, int x) :
* @param buff The buffer of which a partial (depending on start/length of the run) will be shaped. * @param buff The buffer of which a partial (depending on start/length of the run) will be shaped.
* @param length The length of the buffer. * @param length The length of the buffer.
*/ */
void ICURun::Shape(UChar *buff, size_t buff_length) void ICURun::Shape(UChar *buff, size_t buff_length) {
{
auto hbfont = hb_ft_font_create_referenced(*(static_cast<const FT_Face *>(font->fc->GetOSHandle()))); auto hbfont = hb_ft_font_create_referenced(*(static_cast<const FT_Face *>(font->fc->GetOSHandle())));
hb_font_set_scale(hbfont, this->font->fc->GetFontSize() * FONT_SCALE, this->font->fc->GetFontSize() * FONT_SCALE); hb_font_set_scale(hbfont, this->font->fc->GetFontSize() * FONT_SCALE, this->font->fc->GetFontSize() * FONT_SCALE);

View File

@ -534,7 +534,6 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :Über OpenTTD
STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite-Ausrichtung STR_ABOUT_MENU_SPRITE_ALIGNER :Sprite-Ausrichtung
STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Hüllquader anzeigen/ausblenden STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Hüllquader anzeigen/ausblenden
STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Neugezeichnete Felder farbig markieren STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Neugezeichnete Felder farbig markieren
STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :Widget-Umrisse anzeigen/ausblenden
# Place in highscore window # Place in highscore window
###length 15 ###length 15
@ -3385,7 +3384,6 @@ STR_SAVE_PRESET_SAVE :{BLACK}Speicher
STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Voreinstellung unter dem ausgewählten Namen speichern STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Voreinstellung unter dem ausgewählten Namen speichern
# NewGRF parameters window # NewGRF parameters window
STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Parameter der Basisgrafiken ändern
STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}NewGRF Parameter ändern STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}NewGRF Parameter ändern
STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Schließen STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Schließen
STR_NEWGRF_PARAMETERS_RESET :{BLACK}Zurücksetzen STR_NEWGRF_PARAMETERS_RESET :{BLACK}Zurücksetzen
@ -5190,7 +5188,6 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Fahrplan
STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Fahrzeuge halten nur an Stationen STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Fahrzeuge halten nur an Stationen
STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Das Fahrzeug hält nicht an dieser Station STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Das Fahrzeug hält nicht an dieser Station
STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... Fahrplan ist unvollständig STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... Fahrplan ist unvollständig
STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... Fahrplan hat noch nicht begonnen
# Sign related errors # Sign related errors
STR_ERROR_TOO_MANY_SIGNS :{WHITE}... zu viele Schilder STR_ERROR_TOO_MANY_SIGNS :{WHITE}... zu viele Schilder

View File

@ -533,7 +533,6 @@ STR_ABOUT_MENU_ABOUT_OPENTTD :Despre 'OpenTTD
STR_ABOUT_MENU_SPRITE_ALIGNER :Aliniere imagini STR_ABOUT_MENU_SPRITE_ALIGNER :Aliniere imagini
STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Afişează/ascunde casetele de încadrare STR_ABOUT_MENU_TOGGLE_BOUNDING_BOXES :Afişează/ascunde casetele de încadrare
STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Comutator pentru colorarea secțiunilor murdare STR_ABOUT_MENU_TOGGLE_DIRTY_BLOCKS :Comutator pentru colorarea secțiunilor murdare
STR_ABOUT_MENU_TOGGLE_WIDGET_OUTLINES :Comutați contururile widgetului
# Place in highscore window # Place in highscore window
###length 15 ###length 15
@ -925,8 +924,6 @@ STR_NEWS_NEW_VEHICLE_NOW_AVAILABLE_WITH_TYPE :{BLACK}Un nou t
STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP :{BLACK}Deschide fereastra grupului fixată pe grupul vehiculului STR_NEWS_SHOW_VEHICLE_GROUP_TOOLTIP :{BLACK}Deschide fereastra grupului fixată pe grupul vehiculului
STR_NEWS_STATION_NO_LONGER_ACCEPTS_CARGO_LIST :{WHITE}{STATION} nu mai acceptă: {CARGO_LIST}
STR_NEWS_STATION_NOW_ACCEPTS_CARGO_LIST :{WHITE}{STATION} acceptă acum: {CARGO_LIST}
STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED :{BIG_FONT}{BLACK}Ofertă expirată:{}{}Transportul de {STRING} de la {STRING} la {STRING} nu va mai fi subvenţionat STR_NEWS_OFFER_OF_SUBSIDY_EXPIRED :{BIG_FONT}{BLACK}Ofertă expirată:{}{}Transportul de {STRING} de la {STRING} la {STRING} nu va mai fi subvenţionat
STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE :{BIG_FONT}{BLACK}Ofertă retrasă:{}{}Transportul de {STRING} de la {STRING} la {STRING} nu va mai fi subvenţionat STR_NEWS_SUBSIDY_WITHDRAWN_SERVICE :{BIG_FONT}{BLACK}Ofertă retrasă:{}{}Transportul de {STRING} de la {STRING} la {STRING} nu va mai fi subvenţionat
@ -2194,7 +2191,6 @@ STR_CHEAT_EDIT_MAX_HL_QUERY_CAPT :{WHITE}Schimbă
STR_CHEAT_CHANGE_DATE :{LTBLUE}Schimbă data: {ORANGE}{DATE_SHORT} STR_CHEAT_CHANGE_DATE :{LTBLUE}Schimbă data: {ORANGE}{DATE_SHORT}
STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Schimbă anul curent STR_CHEAT_CHANGE_DATE_QUERY_CAPT :{WHITE}Schimbă anul curent
STR_CHEAT_SETUP_PROD :{LTBLUE}Activează accesul la valorile de producţie: {ORANGE}{STRING} STR_CHEAT_SETUP_PROD :{LTBLUE}Activează accesul la valorile de producţie: {ORANGE}{STRING}
STR_CHEAT_STATION_RATING :{LTBLUE}Remediați evaluările staţiei la 100%: {ORANGE}{STRING}
# Livery window # Livery window
STR_LIVERY_CAPTION :{WHITE}{COMPANY} - Schemă de culori STR_LIVERY_CAPTION :{WHITE}{COMPANY} - Schemă de culori
@ -3383,7 +3379,6 @@ STR_SAVE_PRESET_SAVE :{BLACK}Salveaz
STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Salvează setarea pe numele selectat STR_SAVE_PRESET_SAVE_TOOLTIP :{BLACK}Salvează setarea pe numele selectat
# NewGRF parameters window # NewGRF parameters window
STR_BASEGRF_PARAMETERS_CAPTION :{WHITE}Schimbați parametrii grafici de bază
STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Schimbă parametrii NewGRF STR_NEWGRF_PARAMETERS_CAPTION :{WHITE}Schimbă parametrii NewGRF
STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Închide STR_NEWGRF_PARAMETERS_CLOSE :{BLACK}Închide
STR_NEWGRF_PARAMETERS_RESET :{BLACK}Resetează STR_NEWGRF_PARAMETERS_RESET :{BLACK}Resetează
@ -5188,7 +5183,6 @@ STR_ERROR_CAN_T_TIMETABLE_VEHICLE :{WHITE}Nu pot p
STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehiculele pot aştepta numai în staţii STR_ERROR_TIMETABLE_ONLY_WAIT_AT_STATIONS :{WHITE}Vehiculele pot aştepta numai în staţii
STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Acest vehicul nu are oprire în această staţie STR_ERROR_TIMETABLE_NOT_STOPPING_HERE :{WHITE}Acest vehicul nu are oprire în această staţie
STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... orarul este incomplet STR_ERROR_TIMETABLE_INCOMPLETE :{WHITE}... orarul este incomplet
STR_ERROR_TIMETABLE_NOT_STARTED :{WHITE}... orarul nu a început încă
# Sign related errors # Sign related errors
STR_ERROR_TOO_MANY_SIGNS :{WHITE}... prea multe semne STR_ERROR_TOO_MANY_SIGNS :{WHITE}... prea multe semne

View File

@ -278,7 +278,7 @@ private:
this->title = lt->title; this->title = lt->title;
std::vector<const LeagueTableElement *> elements; std::vector<const LeagueTableElement *> elements;
for (LeagueTableElement *lte : LeagueTableElement::Iterate()) { for(LeagueTableElement *lte : LeagueTableElement::Iterate()) {
if (lte->table == this->table) { if (lte->table == this->table) {
elements.push_back(lte); elements.push_back(lte);
} }

View File

@ -569,8 +569,7 @@ LinkGraphLegendWindow::LinkGraphLegendWindow(WindowDesc *desc, int window_number
* Set the overlay belonging to this menu and import its company/cargo settings. * Set the overlay belonging to this menu and import its company/cargo settings.
* @param overlay New overlay for this menu. * @param overlay New overlay for this menu.
*/ */
void LinkGraphLegendWindow::SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay) void LinkGraphLegendWindow::SetOverlay(std::shared_ptr<LinkGraphOverlay> overlay) {
{
this->overlay = overlay; this->overlay = overlay;
CompanyMask companies = this->overlay->GetCompanyMask(); CompanyMask companies = this->overlay->GetCompanyMask();
for (uint c = 0; c < MAX_COMPANIES; c++) { for (uint c = 0; c < MAX_COMPANIES; c++) {

View File

@ -72,8 +72,7 @@ public:
private: private:
/** Helper function to write a tuple to the buffer. */ /** Helper function to write a tuple to the buffer. */
template<class Ttuple, size_t... Tindices> template<class Ttuple, size_t... Tindices>
void WriteTuple(const Ttuple &values, std::index_sequence<Tindices...>) void WriteTuple(const Ttuple &values, std::index_sequence<Tindices...>) {
{
((*this << std::get<Tindices>(values)), ...); ((*this << std::get<Tindices>(values)), ...);
} }
@ -166,8 +165,7 @@ public:
private: private:
/** Helper function to read a tuple from the buffer. */ /** Helper function to read a tuple from the buffer. */
template<class Ttuple, size_t... Tindices> template<class Ttuple, size_t... Tindices>
void ReadTuple(Ttuple &values, std::index_sequence<Tindices...>) void ReadTuple(Ttuple &values, std::index_sequence<Tindices...>) {
{
((*this >> std::get<Tindices>(values)), ...); ((*this >> std::get<Tindices>(values)), ...);
} }

View File

@ -71,8 +71,7 @@ struct DLSFile {
WSMPL wave_sample; WSMPL wave_sample;
std::vector<WLOOP> wave_loops; std::vector<WLOOP> wave_loops;
bool operator ==(long offset) const bool operator ==(long offset) const {
{
return this->file_offset == offset; return this->file_offset == offset;
} }
}; };

View File

@ -43,8 +43,7 @@ public:
/** /**
* Get the currently active instance of the music driver. * Get the currently active instance of the music driver.
*/ */
static MusicDriver *GetInstance() static MusicDriver *GetInstance() {
{
return static_cast<MusicDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_MUSIC)); return static_cast<MusicDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_MUSIC));
} }
}; };

View File

@ -1043,8 +1043,7 @@ static void ShowNewsMessage(const NewsItem *ni)
* Close active news message window * Close active news message window
* @return true if a window was closed. * @return true if a window was closed.
*/ */
bool HideActiveNewsMessage() bool HideActiveNewsMessage() {
{
NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0); NewsWindow *w = (NewsWindow*)FindWindowById(WC_NEWS_WINDOW, 0);
if (w == nullptr) return false; if (w == nullptr) return false;
w->Close(); w->Close();

View File

@ -792,7 +792,7 @@ public:
if (_settings_client.gui.quick_goto && v->owner == _local_company) { if (_settings_client.gui.quick_goto && v->owner == _local_company) {
/* If there are less than 2 station, make Go To active. */ /* If there are less than 2 station, make Go To active. */
int station_orders = 0; int station_orders = 0;
for (const Order *order : v->Orders()) { for(const Order *order : v->Orders()) {
if (order->IsType(OT_GOTO_STATION)) station_orders++; if (order->IsType(OT_GOTO_STATION)) station_orders++;
} }

View File

@ -326,7 +326,7 @@ void LoadCoreTextFont(FontSize fs)
path.reset(CFStringCreateWithCString(kCFAllocatorDefault, settings->font.c_str(), kCFStringEncodingUTF8)); path.reset(CFStringCreateWithCString(kCFAllocatorDefault, settings->font.c_str(), kCFStringEncodingUTF8));
} else { } else {
/* Scan the search-paths to see if it can be found. */ /* Scan the search-paths to see if it can be found. */
std::string full_font = FioFindFullPath(BASE_DIR, settings->font); std::string full_font = FioFindFullPath(BASE_DIR, settings->font.c_str());
if (!full_font.empty()) { if (!full_font.empty()) {
path.reset(CFStringCreateWithCString(kCFAllocatorDefault, full_font.c_str(), kCFStringEncodingUTF8)); path.reset(CFStringCreateWithCString(kCFAllocatorDefault, full_font.c_str(), kCFStringEncodingUTF8));
} }

View File

@ -251,8 +251,7 @@ void OSOpenBrowser(const char *url)
} }
#endif /* __APPLE__ */ #endif /* __APPLE__ */
void SetCurrentThreadName([[maybe_unused]] const char *threadName) void SetCurrentThreadName([[maybe_unused]] const char *threadName) {
{
#if defined(__GLIBC__) #if defined(__GLIBC__)
if (threadName) pthread_setname_np(pthread_self(), threadName); if (threadName) pthread_setname_np(pthread_self(), threadName);
#endif /* defined(__GLIBC__) */ #endif /* defined(__GLIBC__) */

View File

@ -38,8 +38,7 @@ struct EFCParam {
MissingGlyphSearcher *callback; MissingGlyphSearcher *callback;
std::vector<std::wstring> fonts; std::vector<std::wstring> fonts;
bool Add(const std::wstring_view &font) bool Add(const std::wstring_view &font) {
{
for (const auto &entry : this->fonts) { for (const auto &entry : this->fonts) {
if (font.compare(entry) == 0) return false; if (font.compare(entry) == 0) return false;
} }

View File

@ -1372,7 +1372,7 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlag flags, TileIndex tile, Til
last_suitable_trackdir = trackdir; last_suitable_trackdir = trackdir;
} }
} }
} else if (signal_ctr >= last_used_ctr + signal_density) { } else if(signal_ctr >= last_used_ctr + signal_density) {
/* We're always keeping regular interval between signals so doesn't matter whether we succeed or not. */ /* We're always keeping regular interval between signals so doesn't matter whether we succeed or not. */
build_signal(tile, trackdir, false); build_signal(tile, trackdir, false);
last_used_ctr = signal_ctr; last_used_ctr = signal_ctr;
@ -1396,7 +1396,7 @@ static CommandCost CmdSignalTrackHelper(DoCommandFlag flags, TileIndex tile, Til
/* To keep regular interval we need to emulate placing signals on a bridge. /* To keep regular interval we need to emulate placing signals on a bridge.
* We start with TILE_AXIAL_DISTANCE as one bridge tile gets processed in the main loop. */ * We start with TILE_AXIAL_DISTANCE as one bridge tile gets processed in the main loop. */
signal_ctr += TILE_AXIAL_DISTANCE; signal_ctr += TILE_AXIAL_DISTANCE;
for (uint i = TILE_AXIAL_DISTANCE; i < len; i += TILE_AXIAL_DISTANCE) { for(uint i = TILE_AXIAL_DISTANCE; i < len; i += TILE_AXIAL_DISTANCE) {
if (signal_ctr >= last_used_ctr + signal_density) last_used_ctr = signal_ctr; if (signal_ctr >= last_used_ctr + signal_density) last_used_ctr = signal_ctr;
signal_ctr += TILE_AXIAL_DISTANCE; signal_ctr += TILE_AXIAL_DISTANCE;
} }

View File

@ -1395,8 +1395,7 @@ public:
/** /**
* Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass. * Simply to have a easier way to get the StationType for bus, truck and trams from the WindowClass.
*/ */
StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const StationType GetRoadStationTypeByWindowClass(WindowClass window_class) const {
{
switch (window_class) { switch (window_class) {
case WC_BUS_STATION: return STATION_BUS; case WC_BUS_STATION: return STATION_BUS;
case WC_TRUCK_STATION: return STATION_TRUCK; case WC_TRUCK_STATION: return STATION_TRUCK;
@ -1476,15 +1475,13 @@ public:
} }
} }
void OnResize() override void OnResize() override {
{
if (this->vscrollList != nullptr) { if (this->vscrollList != nullptr) {
this->vscrollList->SetCapacityFromWidget(this, WID_BROS_NEWST_LIST); this->vscrollList->SetCapacityFromWidget(this, WID_BROS_NEWST_LIST);
} }
} }
void SetStringParameters(int widget) const override void SetStringParameters(int widget) const override {
{
if (widget == WID_BROS_SHOW_NEWST_TYPE) { if (widget == WID_BROS_SHOW_NEWST_TYPE) {
const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type); const RoadStopSpec *roadstopspec = RoadStopClass::Get(_roadstop_gui_settings.roadstop_class)->GetSpec(_roadstop_gui_settings.roadstop_type);
SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP); SetDParam(0, (roadstopspec != nullptr && roadstopspec->name != 0) ? roadstopspec->name : STR_STATION_CLASS_DFLT_ROADSTOP);

View File

@ -46,7 +46,7 @@ ScriptStorage::~ScriptStorage()
static void PrintFunc(bool error_msg, const std::string &message) static void PrintFunc(bool error_msg, const std::string &message)
{ {
/* Convert to OpenTTD internal capable string */ /* Convert to OpenTTD internal capable string */
ScriptController::Print(error_msg, message); ScriptController::Print(error_msg, message.c_str());
} }
ScriptInstance::ScriptInstance(const char *APIName) : ScriptInstance::ScriptInstance(const char *APIName) :

View File

@ -45,8 +45,7 @@ namespace SQConvert {
template <> struct Return<HSQOBJECT> { static inline int Set(HSQUIRRELVM vm, HSQOBJECT res) { sq_pushobject(vm, res); return 1; } }; template <> struct Return<HSQOBJECT> { static inline int Set(HSQUIRRELVM vm, HSQOBJECT res) { sq_pushobject(vm, res); return 1; } };
template <> struct Return<std::optional<std::string>> { template <> struct Return<std::optional<std::string>> {
static inline int Set(HSQUIRRELVM vm, std::optional<std::string> res) static inline int Set(HSQUIRRELVM vm, std::optional<std::string> res) {
{
if (res.has_value()) { if (res.has_value()) {
sq_pushstring(vm, res.value(), -1); sq_pushstring(vm, res.value(), -1);
} else { } else {

View File

@ -1552,7 +1552,7 @@ void DeleteGRFPresetFromConfig(const char *config_name)
section += config_name; section += config_name;
ConfigIniFile ini(_config_file); ConfigIniFile ini(_config_file);
ini.RemoveGroup(section); ini.RemoveGroup(section.c_str());
ini.SaveToDisk(_config_file); ini.SaveToDisk(_config_file);
} }

View File

@ -563,8 +563,7 @@ struct LinkGraphSettings {
uint8_t demand_distance; ///< influence of distance between stations on the demand function uint8_t demand_distance; ///< influence of distance between stations on the demand function
uint8_t short_path_saturation; ///< percentage up to which short paths are saturated before saturating most capacious paths uint8_t short_path_saturation; ///< percentage up to which short paths are saturated before saturating most capacious paths
inline DistributionType GetDistributionType(CargoID cargo) const inline DistributionType GetDistributionType(CargoID cargo) const {
{
if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax; if (IsCargoInClass(cargo, CC_PASSENGERS)) return this->distribution_pax;
if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail; if (IsCargoInClass(cargo, CC_MAIL)) return this->distribution_mail;
if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured; if (IsCargoInClass(cargo, CC_ARMOURED)) return this->distribution_armoured;

View File

@ -32,8 +32,7 @@ public:
/** /**
* Get the currently active instance of the sound driver. * Get the currently active instance of the sound driver.
*/ */
static SoundDriver *GetInstance() static SoundDriver *GetInstance() {
{
return static_cast<SoundDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND)); return static_cast<SoundDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_SOUND));
} }
}; };

View File

@ -64,8 +64,7 @@ SpriteCache *AllocateSpriteCache(uint index)
* @param filename The name of the file at the disk. * @param filename The name of the file at the disk.
* @return The SpriteFile or \c null. * @return The SpriteFile or \c null.
*/ */
static SpriteFile *GetCachedSpriteFileByName(const std::string &filename) static SpriteFile *GetCachedSpriteFileByName(const std::string &filename) {
{
for (auto &f : _sprite_files) { for (auto &f : _sprite_files) {
if (f->GetFilename() == filename) { if (f->GetFilename() == filename) {
return f.get(); return f.get();

View File

@ -413,8 +413,7 @@ void Station::AddIndustryToDeliver(Industry *ind, TileIndex tile)
* Remove nearby industry from station's industries_near list. * Remove nearby industry from station's industries_near list.
* @param ind Industry * @param ind Industry
*/ */
void Station::RemoveIndustryToDeliver(Industry *ind) void Station::RemoveIndustryToDeliver(Industry *ind) {
{
auto pos = std::find_if(this->industries_near.begin(), this->industries_near.end(), [&](const IndustryListEntry &e) { return e.industry->index == ind->index; }); auto pos = std::find_if(this->industries_near.begin(), this->industries_near.end(), [&](const IndustryListEntry &e) { return e.industry->index == ind->index; });
if (pos != this->industries_near.end()) { if (pos != this->industries_near.end()) {
this->industries_near.erase(pos); this->industries_near.erase(pos);

View File

@ -79,7 +79,7 @@ struct FileStringReader : StringReader {
* @param translation Are we reading a translation? * @param translation Are we reading a translation?
*/ */
FileStringReader(StringData &data, const std::filesystem::path &file, bool master, bool translation) : FileStringReader(StringData &data, const std::filesystem::path &file, bool master, bool translation) :
StringReader(data, file.generic_string(), master, translation) StringReader(data, file.generic_string().c_str(), master, translation)
{ {
this->input_stream.open(file, std::ifstream::binary); this->input_stream.open(file, std::ifstream::binary);
} }

View File

@ -58,7 +58,7 @@ TextDirection _current_text_dir; ///< Text direction of the currently selected l
std::unique_ptr<icu::Collator> _current_collator; ///< Collator for the language currently in use. std::unique_ptr<icu::Collator> _current_collator; ///< Collator for the language currently in use.
#endif /* WITH_ICU_I18N */ #endif /* WITH_ICU_I18N */
ArrayStringParameters<20> _global_string_params; AllocatedStringParameters _global_string_params(20);
/** /**
* Prepare the string parameters for the next formatting run. This means * Prepare the string parameters for the next formatting run. This means
@ -927,7 +927,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
args.SetTypeOfNextParameter(b); args.SetTypeOfNextParameter(b);
switch (b) { switch (b) {
case SCC_ENCODED: { case SCC_ENCODED: {
ArrayStringParameters<20> sub_args; AllocatedStringParameters sub_args(20);
char *p; char *p;
uint32_t stringid = std::strtoul(str, &p, 16); uint32_t stringid = std::strtoul(str, &p, 16);
@ -1440,7 +1440,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
assert(grffile != nullptr); assert(grffile != nullptr);
StartTextRefStackUsage(grffile, 6); StartTextRefStackUsage(grffile, 6);
ArrayStringParameters<6> tmp_params; AllocatedStringParameters tmp_params(6);
GetStringWithArgs(builder, GetGRFStringID(grffile->grfid, 0xD000 + callback), tmp_params); GetStringWithArgs(builder, GetGRFStringID(grffile->grfid, 0xD000 + callback), tmp_params);
StopTextRefStackUsage(); StopTextRefStackUsage();
@ -1448,7 +1448,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
} }
} }
auto tmp_params = ArrayStringParameters<0>(); auto tmp_params = AllocatedStringParameters();
GetStringWithArgs(builder, e->info.string_id, tmp_params); GetStringWithArgs(builder, e->info.string_id, tmp_params);
break; break;
} }
@ -1478,7 +1478,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
} else if (_scan_for_gender_data) { } else if (_scan_for_gender_data) {
/* Gender is defined by the industry type. /* Gender is defined by the industry type.
* STR_FORMAT_INDUSTRY_NAME may have the town first, so it would result in the gender of the town name */ * STR_FORMAT_INDUSTRY_NAME may have the town first, so it would result in the gender of the town name */
auto tmp_params = ArrayStringParameters<0>(); auto tmp_params = AllocatedStringParameters();
FormatString(builder, GetStringPtr(GetIndustrySpec(i->type)->name), tmp_params, next_substr_case_index); FormatString(builder, GetStringPtr(GetIndustrySpec(i->type)->name), tmp_params, next_substr_case_index);
} else { } else {
/* First print the town name and the industry type name. */ /* First print the town name and the industry type name. */
@ -1511,7 +1511,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
/* The station doesn't exist anymore. The only place where we might /* The station doesn't exist anymore. The only place where we might
* be "drawing" an invalid station is in the case of cargo that is * be "drawing" an invalid station is in the case of cargo that is
* in transit. */ * in transit. */
auto tmp_params = ArrayStringParameters<0>(); auto tmp_params = AllocatedStringParameters();
GetStringWithArgs(builder, STR_UNKNOWN_STATION, tmp_params); GetStringWithArgs(builder, STR_UNKNOWN_STATION, tmp_params);
break; break;
} }
@ -1612,7 +1612,7 @@ static void FormatString(StringBuilder &builder, const char *str_arg, StringPara
auto tmp_params = MakeParameters(si->name); auto tmp_params = MakeParameters(si->name);
GetStringWithArgs(builder, STR_JUST_RAW_STRING, tmp_params); GetStringWithArgs(builder, STR_JUST_RAW_STRING, tmp_params);
} else { } else {
auto tmp_params = ArrayStringParameters<0>(); auto tmp_params = AllocatedStringParameters();
GetStringWithArgs(builder, STR_DEFAULT_SIGN_NAME, tmp_params); GetStringWithArgs(builder, STR_DEFAULT_SIGN_NAME, tmp_params);
} }
break; break;

View File

@ -198,35 +198,17 @@ public:
}; };
/** /**
* Extension of StringParameters with its own statically sized buffer for * Extension of StringParameters with its own statically allocated buffer for
* the parameters. * the parameters.
*/ */
template <size_t N> class AllocatedStringParameters : public StringParameters {
class ArrayStringParameters : public StringParameters { std::vector<StringParameter> params; ///< The actual parameters
std::array<StringParameter, N> params{}; ///< The actual parameters
public: public:
ArrayStringParameters() AllocatedStringParameters(size_t parameters = 0) : params(parameters)
{ {
this->parameters = span(params.data(), params.size()); this->parameters = span(params.data(), params.size());
} }
ArrayStringParameters(ArrayStringParameters&& other) noexcept
{
*this = std::move(other);
}
ArrayStringParameters& operator=(ArrayStringParameters &&other) noexcept
{
this->offset = other.offset;
this->next_type = other.next_type;
this->params = std::move(other.params);
this->parameters = span(params.data(), params.size());
return *this;
}
ArrayStringParameters(const ArrayStringParameters& other) = delete;
ArrayStringParameters& operator=(const ArrayStringParameters &other) = delete;
}; };
/** /**
@ -238,7 +220,7 @@ public:
template <typename... Args> template <typename... Args>
static auto MakeParameters(const Args&... args) static auto MakeParameters(const Args&... args)
{ {
ArrayStringParameters<sizeof...(args)> parameters; AllocatedStringParameters parameters(sizeof...(args));
size_t index = 0; size_t index = 0;
(parameters.SetParam(index++, std::forward<const Args&>(args)), ...); (parameters.SetParam(index++, std::forward<const Args&>(args)), ...);
return parameters; return parameters;

View File

@ -38,8 +38,7 @@ public:
* *
* @param timer The timer to register. * @param timer The timer to register.
*/ */
static void RegisterTimer(BaseTimer<TTimerType> &timer) static void RegisterTimer(BaseTimer<TTimerType> &timer) {
{
#ifdef WITH_ASSERT #ifdef WITH_ASSERT
Validate(timer.period); Validate(timer.period);
#endif /* WITH_ASSERT */ #endif /* WITH_ASSERT */
@ -51,8 +50,7 @@ public:
* *
* @param timer The timer to unregister. * @param timer The timer to unregister.
*/ */
static void UnregisterTimer(BaseTimer<TTimerType> &timer) static void UnregisterTimer(BaseTimer<TTimerType> &timer) {
{
GetTimers().erase(&timer); GetTimers().erase(&timer);
} }
@ -89,16 +87,14 @@ private:
* same, it will sort based on the pointer value. * same, it will sort based on the pointer value.
*/ */
struct base_timer_sorter { struct base_timer_sorter {
bool operator() (BaseTimer<TTimerType> *a, BaseTimer<TTimerType> *b) const bool operator() (BaseTimer<TTimerType> *a, BaseTimer<TTimerType> *b) const {
{
if (a->period == b->period) return a < b; if (a->period == b->period) return a < b;
return a->period < b->period; return a->period < b->period;
} }
}; };
/** Singleton list, to store all the active timers. */ /** Singleton list, to store all the active timers. */
static std::set<BaseTimer<TTimerType> *, base_timer_sorter> &GetTimers() static std::set<BaseTimer<TTimerType> *, base_timer_sorter> &GetTimers() {
{
static std::set<BaseTimer<TTimerType> *, base_timer_sorter> timers; static std::set<BaseTimer<TTimerType> *, base_timer_sorter> timers;
return timers; return timers;
} }

View File

@ -690,8 +690,7 @@ static const int LTMN_PERFORMANCE_LEAGUE = -7; ///< Show default league t
static const int LTMN_PERFORMANCE_RATING = -8; ///< Show detailed performance rating static const int LTMN_PERFORMANCE_RATING = -8; ///< Show detailed performance rating
static const int LTMN_HIGHSCORE = -9; ///< Show highscrore table static const int LTMN_HIGHSCORE = -9; ///< Show highscrore table
static void AddDropDownLeagueTableOptions(DropDownList &list) static void AddDropDownLeagueTableOptions(DropDownList &list) {
{
if (LeagueTable::GetNumItems() > 0) { if (LeagueTable::GetNumItems() > 0) {
for (LeagueTable *lt : LeagueTable::Iterate()) { for (LeagueTable *lt : LeagueTable::Iterate()) {
list.push_back(std::make_unique<DropDownListStringItem>(lt->title, lt->index, false)); list.push_back(std::make_unique<DropDownListStringItem>(lt->title, lt->index, false));

View File

@ -304,8 +304,7 @@ void MakeDefaultName(T *obj)
* Converts original town ticks counters to plain game ticks. Note that * Converts original town ticks counters to plain game ticks. Note that
* tick 0 is a valid tick so actual amount is one more than the counter value. * tick 0 is a valid tick so actual amount is one more than the counter value.
*/ */
static inline uint16_t TownTicksToGameTicks(uint16_t ticks) static inline uint16_t TownTicksToGameTicks(uint16_t ticks) {
{
return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * Ticks::TOWN_GROWTH_TICKS - 1; return (std::min(ticks, MAX_TOWN_GROWTH_TICKS) + 1) * Ticks::TOWN_GROWTH_TICKS - 1;
} }

View File

@ -197,8 +197,7 @@ public:
/** /**
* Get the currently active instance of the video driver. * Get the currently active instance of the video driver.
*/ */
static VideoDriver *GetInstance() static VideoDriver *GetInstance() {
{
return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO)); return static_cast<VideoDriver*>(*DriverFactoryBase::GetActiveDriver(Driver::DT_VIDEO));
} }
@ -261,8 +260,7 @@ protected:
* Make sure the video buffer is ready for drawing. * Make sure the video buffer is ready for drawing.
* @returns True if the video buffer has to be unlocked. * @returns True if the video buffer has to be unlocked.
*/ */
virtual bool LockVideoBuffer() virtual bool LockVideoBuffer() {
{
return false; return false;
} }

View File

@ -434,8 +434,7 @@ bool RiverModifyDesertZone(TileIndex tile, void *)
* Make a river tile and remove desert directly around it. * Make a river tile and remove desert directly around it.
* @param tile The tile to change into river and create non-desert around * @param tile The tile to change into river and create non-desert around
*/ */
void MakeRiverAndModifyDesertZoneAround(TileIndex tile) void MakeRiverAndModifyDesertZoneAround(TileIndex tile) {
{
MakeRiver(tile, Random()); MakeRiver(tile, Random());
MarkTileDirtyByTile(tile); MarkTileDirtyByTile(tile);

View File

@ -483,8 +483,7 @@ public:
* @param widgets list of widgets * @param widgets list of widgets
*/ */
template<typename... Args> template<typename... Args>
void RaiseWidgetsWhenLowered(Args... widgets) void RaiseWidgetsWhenLowered(Args... widgets) {
{
(this->RaiseWidgetWhenLowered(widgets), ...); (this->RaiseWidgetWhenLowered(widgets), ...);
} }