mirror of https://github.com/OpenTTD/OpenTTD.git
Codechange: minor bits and pieces related to fmt::format() (#11806)
- Don't make run-time formatting what can be done compile-time. - Be explicit about run-time formatting. - Fix datetime printing.
This commit is contained in:
parent
0b7410d979
commit
6550682b49
|
@ -95,7 +95,7 @@ void DumpDebugFacilityNames(std::back_insert_iterator<std::string> &output_itera
|
|||
} else {
|
||||
fmt::format_to(output_iterator, ", ");
|
||||
}
|
||||
fmt::format_to(output_iterator, i->name);
|
||||
fmt::format_to(output_iterator, "{}", i->name);
|
||||
written = true;
|
||||
}
|
||||
if (written) {
|
||||
|
|
|
@ -242,7 +242,11 @@ void Gamelog::Print(std::function<void(const std::string &)> proc)
|
|||
{
|
||||
/* A NewGRF got removed from the game, either manually or by it missing when loading the game. */
|
||||
auto gm = grf_names.find(this->grfid);
|
||||
fmt::format_to(output_iterator, action_type == GLAT_LOAD ? "Missing NewGRF: " : "Removed NewGRF: ");
|
||||
if (action_type == GLAT_LOAD) {
|
||||
fmt::format_to(output_iterator, "Missing NewGRF: ");
|
||||
} else {
|
||||
fmt::format_to(output_iterator, "Removed NewGRF: ");
|
||||
}
|
||||
AddGrfInfo(output_iterator, this->grfid, nullptr, gm != grf_names.end() ? gm->second.gc : nullptr);
|
||||
if (gm == grf_names.end()) {
|
||||
fmt::format_to(output_iterator, ". Gamelog inconsistency: GrfID was never added!");
|
||||
|
|
|
@ -93,7 +93,7 @@ static const char *GetAddressFormatString(uint16_t family, bool with_family)
|
|||
*/
|
||||
std::string NetworkAddress::GetAddressAsString(bool with_family)
|
||||
{
|
||||
return fmt::format(GetAddressFormatString(this->GetAddress()->ss_family, with_family), this->GetHostname(), this->GetPort());
|
||||
return fmt::format(fmt::runtime(GetAddressFormatString(this->GetAddress()->ss_family, with_family)), this->GetHostname(), this->GetPort());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -131,7 +131,7 @@ void NewGRFProfiler::Abort()
|
|||
*/
|
||||
std::string NewGRFProfiler::GetOutputFilename() const
|
||||
{
|
||||
return fmt::format("{}grfprofile-{%Y%m%d-%H%M}-{:08X}.csv", FiosGetScreenshotDir(), fmt::localtime(time(nullptr)), BSWAP32(this->grffile->grfid));
|
||||
return fmt::format("{}grfprofile-{:%Y%m%d-%H%M}-{:08X}.csv", FiosGetScreenshotDir(), fmt::localtime(time(nullptr)), BSWAP32(this->grffile->grfid));
|
||||
}
|
||||
|
||||
/* static */ uint32_t NewGRFProfiler::FinishAll()
|
||||
|
|
Loading…
Reference in New Issue