Codechange: convert printf DEBUG statements to fmt Debug statements

pull/332/head
rubidium42 3 years ago committed by rubidium42
parent a99ac62c1a
commit 55a11710a6

@ -207,7 +207,7 @@
for (CompanyID c = COMPANY_FIRST; c < MAX_COMPANIES; c++) {
if (_settings_game.ai_config[c] != nullptr && _settings_game.ai_config[c]->HasScript()) {
if (!_settings_game.ai_config[c]->ResetInfo(true)) {
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_game.ai_config[c]->GetName());
_settings_game.ai_config[c]->Change(nullptr);
if (Company::IsValidAiID(c)) {
/* The code belonging to an already running AI was deleted. We can only do
@ -224,7 +224,7 @@
}
if (_settings_newgame.ai_config[c] != nullptr && _settings_newgame.ai_config[c]->HasScript()) {
if (!_settings_newgame.ai_config[c]->ResetInfo(false)) {
DEBUG(script, 0, "After a reload, the AI by the name '%s' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
Debug(script, 0, "After a reload, the AI by the name '{}' was no longer found, and removed from the list.", _settings_newgame.ai_config[c]->GetName());
_settings_newgame.ai_config[c]->Change(nullptr);
}
}

@ -89,7 +89,7 @@ template <> const char *GetClassName<AIInfo, ST_AI>() { return "AIInfo"; }
if (info->engine->MethodExists(*info->SQ_instance, "GetAPIVersion")) {
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version, MAX_GET_OPS)) return SQ_ERROR;
if (!CheckAPIVersion(info->api_version)) {
DEBUG(script, 1, "Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion());
Debug(script, 1, "Loading info.nut from ({}.{}): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion());
return SQ_ERROR;
}
} else {

@ -66,7 +66,7 @@ AIInfo *AIScannerInfo::SelectRandomAI() const
}
if (num_random_ais == 0) {
DEBUG(script, 0, "No suitable AI found, loading 'dummy' AI.");
Debug(script, 0, "No suitable AI found, loading 'dummy' AI.");
return this->info_dummy;
}

@ -1786,7 +1786,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
{
/* error handling */
if (v->pos >= apc->nofelements) {
DEBUG(misc, 0, "[Ap] position %d is not valid for current airport. Max position is %d", v->pos, apc->nofelements-1);
Debug(misc, 0, "[Ap] position {} is not valid for current airport. Max position is {}", v->pos, apc->nofelements-1);
assert(v->pos < apc->nofelements);
}
@ -1825,7 +1825,7 @@ static bool AirportMove(Aircraft *v, const AirportFTAClass *apc)
current = current->next;
} while (current != nullptr);
DEBUG(misc, 0, "[Ap] cannot move further on Airport! (pos %d state %d) for vehicle %d", v->pos, v->state, v->index);
Debug(misc, 0, "[Ap] cannot move further on Airport! (pos {} state {}) for vehicle {}", v->pos, v->state, v->index);
NOT_REACHED();
}

@ -22,8 +22,8 @@
#define fetch_metadata(name) \
item = metadata->GetItem(name, false); \
if (item == nullptr || !item->value.has_value() || item->value->empty()) { \
DEBUG(grf, 0, "Base " SET_TYPE "set detail loading: %s field missing.", name); \
DEBUG(grf, 0, " Is %s readable for the user running OpenTTD?", full_filename); \
Debug(grf, 0, "Base " SET_TYPE "set detail loading: {} field missing.", name); \
Debug(grf, 0, " Is {} readable for the user running OpenTTD?", full_filename); \
return false; \
}
@ -74,7 +74,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
/* Find the filename first. */
item = files->GetItem(BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], false);
if (item == nullptr || (!item->value.has_value() && !allow_empty_filename)) {
DEBUG(grf, 0, "No " SET_TYPE " file for: %s (in %s)", BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], full_filename);
Debug(grf, 0, "No " SET_TYPE " file for: {} (in {})", BaseSet<T, Tnum_files, Tsearch_in_tars>::file_names[i], full_filename);
return false;
}
@ -92,7 +92,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
/* Then find the MD5 checksum */
item = md5s->GetItem(filename, false);
if (item == nullptr || !item->value.has_value()) {
DEBUG(grf, 0, "No MD5 checksum specified for: %s (in %s)", filename, full_filename);
Debug(grf, 0, "No MD5 checksum specified for: {} (in {})", filename, full_filename);
return false;
}
const char *c = item->value->c_str();
@ -105,7 +105,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
} else if ('A' <= *c && *c <= 'F') {
j = *c - 'A' + 10;
} else {
DEBUG(grf, 0, "Malformed MD5 checksum specified for: %s (in %s)", filename, full_filename);
Debug(grf, 0, "Malformed MD5 checksum specified for: {} (in {})", filename, full_filename);
return false;
}
if (i % 2 == 0) {
@ -119,7 +119,7 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
item = origin->GetItem(filename, false);
if (item == nullptr) item = origin->GetItem("default", false);
if (item == nullptr || !item->value.has_value()) {
DEBUG(grf, 1, "No origin warning message specified for: %s", filename);
Debug(grf, 1, "No origin warning message specified for: {}", filename);
file->missing_warning = stredup("");
} else {
file->missing_warning = stredup(item->value->c_str());
@ -136,12 +136,12 @@ bool BaseSet<T, Tnum_files, Tsearch_in_tars>::FillSetDetails(IniFile *ini, const
break;
case MD5File::CR_MISMATCH:
DEBUG(grf, 1, "MD5 checksum mismatch for: %s (in %s)", filename, full_filename);
Debug(grf, 1, "MD5 checksum mismatch for: {} (in {})", filename, full_filename);
this->found_files++;
break;
case MD5File::CR_NO_FILE:
DEBUG(grf, 1, "The file %s specified in %s is missing", filename, full_filename);
Debug(grf, 1, "The file {} specified in {} is missing", filename, full_filename);
break;
}
}
@ -153,7 +153,7 @@ template <class Tbase_set>
bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_length, const std::string &tar_filename)
{
bool ret = false;
DEBUG(grf, 1, "Checking %s for base " SET_TYPE " set", filename.c_str());
Debug(grf, 1, "Checking {} for base " SET_TYPE " set", filename);
Tbase_set *set = new Tbase_set();
IniFile *ini = new IniFile();
@ -179,7 +179,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
/* The more complete set takes precedence over the version number. */
if ((duplicate->valid_files == set->valid_files && duplicate->version >= set->version) ||
duplicate->valid_files > set->valid_files) {
DEBUG(grf, 1, "Not adding %s (%i) as base " SET_TYPE " set (duplicate, %s)", set->name.c_str(), set->version,
Debug(grf, 1, "Not adding {} ({}) as base " SET_TYPE " set (duplicate, {})", set->name, set->version,
duplicate->valid_files > set->valid_files ? "less valid files" : "lower version");
set->next = BaseMedia<Tbase_set>::duplicate_sets;
BaseMedia<Tbase_set>::duplicate_sets = set;
@ -195,7 +195,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
* version number until a new game is started which isn't a big problem */
if (BaseMedia<Tbase_set>::used_set == duplicate) BaseMedia<Tbase_set>::used_set = set;
DEBUG(grf, 1, "Removing %s (%i) as base " SET_TYPE " set (duplicate, %s)", duplicate->name.c_str(), duplicate->version,
Debug(grf, 1, "Removing {} ({}) as base " SET_TYPE " set (duplicate, {})", duplicate->name, duplicate->version,
duplicate->valid_files < set->valid_files ? "less valid files" : "lower version");
duplicate->next = BaseMedia<Tbase_set>::duplicate_sets;
BaseMedia<Tbase_set>::duplicate_sets = duplicate;
@ -209,7 +209,7 @@ bool BaseMedia<Tbase_set>::AddFile(const std::string &filename, size_t basepath_
ret = true;
}
if (ret) {
DEBUG(grf, 1, "Adding %s (%i) as base " SET_TYPE " set", set->name.c_str(), set->version);
Debug(grf, 1, "Adding {} ({}) as base " SET_TYPE " set", set->name, set->version);
}
} else {
delete set;

@ -307,7 +307,7 @@ void Blitter_32bppAnim::DrawColourMappingRect(void *dst, int width, int height,
return;
}
DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
}
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 colour)

@ -106,7 +106,7 @@ void Blitter_32bppSimple::DrawColourMappingRect(void *dst, int width, int height
return;
}
DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('%d')", pal);
Debug(misc, 0, "32bpp blitter doesn't know how to draw this colour table ('{}')", pal);
}
Sprite *Blitter_32bppSimple::Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator)

@ -70,7 +70,7 @@ protected:
*/
blitters.insert(Blitters::value_type(this->name, this));
} else {
DEBUG(driver, 1, "Not registering blitter %s as it is not usable", name);
Debug(driver, 1, "Not registering blitter {} as it is not usable", name);
}
}
@ -104,7 +104,7 @@ public:
delete *GetActiveBlitter();
*GetActiveBlitter() = newb;
DEBUG(driver, 1, "Successfully %s blitter '%s'", name.empty() ? "probed" : "loaded", newb->GetName());
Debug(driver, 1, "Successfully {} blitter '{}'", name.empty() ? "probed" : "loaded", newb->GetName());
return newb;
}

@ -696,7 +696,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
if (!_networking || _generating_world || (cmd & CMD_NETWORK_COMMAND) != 0) {
/* Log the failed command as well. Just to be able to be find
* causes of desyncs due to bad command test implementations. */
DEBUG(desync, 1, "cmdf: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text.c_str(), GetCommandName(cmd));
Debug(desync, 1, "cmdf: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
}
cur_company.Restore();
return_dcpi(res);
@ -716,7 +716,7 @@ CommandCost DoCommandPInternal(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd,
* reset the storages as we've not executed the command. */
return_dcpi(CommandCost());
}
DEBUG(desync, 1, "cmd: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text.c_str(), GetCommandName(cmd));
Debug(desync, 1, "cmd: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, tile, p1, p2, cmd & ~CMD_NETWORK_COMMAND, text, GetCommandName(cmd));
/* Actually try and execute the command. If no cost-type is given
* use the construction one */

@ -271,7 +271,7 @@ static void IConsoleAliasExec(const IConsoleAlias *alias, byte tokencount, char
char alias_buffer[ICON_MAX_STREAMSIZE] = { '\0' };
char *alias_stream = alias_buffer;
DEBUG(console, 6, "Requested command is an alias; parsing...");
Debug(console, 6, "Requested command is an alias; parsing...");
if (recurse_count > ICON_MAX_RECURSE) {
IConsoleError("Too many alias expansions, recursion limit reached. Aborting");
@ -372,7 +372,7 @@ void IConsoleCmdExec(const char *cmdstr, const uint recurse_count)
}
}
DEBUG(console, 4, "Executing cmdline: '%s'", cmdstr);
Debug(console, 4, "Executing cmdline: '{}'", cmdstr);
memset(&tokens, 0, sizeof(tokens));
memset(&tokenstream, 0, sizeof(tokenstream));
@ -432,7 +432,7 @@ void IConsoleCmdExec(const char *cmdstr, const uint recurse_count)
}
for (uint i = 0; i < lengthof(tokens) && tokens[i] != nullptr; i++) {
DEBUG(console, 8, "Token %d is: '%s'", i, tokens[i]);
Debug(console, 8, "Token {} is: '{}'", i, tokens[i]);
}
if (StrEmpty(tokens[0])) return; // don't execute empty commands

@ -51,7 +51,7 @@ struct Backup {
{
/* We cannot assert here, as missing restoration is 'normal' when exceptions are thrown.
* Exceptions are especially used to abort world generation. */
DEBUG(misc, 0, "%s:%d: Backed-up value was not restored!", this->file, this->line);
Debug(misc, 0, "{}:{}: Backed-up value was not restored!", this->file, this->line);
this->Restore();
}
}

@ -72,7 +72,7 @@ void SetRandomSeed(uint32 seed)
uint32 DoRandom(int line, const char *file)
{
if (_networking && (!_network_server || (NetworkClientSocket::IsValidID(0) && NetworkClientSocket::Get(0)->status != NetworkClientSocket::STATUS_INACTIVE))) {
DEBUG(random, 0, "%08x; %02x; %04x; %02x; %s:%d", _date, _date_fract, _frame_counter, (byte)_current_company, file, line);
Debug(random, 0, "{:08x}; {:02x}; {:04x}; {:02x}; {}:{}", _date, _date_fract, _frame_counter, (byte)_current_company, file, line);
}
return _random.Next();

@ -105,7 +105,7 @@ const char *GetDebugString();
#define TOC(str, count)\
_sum_ += ottd_rdtsc() - _xxx_;\
if (++_i_ == count) {\
DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " [avg: %.1f]", str, _sum_, _sum_/(double)_i_);\
Debug(misc, 0, "[{}] {} [avg: {:.1f}]", str, _sum_, _sum_/(double)_i_);\
_i_ = 0;\
_sum_ = 0;\
}\
@ -120,7 +120,7 @@ const char *GetDebugString();
#define TOCC(str, _count_)\
_sum_ += (std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - _start_)).count();\
if (++_i_ == _count_) {\
DEBUG(misc, 0, "[%s] " OTTD_PRINTF64 " us [avg: %.1f us]", str, _sum_, _sum_/(double)_i_);\
Debug(misc, 0, "[{}] {} us [avg: {:.1f} us]", str, _sum_, _sum_/(double)_i_);\
_i_ = 0;\
_sum_ = 0;\
}\

@ -121,13 +121,13 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t
const char *err = newd->Start({});
if (err == nullptr) {
DEBUG(driver, 1, "Successfully probed %s driver '%s'", GetDriverTypeName(type), d->name);
Debug(driver, 1, "Successfully probed {} driver '{}'", GetDriverTypeName(type), d->name);
delete oldd;
return true;
}
*GetActiveDriver(type) = oldd;
DEBUG(driver, 1, "Probing %s driver '%s' failed with error: %s", GetDriverTypeName(type), d->name, err);
Debug(driver, 1, "Probing {} driver '{}' failed with error: {}", GetDriverTypeName(type), d->name, err);
delete newd;
if (type == Driver::DT_VIDEO && _video_hw_accel && d->UsesHardwareAcceleration()) {
@ -170,7 +170,7 @@ bool DriverFactoryBase::SelectDriverImpl(const std::string &name, Driver::Type t
usererror("Unable to load driver '%s'. The error was: %s", d->name, err);
}
DEBUG(driver, 1, "Successfully loaded %s driver '%s'", GetDriverTypeName(type), d->name);
Debug(driver, 1, "Successfully loaded {} driver '{}'", GetDriverTypeName(type), d->name);
delete *GetActiveDriver(type);
*GetActiveDriver(type) = newd;
return true;

@ -418,7 +418,7 @@ uint TarScanner::DoScan(Subdirectory sd)
/* static */ uint TarScanner::DoScan(TarScanner::Mode mode)
{
DEBUG(misc, 1, "Scanning for tars");
Debug(misc, 1, "Scanning for tars");
TarScanner fs;
uint num = 0;
if (mode & TarScanner::BASESET) {
@ -439,7 +439,7 @@ uint TarScanner::DoScan(Subdirectory sd)
num += fs.DoScan(SCENARIO_DIR);
num += fs.DoScan(HEIGHTMAP_DIR);
}
DEBUG(misc, 1, "Scan complete, found %d files", num);
Debug(misc, 1, "Scan complete, found {} files", num);
return num;
}
@ -518,7 +518,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
/* If we have only zeros in the block, it can be an end-of-file indicator */
if (memcmp(&th, &empty[0], 512) == 0) continue;
DEBUG(misc, 0, "The file '%s' isn't a valid tar-file", filename.c_str());
Debug(misc, 0, "The file '{}' isn't a valid tar-file", filename);
fclose(f);
return false;
}
@ -555,7 +555,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
/* Convert to lowercase and our PATHSEPCHAR */
SimplifyFileName(name);
DEBUG(misc, 6, "Found file in tar: %s (" PRINTF_SIZE " bytes, " PRINTF_SIZE " offset)", name, skip, pos);
Debug(misc, 6, "Found file in tar: {} ({} bytes, {} offset)", name, skip, pos);
if (_tar_filelist[this->subdir].insert(TarFileList::value_type(name, entry)).second) num++;
break;
@ -574,7 +574,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
/* Only allow relative links */
if (link[0] == PATHSEPCHAR) {
DEBUG(misc, 1, "Ignoring absolute link in tar: %s -> %s", name, link);
Debug(misc, 1, "Ignoring absolute link in tar: {} -> {}", name, link);
break;
}
@ -600,7 +600,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
} else if (strcmp(pos, "..") == 0) {
/* level up */
if (dest[0] == '\0') {
DEBUG(misc, 1, "Ignoring link pointing outside of data directory: %s -> %s", name, link);
Debug(misc, 1, "Ignoring link pointing outside of data directory: {} -> {}", name, link);
break;
}
@ -616,7 +616,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
}
if (destpos >= lastof(dest)) {
DEBUG(misc, 0, "The length of a link in tar-file '%s' is too large (malformed?)", filename.c_str());
Debug(misc, 0, "The length of a link in tar-file '{}' is too large (malformed?)", filename);
fclose(f);
return false;
}
@ -625,7 +625,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
}
/* Store links in temporary list */
DEBUG(misc, 6, "Found link in tar: %s -> %s", name, dest);
Debug(misc, 6, "Found link in tar: {} -> {}", name, dest);
links.insert(TarLinkList::value_type(name, dest));
break;
@ -636,7 +636,7 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
SimplifyFileName(name);
/* Store the first directory name we detect */
DEBUG(misc, 6, "Found dir in tar: %s", name);
Debug(misc, 6, "Found dir in tar: {}", name);
if (_tar_list[this->subdir][filename].empty()) _tar_list[this->subdir][filename] = name;
break;
@ -648,14 +648,14 @@ bool TarScanner::AddFile(const std::string &filename, size_t basepath_length, co
/* Skip to the next block.. */
skip = Align(skip, 512);
if (fseek(f, skip, SEEK_CUR) < 0) {
DEBUG(misc, 0, "The file '%s' can't be read as a valid tar-file", filename.c_str());
Debug(misc, 0, "The file '{}' can't be read as a valid tar-file", filename);
fclose(f);
return false;
}
pos += skip;
}
DEBUG(misc, 1, "Found tar '%s' with " PRINTF_SIZE " new files", filename.c_str(), num);
Debug(misc, 1, "Found tar '{}' with {} new files", filename, num);
fclose(f);
/* Resolve file links and store directory links.
@ -693,7 +693,7 @@ bool ExtractTar(const std::string &tar_filename, Subdirectory subdir)
/* The file doesn't have a sub directory! */
if (dirname.empty()) {
DEBUG(misc, 1, "Extracting %s failed; archive rejected, the contents must be in a sub directory", tar_filename.c_str());
Debug(misc, 1, "Extracting {} failed; archive rejected, the contents must be in a sub directory", tar_filename);
return false;
}
@ -703,7 +703,7 @@ bool ExtractTar(const std::string &tar_filename, Subdirectory subdir)
if (p == std::string::npos) return false;
filename.replace(p + 1, std::string::npos, dirname);
DEBUG(misc, 8, "Extracting %s to directory %s", tar_filename.c_str(), filename.c_str());
Debug(misc, 8, "Extracting {} to directory {}", tar_filename, filename);
FioCreateDirectory(filename);
for (TarFileList::iterator it2 = _tar_filelist[subdir].begin(); it2 != _tar_filelist[subdir].end(); it2++) {
@ -711,20 +711,20 @@ bool ExtractTar(const std::string &tar_filename, Subdirectory subdir)
filename.replace(p + 1, std::string::npos, it2->first);
DEBUG(misc, 9, " extracting %s", filename.c_str());
Debug(misc, 9, " extracting {}", filename);
/* First open the file in the .tar. */
size_t to_copy = 0;
std::unique_ptr<FILE, FileDeleter> in(FioFOpenFileTar(it2->second, &to_copy));
if (!in) {
DEBUG(misc, 6, "Extracting %s failed; could not open %s", filename.c_str(), tar_filename.c_str());
Debug(misc, 6, "Extracting {} failed; could not open {}", filename, tar_filename);
return false;
}
/* Now open the 'output' file. */
std::unique_ptr<FILE, FileDeleter> out(fopen(filename.c_str(), "wb"));
if (!out) {
DEBUG(misc, 6, "Extracting %s failed; could not open %s", filename.c_str(), filename.c_str());
Debug(misc, 6, "Extracting {} failed; could not open {}", filename, filename);
return false;
}
@ -737,12 +737,12 @@ bool ExtractTar(const std::string &tar_filename, Subdirectory subdir)
}
if (to_copy != 0) {
DEBUG(misc, 6, "Extracting %s failed; still %i bytes to copy", filename.c_str(), (int)to_copy);
Debug(misc, 6, "Extracting {} failed; still {} bytes to copy", filename, to_copy);
return false;
}
}
DEBUG(misc, 9, " extraction successful");
Debug(misc, 9, " extraction successful");
return true;
}
@ -778,7 +778,7 @@ static bool ChangeWorkingDirectoryToExecutable(const char *exe)
if (s != nullptr) {
*s = '\0';
if (chdir(tmp) != 0) {
DEBUG(misc, 0, "Directory with the binary does not exist?");
Debug(misc, 0, "Directory with the binary does not exist?");
} else {
success = true;
}
@ -937,7 +937,7 @@ void DetermineBasePaths(const char *exe)
if (cwd[0] != '\0') {
/* Go back to the current working directory. */
if (chdir(cwd) != 0) {
DEBUG(misc, 0, "Failed to return to working directory!");
Debug(misc, 0, "Failed to return to working directory!");
}
}
@ -990,7 +990,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
for (Searchpath sp : _valid_searchpaths) {
if (sp == SP_WORKING_DIR && !_do_scan_working_directory) continue;
DEBUG(misc, 4, "%s added as search path", _searchpaths[sp].c_str());
Debug(misc, 4, "{} added as search path", _searchpaths[sp]);
}
std::string config_dir;
@ -1023,7 +1023,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
_config_file = config_dir + "openttd.cfg";
}
DEBUG(misc, 3, "%s found as config directory", config_dir.c_str());
Debug(misc, 3, "{} found as config directory", config_dir);
_highscore_file = config_dir + "hs.dat";
extern std::string _hotkeys_file;
@ -1055,7 +1055,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
FioCreateDirectory(_personal_dir);
#endif
DEBUG(misc, 3, "%s found as personal directory", _personal_dir.c_str());
Debug(misc, 3, "{} found as personal directory", _personal_dir);
static const Subdirectory default_subdirs[] = {
SAVE_DIR, AUTOSAVE_DIR, SCENARIO_DIR, HEIGHTMAP_DIR, BASESET_DIR, NEWGRF_DIR, AI_DIR, AI_LIBRARY_DIR, GAME_DIR, GAME_LIBRARY_DIR, SCREENSHOT_DIR
@ -1067,7 +1067,7 @@ void DeterminePaths(const char *exe, bool only_local_path)
/* If we have network we make a directory for the autodownloading of content */
_searchpaths[SP_AUTODOWNLOAD_DIR] = _personal_dir + "content_download" PATHSEP;
DEBUG(misc, 4, "%s added as search path", _searchpaths[SP_AUTODOWNLOAD_DIR].c_str());
Debug(misc, 4, "{} added as search path", _searchpaths[SP_AUTODOWNLOAD_DIR]);
FioCreateDirectory(_searchpaths[SP_AUTODOWNLOAD_DIR]);
FillValidSearchPaths(only_local_path);

@ -259,16 +259,16 @@ TrueTypeFontCache::GlyphEntry *TrueTypeFontCache::GetGlyphPtr(GlyphID key)
void TrueTypeFontCache::SetGlyphPtr(GlyphID key, const GlyphEntry *glyph, bool duplicate)
{
if (this->glyph_to_sprite == nullptr) {
DEBUG(freetype, 3, "Allocating root glyph cache for size %u", this->fs);
Debug(freetype, 3, "Allocating root glyph cache for size {}", this->fs);
this->glyph_to_sprite = CallocT<GlyphEntry*>(256);
}
if (this->glyph_to_sprite[GB(key, 8, 8)] == nullptr) {
DEBUG(freetype, 3, "Allocating glyph cache for range 0x%02X00, size %u", GB(key, 8, 8), this->fs);
Debug(freetype, 3, "Allocating glyph cache for range 0x{:02X}00, size {}", GB(key, 8, 8), this->fs);
this->glyph_to_sprite[GB(key, 8, 8)] = CallocT<GlyphEntry>(256);
}
DEBUG(freetype, 4, "Set glyph for unicode character 0x%04X, size %u", key, this->fs);
Debug(freetype, 4, "Set glyph for unicode character 0x{:04X}, size {}", key, this->fs);
this->glyph_to_sprite[GB(key, 8, 8)][GB(key, 0, 8)].sprite = glyph->sprite;
this->glyph_to_sprite[GB(key, 8, 8)][GB(key, 0, 8)].width = glyph->width;
this->glyph_to_sprite[GB(key, 8, 8)][GB(key, 0, 8)].duplicate = duplicate;
@ -468,7 +468,7 @@ void FreeTypeFontCache::SetFontSize(FontSize fs, FT_Face face, int pixels)
this->height = this->ascender - this->descender;
} else {
/* Both FT_Set_Pixel_Sizes and FT_Select_Size failed. */
DEBUG(freetype, 0, "Font size selection failed. Using FontCache defaults.");
Debug(freetype, 0, "Font size selection failed. Using FontCache defaults.");
}
}
@ -498,7 +498,7 @@ static void LoadFreeTypeFont(FontSize fs)
return;
}
DEBUG(freetype, 2, "Initialized");
Debug(freetype, 2, "Initialized");
}
const char *font_name = settings->font.c_str();
@ -527,7 +527,7 @@ static void LoadFreeTypeFont(FontSize fs)
if (error != FT_Err_Ok) error = GetFontByFaceName(font_name, &face);
if (error == FT_Err_Ok) {
DEBUG(freetype, 2, "Requested '%s', using '%s %s'", font_name, face->family_name, face->style_name);
Debug(freetype, 2, "Requested '{}', using '{} {}'", font_name, face->family_name, face->style_name);
/* Attempt to select the unicode character map */
error = FT_Select_Charmap(face, ft_encoding_unicode);

@ -169,7 +169,7 @@
* the GameConfig. If not, remove the Game from the list. */
if (_settings_game.game_config != nullptr && _settings_game.game_config->HasScript()) {
if (!_settings_game.game_config->ResetInfo(true)) {
DEBUG(script, 0, "After a reload, the GameScript by the name '%s' was no longer found, and removed from the list.", _settings_game.game_config->GetName());
Debug(script, 0, "After a reload, the GameScript by the name '{}' was no longer found, and removed from the list.", _settings_game.game_config->GetName());
_settings_game.game_config->Change(nullptr);
if (Game::instance != nullptr) {
delete Game::instance;
@ -182,7 +182,7 @@
}
if (_settings_newgame.game_config != nullptr && _settings_newgame.game_config->HasScript()) {
if (!_settings_newgame.game_config->ResetInfo(false)) {
DEBUG(script, 0, "After a reload, the GameScript by the name '%s' was no longer found, and removed from the list.", _settings_newgame.game_config->GetName());
Debug(script, 0, "After a reload, the GameScript by the name '{}' was no longer found, and removed from the list.", _settings_newgame.game_config->GetName());
_settings_newgame.game_config->Change(nullptr);
}
}

@ -75,7 +75,7 @@ template <> const char *GetClassName<GameInfo, ST_GS>() { return "GSInfo"; }
if (!info->CheckMethod("GetAPIVersion")) return SQ_ERROR;
if (!info->engine->CallStringMethodStrdup(*info->SQ_instance, "GetAPIVersion", &info->api_version, MAX_GET_OPS)) return SQ_ERROR;
if (!CheckAPIVersion(info->api_version)) {
DEBUG(script, 1, "Loading info.nut from (%s.%d): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion());
Debug(script, 1, "Loading info.nut from ({}.{}): GetAPIVersion returned invalid version", info->GetName(), info->GetVersion());
return SQ_ERROR;
}

@ -32,7 +32,7 @@ void CDECL strgen_warning(const char *s, ...)
va_start(va, s);
vseprintf(buf, lastof(buf), s, va);
va_end(va);
DEBUG(script, 0, "%s:%d: warning: %s", _file, _cur_line, buf);
Debug(script, 0, "{}:{}: warning: {}", _file, _cur_line, buf);
_warnings++;
}
@ -43,7 +43,7 @@ void CDECL strgen_error(const char *s, ...)
va_start(va, s);
vseprintf(buf, lastof(buf), s, va);
va_end(va);
DEBUG(script, 0, "%s:%d: error: %s", _file, _cur_line, buf);
Debug(script, 0, "{}:{}: error: {}", _file, _cur_line, buf);
_errors++;
}
@ -54,7 +54,7 @@ void NORETURN CDECL strgen_fatal(const char *s, ...)
va_start(va, s);
vseprintf(buf, lastof(buf), s, va);
va_end(va);
DEBUG(script, 0, "%s:%d: FATAL: %s", _file, _cur_line, buf);
Debug(script, 0, "{}:{}: FATAL: {}", _file, _cur_line, buf);
throw std::exception();
}

@ -356,7 +356,7 @@ static int _gamelog_print_level = 0; ///< gamelog debug level we need to print s
static void GamelogPrintDebugProc(const char *s)
{
DEBUG(gamelog, _gamelog_print_level, "%s", s);
Debug(gamelog, _gamelog_print_level, "{}", s);
}

@ -91,7 +91,7 @@ static void _GenerateWorld()
try {
_generating_world = true;
if (_network_dedicated) DEBUG(net, 3, "Generating map, please wait...");
if (_network_dedicated) Debug(net, 3, "Generating map, please wait...");
/* Set the Random() seed to generation_seed so we produce the same map with the same seed */
if (_settings_game.game_creation.generation_seed == GENERATE_NEW_SEED) _settings_game.game_creation.generation_seed = _settings_newgame.game_creation.generation_seed = InteractiveRandom();
_random.SetSeed(_settings_game.game_creation.generation_seed);
@ -188,8 +188,8 @@ static void _GenerateWorld()
ShowNewGRFError();
if (_network_dedicated) DEBUG(net, 3, "Map generated, starting game");
DEBUG(desync, 1, "new_map: %08x", _settings_game.game_creation.generation_seed);
if (_network_dedicated) Debug(net, 3, "Map generated, starting game");
Debug(desync, 1, "new_map: {:08x}", _settings_game.game_creation.generation_seed);
if (_debug_desync_level > 0) {
char name[MAX_PATH];
@ -204,7 +204,7 @@ static void _GenerateWorld()
if (_network_dedicated) {
/* Exit the game to prevent a return to main menu. */
DEBUG(net, 0, "Generating map failed; closing server");
Debug(net, 0, "Generating map failed; closing server");
_exit_game = true;
} else {
SwitchToMode(_switch_mode);

@ -1458,7 +1458,7 @@ static void _SetGeneratingWorldProgress(GenWorldProgress cls, uint progress, uin
/* Never show steps smaller than 2%, even if it is a mod 5% */
if (_gws.percent <= last_percent + 2) return;
DEBUG(net, 3, "Map generation percentage complete: %d", _gws.percent);
Debug(net, 3, "Map generation percentage complete: {}", _gws.percent);
last_percent = _gws.percent;
return;

@ -1915,7 +1915,7 @@ bool ToggleFullScreen(bool fs)
{
bool result = VideoDriver::GetInstance()->ToggleFullscreen(fs);
if (_fullscreen != fs && _resolutions.empty()) {
DEBUG(driver, 0, "Could not find a suitable fullscreen resolution");
Debug(driver, 0, "Could not find a suitable fullscreen resolution");
}
return result;
}

@ -696,7 +696,7 @@ Layouter::Layouter(const char *str, int maxw, TextColour colour, FontSize fontsi
if (line.layout == nullptr) {
static bool warned = false;
if (!warned) {
DEBUG(misc, 0, "ICU layouter bailed on the font. Falling back to the fallback layouter");
Debug(misc, 0, "ICU layouter bailed on the font. Falling back to the fallback layouter");
warned = true;
}

@ -49,7 +49,7 @@ static uint LoadGrfFile(const char *filename, uint load_index, bool needs_palett
SpriteFile &file = OpenCachedSpriteFile(filename, BASESET_DIR, needs_palette_remap);
DEBUG(sprite, 2, "Reading grf-file '%s'", filename);
Debug(sprite, 2, "Reading grf-file '{}'", filename);
byte container_ver = file.GetContainerVersion();
if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename);
@ -67,7 +67,7 @@ static uint LoadGrfFile(const char *filename, uint load_index, bool needs_palett
usererror("Too many sprites. Recompile with higher MAX_SPRITES value or remove some custom GRF files.");
}
}
DEBUG(sprite, 2, "Currently %i sprites are loaded", load_index);
Debug(sprite, 2, "Currently {} sprites are loaded", load_index);
return load_index - load_index_org;
}
@ -86,7 +86,7 @@ static void LoadGrfFileIndexed(const char *filename, const SpriteID *index_tbl,
SpriteFile &file = OpenCachedSpriteFile(filename, BASESET_DIR, needs_palette_remap);
DEBUG(sprite, 2, "Reading indexed grf-file '%s'", filename);
Debug(sprite, 2, "Reading indexed grf-file '{}'", filename);
byte container_ver = file.GetContainerVersion();
if (container_ver == 0) usererror("Base grf '%s' is corrupt", filename);
@ -119,7 +119,7 @@ void CheckExternalFiles()
const GraphicsSet *used_set = BaseGraphics::GetUsedSet();
DEBUG(grf, 1, "Using the %s base graphics set", used_set->name.c_str());
Debug(grf, 1, "Using the {} base graphics set", used_set->name);
static const size_t ERROR_MESSAGE_LENGTH = 256;
static const size_t MISSING_FILE_MESSAGE_LENGTH = 128;
@ -223,7 +223,7 @@ static void LoadSpriteTables()
uint total_extra_graphics = SPR_NEWGRFS_BASE - SPR_OPENTTD_BASE;
_missing_extra_graphics = GetSpriteCountForFile(master_filename, SPR_OPENTTD_BASE, SPR_NEWGRFS_BASE);
DEBUG(sprite, 1, "%u extra sprites, %u from baseset, %u from fallback", total_extra_graphics, total_extra_graphics - _missing_extra_graphics, _missing_extra_graphics);
Debug(sprite, 1, "{} extra sprites, {} from baseset, {} from fallback", total_extra_graphics, total_extra_graphics - _missing_extra_graphics, _missing_extra_graphics);
/* The original baseset extra graphics intentionally make use of the fallback graphics.
* Let's say everything which provides less than 500 sprites misses the rest intentionally. */
@ -241,10 +241,10 @@ static void RealChangeBlitter(const char *repl_blitter)
const char *cur_blitter = BlitterFactory::GetCurrentBlitter()->GetName();
if (strcmp(cur_blitter, repl_blitter) == 0) return;
DEBUG(driver, 1, "Switching blitter from '%s' to '%s'... ", cur_blitter, repl_blitter);
Debug(driver, 1, "Switching blitter from '{}' to '{}'... ", cur_blitter, repl_blitter);
Blitter *new_blitter = BlitterFactory::SelectBlitter(repl_blitter);
if (new_blitter == nullptr) NOT_REACHED();
DEBUG(driver, 1, "Successfully switched to %s.", repl_blitter);
Debug(driver, 1, "Successfully switched to {}.", repl_blitter);
if (!VideoDriver::GetInstance()->AfterBlitterChange()) {
/* Failed to switch blitter, let's hope we can return to the old one. */
@ -343,7 +343,7 @@ void CheckBlitter()
/** Initialise and load all the sprites. */
void GfxLoadSprites()
{
DEBUG(sprite, 2, "Loading sprite set %d", _settings_game.game_creation.landscape);
Debug(sprite, 2, "Loading sprite set {}", _settings_game.game_creation.landscape);
SwitchNewGRFBlitter();
VideoDriver::GetInstance()->ClearSystemSprites();

@ -138,7 +138,7 @@ void SaveToHighScore()
fwrite(hs->company, length, 1, fp) > 1 || // Yes... could be 0 bytes too
fwrite(&hs->score, sizeof(hs->score), 1, fp) != 1 ||
fwrite(" ", 2, 1, fp) != 1) { // XXX - placeholder for hs->title, not saved anymore; compatibility
DEBUG(misc, 1, "Could not save highscore.");
Debug(misc, 1, "Could not save highscore.");
i = SP_SAVED_HIGHSCORE_END;
break;
}
@ -166,7 +166,7 @@ void LoadFromHighScore()
fread(hs->company, std::min<int>(lengthof(hs->company), length), 1, fp) > 1 || // Yes... could be 0 bytes too
fread(&hs->score, sizeof(hs->score), 1, fp) != 1 ||
fseek(fp, 2, SEEK_CUR) == -1) { // XXX - placeholder for hs->title, not saved anymore; compatibility
DEBUG(misc, 1, "Highscore corrupted");
Debug(misc, 1, "Highscore corrupted");
i = SP_SAVED_HIGHSCORE_END;
break;
}

@ -112,7 +112,7 @@ bool IniFile::SaveToDisk(const std::string &filename)
SHFileOperation(&shfopt);
#else
if (rename(file_new.c_str(), filename.c_str()) < 0) {
DEBUG(misc, 0, "Renaming %s to %s failed; configuration not saved", file_new.c_str(), filename.c_str());
Debug(misc, 0, "Renaming {} to {} failed; configuration not saved", file_new, filename);
}
#endif

@ -47,7 +47,7 @@ void AllocateMap(uint size_x, uint size_y)
error("Invalid map size");
}
DEBUG(map, 1, "Allocating map of size %dx%d", size_x, size_y);
Debug(map, 1, "Allocating map of size {}x{}", size_x, size_y);
_map_log_x = FindFirstBit(size_x);
_map_log_y = FindFirstBit(size_y);

@ -117,17 +117,17 @@ public:
#else
# define LANDINFOD_LEVEL 1
#endif
DEBUG(misc, LANDINFOD_LEVEL, "TILE: %#x (%i,%i)", tile, TileX(tile), TileY(tile));
DEBUG(misc, LANDINFOD_LEVEL, "type = %#x", _m[tile].type);
DEBUG(misc, LANDINFOD_LEVEL, "height = %#x", _m[tile].height);
DEBUG(misc, LANDINFOD_LEVEL, "m1 = %#x", _m[tile].m1);
DEBUG(misc, LANDINFOD_LEVEL, "m2 = %#x", _m[tile].m2);
DEBUG(misc, LANDINFOD_LEVEL, "m3 = %#x", _m[tile].m3);
DEBUG(misc, LANDINFOD_LEVEL, "m4 = %#x", _m[tile].m4);
DEBUG(misc, LANDINFOD_LEVEL, "m5 = %#x", _m[tile].m5);
DEBUG(misc, LANDINFOD_LEVEL, "m6 = %#x", _me[tile].m6);
DEBUG(misc, LANDINFOD_LEVEL, "m7 = %#x", _me[tile].m7);
DEBUG(misc, LANDINFOD_LEVEL, "m8 = %#x", _me[tile].m8);
Debug(misc, LANDINFOD_LEVEL, "TILE: {:#x} ({},{})", tile, TileX(tile), TileY(tile));
Debug(misc, LANDINFOD_LEVEL, "type = {:#x}", _m[tile].type);
Debug(misc, LANDINFOD_LEVEL, "height = {:#x}", _m[tile].height);
Debug(misc, LANDINFOD_LEVEL, "m1 = {:#x}", _m[tile].m1);
Debug(misc, LANDINFOD_LEVEL, "m2 = {:#x}", _m[tile].m2);
Debug(misc, LANDINFOD_LEVEL, "m3 = {:#x}", _m[tile].m3);
Debug(misc, LANDINFOD_LEVEL, "m4 = {:#x}", _m[tile].m4);
Debug(misc, LANDINFOD_LEVEL, "m5 = {:#x}", _m[tile].m5);
Debug(misc, LANDINFOD_LEVEL, "m6 = {:#x}", _me[tile].m6);
Debug(misc, LANDINFOD_LEVEL, "m7 = {:#x}", _me[tile].m7);
Debug(misc, LANDINFOD_LEVEL, "m8 = {:#x}", _me[tile].m8);
#undef LANDINFOD_LEVEL
}

@ -141,7 +141,7 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
this->songinfo[i].cat_index = atoi(item->value->c_str());
char *songname = GetMusicCatEntryName(filename, this->songinfo[i].cat_index);
if (songname == nullptr) {
DEBUG(grf, 0, "Base music set song missing from CAT file: %s/%d", filename, this->songinfo[i].cat_index);
Debug(grf, 0, "Base music set song missing from CAT file: {}/{}", filename, this->songinfo[i].cat_index);
this->songinfo[i].songname[0] = '\0';
continue;
}
@ -168,7 +168,7 @@ bool MusicSet::FillSetDetails(IniFile *ini, const char *path, const char *full_f
if (item != nullptr && item->value.has_value() && !item->value->empty()) {
strecpy(this->songinfo[i].songname, item->value->c_str(), lastof(this->songinfo[i].songname));
} else {
DEBUG(grf, 0, "Base music set song name missing: %s", filename);
Debug(grf, 0, "Base music set song name missing: {}", filename);
return false;
}
}

@ -29,20 +29,20 @@ extern int _allegro_instance_count;
const char *MusicDriver_Allegro::Start(const StringList &param)
{
if (_allegro_instance_count == 0 && install_allegro(SYSTEM_AUTODETECT, &errno, nullptr)) {
DEBUG(driver, 0, "allegro: install_allegro failed '%s'", allegro_error);
Debug(driver, 0, "allegro: install_allegro failed '{}'", allegro_error);
return "Failed to set up Allegro";
}
_allegro_instance_count++;
/* Initialise the sound */
if (install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, nullptr) != 0) {
DEBUG(driver, 0, "allegro: install_sound failed '%s'", allegro_error);
Debug(driver, 0, "allegro: install_sound failed '{}'", allegro_error);
return "Failed to set up Allegro sound";
}
/* Okay, there's no soundcard */
if (midi_card == MIDI_NONE) {
DEBUG(driver, 0, "allegro: no midi card found");
Debug(driver, 0, "allegro: no midi card found");
return "No sound card found";
}

@ -67,7 +67,7 @@ static void DoSetVolume()
}
}
if (output_unit == nullptr) {
DEBUG(driver, 1, "cocoa_m: Failed to get output node to set volume");
Debug(driver, 1, "cocoa_m: Failed to get output node to set volume");
return;
}
@ -119,7 +119,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
{
std::string filename = MidiFile::GetSMFFile(song);
DEBUG(driver, 2, "cocoa_m: trying to play '%s'", filename.c_str());
Debug(driver, 2, "cocoa_m: trying to play '{}'", filename);
this->StopSong();
if (_sequence != nullptr) {
@ -130,7 +130,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
if (filename.empty()) return;
if (NewMusicSequence(&_sequence) != noErr) {
DEBUG(driver, 0, "cocoa_m: Failed to create music sequence");
Debug(driver, 0, "cocoa_m: Failed to create music sequence");
return;
}
@ -138,7 +138,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
CFAutoRelease<CFURLRef> url(CFURLCreateFromFileSystemRepresentation(kCFAllocatorDefault, (const UInt8*)os_file.c_str(), os_file.length(), false));
if (MusicSequenceFileLoad(_sequence, url.get(), kMusicSequenceFile_AnyType, 0) != noErr) {
DEBUG(driver, 0, "cocoa_m: Failed to load MIDI file");
Debug(driver, 0, "cocoa_m: Failed to load MIDI file");
return;
}
@ -148,7 +148,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
MusicSequenceGetAUGraph(_sequence, &graph);
AUGraphOpen(graph);
if (AUGraphInitialize(graph) != noErr) {
DEBUG(driver, 0, "cocoa_m: Failed to initialize AU graph");
Debug(driver, 0, "cocoa_m: Failed to initialize AU graph");
return;
}
@ -173,7 +173,7 @@ void MusicDriver_Cocoa::PlaySong(const MusicSongInfo &song)
if (MusicPlayerStart(_player) != noErr) return;
_playing = true;
DEBUG(driver, 3, "cocoa_m: playing '%s'", filename.c_str());
Debug(driver, 3, "cocoa_m: playing '{}'", filename);
}

@ -229,7 +229,7 @@ bool DLSFile::ReadDLSRegion(FILE *f, DWORD list_length, std::vector<DLSRegion> &
break;
default:
DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
fseek(f, chunk.length, SEEK_CUR);
break;
}
@ -252,11 +252,11 @@ bool DLSFile::ReadDLSRegionList(FILE *f, DWORD list_length, DLSInstrument &instr
if (list_type == FOURCC_RGN) {
this->ReadDLSRegion(f, chunk.length - sizeof(list_type), instrument.regions);
} else {
DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF));
fseek(f, chunk.length - sizeof(list_type), SEEK_CUR);
}
} else {
DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
fseek(f, chunk.length, SEEK_CUR);
}
}
@ -299,7 +299,7 @@ bool DLSFile::ReadDLSInstrument(FILE *f, DWORD list_length)
break;
default:
DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
fseek(f, chunk.length, SEEK_CUR);
break;
}
@ -320,15 +320,15 @@ bool DLSFile::ReadDLSInstrumentList(FILE *f, DWORD list_length)
if (fread(&list_type, sizeof(list_type), 1, f) != 1) return false;
if (list_type == FOURCC_INS) {
DEBUG(driver, 6, "DLS: Reading instrument %d", (int)instruments.size());
Debug(driver, 6, "DLS: Reading instrument {}", (int)instruments.size());
if (!this->ReadDLSInstrument(f, chunk.length - sizeof(list_type))) return false;
} else {
DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF));
fseek(f, chunk.length - sizeof(list_type), SEEK_CUR);
}
} else {
DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
fseek(f, chunk.length, SEEK_CUR);
}
}
@ -387,7 +387,7 @@ bool DLSFile::ReadDLSWave(FILE *f, DWORD list_length, long offset)
break;
default:
DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
fseek(f, chunk.length, SEEK_CUR);
break;
}
@ -412,15 +412,15 @@ bool DLSFile::ReadDLSWaveList(FILE *f, DWORD list_length)
if (fread(&list_type, sizeof(list_type), 1, f) != 1) return false;
if (list_type == FOURCC_wave) {
DEBUG(driver, 6, "DLS: Reading wave %d", (int)waves.size());
Debug(driver, 6, "DLS: Reading wave {}", waves.size());
if (!this->ReadDLSWave(f, chunk.length - sizeof(list_type), chunk_offset - base_offset)) return false;
} else {
DEBUG(driver, 7, "DLS: Ignoring unknown list chunk of type %c%c%c%c", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring unknown list chunk of type {}{}{}{}", (char)(list_type & 0xFF), (char)((list_type >> 8) & 0xFF), (char)((list_type >> 16) & 0xFF), (char)((list_type >> 24) & 0xFF));
fseek(f, chunk.length - sizeof(list_type), SEEK_CUR);
}
} else {
DEBUG(driver, 7, "DLS: Ignoring chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
fseek(f, chunk.length, SEEK_CUR);
}
}
@ -430,7 +430,7 @@ bool DLSFile::ReadDLSWaveList(FILE *f, DWORD list_length)
bool DLSFile::LoadFile(const wchar_t *file)
{
DEBUG(driver, 2, "DMusic: Try to load DLS file %s", FS2OTTD(file).c_str());
Debug(driver, 2, "DMusic: Try to load DLS file {}", FS2OTTD(file));
FILE *f = _wfopen(file, L"rb");
if (f == nullptr) return false;
@ -446,7 +446,7 @@ bool DLSFile::LoadFile(const wchar_t *file)
hdr.length -= sizeof(FOURCC);
DEBUG(driver, 2, "DMusic: Parsing DLS file");
Debug(driver, 2, "DMusic: Parsing DLS file");
DLSHEADER header;
MemSetT(&header, 0);
@ -495,7 +495,7 @@ bool DLSFile::LoadFile(const wchar_t *file)
break;
default:
DEBUG(driver, 7, "DLS: Ignoring unknown chunk %c%c%c%c", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
Debug(driver, 7, "DLS: Ignoring unknown chunk {}{}{}{}", (char)(chunk.type & 0xFF), (char)((chunk.type >> 8) & 0xFF), (char)((chunk.type >> 16) & 0xFF), (char)((chunk.type >> 24) & 0xFF));
fseek(f, chunk.length, SEEK_CUR);
break;
}
@ -585,7 +585,7 @@ static void TransmitNotesOff(IDirectMusicBuffer *buffer, REFERENCE_TIME block_ti
static void MidiThreadProc()
{
DEBUG(driver, 2, "DMusic: Entering playback thread");
Debug(driver, 2, "DMusic: Entering playback thread");
REFERENCE_TIME last_volume_time = 0; // timestamp of the last volume change
REFERENCE_TIME block_time = 0; // timestamp of the last block sent to the port
@ -617,7 +617,7 @@ static void MidiThreadProc()
}
if (_playback.do_stop) {
DEBUG(driver, 2, "DMusic thread: Stopping playback");
Debug(driver, 2, "DMusic thread: Stopping playback");
/* Turn all notes off and wait a bit to allow the messages to be handled. */
clock->GetTime(&cur_time);
@ -632,7 +632,7 @@ static void MidiThreadProc()
if (wfso == WAIT_OBJECT_0) {
if (_playback.do_start) {
DEBUG(driver, 2, "DMusic thread: Starting playback");
Debug(driver, 2, "DMusic thread: Starting playback");
{
/* New scope to limit the time the mutex is locked. */
std::lock_guard<std::mutex> lock(_thread_mutex);
@ -669,14 +669,14 @@ static void MidiThreadProc()
preload_bytes += block.data.size();
if (block.ticktime >= current_segment.start) {
if (current_segment.loop) {
DEBUG(driver, 2, "DMusic: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes);
Debug(driver, 2, "DMusic: timer: loop from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes);
current_segment.start_block = bl;
break;
} else {
/* Skip the transmission delay compensation performed in the Win32 MIDI driver.
* The DMusic driver will most likely be used with the MS softsynth, which is not subject to transmission delays.
*/
DEBUG(driver, 2, "DMusic: timer: start from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes);
Debug(driver, 2, "DMusic: timer: start from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes);
playback_start_time -= block.realtime * MIDITIME_TO_REFTIME;
break;
}
@ -691,7 +691,7 @@ static void MidiThreadProc()
/* Check for volume change. */
if (current_volume != _playback.new_volume) {
if (current_time - last_volume_time > 10 * MS_TO_REFTIME) {
DEBUG(driver, 2, "DMusic thread: volume change");
Debug(driver, 2, "DMusic thread: volume change");
current_volume = _playback.new_volume;
last_volume_time = current_time;
for (int ch = 0; ch < 16; ch++) {
@ -709,7 +709,7 @@ static void MidiThreadProc()
/* check that block isn't at end-of-song override */
if (current_segment.end > 0 && block.ticktime >= current_segment.end) {
if (current_segment.loop) {
DEBUG(driver, 2, "DMusic thread: Looping song");
Debug(driver, 2, "DMusic thread: Looping song");
current_block = current_segment.start_block;
playback_start_time = current_time - current_file.blocks[current_block].realtime * MIDITIME_TO_REFTIME;
} else {
@ -723,13 +723,13 @@ static void MidiThreadProc()
if (block.realtime * MIDITIME_TO_REFTIME > playback_time + 3 *_playback.preload_time * MS_TO_REFTIME) {
/* Stop the thread loop until we are at the preload time of the next block. */
next_timeout = Clamp(((int64)block.realtime * MIDITIME_TO_REFTIME - playback_time) / MS_TO_REFTIME - _playback.preload_time, 0, 1000);
DEBUG(driver, 9, "DMusic thread: Next event in %lu ms (music %u, ref " OTTD_PRINTF64 ")", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time);
Debug(driver, 9, "DMusic thread: Next event in {} ms (music {}, ref {})", next_timeout, block.realtime * MIDITIME_TO_REFTIME, playback_time);
break;
}
/* Timestamp of the current block. */
block_time = playback_start_time + block.realtime * MIDITIME_TO_REFTIME;
DEBUG(driver, 9, "DMusic thread: Streaming block " PRINTF_SIZE " (cur=" OTTD_PRINTF64 ", block=" OTTD_PRINTF64 ")", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME));
Debug(driver, 9, "DMusic thread: Streaming block {} (cur={}, block={})", current_block, (long long)(current_time / MS_TO_REFTIME), (long long)(block_time / MS_TO_REFTIME));
const byte *data = block.data.data();
size_t remaining = block.data.size();
@ -822,7 +822,7 @@ static void MidiThreadProc()
}
}
DEBUG(driver, 2, "DMusic: Exiting playback thread");
Debug(driver, 2, "DMusic: Exiting playback thread");
/* Turn all notes off and wait a bit to allow the messages to be handled by real hardware. */
clock->GetTime(&cur_time);
@ -867,7 +867,7 @@ static const char *LoadDefaultDLSFile(const char *user_dls)
if (SUCCEEDED(RegQueryValueEx(hkDM, L"GMFilePath", nullptr, nullptr, (LPBYTE)dls_path, &buf_size))) {
wchar_t expand_path[MAX_PATH * 2];
ExpandEnvironmentStrings(dls_path, expand_path, lengthof(expand_path));
if (!dls_file.LoadFile(expand_path)) DEBUG(driver, 1, "Failed to load default GM DLS file from registry");
if (!dls_file.LoadFile(expand_path)) Debug(driver, 1, "Failed to load default GM DLS file from registry");
}
RegCloseKey(hkDM);
}
@ -1100,10 +1100,10 @@ const char *MusicDriver_DMusic::Start(const StringList &parm)
MemSetT(&caps, 0);
caps.dwSize = sizeof(DMUS_PORTCAPS);
DEBUG(driver, 1, "Detected DirectMusic ports:");
Debug(driver, 1, "Detected DirectMusic ports:");
for (int i = 0; _music->EnumPort(i, &caps) == S_OK; i++) {
if (caps.dwClass == DMUS_PC_OUTPUTCLASS) {
DEBUG(driver, 1, " %d: %s%s", i, convert_from_fs(caps.wszDescription, desc, lengthof(desc)), i == pIdx ? " (selected)" : "");
Debug(driver, 1, " {}: {}{}", i, convert_from_fs(caps.wszDescription, desc, lengthof(desc)), i == pIdx ? " (selected)" : "");
}
}
}

@ -110,7 +110,7 @@ bool MusicDriver_ExtMidi::IsSongPlaying()
void MusicDriver_ExtMidi::SetVolume(byte vol)
{
DEBUG(driver, 1, "extmidi: set volume not implemented");
Debug(driver, 1, "extmidi: set volume not implemented");
}
void MusicDriver_ExtMidi::DoPlay()
@ -127,7 +127,7 @@ void MusicDriver_ExtMidi::DoPlay()
}
case -1:
DEBUG(driver, 0, "extmidi: couldn't fork: %s", strerror(errno));
Debug(driver, 0, "extmidi: couldn't fork: {}", strerror(errno));
FALLTHROUGH;
default:
@ -153,7 +153,7 @@ void MusicDriver_ExtMidi::DoStop()
CSleep(10);
}
DEBUG(driver, 0, "extmidi: gracefully stopping failed, trying the hard way");
Debug(driver, 0, "extmidi: gracefully stopping failed, trying the hard way");
/* Gracefully stopping failed. Do it the hard way
* and wait till the process finally died. */
kill(this->pid, SIGKILL);

@ -65,7 +65,7 @@ const char *MusicDriver_FluidSynth::Start(const StringList &param)
const char *sfont_name = GetDriverParam(param, "soundfont");
int sfont_id;
DEBUG(driver, 1, "Fluidsynth: sf %s", sfont_name);
Debug(driver, 1, "Fluidsynth: sf {}", sfont_name);
/* Create the settings. */
_midi.settings = new_fluid_settings();
@ -76,7 +76,7 @@ const char *MusicDriver_FluidSynth::Start(const StringList &param)
/* Install the music render routine and set up the samplerate */
uint32 samplerate = MxSetMusicSource(RenderMusicStream);
fluid_settings_setnum(_midi.settings, "synth.sample-rate", samplerate);
DEBUG(driver, 1, "Fluidsynth: samplerate %.0f", (float)samplerate);
Debug(driver, 1, "Fluidsynth: samplerate {:.0f}", (float)samplerate);
/* Create the synthesizer. */
_midi.synth = new_fluid_synth(_midi.settings);
@ -143,18 +143,18 @@ void MusicDriver_FluidSynth::PlaySong(const MusicSongInfo &song)
_midi.player = new_fluid_player(_midi.synth);
if (_midi.player == nullptr) {
DEBUG(driver, 0, "Could not create midi player");
Debug(driver, 0, "Could not create midi player");
return;
}
if (fluid_player_add(_midi.player, filename.c_str()) != FLUID_OK) {
DEBUG(driver, 0, "Could not open music file");
Debug(driver, 0, "Could not open music file");
delete_fluid_player(_midi.player);
_midi.player = nullptr;
return;
}
if (fluid_player_play(_midi.player) != FLUID_OK) {
DEBUG(driver, 0, "Could not start midi player");
Debug(driver, 0, "Could not start midi player");
delete_fluid_player(_midi.player);
_midi.player = nullptr;
return;
@ -194,6 +194,6 @@ void MusicDriver_FluidSynth::SetVolume(byte vol)
* and 0.2. */
double gain = (1.0 * vol) / (128.0 * 5.0);
if (fluid_settings_setnum(_midi.settings, "synth.gain", gain) != FLUID_OK) {
DEBUG(driver, 0, "Could not set volume");
Debug(driver, 0, "Could not set volume");
}
}

@ -115,7 +115,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
/* check for stop */
if (_midi.do_stop) {
DEBUG(driver, 2, "Win32-MIDI: timer: do_stop is set");
Debug(driver, 2, "Win32-MIDI: timer: do_stop is set");
midiOutReset(_midi.midi_out);
_midi.playing = false;
_midi.do_stop = false;
@ -128,7 +128,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
if (timeGetTime() - _midi.playback_start_time < 50) {
return;
}
DEBUG(driver, 2, "Win32-MIDI: timer: do_start step %d", _midi.do_start);
Debug(driver, 2, "Win32-MIDI: timer: do_start step {}", _midi.do_start);
if (_midi.do_start == 1) {
/* Send "all notes off" */
@ -165,7 +165,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
}
} else if (!_midi.playing) {
/* not playing, stop the timer */
DEBUG(driver, 2, "Win32-MIDI: timer: not playing, stopping timer");
Debug(driver, 2, "Win32-MIDI: timer: not playing, stopping timer");
timeKillEvent(uTimerID);
_midi.timer_id = 0;
return;
@ -175,7 +175,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
static int volume_throttle = 0;
if (_midi.current_volume != _midi.new_volume) {
if (volume_throttle == 0) {
DEBUG(driver, 2, "Win32-MIDI: timer: volume change");
Debug(driver, 2, "Win32-MIDI: timer: volume change");
_midi.current_volume = _midi.new_volume;
volume_throttle = 20 / _midi.time_period;
for (int ch = 0; ch < 16; ch++) {
@ -198,7 +198,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
preload_bytes += block.data.size();
if (block.ticktime >= _midi.current_segment.start) {
if (_midi.current_segment.loop) {
DEBUG(driver, 2, "Win32-MIDI: timer: loop from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime)/1000.0, (int)preload_bytes);
Debug(driver, 2, "Win32-MIDI: timer: loop from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime)/1000.0, preload_bytes);
_midi.current_segment.start_block = bl;
break;
} else {
@ -207,7 +207,7 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
* which have a bitrate of 31,250 bits/sec, and transmit 1+8+1 start/data/stop bits per byte.
* The delay compensation is needed to avoid time-compression of following messages.
*/
DEBUG(driver, 2, "Win32-MIDI: timer: start from block %d (ticktime %d, realtime %.3f, bytes %d)", (int)bl, (int)block.ticktime, ((int)block.realtime) / 1000.0, (int)preload_bytes);
Debug(driver, 2, "Win32-MIDI: timer: start from block {} (ticktime {}, realtime {:.3f}, bytes {})", bl, block.ticktime, ((int)block.realtime) / 1000.0, preload_bytes);
_midi.playback_start_time -= block.realtime / 1000 - (DWORD)(preload_bytes * 1000 / 3125);
break;
}
@ -320,11 +320,11 @@ void CALLBACK TimerCallback(UINT uTimerID, UINT, DWORD_PTR dwUser, DWORD_PTR, DW
void MusicDriver_Win32::PlaySong(const MusicSongInfo &song)
{
DEBUG(driver, 2, "Win32-MIDI: PlaySong: entry");
Debug(driver, 2, "Win32-MIDI: PlaySong: entry");
MidiFile new_song;
if (!new_song.LoadSong(song)) return;
DEBUG(driver, 2, "Win32-MIDI: PlaySong: Loaded song");
Debug(driver, 2, "Win32-MIDI: PlaySong: Loaded song");
std::lock_guard<std::mutex> mutex_lock(_midi.lock);
@ -333,21 +333,21 @@ void MusicDriver_Win32::PlaySong(const MusicSongInfo &song)
_midi.next_segment.end = song.override_end;
_midi.next_segment.loop = song.loop;
DEBUG(driver, 2, "Win32-MIDI: PlaySong: setting flag");
Debug(driver, 2, "Win32-MIDI: PlaySong: setting flag");
_midi.do_stop = _midi.playing;
_midi.do_start = 1;
if (_midi.timer_id == 0) {
DEBUG(driver, 2, "Win32-MIDI: PlaySong: starting timer");
Debug(driver, 2, "Win32-MIDI: PlaySong: starting timer");
_midi.timer_id = timeSetEvent(_midi.time_period, _midi.time_period, TimerCallback, (DWORD_PTR)this, TIME_PERIODIC | TIME_CALLBACK_FUNCTION);
}
}
void MusicDriver_Win32::StopSong()
{
DEBUG(driver, 2, "Win32-MIDI: StopSong: entry");
Debug(driver, 2, "Win32-MIDI: StopSong: entry");
std::lock_guard<std::mutex> mutex_lock(_midi.lock);
DEBUG(driver, 2, "Win32-MIDI: StopSong: setting flag");
Debug(driver, 2, "Win32-MIDI: StopSong: setting flag");
_midi.do_stop = true;
}
@ -364,7 +364,7 @@ void MusicDriver_Win32::SetVolume(byte vol)
const char *MusicDriver_Win32::Start(const StringList &parm)
{
DEBUG(driver, 2, "Win32-MIDI: Start: initializing");
Debug(driver, 2, "Win32-MIDI: Start: initializing");
int resolution = GetDriverParamInt(parm, "resolution", 5);
uint port = (uint)GetDriverParamInt(parm, "port", UINT_MAX);
@ -373,7 +373,7 @@ const char *MusicDriver_Win32::Start(const StringList &parm)
/* Enumerate ports either for selecting port by name, or for debug output */
if (portname != nullptr || _debug_driver_level > 0) {
uint numports = midiOutGetNumDevs();
DEBUG(driver, 1, "Win32-MIDI: Found %d output devices:", numports);
Debug(driver, 1, "Win32-MIDI: Found {} output devices:", numports);
for (uint tryport = 0; tryport < numports; tryport++) {
MIDIOUTCAPS moc{};
if (midiOutGetDevCaps(tryport, &moc, sizeof(moc)) == MMSYSERR_NOERROR) {
@ -384,7 +384,7 @@ const char *MusicDriver_Win32::Start(const StringList &parm)
* If multiple ports have the same name, this will select the last matching port, and the debug output will be confusing. */
if (portname != nullptr && strncmp(tryportname, portname, lengthof(tryportname)) == 0) port = tryport;
DEBUG(driver, 1, "MIDI port %2d: %s%s", tryport, tryportname, (tryport == port) ? " [selected]" : "");
Debug(driver, 1, "MIDI port {:2d}: {}{}", tryport, tryportname, (tryport == port) ? " [selected]" : "");
}
}
}
@ -410,7 +410,7 @@ const char *MusicDriver_Win32::Start(const StringList &parm)
_midi.time_period = std::min(std::max((UINT)resolution, timecaps.wPeriodMin), timecaps.wPeriodMax);
if (timeBeginPeriod(_midi.time_period) == MMSYSERR_NOERROR) {
/* success */
DEBUG(driver, 2, "Win32-MIDI: Start: timer resolution is %d", (int)_midi.time_period);
Debug(driver, 2, "Win32-MIDI: Start: timer resolution is {}", _midi.time_period);
return nullptr;
}
}

@ -247,9 +247,9 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
auto end = std::chrono::steady_clock::now();
std::chrono::seconds duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
if (!_resolve_timeout_error_message_shown && duration >= std::chrono::seconds(5)) {
DEBUG(net, 0, "getaddrinfo for hostname \"%s\", port %s, address family %s and socket type %s took %i seconds",
this->hostname.c_str(), port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), (int)duration.count());
DEBUG(net, 0, " this is likely an issue in the DNS name resolver's configuration causing it to time out");
Debug(net, 0, "getaddrinfo for hostname \"{}\", port {}, address family {} and socket type {} took {} seconds",
this->hostname, port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), duration.count());
Debug(net, 0, " this is likely an issue in the DNS name resolver's configuration causing it to time out");
_resolve_timeout_error_message_shown = true;
}
@ -258,8 +258,8 @@ SOCKET NetworkAddress::Resolve(int family, int socktype, int flags, SocketList *
if (e != 0) {
if (func != ResolveLoopProc) {
DEBUG(net, 0, "getaddrinfo for hostname \"%s\", port %s, address family %s and socket type %s failed: %s",
this->hostname.c_str(), port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), FS2OTTD(gai_strerror(e)).c_str());
Debug(net, 0, "getaddrinfo for hostname \"{}\", port {}, address family {} and socket type {} failed: {}",
this->hostname, port_name, AddressFamilyAsString(family), SocketTypeAsString(socktype), FS2OTTD(gai_strerror(e)));
}
return INVALID_SOCKET;
}
@ -317,35 +317,35 @@ static SOCKET ListenLoopProc(addrinfo *runp)
if (sock == INVALID_SOCKET) {
const char *type = NetworkAddress::SocketTypeAsString(runp->ai_socktype);
const char *family = NetworkAddress::AddressFamilyAsString(runp->ai_family);
DEBUG(net, 0, "Could not create %s %s socket: %s", type, family, NetworkError::GetLast().AsString());
Debug(net, 0, "Could not create {} {} socket: {}", type, family, NetworkError::GetLast().AsString());
return INVALID_SOCKET;
}
if (runp->ai_socktype == SOCK_STREAM && !SetNoDelay(sock)) {
DEBUG(net, 1, "Setting no-delay mode failed: %s", NetworkError::GetLast().AsString());
Debug(net, 1, "Setting no-delay mode failed: {}", NetworkError::GetLast().AsString());
}
int on = 1;
/* The (const char*) cast is needed for windows!! */
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (const char*)&on, sizeof(on)) == -1) {
DEBUG(net, 0, "Setting reuse-address mode failed: %s", NetworkError::GetLast().AsString());
Debug(net, 0, "Setting reuse-address mode failed: {}", NetworkError::GetLast().AsString());
}
#ifndef __OS2__
if (runp->ai_family == AF_INET6 &&
setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY, (const char*)&on, sizeof(on)) == -1) {
DEBUG(net, 3, "Could not disable IPv4 over IPv6: %s", NetworkError::GetLast().AsString());
Debug(net, 3, "Could not disable IPv4 over IPv6: {}", NetworkError::GetLast().AsString());
}
#endif
if (bind(sock, runp->ai_addr, (int)runp->ai_addrlen) != 0) {
DEBUG(net, 0, "Could not bind socket on %s: %s", address.c_str(), NetworkError::GetLast().AsString());
Debug(net, 0, "Could not bind socket on {}: {}", address, NetworkError::GetLast().AsString());
closesocket(sock);
return INVALID_SOCKET;
}
if (runp->ai_socktype != SOCK_DGRAM && listen(sock, 1) != 0) {
DEBUG(net, 0, "Could not listen on socket: %s", NetworkError::GetLast().AsString());
Debug(net, 0, "Could not listen on socket: {}", NetworkError::GetLast().AsString());
closesocket(sock);
return INVALID_SOCKET;
}
@ -353,10 +353,10 @@ static SOCKET ListenLoopProc(addrinfo *runp)
/* Connection succeeded */
if (!SetNonBlocking(sock)) {
DEBUG(net, 0, "Setting non-blocking mode failed: %s", NetworkError::GetLast().AsString());
Debug(net, 0, "Setting non-blocking mode failed: {}", NetworkError::GetLast().AsString());
}
DEBUG(net, 3, "Listening on %s", address.c_str());
Debug(net, 3, "Listening on {}", address);
return sock;
}

@ -27,9 +27,9 @@ bool NetworkCoreInitialize()
#ifdef _WIN32
{
WSADATA wsa;
DEBUG(net, 5, "Loading windows socket library");
Debug(net, 5, "Loading windows socket library");
if (WSAStartup(MAKEWORD(2, 0), &wsa) != 0) {
DEBUG(net, 0, "WSAStartup failed, network unavailable");
Debug(net, 0, "WSAStartup failed, network unavailable");
return false;
}
}

@ -51,7 +51,7 @@ const char *GetNetworkRevisionString()
/* Tag names are not mangled further. */
if (_openttd_revision_tagged) {
DEBUG(net, 3, "Network revision name: %s", network_revision);
Debug(net, 3, "Network revision name: {}", network_revision);
return network_revision;
}
@ -71,7 +71,7 @@ const char *GetNetworkRevisionString()
/* Replace the git hash in revision string. */
strecpy(network_revision + hashofs, githash_suffix, network_revision + NETWORK_REVISION_LENGTH);
assert(strlen(network_revision) < NETWORK_REVISION_LENGTH); // strlen does not include terminator, constant does, hence strictly less than
DEBUG(net, 3, "Network revision name: %s", network_revision);
Debug(net, 3, "Network revision name: {}", network_revision);
}
return network_revision;

@ -131,10 +131,10 @@ void NetworkFindBroadcastIPs(NetworkAddressList *broadcast)
NetworkFindBroadcastIPsInternal(broadcast);
/* Now display to the debug all the detected ips */
DEBUG(net, 3, "Detected broadcast addresses:");
Debug(net, 3, "Detected broadcast addresses:");
int i = 0;
for (NetworkAddress &addr : *broadcast) {
addr.SetPort(NETWORK_DEFAULT_PORT);
DEBUG(net, 3, " %d) %s", i++, addr.GetHostname());
Debug(net, 3, " {}) {}", i++, addr.GetHostname());
}
}

@ -112,7 +112,7 @@ SendPacketsState NetworkTCPSocketHandler::SendPackets(bool closing_down)
if (!err.WouldBlock()) {
/* Something went wrong.. close client! */
if (!closing_down) {
DEBUG(net, 0, "Send failed: %s", err.AsString());
Debug(net, 0, "Send failed: {}", err.AsString());
this->CloseConnection();
}
return SPS_CLOSED;
@ -161,7 +161,7 @@ Packet *NetworkTCPSocketHandler::ReceivePacket()
NetworkError err = NetworkError::GetLast();
if (!err.WouldBlock()) {
/* Something went wrong... */
if (!err.IsConnectionReset()) DEBUG(net, 0, "Recv failed: %s", err.AsString());
if (!err.IsConnectionReset()) Debug(net, 0, "Recv failed: {}", err.AsString());
this->CloseConnection();
return nullptr;
}
@ -189,7 +189,7 @@ Packet *NetworkTCPSocketHandler::ReceivePacket()
NetworkError err = NetworkError::GetLast();
if (!err.WouldBlock()) {
/* Something went wrong... */
if (!err.IsConnectionReset()) DEBUG(net, 0, "Recv failed: %s", err.AsString());
if (!err.IsConnectionReset()) Debug(net, 0, "Recv failed: {}", err.AsString());
this->CloseConnection();
return nullptr;
}

@ -87,9 +87,9 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p)
default:
if (this->HasClientQuit()) {
DEBUG(net, 0, "[tcp/admin] Received invalid packet type %d from '%s' (%s)", type, this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 0, "[tcp/admin] Received invalid packet type {} from '{}' ({})", type, this->admin_name, this->admin_version);
} else {
DEBUG(net, 0, "[tcp/admin] Received illegal packet from '%s' (%s)", this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 0, "[tcp/admin] Received illegal packet from '{}' ({})", this->admin_name, this->admin_version);
}
this->CloseConnection();
@ -123,7 +123,7 @@ NetworkRecvStatus NetworkAdminSocketHandler::ReceivePackets()
*/
NetworkRecvStatus NetworkAdminSocketHandler::ReceiveInvalidPacket(PacketAdminType type)
{
DEBUG(net, 0, "[tcp/admin] Received illegal packet type %d from admin %s (%s)", type, this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 0, "[tcp/admin] Received illegal packet type {} from admin {} ({})", type, this->admin_name, this->admin_version);
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}

@ -56,25 +56,25 @@ void TCPConnecter::Connect(addrinfo *address)
{
SOCKET sock = socket(address->ai_family, address->ai_socktype, address->ai_protocol);
if (sock == INVALID_SOCKET) {
DEBUG(net, 0, "Could not create %s %s socket: %s", NetworkAddress::SocketTypeAsString(address->ai_socktype), NetworkAddress::AddressFamilyAsString(address->ai_family), NetworkError::GetLast().AsString());
Debug(net, 0, "Could not create {} {} socket: {}", NetworkAddress::SocketTypeAsString(address->ai_socktype), NetworkAddress::AddressFamilyAsString(address->ai_family), NetworkError::GetLast().AsString());
return;
}
if (!SetNoDelay(sock)) {
DEBUG(net, 1, "Setting TCP_NODELAY failed: %s", NetworkError::GetLast().AsString());
Debug(net, 1, "Setting TCP_NODELAY failed: {}", NetworkError::GetLast().AsString());
}
if (!SetNonBlocking(sock)) {
DEBUG(net, 0, "Setting non-blocking mode failed: %s", NetworkError::GetLast().AsString());
Debug(net, 0, "Setting non-blocking mode failed: {}", NetworkError::GetLast().AsString());
}
NetworkAddress network_address = NetworkAddress(address->ai_addr, (int)address->ai_addrlen);
DEBUG(net, 5, "Attempting to connect to %s", network_address.GetAddressAsString().c_str());
Debug(net, 5, "Attempting to connect to {}", network_address.GetAddressAsString());
int err = connect(sock, address->ai_addr, (int)address->ai_addrlen);
if (err != 0 && !NetworkError::GetLast().IsConnectInProgress()) {
closesocket(sock);
DEBUG(net, 1, "Could not connect to %s: %s", network_address.GetAddressAsString().c_str(), NetworkError::GetLast().AsString());
Debug(net, 1, "Could not connect to {}: {}", network_address.GetAddressAsString(), NetworkError::GetLast().AsString());
return;
}
@ -150,9 +150,9 @@ void TCPConnecter::OnResolved(addrinfo *ai)
}
if (_debug_net_level >= 6) {
DEBUG(net, 6, "%s resolved in:", this->connection_string.c_str());
Debug(net, 6, "{} resolved in:", this->connection_string);
for (const auto &address : this->addresses) {
DEBUG(net, 6, "- %s", NetworkAddress(address->ai_addr, (int)address->ai_addrlen).GetAddressAsString().c_str());
Debug(net, 6, "- {}", NetworkAddress(address->ai_addr, (int)address->ai_addrlen).GetAddressAsString());
}
}
@ -188,13 +188,13 @@ void TCPConnecter::Resolve()
auto end = std::chrono::steady_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
if (!getaddrinfo_timeout_error_shown && duration >= std::chrono::seconds(5)) {
DEBUG(net, 0, "getaddrinfo() for address \"%s\" took %i seconds", this->connection_string.c_str(), (int)duration.count());
DEBUG(net, 0, " This is likely an issue in the DNS name resolver's configuration causing it to time out");
Debug(net, 0, "getaddrinfo() for address \"{}\" took {} seconds", this->connection_string, duration.count());
Debug(net, 0, " This is likely an issue in the DNS name resolver's configuration causing it to time out");
getaddrinfo_timeout_error_shown = true;
}
if (error != 0) {
DEBUG(net, 0, "Failed to resolve DNS for %s", this->connection_string.c_str());
Debug(net, 0, "Failed to resolve DNS for {}", this->connection_string);
this->status = Status::FAILURE;
return;
}
@ -272,7 +272,7 @@ bool TCPConnecter::CheckActivity()
/* select() failed; hopefully next try it doesn't. */
if (n < 0) {
/* select() normally never fails; so hopefully it works next try! */
DEBUG(net, 1, "select() failed: %s", NetworkError::GetLast().AsString());
Debug(net, 1, "select() failed: {}", NetworkError::GetLast().AsString());
return false;
}
@ -289,7 +289,7 @@ bool TCPConnecter::CheckActivity()
/* More than 3 seconds no socket reported activity, and there are no
* more address to try. Timeout the attempt. */
DEBUG(net, 0, "Timeout while connecting to %s", this->connection_string.c_str());
Debug(net, 0, "Timeout while connecting to {}", this->connection_string);
for (const auto &socket : this->sockets) {
closesocket(socket);
@ -305,7 +305,7 @@ bool TCPConnecter::CheckActivity()
for (auto it = this->sockets.begin(); it != this->sockets.end(); /* nothing */) {
NetworkError socket_error = GetSocketError(*it);
if (socket_error.HasError()) {
DEBUG(net, 1, "Could not connect to %s: %s", this->sock_to_address[*it].GetAddressAsString().c_str(), socket_error.AsString());
Debug(net, 1, "Could not connect to {}: {}", this->sock_to_address[*it].GetAddressAsString(), socket_error.AsString());
closesocket(*it);
this->sock_to_address.erase(*it);
it = this->sockets.erase(it);
@ -338,9 +338,9 @@ bool TCPConnecter::CheckActivity()
}
assert(connected_socket != INVALID_SOCKET);
DEBUG(net, 3, "Connected to %s", this->connection_string.c_str());
Debug(net, 3, "Connected to {}", this->connection_string);
if (_debug_net_level >= 5) {
DEBUG(net, 5, "- using %s", NetworkAddress::GetPeerName(connected_socket).c_str());
Debug(net, 5, "- using {}", NetworkAddress::GetPeerName(connected_socket));
}
this->OnConnect(connected_socket);

@ -114,9 +114,9 @@ bool NetworkContentSocketHandler::HandlePacket(Packet *p)
default:
if (this->HasClientQuit()) {
DEBUG(net, 0, "[tcp/content] Received invalid packet type %d", type);
Debug(net, 0, "[tcp/content] Received invalid packet type {}", type);
} else {
DEBUG(net, 0, "[tcp/content] Received illegal packet");
Debug(net, 0, "[tcp/content] Received illegal packet");
}
return false;
}
@ -167,7 +167,7 @@ bool NetworkContentSocketHandler::ReceivePackets()
*/
bool NetworkContentSocketHandler::ReceiveInvalidPacket(PacketContentType type)
{
DEBUG(net, 0, "[tcp/content] Received illegal packet type %d", type);
Debug(net, 0, "[tcp/content] Received illegal packet type {}", type);
return false;
}

@ -117,9 +117,9 @@ NetworkRecvStatus NetworkGameSocketHandler::HandlePacket(Packet *p)
this->CloseConnection();
if (this->HasClientQuit()) {
DEBUG(net, 0, "[tcp/game] Received invalid packet type %d from client %d", type, this->client_id);
Debug(net, 0, "[tcp/game] Received invalid packet type {} from client {}", type, this->client_id);
} else {
DEBUG(net, 0, "[tcp/game] Received illegal packet from client %d", this->client_id);
Debug(net, 0, "[tcp/game] Received illegal packet from client {}", this->client_id);
}
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}
@ -151,7 +151,7 @@ NetworkRecvStatus NetworkGameSocketHandler::ReceivePackets()
*/
NetworkRecvStatus NetworkGameSocketHandler::ReceiveInvalidPacket(PacketGameType type)
{
DEBUG(net, 0, "[tcp/game] Received illegal packet type %d from client %d", type, this->client_id);
Debug(net, 0, "[tcp/game] Received illegal packet type {} from client {}", type, this->client_id);
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}

@ -45,7 +45,7 @@ NetworkHTTPSocketHandler::NetworkHTTPSocketHandler(SOCKET s,
size_t bufferSize = strlen(url) + strlen(host) + strlen(GetNetworkRevisionString()) + (data == nullptr ? 0 : strlen(data)) + 128;
char *buffer = AllocaM(char, bufferSize);
DEBUG(net, 5, "[tcp/http] Requesting %s%s", host, url);
Debug(net, 5, "[tcp/http] Requesting {}{}", host, url);
if (data != nullptr) {
seprintf(buffer, buffer + bufferSize - 1, "POST %s HTTP/1.0\r\nHost: %s\r\nUser-Agent: OpenTTD/%s\r\nContent-Type: text/plain\r\nContent-Length: %d\r\n\r\n%s\r\n", url, host, GetNetworkRevisionString(), (int)strlen(data), data);
} else {
@ -86,7 +86,7 @@ void NetworkHTTPSocketHandler::CloseSocket()
* Helper to simplify the error handling.
* @param msg the error message to show.
*/
#define return_error(msg) { DEBUG(net, 1, msg); return -1; }
#define return_error(msg) { Debug(net, 1, msg); return -1; }
static const char * const NEWLINE = "\r\n"; ///< End of line marker
static const char * const END_OF_HEADER = "\r\n\r\n"; ///< End of header marker
@ -142,7 +142,7 @@ int NetworkHTTPSocketHandler::HandleHeader()
* wrong. You can't have gzips of 0 bytes! */
if (len == 0) return_error("[tcp/http] Refusing to download 0 bytes");
DEBUG(net, 7, "[tcp/http] Downloading %i bytes", len);
Debug(net, 7, "[tcp/http] Downloading {} bytes", len);
return len;
}
@ -155,7 +155,7 @@ int NetworkHTTPSocketHandler::HandleHeader()
/* Search the end of the line. This is safe because the header will
* always end with two newlines. */
*strstr(status, NEWLINE) = '\0';
DEBUG(net, 1, "[tcp/http] Unhandled status reply %s", status);
Debug(net, 1, "[tcp/http] Unhandled status reply {}", status);
return -1;
}
@ -172,7 +172,7 @@ int NetworkHTTPSocketHandler::HandleHeader()
char *end_of_line = strstr(uri, NEWLINE);
*end_of_line = '\0';
DEBUG(net, 7, "[tcp/http] Redirecting to %s", uri);
Debug(net, 7, "[tcp/http] Redirecting to {}", uri);
int ret = NetworkHTTPSocketHandler::Connect(uri, this->callback, this->data, this->redirect_depth + 1);
if (ret != 0) return ret;
@ -229,7 +229,7 @@ int NetworkHTTPSocketHandler::Receive()
NetworkError err = NetworkError::GetLast();
if (!err.WouldBlock()) {
/* Something went wrong... */
if (!err.IsConnectionReset()) DEBUG(net, 0, "Recv failed: %s", err.AsString());
if (!err.IsConnectionReset()) Debug(net, 0, "Recv failed: {}", err.AsString());
return -1;
}
/* Connection would block, so stop for now */
@ -257,7 +257,7 @@ int NetworkHTTPSocketHandler::Receive()
if (end_of_header == nullptr) {
if (read == lengthof(this->recv_buffer)) {
DEBUG(net, 1, "[tcp/http] Header too big");
Debug(net, 1, "[tcp/http] Header too big");
return -1;
}
this->recv_pos = read;

@ -49,7 +49,7 @@ public:
SetNonBlocking(s); // XXX error handling?
NetworkAddress address(sin, sin_len);
DEBUG(net, 3, "[%s] Client connected from %s on frame %d", Tsocket::GetName(), address.GetHostname(), _frame_counter);
Debug(net, 3, "[{}] Client connected from {} on frame {}", Tsocket::GetName(), address.GetHostname(), _frame_counter);
SetNoDelay(s); // XXX error handling?
@ -61,10 +61,10 @@ public:
Packet p(Tban_packet);
p.PrepareToSend();
DEBUG(net, 2, "[%s] Banned ip tried to join (%s), refused", Tsocket::GetName(), entry.c_str());
Debug(net, 2, "[{}] Banned ip tried to join ({}), refused", Tsocket::GetName(), entry);
if (p.TransferOut<int>(send, s, 0) < 0) {
DEBUG(net, 0, "[%s] send failed: %s", Tsocket::GetName(), NetworkError::GetLast().AsString());
Debug(net, 0, "[{}] send failed: {}", Tsocket::GetName(), NetworkError::GetLast().AsString());
}
closesocket(s);
break;
@ -81,7 +81,7 @@ public:
p.PrepareToSend();
if (p.TransferOut<int>(send, s, 0) < 0) {
DEBUG(net, 0, "[%s] send failed: %s", Tsocket::GetName(), NetworkError::GetLast().AsString());
Debug(net, 0, "[{}] send failed: {}", Tsocket::GetName(), NetworkError::GetLast().AsString());
}
closesocket(s);
@ -150,7 +150,7 @@ public:
}
if (sockets.size() == 0) {
DEBUG(net, 0, "Could not start network: could not create listening socket");
Debug(net, 0, "Could not start network: could not create listening socket");
ShowNetworkError(STR_NETWORK_ERROR_SERVER_START);
return false;
}
@ -165,7 +165,7 @@ public:
closesocket(s.second);
}
sockets.clear();
DEBUG(net, 5, "[%s] Closed listeners", Tsocket::GetName());
Debug(net, 5, "[{}] Closed listeners", Tsocket::GetName());
}
};

@ -89,16 +89,16 @@ void NetworkUDPSocketHandler::SendPacket(Packet *p, NetworkAddress *recv, bool a
/* Enable broadcast */
unsigned long val = 1;
if (setsockopt(s.second, SOL_SOCKET, SO_BROADCAST, (char *) &val, sizeof(val)) < 0) {
DEBUG(net, 1, "Setting broadcast mode failed: %s", NetworkError::GetLast().AsString());
Debug(net, 1, "Setting broadcast mode failed: {}", NetworkError::GetLast().AsString());
}
}
/* Send the buffer */
ssize_t res = p->TransferOut<int>(sendto, s.second, 0, (const struct sockaddr *)send.GetAddress(), send.GetAddressLength());
DEBUG(net, 7, "sendto(%s)", send.GetAddressAsString().c_str());
Debug(net, 7, "sendto({})", send.GetAddressAsString());
/* Check for any errors, but ignore it otherwise */
if (res == -1) DEBUG(net, 1, "sendto(%s) failed: %s", send.GetAddressAsString().c_str(), NetworkError::GetLast().AsString());
if (res == -1) Debug(net, 1, "sendto({}) failed: {}", send.GetAddressAsString(), NetworkError::GetLast().AsString());
if (!all) break;
}
@ -134,7 +134,7 @@ void NetworkUDPSocketHandler::ReceivePackets()
/* If the size does not match the packet must be corrupted.
* Otherwise it will be marked as corrupted later on. */
if (!p.ParsePacketSize() || (size_t)nbytes != p.Size()) {
DEBUG(net, 1, "Received a packet with mismatching size from %s", address.GetAddressAsString().c_str());
Debug(net, 1, "Received a packet with mismatching size from {}", address.GetAddressAsString());
continue;
}
p.PrepareToRead();
@ -175,9 +175,9 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_
default:
if (this->HasClientQuit()) {
DEBUG(net, 0, "[udp] Received invalid packet type %d from %s", type, client_addr->GetAddressAsString().c_str());
Debug(net, 0, "[udp] Received invalid packet type {} from {}", type, client_addr->GetAddressAsString());
} else {
DEBUG(net, 0, "[udp] Received illegal packet from %s", client_addr->GetAddressAsString().c_str());
Debug(net, 0, "[udp] Received illegal packet from {}", client_addr->GetAddressAsString());
}
break;
}
@ -190,7 +190,7 @@ void NetworkUDPSocketHandler::HandleUDPPacket(Packet *p, NetworkAddress *client_
*/
void NetworkUDPSocketHandler::ReceiveInvalidPacket(PacketUDPType type, NetworkAddress *client_addr)
{
DEBUG(net, 0, "[udp] Received packet type %d on wrong port from %s", type, client_addr->GetAddressAsString().c_str());
Debug(net, 0, "[udp] Received packet type {} on wrong port from {}", type, client_addr->GetAddressAsString());
}
void NetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet *p, NetworkAddress *client_addr) { this->ReceiveInvalidPacket(PACKET_UDP_CLIENT_FIND_SERVER, client_addr); }

@ -264,7 +264,7 @@ void NetworkTextMessage(NetworkAction action, TextColour colour, bool self_send,
char *msg_ptr = message + Utf8Encode(message, _current_text_dir == TD_LTR ? CHAR_TD_LRM : CHAR_TD_RLM);
GetString(msg_ptr, strid, lastof(message));
DEBUG(desync, 1, "msg: %08x; %02x; %s", _date, _date_fract, message);
Debug(desync, 1, "msg: {:08x}; {:02x}; {}", _date, _date_fract, message);
IConsolePrintF(colour, "%s", message);
NetworkAddChatMessage((TextColour)colour, _settings_client.gui.network_chat_timeout, message);
}
@ -877,14 +877,14 @@ static void CheckClientAndServerName()
static const std::string fallback_client_name = "Unnamed Client";
StrTrimInPlace(_settings_client.network.client_name);
if (_settings_client.network.client_name.empty() || _settings_client.network.client_name.compare(fallback_client_name) == 0) {
DEBUG(net, 1, "No \"client_name\" has been set, using \"%s\" instead. Please set this now using the \"name <new name>\" command", fallback_client_name.c_str());
Debug(net, 1, "No \"client_name\" has been set, using \"{}\" instead. Please set this now using the \"name <new name>\" command", fallback_client_name);
_settings_client.network.client_name = fallback_client_name;
}
static const std::string fallback_server_name = "Unnamed Server";
StrTrimInPlace(_settings_client.network.server_name);
if (_settings_client.network.server_name.empty() || _settings_client.network.server_name.compare(fallback_server_name) == 0) {
DEBUG(net, 1, "No \"server_name\" has been set, using \"%s\" instead. Please set this now using the \"server_name <new name>\" command", fallback_server_name.c_str());
Debug(net, 1, "No \"server_name\" has been set, using \"{}\" instead. Please set this now using the \"server_name <new name>\" command", fallback_server_name);
_settings_client.network.server_name = fallback_server_name;
}
}
@ -902,17 +902,17 @@ bool NetworkServerStart()
NetworkDisconnect(false, false);
NetworkInitialize(false);
DEBUG(net, 5, "Starting listeners for clients");
Debug(net, 5, "Starting listeners for clients");
if (!ServerNetworkGameSocketHandler::Listen(_settings_client.network.server_port)) return false;
/* Only listen for admins when the password isn't empty. */
if (!_settings_client.network.admin_password.empty()) {
DEBUG(net, 5, "Starting listeners for admins");
Debug(net, 5, "Starting listeners for admins");
if (!ServerNetworkAdminSocketHandler::Listen(_settings_client.network.server_admin_port)) return false;
}
/* Try to start UDP-server */
DEBUG(net, 5, "Starting listeners for incoming server queries");
Debug(net, 5, "Starting listeners for incoming server queries");
NetworkUDPServerListen();
_network_company_states = new NetworkCompanyState[MAX_COMPANIES];
@ -1049,7 +1049,7 @@ void NetworkGameLoop()
/* We don't want to log multiple times if paused. */
static Date last_log;
if (last_log != _date) {
DEBUG(desync, 1, "sync: %08x; %02x; %08x; %08x", _date, _date_fract, _random.state[0], _random.state[1]);
Debug(desync, 1, "sync: {:08x}; {:02x}; {:08x}; {:08x}", _date, _date_fract, _random.state[0], _random.state[1]);
last_log = _date;
}
}
@ -1063,7 +1063,7 @@ void NetworkGameLoop()
static bool check_sync_state = false;
static uint32 sync_state[2];
if (f == nullptr && next_date == 0) {
DEBUG(desync, 0, "Cannot open commands.log");
Debug(desync, 0, "Cannot open commands.log");
next_date = 1;
}
@ -1071,15 +1071,15 @@ void NetworkGameLoop()
if (_date == next_date && _date_fract == next_date_fract) {
if (cp != nullptr) {
NetworkSendCommand(cp->tile, cp->p1, cp->p2, cp->cmd & ~CMD_FLAGS_MASK, nullptr, cp->text, cp->company);
DEBUG(desync, 0, "Injecting: %08x; %02x; %02x; %06x; %08x; %08x; %08x; \"%s\" (%s)", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text.c_str(), GetCommandName(cp->cmd));
Debug(desync, 0, "Injecting: {:08x}; {:02x}; {:02x}; {:06x}; {:08x}; {:08x}; {:08x}; \"{}\" ({})", _date, _date_fract, (int)_current_company, cp->tile, cp->p1, cp->p2, cp->cmd, cp->text, GetCommandName(cp->cmd));
delete cp;
cp = nullptr;
}
if (check_sync_state) {
if (sync_state[0] == _random.state[0] && sync_state[1] == _random.state[1]) {
DEBUG(desync, 0, "Sync check: %08x; %02x; match", _date, _date_fract);
Debug(desync, 0, "Sync check: {:08x}; {:02x}; match", _date, _date_fract);
} else {
DEBUG(desync, 0, "Sync check: %08x; %02x; mismatch expected {%08x, %08x}, got {%08x, %08x}",
Debug(desync, 0, "Sync check: {:08x}; {:02x}; mismatch expected {{:08x}, {:08x}}, got {{:08x}, {:08x}}",
_date, _date_fract, sync_state[0], sync_state[1], _random.state[0], _random.state[1]);
NOT_REACHED();
}
@ -1121,7 +1121,7 @@ void NetworkGameLoop()
/* Manually insert a pause when joining; this way the client can join at the exact right time. */
int ret = sscanf(p + 6, "%x; %x", &next_date, &next_date_fract);
assert(ret == 2);
DEBUG(desync, 0, "Injecting pause for join at %08x:%02x; please join when paused", next_date, next_date_fract);
Debug(desync, 0, "Injecting pause for join at {:08x}:{:02x}; please join when paused", next_date, next_date_fract);
cp = new CommandPacket();
cp->company = COMPANY_SPECTATOR;
cp->cmd = CMD_PAUSE;
@ -1137,16 +1137,16 @@ void NetworkGameLoop()
/* A message that is not very important to the log playback, but part of the log. */
#ifndef DEBUG_FAILED_DUMP_COMMANDS
} else if (strncmp(p, "cmdf: ", 6) == 0) {
DEBUG(desync, 0, "Skipping replay of failed command: %s", p + 6);
Debug(desync, 0, "Skipping replay of failed command: {}", p + 6);
#endif
} else {
/* Can't parse a line; what's wrong here? */
DEBUG(desync, 0, "Trying to parse: %s", p);
Debug(desync, 0, "Trying to parse: {}", p);
NOT_REACHED();
}
}
if (f != nullptr && feof(f)) {
DEBUG(desync, 0, "End of commands.log");
Debug(desync, 0, "End of commands.log");
fclose(f);
f = nullptr;
}
@ -1233,12 +1233,12 @@ public:
void OnFailure() override
{
DEBUG(net, 0, "Failed to open connection to %s for redirecting DEBUG()", this->connection_string.c_str());
Debug(net, 0, "Failed to open connection to {} for redirecting Debug()", this->connection_string);
}
void OnConnect(SOCKET s) override
{
DEBUG(net, 3, "Redirecting DEBUG() to %s", this->connection_string.c_str());
Debug(net, 3, "Redirecting Debug() to {}", this->connection_string);
extern SOCKET _debug_socket;
_debug_socket = s;
@ -1253,7 +1253,7 @@ void NetworkStartDebugLog(const std::string &connection_string)
/** This tries to launch the network for a given OS */
void NetworkStartUp()
{
DEBUG(net, 3, "Starting network");
Debug(net, 3, "Starting network");
/* Network is available */
_network_available = NetworkCoreInitialize();
@ -1266,7 +1266,7 @@ void NetworkStartUp()
_network_game_info = {};
NetworkInitialize();
DEBUG(net, 3, "Network online, multiplayer available");
Debug(net, 3, "Network online, multiplayer available");
NetworkFindBroadcastIPs(&_broadcast_list);
}
@ -1276,7 +1276,7 @@ void NetworkShutDown()
NetworkDisconnect(true);
NetworkUDPClose();
DEBUG(net, 3, "Shutting down network");
Debug(net, 3, "Shutting down network");
_network_available = false;

@ -74,7 +74,7 @@ ServerNetworkAdminSocketHandler::ServerNetworkAdminSocketHandler(SOCKET s) : Net
ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
{
_network_admins_connected--;
DEBUG(net, 3, "[admin] '%s' (%s) has disconnected", this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 3, "[admin] '{}' ({}) has disconnected", this->admin_name, this->admin_version);
if (_redirect_console_to_admin == this->index) _redirect_console_to_admin = INVALID_ADMIN_ID;
}
@ -97,7 +97,7 @@ ServerNetworkAdminSocketHandler::~ServerNetworkAdminSocketHandler()
{
for (ServerNetworkAdminSocketHandler *as : ServerNetworkAdminSocketHandler::Iterate()) {
if (as->status == ADMIN_STATUS_INACTIVE && std::chrono::steady_clock::now() > as->connect_time + ADMIN_AUTHORISATION_TIMEOUT) {
DEBUG(net, 2, "[admin] Admin did not send its authorisation within %d seconds", (uint32)std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
Debug(net, 2, "[admin] Admin did not send its authorisation within {} seconds", std::chrono::duration_cast<std::chrono::seconds>(ADMIN_AUTHORISATION_TIMEOUT).count());
as->CloseConnection(true);
continue;
}
@ -135,7 +135,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::SendError(NetworkErrorCode er
std::string error_message = GetString(GetNetworkErrorMsg(error));
DEBUG(net, 1, "[admin] The admin '%s' (%s) made an error and has been disconnected: '%s'", this->admin_name.c_str(), this->admin_version.c_str(), error_message.c_str());
Debug(net, 1, "[admin] The admin '{}' ({}) made an error and has been disconnected: '{}'", this->admin_name, this->admin_version, error_message);
return this->CloseConnection(true);
}
@ -500,7 +500,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_RCON(Packet *p)
std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH);
DEBUG(net, 3, "[admin] Rcon command from '%s' (%s): %s", this->admin_name.c_str(), this->admin_version.c_str(), command.c_str());
Debug(net, 3, "[admin] Rcon command from '{}' ({}): {}", this->admin_name, this->admin_version, command);
_redirect_console_to_admin = this->index;
IConsoleCmdExec(command.c_str());
@ -514,7 +514,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_GAMESCRIPT(Pack
std::string json = p->Recv_string(NETWORK_GAMESCRIPT_JSON_LENGTH);
DEBUG(net, 6, "[admin] GameScript JSON from '%s' (%s): %s", this->admin_name.c_str(), this->admin_version.c_str(), json.c_str());
Debug(net, 6, "[admin] GameScript JSON from '{}' ({}): {}", this->admin_name, this->admin_version, json);
Game::NewEvent(new ScriptEventAdminPort(json));
return NETWORK_RECV_STATUS_OKAY;
@ -526,7 +526,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_PING(Packet *p)
uint32 d1 = p->Recv_uint32();
DEBUG(net, 6, "[admin] Ping from '%s' (%s): %d", this->admin_name.c_str(), this->admin_version.c_str(), d1);
Debug(net, 6, "[admin] Ping from '{}' ({}): {}", this->admin_name, this->admin_version, d1);
return this->SendPong(d1);
}
@ -662,7 +662,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_JOIN(Packet *p)
this->status = ADMIN_STATUS_ACTIVE;
DEBUG(net, 3, "[admin] '%s' (%s) has connected", this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 3, "[admin] '{}' ({}) has connected", this->admin_name, this->admin_version);
return this->SendProtocol();
}
@ -682,7 +682,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_UPDATE_FREQUENC
if (type >= ADMIN_UPDATE_END || (_admin_update_type_frequencies[type] & freq) != freq) {
/* The server does not know of this UpdateType. */
DEBUG(net, 1, "[admin] Not supported update frequency %d (%d) from '%s' (%s)", type, freq, this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 1, "[admin] Not supported update frequency {} ({}) from '{}' ({})", type, freq, this->admin_name, this->admin_version);
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
}
@ -750,7 +750,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_POLL(Packet *p)
default:
/* An unsupported "poll" update type. */
DEBUG(net, 1, "[admin] Not supported poll %d (%d) from '%s' (%s).", type, d1, this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 1, "[admin] Not supported poll {} ({}) from '{}' ({}).", type, d1, this->admin_name, this->admin_version);
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
}
@ -776,7 +776,7 @@ NetworkRecvStatus ServerNetworkAdminSocketHandler::Receive_ADMIN_CHAT(Packet *p)
break;
default:
DEBUG(net, 1, "[admin] Invalid chat action %d from admin '%s' (%s).", action, this->admin_name.c_str(), this->admin_version.c_str());
Debug(net, 1, "[admin] Invalid chat action {} from admin '{}' ({}).", action, this->admin_name, this->admin_version);
return this->SendError(NETWORK_ERROR_ILLEGAL_PACKET);
}
@ -852,7 +852,7 @@ void NetworkAdminClientError(ClientID client_id, NetworkErrorCode error_code)
void NetworkAdminCompanyInfo(const Company *company, bool new_company)
{
if (company == nullptr) {
DEBUG(net, 1, "[admin] Empty company given for update");
Debug(net, 1, "[admin] Empty company given for update");
return;
}

@ -136,7 +136,7 @@ void ClientNetworkEmergencySave()
if (!_networking) return;
const char *filename = "netsave.sav";
DEBUG(net, 3, "Performing emergency save: %s", filename);
Debug(net, 3, "Performing emergency save: {}", filename);
SaveOrLoad(filename, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR, false);
}
@ -173,7 +173,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
*/
if (this->sock == INVALID_SOCKET) return status;
DEBUG(net, 3, "Closed client connection %d", this->client_id);
Debug(net, 3, "Closed client connection {}", this->client_id);
this->SendPackets(true);
@ -285,8 +285,8 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
if (_sync_seed_1 != _random.state[0]) {
#endif
ShowNetworkError(STR_NETWORK_ERROR_DESYNC);
DEBUG(desync, 1, "sync_err: %08x; %02x", _date, _date_fract);
DEBUG(net, 0, "Sync error detected");
Debug(desync, 1, "sync_err: {:08x}; {:02x}", _date, _date_fract);
Debug(net, 0, "Sync error detected");
my_client->ClientError(NETWORK_RECV_STATUS_DESYNC);
return false;
}
@ -301,7 +301,7 @@ void ClientNetworkGameSocketHandler::ClientError(NetworkRecvStatus res)
_sync_frame = 0;
} else if (_sync_frame < _frame_counter) {
DEBUG(net, 1, "Missed frame for sync-test: %d / %d", _sync_frame, _frame_counter);
Debug(net, 1, "Missed frame for sync-test: {} / {}", _sync_frame, _frame_counter);
_sync_frame = 0;
}
}
@ -777,7 +777,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_CHECK_NEWGRFS(P
/* We do not know this GRF, bail out of initialization */
char buf[sizeof(c.md5sum) * 2 + 1];
md5sumToString(buf, lastof(buf), c.md5sum);
DEBUG(grf, 0, "NewGRF %08X not found; checksum %s", BSWAP32(c.grfid), buf);
Debug(grf, 0, "NewGRF {:08X} not found; checksum {}", BSWAP32(c.grfid), buf);
ret = NETWORK_RECV_STATUS_NEWGRF_MISMATCH;
}
}
@ -974,13 +974,13 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_FRAME(Packet *p
/* Receive the token. */
if (p->CanReadFromPacket(sizeof(uint8))) this->token = p->Recv_uint8();
DEBUG(net, 7, "Received FRAME %d", _frame_counter_server);
Debug(net, 7, "Received FRAME {}", _frame_counter_server);
/* Let the server know that we received this frame correctly
* We do this only once per day, to save some bandwidth ;) */
if (!_network_first_time && last_ack_frame < _frame_counter) {
last_ack_frame = _frame_counter + DAY_TICKS;
DEBUG(net, 7, "Sent ACK at %d", _frame_counter);
Debug(net, 7, "Sent ACK at {}", _frame_counter);
SendAck();
}
@ -1096,7 +1096,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_QUIT(Packet *p)
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, ci->client_name, "", STR_NETWORK_MESSAGE_CLIENT_LEAVING);
delete ci;
} else {
DEBUG(net, 1, "Unknown client (%d) is leaving the game", client_id);
Debug(net, 1, "Unknown client ({}) is leaving the game", client_id);
}
InvalidateWindowData(WC_CLIENT_LIST, 0);
@ -1175,7 +1175,7 @@ NetworkRecvStatus ClientNetworkGameSocketHandler::Receive_SERVER_MOVE(Packet *p)
if (client_id == 0) {
/* definitely an invalid client id, debug message and do nothing. */
DEBUG(net, 1, "Received invalid client index = 0");
Debug(net, 1, "Received invalid client index = 0");
return NETWORK_RECV_STATUS_MALFORMED_PACKET;
}

@ -332,7 +332,7 @@ void NetworkGameSocketHandler::SendCommand(Packet *p, const CommandPacket *cp)
}
if (callback == lengthof(_callback_table)) {
DEBUG(net, 0, "Unknown callback for command; no callback sent (command: %d)", cp->cmd);
Debug(net, 0, "Unknown callback for command; no callback sent (command: {})", cp->cmd);
callback = 0; // _callback_table[0] == nullptr
}
p->Send_uint8 (callback);

@ -283,7 +283,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::CloseConnection(NetworkRecvSta
}
NetworkAdminClientError(this->client_id, NETWORK_ERROR_CONNECTION_LOST);
DEBUG(net, 3, "Closed client connection %d", this->client_id);
Debug(net, 3, "Closed client connection {}", this->client_id);
/* We just lost one client :( */
if (this->status >= STATUS_AUTHORIZED) _network_game_info.clients_on--;
@ -445,7 +445,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
this->GetClientName(client_name, lastof(client_name));
DEBUG(net, 1, "'%s' made an error and has been disconnected: %s", client_name, GetString(strid).c_str());
Debug(net, 1, "'{}' made an error and has been disconnected: {}", client_name, GetString(strid));
if (error == NETWORK_ERROR_KICKED && !reason.empty()) {
NetworkTextMessage(NETWORK_ACTION_KICKED, CC_DEFAULT, false, client_name, reason, strid);
@ -466,7 +466,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::SendError(NetworkErrorCode err
NetworkAdminClientError(this->client_id, error);
} else {
DEBUG(net, 1, "Client %d made an error and has been disconnected: %s", this->client_id, GetString(strid).c_str());
Debug(net, 1, "Client {} made an error and has been disconnected: {}", this->client_id, GetString(strid));
}
/* The client made a mistake, so drop the connection now! */
@ -925,7 +925,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_JOIN(Packet *p)
ci->join_date = _date;
ci->client_name = client_name;
ci->client_playas = playas;
DEBUG(desync, 1, "client: %08x; %02x; %02x; %02x", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:02x}", _date, _date_fract, (int)ci->client_playas, (int)ci->index);
/* Make sure companies to which people try to join are not autocleaned */
if (Company::IsValidID(playas)) _network_company_states[playas].months_empty = 0;
@ -1133,7 +1133,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_ERROR(Packet *p
StringID strid = GetNetworkErrorMsg(errorno);
DEBUG(net, 1, "'%s' reported an error and is closing its connection: %s", client_name, GetString(strid).c_str());
Debug(net, 1, "'{}' reported an error and is closing its connection: {}", client_name, GetString(strid));
NetworkTextMessage(NETWORK_ACTION_LEAVE, CC_DEFAULT, false, client_name, "", strid);
@ -1323,7 +1323,7 @@ void NetworkServerSendChat(NetworkAction action, DestType desttype, int dest, co
break;
}
default:
DEBUG(net, 1, "Received unknown chat destination type %d; doing broadcast instead", desttype);
Debug(net, 1, "Received unknown chat destination type {}; doing broadcast instead", desttype);
FALLTHROUGH;
case DESTTYPE_BROADCAST:
@ -1425,11 +1425,11 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_RCON(Packet *p)
std::string command = p->Recv_string(NETWORK_RCONCOMMAND_LENGTH);
if (_settings_client.network.rcon_password.compare(password) != 0) {
DEBUG(net, 1, "[rcon] Wrong password from client-id %d", this->client_id);
Debug(net, 1, "[rcon] Wrong password from client-id {}", this->client_id);
return NETWORK_RECV_STATUS_OKAY;
}
DEBUG(net, 3, "[rcon] Client-id %d executed: %s", this->client_id, command.c_str());
Debug(net, 3, "[rcon] Client-id {} executed: {}", this->client_id, command);
_redirect_console_to_client = this->client_id;
IConsoleCmdExec(command.c_str());
@ -1453,7 +1453,7 @@ NetworkRecvStatus ServerNetworkGameSocketHandler::Receive_CLIENT_MOVE(Packet *p)
/* Incorrect password sent, return! */
if (_network_company_states[company_id].password.compare(password) != 0) {
DEBUG(net, 2, "Wrong password from client-id #%d for company #%d", this->client_id, company_id + 1);
Debug(net, 2, "Wrong password from client-id #{} for company #{}", this->client_id, company_id + 1);
return NETWORK_RECV_STATUS_OKAY;
}
}
@ -1561,7 +1561,7 @@ void NetworkUpdateClientInfo(ClientID client_id)
if (ci == nullptr) return;
DEBUG(desync, 1, "client: %08x; %02x; %02x; %04x", _date, _date_fract, (int)ci->client_playas, client_id);
Debug(desync, 1, "client: {:08x}; {:02x}; {:02x}; {:04x}", _date, _date_fract, (int)ci->client_playas, client_id);
for (NetworkClientSocket *cs : NetworkClientSocket::Iterate()) {
if (cs->status >= ServerNetworkGameSocketHandler::STATUS_AUTHORIZED) {
@ -1576,7 +1576,7 @@ void NetworkUpdateClientInfo(ClientID client_id)
static void NetworkCheckRestartMap()
{
if (_settings_client.network.restart_game_year != 0 && _cur_year >= _settings_client.network.restart_game_year) {
DEBUG(net, 3, "Auto-restarting map: year %d reached", _cur_year);
Debug(net, 3, "Auto-restarting map: year {} reached", _cur_year);
_settings_newgame.game_creation.generation_seed = GENERATE_NEW_SEED;
switch(_file_to_saveload.abstract_ftype) {

@ -67,7 +67,7 @@ struct UDPSocket {
std::unique_lock<std::mutex> lock(mutex, std::defer_lock);
if (!lock.try_lock()) {
if (++receive_iterations_locked % 32 == 0) {
DEBUG(net, 0, "%s background UDP loop processing appears to be blocked. Your OS may be low on UDP send buffers.", name.c_str());
Debug(net, 0, "{} background UDP loop processing appears to be blocked. Your OS may be low on UDP send buffers.", name);
}
return;
}
@ -133,7 +133,7 @@ public:
void MasterNetworkUDPSocketHandler::Receive_MASTER_ACK_REGISTER(Packet *p, NetworkAddress *client_addr)
{
_network_advertise_retries = 0;
DEBUG(net, 3, "Advertising on master server successful (%s)", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
Debug(net, 3, "Advertising on master server successful ({})", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
/* We are advertised, but we don't want to! */
if (!_settings_client.network.server_advertise) NetworkUDPRemoveAdvertise(false);
@ -142,7 +142,7 @@ void MasterNetworkUDPSocketHandler::Receive_MASTER_ACK_REGISTER(Packet *p, Netwo
void MasterNetworkUDPSocketHandler::Receive_MASTER_SESSION_KEY(Packet *p, NetworkAddress *client_addr)
{
_session_key = p->Recv_uint64();
DEBUG(net, 6, "Received new session key from master server (%s)", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
Debug(net, 6, "Received new session key from master server ({})", NetworkAddress::AddressFamilyAsString(client_addr->GetAddress()->ss_family));
}
///*** Communication with clients (we are server) ***/
@ -175,7 +175,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_FIND_SERVER(Packet *p, Networ
/* Let the client know that we are here */
this->SendPacket(&packet, client_addr);
DEBUG(net, 7, "Queried from %s", client_addr->GetHostname());
Debug(net, 7, "Queried from {}", client_addr->GetHostname());
}
void ServerNetworkUDPSocketHandler::Receive_CLIENT_DETAIL_INFO(Packet *p, NetworkAddress *client_addr)
@ -252,7 +252,7 @@ void ServerNetworkUDPSocketHandler::Receive_CLIENT_GET_NEWGRFS(Packet *p, Networ
uint8 in_reply_count = 0;
size_t packet_len = 0;
DEBUG(net, 7, "NewGRF data request from %s", client_addr->GetAddressAsString().c_str());
Debug(net, 7, "NewGRF data request from {}", client_addr->GetAddressAsString());
num_grfs = p->Recv_uint8 ();
if (num_grfs > NETWORK_MAX_GRF_COUNT) return;
@ -314,7 +314,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_RESPONSE(Packet *p, NetworkAd
/* Just a fail-safe.. should never happen */
if (_network_udp_server) return;
DEBUG(net, 3, "Server response from %s", client_addr->GetAddressAsString().c_str());
Debug(net, 3, "Server response from {}", client_addr->GetAddressAsString());
/* Find next item */
item = NetworkGameListAddItem(client_addr->GetAddressAsString(false));
@ -409,7 +409,7 @@ void ClientNetworkUDPSocketHandler::Receive_SERVER_NEWGRFS(Packet *p, NetworkAdd
uint8 num_grfs;
uint i;
DEBUG(net, 7, "NewGRF data reply from %s", client_addr->GetAddressAsString().c_str());
Debug(net, 7, "NewGRF data reply from {}", client_addr->GetAddressAsString());
num_grfs = p->Recv_uint8 ();
if (num_grfs > NETWORK_MAX_GRF_COUNT) return;
@ -440,7 +440,7 @@ static void NetworkUDPBroadCast(NetworkUDPSocketHandler *socket)
for (NetworkAddress &addr : _broadcast_list) {
Packet p(PACKET_UDP_CLIENT_FIND_SERVER);
DEBUG(net, 5, "Broadcasting to %s", addr.GetHostname());
Debug(net, 5, "Broadcasting to {}", addr.GetHostname());
socket->SendPacket(&p, &addr, true, true);
}
@ -460,7 +460,7 @@ void NetworkUDPQueryMasterServer()
std::lock_guard<std::mutex> lock(_udp_client.mutex);
_udp_client.socket->SendPacket(&p, &out_addr, true);
DEBUG(net, 6, "Master server queried at %s", out_addr.GetAddressAsString().c_str());
Debug(net, 6, "Master server queried at {}", out_addr.GetAddressAsString());
}
/** Find all servers */
@ -469,7 +469,7 @@ void NetworkUDPSearchGame()
/* We are still searching.. */
if (_network_udp_broadcast > 0) return;
DEBUG(net, 3, "Searching server");
Debug(net, 3, "Searching server");
NetworkUDPBroadCast(_udp_client.socket);
_network_udp_broadcast = 300; // Stay searching for 300 ticks
@ -480,7 +480,7 @@ void NetworkUDPSearchGame()
*/
static void NetworkUDPRemoveAdvertiseThread()
{
DEBUG(net, 3, "Removing advertise from master server");
Debug(net, 3, "Removing advertise from master server");
/* Find somewhere to send */
NetworkAddress out_addr(NETWORK_MASTER_SERVER_HOST, NETWORK_MASTER_SERVER_PORT);
@ -517,22 +517,22 @@ static void NetworkUDPAdvertiseThread()
/* Find somewhere to send */
NetworkAddress out_addr(NETWORK_MASTER_SERVER_HOST, NETWORK_MASTER_SERVER_PORT);
DEBUG(net, 3, "Advertising to master server");
Debug(net, 3, "Advertising to master server");
/* Add a bit more messaging when we cannot get a session key */
static byte session_key_retries = 0;
if (_session_key == 0 && session_key_retries++ == 2) {
DEBUG(net, 0, "Advertising to the master server is failing");
DEBUG(net, 0, " we are not receiving the session key from the server");
DEBUG(net, 0, " please allow udp packets from %s to you to be delivered", out_addr.GetAddressAsString(false).c_str());
DEBUG(net, 0, " please allow udp packets from you to %s to be delivered", out_addr.GetAddressAsString(false).c_str());
Debug(net, 0, "Advertising to the master server is failing");
Debug(net, 0, " we are not receiving the session key from the server");
Debug(net, 0, " please allow udp packets from {} to you to be delivered", out_addr.GetAddressAsString(false));
Debug(net, 0, " please allow udp packets from you to {} to be delivered", out_addr.GetAddressAsString(false));
}
if (_session_key != 0 && _network_advertise_retries == 0) {
DEBUG(net, 0, "Advertising to the master server is failing");
DEBUG(net, 0, " we are not receiving the acknowledgement from the server");
DEBUG(net, 0, " this usually means that the master server cannot reach us");
DEBUG(net, 0, " please allow udp and tcp packets to port %u to be delivered", _settings_client.network.server_port);
DEBUG(net, 0, " please allow udp and tcp packets from port %u to be delivered", _settings_client.network.server_port);
Debug(net, 0, "Advertising to the master server is failing");
Debug(net, 0, " we are not receiving the acknowledgement from the server");
Debug(net, 0, " this usually means that the master server cannot reach us");
Debug(net, 0, " please allow udp and tcp packets to port {} to be delivered", _settings_client.network.server_port);
Debug(net, 0, " please allow udp and tcp packets from port {} to be delivered", _settings_client.network.server_port);
}
/* Send the packet */
@ -588,7 +588,7 @@ void NetworkUDPInitialize()
/* If not closed, then do it. */
if (_udp_server.socket != nullptr) NetworkUDPClose();
DEBUG(net, 3, "Initializing UDP listeners");
Debug(net, 3, "Initializing UDP listeners");
assert(_udp_client.socket == nullptr && _udp_server.socket == nullptr && _udp_master.socket == nullptr);
std::scoped_lock lock(_udp_client.mutex, _udp_server.mutex, _udp_master.mutex);
@ -624,7 +624,7 @@ void NetworkUDPClose()
_network_udp_server = false;
_network_udp_broadcast = 0;
DEBUG(net, 5, "Closed UDP listeners");
Debug(net, 5, "Closed UDP listeners");
}
/** Receive the UDP packets. */

@ -380,8 +380,8 @@ typedef std::map<GRFLocation, byte*> GRFLineToSpriteOverride;
static GRFLineToSpriteOverride _grf_line_to_action6_sprite_override;
/**
* DEBUG() function dedicated to newGRF debugging messages
* Function is essentially the same as DEBUG(grf, severity, ...) with the
* Debug() function dedicated to newGRF debugging messages
* Function is essentially the same as Debug(grf, severity, ...) with the
* addition of file:line information when parsing grf files.
* NOTE: for the above reason(s) grfmsg() should ONLY be used for
* loading/parsing grf files, not for runtime debug messages as there
@ -398,7 +398,7 @@ void CDECL grfmsg(int severity, const char *str, ...)
vseprintf(buf, lastof(buf), str, va);
va_end(va);
DEBUG(grf, severity, "[%s:%d] %s", _cur.grfconfig->filename, _cur.nfo_line, buf);
Debug(grf, severity, "[{}:{}] {}", _cur.grfconfig->filename, _cur.nfo_line, buf);
}
/**
@ -549,7 +549,7 @@ static StringID TTDPStringIDToOTTDStringIDMapping(StringID str)
if (str == STR_NULL) return STR_EMPTY;
DEBUG(grf, 0, "Unknown StringID 0x%04X remapped to STR_EMPTY. Please open a Feature Request if you need it", str);
Debug(grf, 0, "Unknown StringID 0x{:04X} remapped to STR_EMPTY. Please open a Feature Request if you need it", str);
return STR_EMPTY;
}
@ -6731,7 +6731,7 @@ static void ScanInfo(ByteReader *buf)
if (grf_version < 2 || grf_version > 8) {
SetBit(_cur.grfconfig->flags, GCF_INVALID);
DEBUG(grf, 0, "%s: NewGRF \"%s\" (GRFID %08X) uses GRF version %d, which is incompatible with this version of OpenTTD.", _cur.grfconfig->filename, name, BSWAP32(grfid), grf_version);
Debug(grf, 0, "{}: NewGRF \"{}\" (GRFID {:08X}) uses GRF version {}, which is incompatible with this version of OpenTTD.", _cur.grfconfig->filename, name, BSWAP32(grfid), grf_version);
}
/* GRF IDs starting with 0xFF are reserved for internal TTDPatch use */
@ -6768,7 +6768,7 @@ static void GRFInfo(ByteReader *buf)
}
if (_cur.grffile->grfid != grfid) {
DEBUG(grf, 0, "GRFInfo: GRFID %08X in FILESCAN stage does not match GRFID %08X in INIT/RESERVE/ACTIVATION stage", BSWAP32(_cur.grffile->grfid), BSWAP32(grfid));
Debug(grf, 0, "GRFInfo: GRFID {:08X} in FILESCAN stage does not match GRFID {:08X} in INIT/RESERVE/ACTIVATION stage", BSWAP32(_cur.grffile->grfid), BSWAP32(grfid));
_cur.grffile->grfid = grfid;
}
@ -6776,7 +6776,7 @@ static void GRFInfo(ByteReader *buf)
_cur.grfconfig->status = _cur.stage < GLS_RESERVE ? GCS_INITIALISED : GCS_ACTIVATED;
/* Do swap the GRFID for displaying purposes since people expect that */
DEBUG(grf, 1, "GRFInfo: Loaded GRFv%d set %08X - %s (palette: %s, version: %i)", version, BSWAP32(grfid), name, (_cur.grfconfig->palette & GRFP_USE_MASK) ? "Windows" : "DOS", _cur.grfconfig->version);
Debug(grf, 1, "GRFInfo: Loaded GRFv{} set {:08X} - {} (palette: {}, version: {})", version, BSWAP32(grfid), name, (_cur.grfconfig->palette & GRFP_USE_MASK) ? "Windows" : "DOS", _cur.grfconfig->version);
}
/* Action 0x0A */
@ -9019,7 +9019,7 @@ static bool IsHouseSpecValid(HouseSpec *hs, const HouseSpec *next1, const HouseS
(next2 == nullptr || !next2->enabled || (next2->building_flags & BUILDING_HAS_1_TILE) != 0 ||
next3 == nullptr || !next3->enabled || (next3->building_flags & BUILDING_HAS_1_TILE) != 0))) {
hs->enabled = false;
if (filename != nullptr) DEBUG(grf, 1, "FinaliseHouseArray: %s defines house %d as multitile, but no suitable tiles follow. Disabling house.", filename, hs->grf_prop.local_id);
if (filename != nullptr) Debug(grf, 1, "FinaliseHouseArray: {} defines house {} as multitile, but no suitable tiles follow. Disabling house.", filename, hs->grf_prop.local_id);
return false;
}
@ -9029,7 +9029,7 @@ static bool IsHouseSpecValid(HouseSpec *hs, const HouseSpec *next1, const HouseS
if (((hs->building_flags & BUILDING_HAS_2_TILES) != 0 && next1->population != 0) ||
((hs->building_flags & BUILDING_HAS_4_TILES) != 0 && (next2->population != 0 || next3->population != 0))) {
hs->enabled = false;
if (filename != nullptr) DEBUG(grf, 1, "FinaliseHouseArray: %s defines multitile house %d with non-zero population on additional tiles. Disabling house.", filename, hs->grf_prop.local_id);
if (filename != nullptr) Debug(grf, 1, "FinaliseHouseArray: {} defines multitile house {} with non-zero population on additional tiles. Disabling house.", filename, hs->grf_prop.local_id);
return false;
}
@ -9037,14 +9037,14 @@ static bool IsHouseSpecValid(HouseSpec *hs, const HouseSpec *next1, const HouseS
* This check should only be done for NewGRF houses because grf_prop.subst_id is not set for original houses.*/
if (filename != nullptr && (hs->building_flags & BUILDING_HAS_1_TILE) != (HouseSpec::Get(hs->grf_prop.subst_id)->building_flags & BUILDING_HAS_1_TILE)) {
hs->enabled = false;
DEBUG(grf, 1, "FinaliseHouseArray: %s defines house %d with different house size then it's substitute type. Disabling house.", filename, hs->grf_prop.local_id);
Debug(grf, 1, "FinaliseHouseArray: {} defines house {} with different house size then it's substitute type. Disabling house.", filename, hs->grf_prop.local_id);
return false;
}
/* Make sure that additional parts of multitile houses are not available. */
if ((hs->building_flags & BUILDING_HAS_1_TILE) == 0 && (hs->building_availability & HZ_ZONALL) != 0 && (hs->building_availability & HZ_CLIMALL) != 0) {
hs->enabled = false;
if (filename != nullptr) DEBUG(grf, 1, "FinaliseHouseArray: %s defines house %d without a size but marked it as available. Disabling house.", filename, hs->grf_prop.local_id);
if (filename != nullptr) Debug(grf, 1, "FinaliseHouseArray: {} defines house {} without a size but marked it as available. Disabling house.", filename, hs->grf_prop.local_id);
return false;
}
@ -9361,11 +9361,11 @@ static void LoadNewGRFFileFromFile(GRFConfig *config, GrfLoadingStage stage, Spr
_cur.file = &file;
_cur.grfconfig = config;
DEBUG(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '%s'", config->filename);
Debug(grf, 2, "LoadNewGRFFile: Reading NewGRF-file '{}'", config->filename);
byte grf_container_version = file.GetContainerVersion();
if (grf_container_version == 0) {
DEBUG(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format");
Debug(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format");
return;
}
@ -9382,7 +9382,7 @@ static void LoadNewGRFFileFromFile(GRFConfig *config, GrfLoadingStage stage, Spr
/* Read compression value. */
byte compression = file.ReadByte();
if (compression != 0) {
DEBUG(grf, 7, "LoadNewGRFFile: Unsupported compression format");
Debug(grf, 7, "LoadNewGRFFile: Unsupported compression format");
return;
}
}
@ -9394,7 +9394,7 @@ static void LoadNewGRFFileFromFile(GRFConfig *config, GrfLoadingStage stage, Spr
if (num == 4 && file.ReadByte() == 0xFF) {
file.ReadDword();
} else {
DEBUG(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format");
Debug(grf, 7, "LoadNewGRFFile: Custom .grf has invalid format");
return;
}
@ -9569,7 +9569,7 @@ static void FinalisePriceBaseMultipliers()
for (Price p = PR_BEGIN; p < PR_END; p++) {
/* No price defined -> nothing to do */
if (!HasBit(features, _price_base_specs[p].grf_feature) || source->price_base_multipliers[p] == INVALID_PRICE_MODIFIER) continue;
DEBUG(grf, 3, "'%s' overrides price base multiplier %d of '%s'", source->filename, p, dest->filename);
Debug(grf, 3, "'{}' overrides price base multiplier {} of '{}'", source->filename, p, dest->filename);
dest->price_base_multipliers[p] = source->price_base_multipliers[p];
}
}
@ -9587,7 +9587,7 @@ static void FinalisePriceBaseMultipliers()
for (Price p = PR_BEGIN; p < PR_END; p++) {
/* Already a price defined -> nothing to do */
if (!HasBit(features, _price_base_specs[p].grf_feature) || dest->price_base_multipliers[p] != INVALID_PRICE_MODIFIER) continue;
DEBUG(grf, 3, "Price base multiplier %d from '%s' propagated to '%s'", p, source->filename, dest->filename);
Debug(grf, 3, "Price base multiplier {} from '{}' propagated to '{}'", p, source->filename, dest->filename);
dest->price_base_multipliers[p] = source->price_base_multipliers[p];
}
}
@ -9605,7 +9605,7 @@ static void FinalisePriceBaseMultipliers()
for (Price p = PR_BEGIN; p < PR_END; p++) {
if (!HasBit(features, _price_base_specs[p].grf_feature)) continue;
if (source->price_base_multipliers[p] != dest->price_base_multipliers[p]) {
DEBUG(grf, 3, "Price base multiplier %d from '%s' propagated to '%s'", p, dest->filename, source->filename);
Debug(grf, 3, "Price base multiplier {} from '{}' propagated to '{}'", p, dest->filename, source->filename);
}
source->price_base_multipliers[p] = dest->price_base_multipliers[p];
}
@ -9636,11 +9636,11 @@ static void FinalisePriceBaseMultipliers()
if (!HasBit(file->grf_features, _price_base_specs[p].grf_feature)) {
/* The grf does not define any objects of the feature,
* so it must be a difficulty setting. Apply it globally */
DEBUG(grf, 3, "'%s' sets global price base multiplier %d", file->filename, p);
Debug(grf, 3, "'{}' sets global price base multiplier {}", file->filename, p);
SetPriceBaseMultiplier(p, price_base_multipliers[p]);
price_base_multipliers[p] = 0;
} else {
DEBUG(grf, 3, "'%s' sets local price base multiplier %d", file->filename, p);
Debug(grf, 3, "'{}' sets local price base multiplier {}", file->filename, p);
}
}
}
@ -9839,7 +9839,7 @@ void LoadNewGRF(uint load_index, uint num_baseset)
Subdirectory subdir = num_grfs < num_baseset ? BASESET_DIR : NEWGRF_DIR;
if (!FioCheckFileExists(c->filename, subdir)) {
DEBUG(grf, 0, "NewGRF file is missing '%s'; disabling", c->filename);
Debug(grf, 0, "NewGRF file is missing '{}'; disabling", c->filename);
c->status = GCS_NOT_FOUND;
continue;
}
@ -9848,7 +9848,7 @@ void LoadNewGRF(uint load_index, uint num_baseset)
if (!HasBit(c->flags, GCF_STATIC) && !HasBit(c->flags, GCF_SYSTEM)) {
if (num_non_static == NETWORK_MAX_GRF_COUNT) {
DEBUG(grf, 0, "'%s' is not loaded as the maximum number of non-static GRFs has been reached", c->filename);
Debug(grf, 0, "'{}' is not loaded as the maximum number of non-static GRFs has been reached", c->filename);
c->status = GCS_DISABLED;
c->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
continue;
@ -9857,7 +9857,7 @@ void LoadNewGRF(uint load_index, uint num_baseset)
}
if (num_grfs >= MAX_GRF_COUNT) {
DEBUG(grf, 0, "'%s' is not loaded as the maximum number of file slots has been reached", c->filename);
Debug(grf, 0, "'{}' is not loaded as the maximum number of file slots has been reached", c->filename);
c->status = GCS_DISABLED;
c->error = new GRFError(STR_NEWGRF_ERROR_MSG_FATAL, STR_NEWGRF_ERROR_TOO_MANY_NEWGRFS_LOADED);
continue;
@ -9872,7 +9872,7 @@ void LoadNewGRF(uint load_index, uint num_baseset)
assert(GetFileByGRFID(c->ident.grfid) == _cur.grffile);
ClearTemporaryNewGRFData(_cur.grffile);
BuildCargoTranslationMap();
DEBUG(sprite, 2, "LoadNewGRF: Currently %i sprites are loaded", _cur.spriteid);
Debug(sprite, 2, "LoadNewGRF: Currently {} sprites are loaded", _cur.spriteid);
} else if (stage == GLS_INIT && HasBit(c->flags, GCF_INIT_ONLY)) {
/* We're not going to activate this, so free whatever data we allocated */
ClearTemporaryNewGRFData(_cur.grffile);

@ -193,7 +193,7 @@ static uint32 GetAirportTileIDAtOffset(TileIndex tile, const Station *st, uint32
case 0x62: return GetAirportTileIDAtOffset(GetNearbyTile(parameter, this->tile), this->st, this->ro.grffile->grfid);
}
DEBUG(grf, 1, "Unhandled airport tile variable 0x%X", variable);
Debug(grf, 1, "Unhandled airport tile variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -100,7 +100,7 @@ struct CanalResolverObject : public ResolverObject {
case 0x83: return IsTileType(this->tile, MP_WATER) ? GetWaterTileRandomBits(this->tile) : 0;
}
DEBUG(grf, 1, "Unhandled canal variable 0x%02X", variable);
Debug(grf, 1, "Unhandled canal variable 0x{:02X}", variable);
*available = false;
return UINT_MAX;

@ -530,12 +530,12 @@ void ErrorUnknownCallbackResult(uint32 grfid, uint16 cbid, uint16 cb_res)
SetDParamStr(0, grfconfig->GetName());
GetString(buffer, STR_NEWGRF_BUGGY, lastof(buffer));
DEBUG(grf, 0, "%s", buffer + 3);
Debug(grf, 0, "{}", buffer + 3);
SetDParam(1, cbid);
SetDParam(2, cb_res);
GetString(buffer, STR_NEWGRF_BUGGY_UNKNOWN_CALLBACK_RESULT, lastof(buffer));
DEBUG(grf, 0, "%s", buffer + 3);
Debug(grf, 0, "{}", buffer + 3);
}
/**

@ -307,7 +307,7 @@ size_t GRFGetSizeOfDataSection(FILE *f)
/* Valid container version 2, get data section size. */
size_t offset = ((size_t)data[13] << 24) | ((size_t)data[12] << 16) | ((size_t)data[11] << 8) | (size_t)data[10];
if (offset >= 1 * 1024 * 1024 * 1024) {
DEBUG(grf, 0, "Unexpectedly large offset for NewGRF");
Debug(grf, 0, "Unexpectedly large offset for NewGRF");
/* Having more than 1 GiB of data is very implausible. Mostly because then
* all pools in OpenTTD are flooded already. Or it's just Action C all over.
* In any case, the offsets to graphics will likely not work either. */
@ -524,7 +524,7 @@ GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
f = FindGRFConfig(c->ident.grfid, FGCM_COMPATIBLE, nullptr, c->version);
if (f != nullptr) {
md5sumToString(buf, lastof(buf), c->ident.md5sum);
DEBUG(grf, 1, "NewGRF %08X (%s) not found; checksum %s. Compatibility mode on", BSWAP32(c->ident.grfid), c->filename, buf);
Debug(grf, 1, "NewGRF {:08X} ({}) not found; checksum {}. Compatibility mode on", BSWAP32(c->ident.grfid), c->filename, buf);
if (!HasBit(c->flags, GCF_COMPATIBLE)) {
/* Preserve original_md5sum after it has been assigned */
SetBit(c->flags, GCF_COMPATIBLE);
@ -538,13 +538,13 @@ GRFListCompatibility IsGoodGRFConfigList(GRFConfig *grfconfig)
/* No compatible grf was found, mark it as disabled */
md5sumToString(buf, lastof(buf), c->ident.md5sum);
DEBUG(grf, 0, "NewGRF %08X (%s) not found; checksum %s", BSWAP32(c->ident.grfid), c->filename, buf);
Debug(grf, 0, "NewGRF {:08X} ({}) not found; checksum {}", BSWAP32(c->ident.grfid), c->filename, buf);
c->status = GCS_NOT_FOUND;
res = GLC_NOT_FOUND;
} else {
compatible_grf:
DEBUG(grf, 1, "Loading GRF %08X from %s", BSWAP32(f->ident.grfid), f->filename);
Debug(grf, 1, "Loading GRF {:08X} from {}", BSWAP32(f->ident.grfid), f->filename);
/* The filename could be the filename as in the savegame. As we need
* to load the GRF here, we need the correct filename, so overwrite that
* in any case and set the name and info when it is not set already.
@ -673,10 +673,10 @@ void DoScanNewGRFFiles(NewGRFScanCallback *callback)
ClearGRFConfigList(&_all_grfs);
TarScanner::DoScan(TarScanner::NEWGRF);
DEBUG(grf, 1, "Scanning for NewGRFs");
Debug(grf, 1, "Scanning for NewGRFs");
uint num = GRFFileScanner::DoScan();
DEBUG(grf, 1, "Scan complete, found %d files", num);
Debug(grf, 1, "Scan complete, found {} files", num);
if (num != 0 && _all_grfs != nullptr) {
/* Sort the linked list using quicksort.
* For that we first have to make an array, then sort and

@ -946,7 +946,7 @@ static uint32 VehicleGetVariable(Vehicle *v, const VehicleScopeResolver *object,
default: break;
}
DEBUG(grf, 1, "Unhandled vehicle variable 0x%X, type 0x%X", variable, (uint)v->type);
Debug(grf, 1, "Unhandled vehicle variable 0x{:X}, type 0x{:X}", variable, (uint)v->type);
*available = false;
return UINT_MAX;

@ -139,7 +139,7 @@ void AddGenericCallback(uint8 feature, const GRFFile *file, const SpriteGroup *g
}
}
DEBUG(grf, 1, "Unhandled generic feature variable 0x%02X", variable);
Debug(grf, 1, "Unhandled generic feature variable 0x{:02X}", variable);
*available = false;
return UINT_MAX;

@ -404,7 +404,7 @@ static uint32 GetDistanceFromNearbyHouse(uint8 parameter, TileIndex tile, HouseI
}
}
DEBUG(grf, 1, "Unhandled house variable 0x%X", variable);
Debug(grf, 1, "Unhandled house variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -168,7 +168,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
case 0x82: return this->industry->town->index;
case 0x83:
case 0x84:
case 0x85: DEBUG(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported
case 0x85: Debug(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported
/* Number of the layout */
case 0x86: return this->industry->selected_layout;
@ -199,7 +199,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
const IndustrySpec *indspec = GetIndustrySpec(this->type);
if (this->industry == nullptr) {
DEBUG(grf, 1, "Unhandled variable 0x%X (no available industry) in callback 0x%x", variable, this->ro.callback);
Debug(grf, 1, "Unhandled variable 0x{:X} (no available industry) in callback 0x{:x}", variable, this->ro.callback);
*available = false;
return UINT_MAX;
@ -352,7 +352,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
case 0x82: return this->industry->town->index;
case 0x83:
case 0x84:
case 0x85: DEBUG(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported
case 0x85: Debug(grf, 0, "NewGRFs shouldn't be doing pointer magic"); break; // not supported
case 0x86: return this->industry->location.w;
case 0x87: return this->industry->location.h;// xy dimensions
@ -408,7 +408,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte param_setID, byte layout
}
}
DEBUG(grf, 1, "Unhandled industry variable 0x%X", variable);
Debug(grf, 1, "Unhandled industry variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -93,7 +93,7 @@ uint32 GetRelativePosition(TileIndex tile, TileIndex ind_tile)
case 0x62: return GetIndustryIDAtOffset(GetNearbyTile(parameter, this->tile), this->industry, this->ro.grffile->grfid);
}
DEBUG(grf, 1, "Unhandled industry tile variable 0x%X", variable);
Debug(grf, 1, "Unhandled industry tile variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -335,7 +335,7 @@ static uint32 GetCountAndDistanceOfClosestInstance(byte local_id, uint32 grfid,
}
unhandled:
DEBUG(grf, 1, "Unhandled object variable 0x%X", variable);
Debug(grf, 1, "Unhandled object variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -52,7 +52,7 @@
}
}
DEBUG(grf, 1, "Unhandled rail type tile variable 0x%X", variable);
Debug(grf, 1, "Unhandled rail type tile variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -52,7 +52,7 @@
}
}
DEBUG(grf, 1, "Unhandled road type tile variable 0x%X", variable);
Debug(grf, 1, "Unhandled road type tile variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -86,14 +86,14 @@ bool LoadNewGRFSound(SoundEntry *sound)
/* Test string termination */
if (name[name_len] != 0) {
DEBUG(grf, 2, "LoadNewGRFSound [%s]: Name not properly terminated", file.GetSimplifiedFilename().c_str());
Debug(grf, 2, "LoadNewGRFSound [{}]: Name not properly terminated", file.GetSimplifiedFilename());
return false;
}
DEBUG(grf, 2, "LoadNewGRFSound [%s]: Sound name '%s'...", file.GetSimplifiedFilename().c_str(), name);
Debug(grf, 2, "LoadNewGRFSound [{}]: Sound name '{}'...", file.GetSimplifiedFilename(), name);
if (file.ReadDword() != BSWAP32('RIFF')) {
DEBUG(grf, 1, "LoadNewGRFSound [%s]: Missing RIFF header", file.GetSimplifiedFilename().c_str());
Debug(grf, 1, "LoadNewGRFSound [{}]: Missing RIFF header", file.GetSimplifiedFilename());
return false;
}
@ -101,12 +101,12 @@ bool LoadNewGRFSound(SoundEntry *sound)
uint header_size = 11;
if (sound->grf_container_ver >= 2) header_size++; // The first FF in the sprite is only counted for container version >= 2.
if (total_size + name_len + header_size > num) {
DEBUG(grf, 1, "LoadNewGRFSound [%s]: RIFF was truncated", file.GetSimplifiedFilename().c_str());
Debug(grf, 1, "LoadNewGRFSound [{}]: RIFF was truncated", file.GetSimplifiedFilename());
return false;
}
if (file.ReadDword() != BSWAP32('WAVE')) {
DEBUG(grf, 1, "LoadNewGRFSound [%s]: Invalid RIFF type", file.GetSimplifiedFilename().c_str());
Debug(grf, 1, "LoadNewGRFSound [{}]: Invalid RIFF type", file.GetSimplifiedFilename());
return false;
}
@ -115,7 +115,7 @@ bool LoadNewGRFSound(SoundEntry *sound)
uint32 size = file.ReadDword();
total_size -= 8;
if (total_size < size) {
DEBUG(grf, 1, "LoadNewGRFSound [%s]: Invalid RIFF", file.GetSimplifiedFilename().c_str());
Debug(grf, 1, "LoadNewGRFSound [{}]: Invalid RIFF", file.GetSimplifiedFilename());
return false;
}
total_size -= size;
@ -124,7 +124,7 @@ bool LoadNewGRFSound(SoundEntry *sound)
case ' tmf': // 'fmt '
/* Audio format, must be 1 (PCM) */
if (size < 16 || file.ReadWord() != 1) {
DEBUG(grf, 1, "LoadGRFSound [%s]: Invalid audio format", file.GetSimplifiedFilename().c_str());
Debug(grf, 1, "LoadGRFSound [{}]: Invalid audio format", file.GetSimplifiedFilename());
return false;
}
sound->channels = file.ReadWord();
@ -141,7 +141,7 @@ bool LoadNewGRFSound(SoundEntry *sound)
sound->file_size = size;
sound->file_offset = file.GetPos();
DEBUG(grf, 2, "LoadNewGRFSound [%s]: channels %u, sample rate %u, bits per sample %u, length %u", file.GetSimplifiedFilename().c_str(), sound->channels, sound->rate, sound->bits_per_sample, size);
Debug(grf, 2, "LoadNewGRFSound [{}]: channels {}, sample rate {}, bits per sample {}, length {}", file.GetSimplifiedFilename(), sound->channels, sound->rate, sound->bits_per_sample, size);
return true; // the fmt chunk has to appear before data, so we are finished
default:
@ -153,7 +153,7 @@ bool LoadNewGRFSound(SoundEntry *sound)
if (size > 0) file.SkipBytes(size);
}
DEBUG(grf, 1, "LoadNewGRFSound [%s]: RIFF does not contain any sound data", file.GetSimplifiedFilename().c_str());
Debug(grf, 1, "LoadNewGRFSound [{}]: RIFF does not contain any sound data", file.GetSimplifiedFilename());
/* Clear everything that was read */
MemSetT(sound, 0);

@ -105,7 +105,7 @@ static inline uint32 GetVariable(const ResolverObject &object, ScopeResolver *sc
*/
/* virtual */ uint32 ScopeResolver::GetVariable(byte variable, uint32 parameter, bool *available) const
{
DEBUG(grf, 1, "Unhandled scope variable 0x%X", variable);
Debug(grf, 1, "Unhandled scope variable 0x{:X}", variable);
*available = false;
return UINT_MAX;
}

@ -454,7 +454,7 @@ uint32 Station::GetNewGRFVariable(const ResolverObject &object, byte variable, b
}
}
DEBUG(grf, 1, "Unhandled station variable 0x%X", variable);
Debug(grf, 1, "Unhandled station variable 0x{:X}", variable);
*available = false;
return UINT_MAX;
@ -486,7 +486,7 @@ uint32 Waypoint::GetNewGRFVariable(const ResolverObject &object, byte variable,
}
}
DEBUG(grf, 1, "Unhandled station variable 0x%X", variable);
Debug(grf, 1, "Unhandled station variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -92,7 +92,7 @@ void AddChangedPersistentStorage(BasePersistentStorageArray *storage)
/* Discard all temporary changes */
for (std::set<BasePersistentStorageArray*>::iterator it = _changed_storage_arrays->begin(); it != _changed_storage_arrays->end(); it++) {
DEBUG(desync, 1, "Discarding persistent storage changes: Feature %d, GrfID %08X, Tile %d", (*it)->feature, BSWAP32((*it)->grfid), (*it)->tile);
Debug(desync, 1, "Discarding persistent storage changes: Feature {}, GrfID {:08X}, Tile {}", (*it)->feature, BSWAP32((*it)->grfid), (*it)->tile);
(*it)->ClearChanges();
}
_changed_storage_arrays->clear();

@ -884,7 +884,7 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
case SCC_NEWGRF_PRINT_WORD_STATION_NAME:
case SCC_NEWGRF_PRINT_WORD_CARGO_NAME:
if (argv_size < 1) {
DEBUG(misc, 0, "Too many NewGRF string parameters.");
Debug(misc, 0, "Too many NewGRF string parameters.");
return 0;
}
break;
@ -893,7 +893,7 @@ uint RemapNewGRFStringControlCode(uint scc, char *buf_start, char **buff, const
case SCC_NEWGRF_PRINT_WORD_CARGO_SHORT:
case SCC_NEWGRF_PRINT_WORD_CARGO_TINY:
if (argv_size < 2) {
DEBUG(misc, 0, "Too many NewGRF string parameters.");
Debug(misc, 0, "Too many NewGRF string parameters.");
return 0;
}
break;

@ -111,7 +111,7 @@
case 0xD5: return this->t->fund_buildings_months;
}
DEBUG(grf, 1, "Unhandled town variable 0x%X", variable);
Debug(grf, 1, "Unhandled town variable 0x{:X}", variable);
*available = false;
return UINT_MAX;

@ -188,7 +188,7 @@ static void ShowHelp()
" -p password = Password to join server\n"
" -P password = Password to join company\n"
" -D [ip][:port] = Start dedicated server\n"
" -l ip[:port] = Redirect DEBUG()\n"
" -l ip[:port] = Redirect Debug()\n"
#if !defined(_WIN32)
" -f = Fork into the background (dedicated only)\n"
#endif
@ -666,7 +666,7 @@ int openttd_main(int argc, char *argv[])
DeterminePaths(argv[0], only_local_path);
TarScanner::DoScan(TarScanner::BASESET);
if (dedicated) DEBUG(net, 3, "Starting dedicated server, version %s", _openttd_revision);
if (dedicated) Debug(net, 3, "Starting dedicated server, version {}", _openttd_revision);
if (_dedicated_forks && !dedicated) _dedicated_forks = false;
#if defined(UNIX)
@ -715,7 +715,7 @@ int openttd_main(int argc, char *argv[])
/* Initialize game palette */
GfxInitPalettes();
DEBUG(misc, 1, "Loading blitter...");
Debug(misc, 1, "Loading blitter...");
if (blitter.empty() && !_ini_blitter.empty()) blitter = _ini_blitter;
_blitter_autodetected = blitter.empty();
/* Activate the initial blitter.
@ -945,7 +945,7 @@ bool SafeLoad(const std::string &filename, SaveLoadOperation fop, DetailedFileTy
* special cases which make clients desync immediately. So we fall
* back to just generating a new game with the current settings.
*/
DEBUG(net, 0, "Loading game failed, so a new (random) game will be started");
Debug(net, 0, "Loading game failed, so a new (random) game will be started");
MakeNewGame(false, true);
return false;
}
@ -1136,7 +1136,7 @@ static void CheckCaches()
uint i = 0;
for (Town *t : Town::Iterate()) {
if (MemCmpT(old_town_caches.data() + i, &t->cache) != 0) {
DEBUG(desync, 2, "town cache mismatch: town %i", (int)t->index);
Debug(desync, 2, "town cache mismatch: town {}", t->index);
}
i++;
}
@ -1151,7 +1151,7 @@ static void CheckCaches()
i = 0;
for (const Company *c : Company::Iterate()) {
if (MemCmpT(old_infrastructure.data() + i, &c->infrastructure) != 0) {
DEBUG(desync, 2, "infrastructure cache mismatch: company %i", (int)c->index);
Debug(desync, 2, "infrastructure cache mismatch: company {}", c->index);
}
i++;
}
@ -1208,23 +1208,23 @@ static void CheckCaches()
for (const Vehicle *u = v; u != nullptr; u = u->Next()) {
FillNewGRFVehicleCache(u);
if (memcmp(&grf_cache[length], &u->grf_cache, sizeof(NewGRFCache)) != 0) {
DEBUG(desync, 2, "newgrf cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
Debug(desync, 2, "newgrf cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
}
if (memcmp(&veh_cache[length], &u->vcache, sizeof(VehicleCache)) != 0) {
DEBUG(desync, 2, "vehicle cache mismatch: type %i, vehicle %i, company %i, unit number %i, wagon %i", (int)v->type, v->index, (int)v->owner, v->unitnumber, length);
Debug(desync, 2, "vehicle cache mismatch: type {}, vehicle {}, company {}, unit number {}, wagon {}", v->type, v->index, v->owner, v->unitnumber, length);
}
switch (u->type) {
case VEH_TRAIN:
if (memcmp(&gro_cache[length], &Train::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
DEBUG(desync, 2, "train ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
Debug(desync, 2, "train ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
}
if (memcmp(&tra_cache[length], &Train::From(u)->tcache, sizeof(TrainCache)) != 0) {
DEBUG(desync, 2, "train cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
Debug(desync, 2, "train cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
}
break;
case VEH_ROAD:
if (memcmp(&gro_cache[length], &RoadVehicle::From(u)->gcache, sizeof(GroundVehicleCache)) != 0) {
DEBUG(desync, 2, "road vehicle ground vehicle cache mismatch: vehicle %i, company %i, unit number %i, wagon %i", v->index, (int)v->owner, v->unitnumber, length);
Debug(desync, 2, "road vehicle ground vehicle cache mismatch: vehicle {}, company {}, unit number {}, wagon {}", v->index, v->owner, v->unitnumber, length);
}
break;
default:
@ -1271,11 +1271,11 @@ static void CheckCaches()
}
UpdateStationDockingTiles(st);
if (ta.tile != st->docking_station.tile || ta.w != st->docking_station.w || ta.h != st->docking_station.h) {
DEBUG(desync, 2, "station docking mismatch: station %i, company %i", st->index, (int)st->owner);
Debug(desync, 2, "station docking mismatch: station {}, company {}", st->index, st->owner);
}
for (TileIndex tile : ta) {
if (docking_tiles[tile] != IsDockingTile(tile)) {
DEBUG(desync, 2, "docking tile mismatch: tile %i", (int)tile);
Debug(desync, 2, "docking tile mismatch: tile {}", tile);
}
}
@ -1283,7 +1283,7 @@ static void CheckCaches()
IndustryList industries_near = st->industries_near;
st->RecomputeCatchment();
if (st->industries_near != industries_near) {
DEBUG(desync, 2, "station industries near mismatch: station %i", st->index);
Debug(desync, 2, "station industries near mismatch: station {}", st->index);
}
}
@ -1291,14 +1291,14 @@ static void CheckCaches()
i = 0;
for (Town *t : Town::Iterate()) {
if (t->stations_near != old_town_stations_near[i]) {
DEBUG(desync, 2, "town stations near mismatch: town %i", t->index);
Debug(desync, 2, "town stations near mismatch: town {}", t->index);
}
i++;
}
i = 0;
for (Industry *ind : Industry::Iterate()) {
if (ind->stations_near != old_industry_stations_near[i]) {
DEBUG(desync, 2, "industry stations near mismatch: industry %i", ind->index);
Debug(desync, 2, "industry stations near mismatch: industry {}", ind->index);
}
i++;
}
@ -1406,7 +1406,7 @@ static void DoAutosave()
if (++_autosave_ctr >= _settings_client.gui.max_num_autosaves) _autosave_ctr = 0;
}
DEBUG(sl, 2, "Autosaving to '%s'", buf);
Debug(sl, 2, "Autosaving to '{}'", buf);
if (SaveOrLoad(buf, SLO_SAVE, DFT_GAME_FILE, AUTOSAVE_DIR) != SL_OK) {
ShowErrorMessage(STR_ERROR_AUTOSAVE_FAILED, INVALID_STRING_ID, WL_ERROR);
}

@ -620,7 +620,7 @@ void OrderList::DebugCheckSanity() const
Ticks check_timetable_duration = 0;
Ticks check_total_duration = 0;
DEBUG(misc, 6, "Checking OrderList %hu for sanity...", this->index);
Debug(misc, 6, "Checking OrderList {} for sanity...", this->index);
for (const Order *o = this->first; o != nullptr; o = o->next) {
++check_num_orders;
@ -638,7 +638,7 @@ void OrderList::DebugCheckSanity() const
assert(v->orders.list == this);
}
assert(this->num_vehicles == check_num_vehicles);
DEBUG(misc, 6, "... detected %u orders (%u manual), %u vehicles, %i timetabled, %i total",
Debug(misc, 6, "... detected {} orders ({} manual), {} vehicles, {} timetabled, {} total",
(uint)this->num_orders, (uint)this->num_manual_orders,
this->num_vehicles, this->timetable_duration, this->total_duration);
}

@ -57,7 +57,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
}
if (os_err == noErr) {
DEBUG(freetype, 3, "Font path for %s: %s", font_name, file_path);
Debug(freetype, 3, "Font path for {}: {}", font_name, file_path);
err = FT_New_Face(_library, (const char *)file_path, 0, face);
}
@ -134,7 +134,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
/* Save result. */
callback->SetFontNames(settings, name);
if (!callback->FindMissingGlyphs()) {
DEBUG(freetype, 2, "CT-Font for %s: %s", language_isocode, name);
Debug(freetype, 2, "CT-Font for {}: {}", language_isocode, name);
result = true;
break;
}
@ -221,7 +221,7 @@ void CoreTextFontCache::SetFontSize(int pixels)
CFStringGetCString(font_name.get(), name, lengthof(name), kCFStringEncodingUTF8);
this->font_name = name;
DEBUG(freetype, 2, "Loaded font '%s' with size %d", this->font_name.c_str(), pixels);
Debug(freetype, 2, "Loaded font '{}' with size {}", this->font_name, pixels);
}
GlyphID CoreTextFontCache::MapCharToGlyph(WChar key)

@ -206,7 +206,7 @@ bool GetClipboardContents(char *buffer, const char *last)
void OSOpenBrowser(const char *url)
{
// stub only
DEBUG(misc, 0, "Failed to open url: %s", url);
Debug(misc, 0, "Failed to open url: {}", url);
}
void SetCurrentThreadName(const char *)

@ -148,7 +148,7 @@ bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, i
callback->SetFontNames(settings, (const char *)file);
bool missing = callback->FindMissingGlyphs();
DEBUG(freetype, 1, "Font \"%s\" misses%s glyphs", file, missing ? "" : " no");
Debug(freetype, 1, "Font \"{}\" misses{} glyphs", file, missing ? "" : " no");
if (!missing) {
best_weight = value;

@ -164,7 +164,7 @@ static const char *convert_tofrom_fs(iconv_t convd, const char *name, char *outb
iconv(convd, nullptr, nullptr, nullptr, nullptr);
if (iconv(convd, &inbuf, &inlen, &outbuf, &outlen) == (size_t)(-1)) {
DEBUG(misc, 0, "[iconv] error converting '%s'. Errno %d", name, errno);
Debug(misc, 0, "[iconv] error converting '{}'. Errno {}", name, errno);
}
*outbuf = '\0';
@ -186,7 +186,7 @@ std::string OTTD2FS(const std::string &name)
const char *env = GetLocalCode();
convd = iconv_open(env, INTERNALCODE);
if (convd == (iconv_t)(-1)) {
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", INTERNALCODE, env);
Debug(misc, 0, "[iconv] conversion from codeset '{}' to '{}' unsupported", INTERNALCODE, env);
return name;
}
}
@ -208,7 +208,7 @@ std::string FS2OTTD(const std::string &name)
const char *env = GetLocalCode();
convd = iconv_open(INTERNALCODE, env);
if (convd == (iconv_t)(-1)) {
DEBUG(misc, 0, "[iconv] conversion from codeset '%s' to '%s' unsupported", env, INTERNALCODE);
Debug(misc, 0, "[iconv] conversion from codeset '{}' to '{}' unsupported", env, INTERNALCODE);
return name;
}
}
@ -306,7 +306,7 @@ void OSOpenBrowser(const char *url)
args[1] = url;
args[2] = nullptr;
execvp(args[0], const_cast<char * const *>(args));
DEBUG(misc, 0, "Failed to open url: %s", url);
Debug(misc, 0, "Failed to open url: {}", url);
exit(0);
}
#endif /* __APPLE__ */

@ -78,7 +78,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
ret = RegOpenKeyEx(HKEY_LOCAL_MACHINE, FONT_DIR_NT, 0, KEY_READ, &hKey);
if (ret != ERROR_SUCCESS) {
DEBUG(freetype, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
Debug(freetype, 0, "Cannot open registry key HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Fonts");
return err;
}
@ -113,7 +113,7 @@ FT_Error GetFontByFaceName(const char *font_name, FT_Face *face)
}
if (!SUCCEEDED(SHGetFolderPath(nullptr, CSIDL_FONTS, nullptr, SHGFP_TYPE_CURRENT, vbuffer))) {
DEBUG(freetype, 0, "SHGetFolderPath cannot return fonts directory");
Debug(freetype, 0, "SHGetFolderPath cannot return fonts directory");
goto folder_error;
}
@ -334,17 +334,17 @@ static int CALLBACK EnumFontCallback(const ENUMLOGFONTEX *logfont, const NEWTEXT
info->callback->SetFontNames(info->settings, font_name, &logfont->elfLogFont);
if (info->callback->FindMissingGlyphs()) return 1;
DEBUG(freetype, 1, "Fallback font: %s (%s)", font_name, english_name);
Debug(freetype, 1, "Fallback font: {} ({})", font_name, english_name);
return 0; // stop enumerating
}
bool SetFallbackFont(FreeTypeSettings *settings, const char *language_isocode, int winlangid, MissingGlyphSearcher *callback)
{
DEBUG(freetype, 1, "Trying fallback fonts");
Debug(freetype, 1, "Trying fallback fonts");
EFCParam langInfo;
if (GetLocaleInfo(MAKELCID(winlangid, SORT_DEFAULT), LOCALE_FONTSIGNATURE, (LPTSTR)&langInfo.locale, sizeof(langInfo.locale) / sizeof(wchar_t)) == 0) {
/* Invalid langid or some other mysterious error, can't determine fallback font. */
DEBUG(freetype, 1, "Can't get locale info for fallback font (langid=0x%x)", winlangid);
Debug(freetype, 1, "Can't get locale info for fallback font (langid=0x{:x})", winlangid);
return false;
}
langInfo.settings = settings;
@ -439,7 +439,7 @@ void Win32FontCache::SetFontSize(FontSize fs, int pixels)
this->glyph_size.cx = otm->otmTextMetrics.tmMaxCharWidth;
this->glyph_size.cy = otm->otmTextMetrics.tmHeight;
DEBUG(freetype, 2, "Loaded font '%s' with size %d", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)).c_str(), pixels);
Debug(freetype, 2, "Loaded font '{}' with size {}", FS2OTTD((LPWSTR)((BYTE *)otm + (ptrdiff_t)otm->otmpFullName)), pixels);
}
/**

@ -471,7 +471,7 @@ void DetermineBasePaths(const char *exe)
wchar_t config_dir[MAX_PATH];
wcsncpy(path, convert_to_fs(_config_file.c_str(), path, lengthof(path)), lengthof(path));
if (!GetFullPathName(path, lengthof(config_dir), config_dir, nullptr)) {
DEBUG(misc, 0, "GetFullPathName failed (%lu)\n", GetLastError());
Debug(misc, 0, "GetFullPathName failed ({})", GetLastError());
_searchpaths[SP_WORKING_DIR].clear();
} else {
std::string tmp(FS2OTTD(config_dir));
@ -483,13 +483,13 @@ void DetermineBasePaths(const char *exe)
}
if (!GetModuleFileName(nullptr, path, lengthof(path))) {
DEBUG(misc, 0, "GetModuleFileName failed (%lu)\n", GetLastError());
Debug(misc, 0, "GetModuleFileName failed ({})", GetLastError());
_searchpaths[SP_BINARY_DIR].clear();
} else {
wchar_t exec_dir[MAX_PATH];
wcsncpy(path, convert_to_fs(exe, path, lengthof(path)), lengthof(path));
if (!GetFullPathName(path, lengthof(exec_dir), exec_dir, nullptr)) {
DEBUG(misc, 0, "GetFullPathName failed (%lu)\n", GetLastError());
Debug(misc, 0, "GetFullPathName failed ({})", GetLastError());
_searchpaths[SP_BINARY_DIR].clear();
} else {
std::string tmp(FS2OTTD(exec_dir));

@ -178,7 +178,7 @@ static int32 NPFCalcStationOrTileHeuristic(AyStar *as, AyStarNode *current, Open
dist = NPFDistanceTrack(from, to);
}
DEBUG(npf, 4, "Calculating H for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), dist);
Debug(npf, 4, "Calculating H for: ({}, {}). Result: {}", TileX(current->tile), TileY(current->tile), dist);
if (dist < ftd->best_bird_dist) {
ftd->best_bird_dist = dist;
@ -198,7 +198,7 @@ static void NPFFillTrackdirChoice(AyStarNode *current, OpenListNode *parent)
/* This is a first order decision, so we'd better save the
* direction we chose */
current->user_data[NPF_TRACKDIR_CHOICE] = trackdir;
DEBUG(npf, 6, "Saving trackdir: 0x%X", trackdir);
Debug(npf, 6, "Saving trackdir: 0x{:X}", trackdir);
} else {
/* We've already made the decision, so just save our parent's decision */
current->user_data[NPF_TRACKDIR_CHOICE] = parent->path.node.user_data[NPF_TRACKDIR_CHOICE];
@ -394,7 +394,7 @@ static int32 NPFRoadPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare
}
NPFMarkTile(tile);
DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost);
Debug(npf, 4, "Calculating G for: ({}, {}). Result: {}", TileX(current->tile), TileY(current->tile), cost);
return cost;
}
@ -546,7 +546,7 @@ static int32 NPFRailPathCost(AyStar *as, AyStarNode *current, OpenListNode *pare
cost += NPFReservedTrackCost(current);
NPFMarkTile(tile);
DEBUG(npf, 4, "Calculating G for: (%d, %d). Result: %d", TileX(current->tile), TileY(current->tile), cost);
Debug(npf, 4, "Calculating G for: ({}, {}). Result: {}", TileX(current->tile), TileY(current->tile), cost);
return cost;
}
@ -865,7 +865,7 @@ static TrackdirBits GetDriveableTrackdirBits(TileIndex dst_tile, TileIndex src_t
}
}
DEBUG(npf, 4, "Next node: (%d, %d) [%d], possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), dst_tile, trackdirbits);
Debug(npf, 4, "Next node: ({}, {}) [{}], possible trackdirs: 0x{:X}", TileX(dst_tile), TileY(dst_tile), dst_tile, trackdirbits);
/* Select only trackdirs we can reach from our current trackdir */
trackdirbits &= TrackdirReachesTrackdirs(src_trackdir);
@ -875,7 +875,7 @@ static TrackdirBits GetDriveableTrackdirBits(TileIndex dst_tile, TileIndex src_t
trackdirbits &= ~TrackdirCrossesTrackdirs(src_trackdir);
}
DEBUG(npf, 6, "After filtering: (%d, %d), possible trackdirs: 0x%X", TileX(dst_tile), TileY(dst_tile), trackdirbits);
Debug(npf, 6, "After filtering: ({}, {}), possible trackdirs: 0x{:X}", TileX(dst_tile), TileY(dst_tile), trackdirbits);
return trackdirbits;
}
@ -901,7 +901,7 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
/* Initialize to 0, so we can jump out (return) somewhere an have no neighbours */
aystar->num_neighbours = 0;
DEBUG(npf, 4, "Expanding: (%d, %d, %d) [%d]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
Debug(npf, 4, "Expanding: ({}, {}, {}) [{}]", TileX(src_tile), TileY(src_tile), src_trackdir, src_tile);
/* We want to determine the tile we arrive, and which choices we have there */
TileIndex dst_tile;
@ -966,7 +966,7 @@ static void NPFFollowTrack(AyStar *aystar, OpenListNode *current)
uint i = 0;
while (trackdirbits != TRACKDIR_BIT_NONE) {
Trackdir dst_trackdir = RemoveFirstTrackdir(&trackdirbits);
DEBUG(npf, 5, "Expanded into trackdir: %d, remaining trackdirs: 0x%X", dst_trackdir, trackdirbits);
Debug(npf, 5, "Expanded into trackdir: {}, remaining trackdirs: 0x{:X}", dst_trackdir, trackdirbits);
/* Tile with signals? */
if (IsTileType(dst_tile, MP_RAILWAY) && GetRailTileType(dst_tile) == RAIL_TILE_SIGNALS) {
@ -1050,10 +1050,10 @@ static NPFFoundTargetData NPFRouteInternal(AyStarNode *start1, bool ignore_start
if (result.best_bird_dist != 0) {
if (target != nullptr) {
DEBUG(npf, 1, "Could not find route to tile 0x%X from 0x%X.", target->dest_coords, start1->tile);
Debug(npf, 1, "Could not find route to tile 0x{:X} from 0x{:X}.", target->dest_coords, start1->tile);
} else {
/* Assumption: target == nullptr, so we are looking for a depot */
DEBUG(npf, 1, "Could not find route to a depot from tile 0x%X.", start1->tile);
Debug(npf, 1, "Could not find route to a depot from tile 0x{:X}.", start1->tile);
}
}

@ -146,7 +146,7 @@ public:
int cost = bDestFound ? m_pBestDestNode->m_cost : -1;
int dist = bDestFound ? m_pBestDestNode->m_estimate - m_pBestDestNode->m_cost : -1;
DEBUG(yapf, 3, "[YAPF%c]%c%4d- %d rounds - %d open - %d closed - CHR %4.1f%% - C %d D %d",
Debug(yapf, 3, "[YAPF{}]{}{:4d} - {} rounds - {} open - {} closed - CHR {:4.1f}% - C {} D {}",
ttc, bDestFound ? '-' : '!', veh_idx, m_num_steps, m_nodes.OpenCount(), m_nodes.ClosedCount(), cache_hit_ratio, cost, dist
);
}

@ -241,7 +241,7 @@ public:
pf2.DisableCache(true);
FindDepotData result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_penalty, reverse_penalty);
if (result1.tile != result2.tile || (result1.reverse != result2.reverse)) {
DEBUG(desync, 2, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]",
Debug(desync, 2, "CACHE ERROR: FindNearestDepotTwoWay() = [{}, {}]",
result1.tile != INVALID_TILE ? "T" : "F",
result2.tile != INVALID_TILE ? "T" : "F");
DumpState(pf1, pf2);
@ -325,7 +325,7 @@ public:
pf2.DisableCache(true);
result1 = pf2.FindNearestSafeTile(v, t1, td, override_railtype, false);
if (result1 != result2) {
DEBUG(desync, 2, "CACHE ERROR: FindSafeTile() = [%s, %s]", result2 ? "T" : "F", result1 ? "T" : "F");
Debug(desync, 2, "CACHE ERROR: FindSafeTile() = [{}, {}]", result2 ? "T" : "F", result1 ? "T" : "F");
DumpState(pf1, pf2);
}
}
@ -409,7 +409,7 @@ public:
pf2.DisableCache(true);
Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_found, reserve_track, target);
if (result1 != result2) {
DEBUG(desync, 2, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2);
Debug(desync, 2, "CACHE ERROR: ChooseRailTrack() = [{}, {}]", result1, result2);
DumpState(pf1, pf2);
}
}
@ -467,7 +467,7 @@ public:
pf2.DisableCache(true);
bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2, reverse_penalty);
if (result1 != result2) {
DEBUG(desync, 2, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
Debug(desync, 2, "CACHE ERROR: CheckReverseTrain() = [{}, {}]", result1 ? "T" : "F", result2 ? "T" : "F");
DumpState(pf1, pf2);
}
}

@ -86,7 +86,7 @@ void RandomAccessFile::SeekTo(size_t pos, int mode)
this->pos = pos;
if (fseek(this->file_handle, this->pos, SEEK_SET) < 0) {
DEBUG(misc, 0, "Seeking in %s failed", this->filename.c_str());
Debug(misc, 0, "Seeking in {} failed", this->filename);
}
/* Reset the buffer, so the next ReadByte will read bytes from the file. */

@ -568,8 +568,8 @@ bool AfterLoadGame()
if (IsSavegameVersionBefore(SLV_119)) {
_pause_mode = (_pause_mode == 2) ? PM_PAUSED_NORMAL : PM_UNPAUSED;
} else if (_network_dedicated && (_pause_mode & PM_PAUSED_ERROR) != 0) {
DEBUG(net, 0, "The loading savegame was paused due to an error state");
DEBUG(net, 0, " This savegame cannot be used for multiplayer");
Debug(net, 0, "The loading savegame was paused due to an error state");
Debug(net, 0, " This savegame cannot be used for multiplayer");
/* Restore the signals */
ResetSignalHandlers();
return false;
@ -2308,7 +2308,7 @@ bool AfterLoadGame()
/* At some point, invalid depots were saved into the game (possibly those removed in the past?)
* Remove them here, so they don't cause issues further down the line */
if (!IsDepotTile(d->xy)) {
DEBUG(sl, 0, "Removing invalid depot %d at %d, %d", d->index, TileX(d->xy), TileY(d->xy));
Debug(sl, 0, "Removing invalid depot {} at {}, {}", d->index, TileX(d->xy), TileY(d->xy));
delete d;
d = nullptr;
continue;

@ -86,15 +86,15 @@ static void Load_AIPL()
config->Change(_ai_saveload_name.c_str(), -1, false, _ai_saveload_is_random);
if (!config->HasScript()) {
if (_ai_saveload_name.compare("%_dummy") != 0) {
DEBUG(script, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name.c_str(), _ai_saveload_version);
DEBUG(script, 0, "A random other AI will be loaded in its place.");
Debug(script, 0, "The savegame has an AI by the name '{}', version {} which is no longer available.", _ai_saveload_name, _ai_saveload_version);
Debug(script, 0, "A random other AI will be loaded in its place.");
} else {
DEBUG(script, 0, "The savegame had no AIs available at the time of saving.");
DEBUG(script, 0, "A random available AI will be loaded now.");
Debug(script, 0, "The savegame had no AIs available at the time of saving.");
Debug(script, 0, "A random available AI will be loaded now.");
}
} else {
DEBUG(script, 0, "The savegame has an AI by the name '%s', version %d which is no longer available.", _ai_saveload_name.c_str(), _ai_saveload_version);
DEBUG(script, 0, "The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible.");
Debug(script, 0, "The savegame has an AI by the name '{}', version {} which is no longer available.", _ai_saveload_name, _ai_saveload_version);
Debug(script, 0, "The latest version of that AI has been loaded instead, but it'll not get the savegame data as it's incompatible.");
}
/* Make sure the AI doesn't get the saveload data, as it was not the
* writer of the saveload data in the first place */

@ -77,15 +77,15 @@ static void Load_GSDT()
config->Change(_game_saveload_name.c_str(), -1, false, _game_saveload_is_random);
if (!config->HasScript()) {
if (_game_saveload_name.compare("%_dummy") != 0) {
DEBUG(script, 0, "The savegame has an GameScript by the name '%s', version %d which is no longer available.", _game_saveload_name.c_str(), _game_saveload_version);
DEBUG(script, 0, "This game will continue to run without GameScript.");
Debug(script, 0, "The savegame has an GameScript by the name '{}', version {} which is no longer available.", _game_saveload_name, _game_saveload_version);
Debug(script, 0, "This game will continue to run without GameScript.");
} else {
DEBUG(script, 0, "The savegame had no GameScript available at the time of saving.");
DEBUG(script, 0, "This game will continue to run without GameScript.");
Debug(script, 0, "The savegame had no GameScript available at the time of saving.");
Debug(script, 0, "This game will continue to run without GameScript.");
}
} else {
DEBUG(script, 0, "The savegame has an GameScript by the name '%s', version %d which is no longer available.", _game_saveload_name.c_str(), _game_saveload_version);
DEBUG(script, 0, "The latest version of that GameScript has been loaded instead, but it'll not get the savegame data as it's incompatible.");
Debug(script, 0, "The savegame has an GameScript by the name '{}', version {} which is no longer available.", _game_saveload_name, _game_saveload_version);
Debug(script, 0, "The latest version of that GameScript has been loaded instead, but it'll not get the savegame data as it's incompatible.");
}
/* Make sure the GameScript doesn't get the saveload data, as it was not the
* writer of the saveload data in the first place */

@ -56,7 +56,7 @@ static byte ReadByteFromFile(LoadgameState *ls)
/* We tried to read, but there is nothing in the file anymore.. */
if (count == 0) {
DEBUG(oldloader, 0, "Read past end of file, loading failed");
Debug(oldloader, 0, "Read past end of file, loading failed");
throw std::exception();
}
@ -132,7 +132,7 @@ bool LoadChunk(LoadgameState *ls, void *base, const OldChunks *chunks)
break;
case OC_ASSERT:
DEBUG(oldloader, 4, "Assert point: 0x%X / 0x%X", ls->total_read, (uint)(size_t)chunk->ptr + _bump_assert_value);
Debug(oldloader, 4, "Assert point: 0x{:X} / 0x{:X}", ls->total_read, (uint)(size_t)chunk->ptr + _bump_assert_value);
if (ls->total_read != (size_t)chunk->ptr + _bump_assert_value) throw std::exception();
default: break;
}
@ -273,7 +273,7 @@ bool LoadOldSaveGame(const std::string &file)
{
LoadgameState ls;
DEBUG(oldloader, 3, "Trying to load a TTD(Patch) savegame");
Debug(oldloader, 3, "Trying to load a TTD(Patch) savegame");
InitLoading(&ls);
@ -281,7 +281,7 @@ bool LoadOldSaveGame(const std::string &file)
ls.file = FioFOpenFile(file, "rb", NO_DIRECTORY);
if (ls.file == nullptr) {
DEBUG(oldloader, 0, "Cannot open file '%s'", file.c_str());
Debug(oldloader, 0, "Cannot open file '{}'", file);
return false;
}

@ -132,7 +132,7 @@ static uint32 RemapOldTownName(uint32 townnameparts, byte old_town_name_type)
return FIXNUM(townnameparts - 86, lengthof(_name_french_real), 0);
case 2: // German
DEBUG(misc, 0, "German Townnames are buggy (%d)", townnameparts);
Debug(misc, 0, "German Townnames are buggy ({})", townnameparts);
return townnameparts;
case 4: // Latin-American
@ -532,9 +532,9 @@ static void ReadTTDPatchFlags()
for (uint i = 0; i < 17; i++) _old_map3[i] = 0;
for (uint i = 0x1FE00; i < 0x20000; i++) _old_map3[i] = 0;
if (_savegame_type == SGT_TTDP2) DEBUG(oldloader, 2, "Found TTDPatch game");
if (_savegame_type == SGT_TTDP2) Debug(oldloader, 2, "Found TTDPatch game");
DEBUG(oldloader, 3, "Vehicle-multiplier is set to %d (%d vehicles)", _old_vehicle_multiplier, _old_vehicle_multiplier * 850);
Debug(oldloader, 3, "Vehicle-multiplier is set to {} ({} vehicles)", _old_vehicle_multiplier, _old_vehicle_multiplier * 850);
}
static const OldChunks town_chunk[] = {
@ -1114,7 +1114,7 @@ static bool LoadOldVehicleUnion(LoadgameState *ls, int num)
/* This chunk size should always be 10 bytes */
if (ls->total_read - temp != 10) {
DEBUG(oldloader, 0, "Assert failed in VehicleUnion: invalid chunk size");
Debug(oldloader, 0, "Assert failed in VehicleUnion: invalid chunk size");
return false;
}
@ -1327,7 +1327,7 @@ bool LoadOldVehicle(LoadgameState *ls, int num)
/* This should be consistent, else we have a big problem... */
if (v->index != _current_vehicle_id) {
DEBUG(oldloader, 0, "Loading failed - vehicle-array is invalid");
Debug(oldloader, 0, "Loading failed - vehicle-array is invalid");
return false;
}
}
@ -1512,7 +1512,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num)
{
ReadTTDPatchFlags();
DEBUG(oldloader, 2, "Found %d extra chunk(s)", _old_extra_chunk_nums);
Debug(oldloader, 2, "Found {} extra chunk(s)", _old_extra_chunk_nums);
for (int i = 0; i != _old_extra_chunk_nums; i++) {
uint16 id = ReadUint16(ls);
@ -1535,7 +1535,7 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num)
c->ident.grfid = grfid;
AppendToGRFConfigList(&_grfconfig, c);
DEBUG(oldloader, 3, "TTDPatch game using GRF file with GRFID %0X", BSWAP32(c->ident.grfid));
Debug(oldloader, 3, "TTDPatch game using GRF file with GRFID {:08X}", BSWAP32(c->ident.grfid));
}
len -= 5;
}
@ -1548,14 +1548,14 @@ static bool LoadTTDPatchExtraChunks(LoadgameState *ls, int num)
/* TTDPatch version and configuration */
case 0x3:
_ttdp_version = ReadUint32(ls);
DEBUG(oldloader, 3, "Game saved with TTDPatch version %d.%d.%d r%d",
Debug(oldloader, 3, "Game saved with TTDPatch version {}.{}.{} r{}",
GB(_ttdp_version, 24, 8), GB(_ttdp_version, 20, 4), GB(_ttdp_version, 16, 4), GB(_ttdp_version, 0, 16));
len -= 4;
while (len-- != 0) ReadByte(ls); // skip the configuration
break;
default:
DEBUG(oldloader, 4, "Skipping unknown extra chunk %X", id);
Debug(oldloader, 4, "Skipping unknown extra chunk {}", id);
while (len-- != 0) ReadByte(ls);
break;
}
@ -1742,7 +1742,7 @@ static const OldChunks main_chunk[] = {
bool LoadTTDMain(LoadgameState *ls)
{
DEBUG(oldloader, 3, "Reading main chunk...");
Debug(oldloader, 3, "Reading main chunk...");
_read_ttdpatch_flags = false;
@ -1752,7 +1752,7 @@ bool LoadTTDMain(LoadgameState *ls)
_old_vehicle_names = nullptr;
try {
if (!LoadChunk(ls, nullptr, main_chunk)) {
DEBUG(oldloader, 0, "Loading failed");
Debug(oldloader, 0, "Loading failed");
free(_old_vehicle_names);
return false;
}
@ -1761,7 +1761,7 @@ bool LoadTTDMain(LoadgameState *ls)
throw;
}
DEBUG(oldloader, 3, "Done, converting game data...");
Debug(oldloader, 3, "Done, converting game data...");
FixTTDMapArray();
FixTTDDepots();
@ -1776,8 +1776,8 @@ bool LoadTTDMain(LoadgameState *ls)
/* We have a new difficulty setting */
_settings_game.difficulty.town_council_tolerance = Clamp(_old_diff_level, 0, 2);
DEBUG(oldloader, 3, "Finished converting game data");
DEBUG(oldloader, 1, "TTD(Patch) savegame successfully converted");
Debug(oldloader, 3, "Finished converting game data");
Debug(oldloader, 1, "TTD(Patch) savegame successfully converted");
free(_old_vehicle_names);
@ -1786,7 +1786,7 @@ bool LoadTTDMain(LoadgameState *ls)
bool LoadTTOMain(LoadgameState *ls)
{
DEBUG(oldloader, 3, "Reading main chunk...");
Debug(oldloader, 3, "Reading main chunk...");
_read_ttdpatch_flags = false;
@ -1797,10 +1797,10 @@ bool LoadTTOMain(LoadgameState *ls)
/* Load the biggest chunk */
if (!LoadChunk(ls, nullptr, main_chunk)) {
DEBUG(oldloader, 0, "Loading failed");
Debug(oldloader, 0, "Loading failed");
return false;
}
DEBUG(oldloader, 3, "Done, converting game data...");
Debug(oldloader, 3, "Done, converting game data...");
if (_settings_game.game_creation.town_name != 0) _settings_game.game_creation.town_name++;
@ -1808,7 +1808,7 @@ bool LoadTTOMain(LoadgameState *ls)
_trees_tick_ctr = 0xFF;
if (!FixTTOMapArray() || !FixTTOEngines()) {
DEBUG(oldloader, 0, "Conversion failed");
Debug(oldloader, 0, "Conversion failed");
return false;
}
@ -1825,8 +1825,8 @@ bool LoadTTOMain(LoadgameState *ls)
* the vehicles stay the same" */
_economy.inflation_payment = std::min(_economy.inflation_payment * 124 / 74, MAX_INFLATION);
DEBUG(oldloader, 3, "Finished converting game data");
DEBUG(oldloader, 1, "TTO savegame successfully converted");
Debug(oldloader, 3, "Finished converting game data");
Debug(oldloader, 1, "TTO savegame successfully converted");
return true;
}

@ -313,7 +313,7 @@ static void SlNullPointers()
for (auto &ch : ChunkHandlers()) {
if (ch.ptrs_proc != nullptr) {
DEBUG(sl, 3, "Nulling pointers for %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
Debug(sl, 3, "Nulling pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
ch.ptrs_proc();
}
}
@ -656,7 +656,7 @@ int SlIterateArray()
case CH_SPARSE_ARRAY: index = (int)SlReadSparseIndex(); break;
case CH_ARRAY: index = _sl.array_index++; break;
default:
DEBUG(sl, 0, "SlIterateArray error");
Debug(sl, 0, "SlIterateArray error");
return -1; // error
}
@ -949,7 +949,7 @@ static void SlString(void *ptr, size_t length, VarType conv)
return;
case SLE_VAR_STRB:
if (len >= length) {
DEBUG(sl, 1, "String length in savegame is bigger than buffer, truncating");
Debug(sl, 1, "String length in savegame is bigger than buffer, truncating");
SlCopyBytes(ptr, length);
SlSkipBytes(len - length);
len = length - 1;
@ -1718,7 +1718,7 @@ static void SlSaveChunk(const ChunkHandler &ch)
if (proc == nullptr) return;
SlWriteUint32(ch.id);
DEBUG(sl, 2, "Saving chunk %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
Debug(sl, 2, "Saving chunk {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
_sl.block_mode = ch.type;
switch (ch.type) {
@ -1771,7 +1771,7 @@ static void SlLoadChunks()
const ChunkHandler *ch;
for (id = SlReadUint32(); id != 0; id = SlReadUint32()) {
DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id);
Debug(sl, 2, "Loading chunk {:c}{:c}{:c}{:c}", id >> 24, id >> 16, id >> 8, id);
ch = SlFindChunkHandler(id);
if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");
@ -1786,7 +1786,7 @@ static void SlLoadCheckChunks()
const ChunkHandler *ch;
for (id = SlReadUint32(); id != 0; id = SlReadUint32()) {
DEBUG(sl, 2, "Loading chunk %c%c%c%c", id >> 24, id >> 16, id >> 8, id);
Debug(sl, 2, "Loading chunk {:c}{:c}{:c}{:c}", id >> 24, id >> 16, id >> 8, id);
ch = SlFindChunkHandler(id);
if (ch == nullptr) SlErrorCorrupt("Unknown chunk type");
@ -1801,7 +1801,7 @@ static void SlFixPointers()
for (auto &ch : ChunkHandlers()) {
if (ch.ptrs_proc != nullptr) {
DEBUG(sl, 3, "Fixing pointers for %c%c%c%c", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
Debug(sl, 3, "Fixing pointers for {:c}{:c}{:c}{:c}", ch.id >> 24, ch.id >> 16, ch.id >> 8, ch.id);
ch.ptrs_proc();
}
}
@ -1845,7 +1845,7 @@ struct FileReader : LoadFilter {
{
clearerr(this->file);
if (fseek(this->file, this->begin, SEEK_SET)) {
DEBUG(sl, 1, "Could not reset the file reading");
Debug(sl, 1, "Could not reset the file reading");
}
}
};
@ -2470,7 +2470,7 @@ static SaveOrLoadResult SaveFileToDisk(bool threaded)
* cancelled due to a client disconnecting. */
if (_sl.error_str != STR_NETWORK_ERROR_LOSTCONNECTION) {
/* Skip the "colour" character */
DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3);
Debug(sl, 0, "{}", GetSaveLoadErrorString() + 3);
asfp = SaveFileError;
}
@ -2516,7 +2516,7 @@ static SaveOrLoadResult DoSave(SaveFilter *writer, bool threaded)
SaveFileStart();
if (!threaded || !StartNewThread(&_save_thread, "ottd:savegame", &SaveFileToDisk, true)) {
if (threaded) DEBUG(sl, 1, "Cannot create savegame thread, reverting to single-threaded mode...");
if (threaded) Debug(sl, 1, "Cannot create savegame thread, reverting to single-threaded mode...");
SaveOrLoadResult result = SaveFileToDisk(false);
SaveFileDone();
@ -2569,7 +2569,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
for (;;) {
/* No loader found, treat as version 0 and use LZO format */
if (fmt == endof(_saveload_formats)) {
DEBUG(sl, 0, "Unknown savegame type, trying to load it as the buggy format");
Debug(sl, 0, "Unknown savegame type, trying to load it as the buggy format");
_sl.lf->Reset();
_sl_version = SL_MIN_VERSION;
_sl_minor_version = 0;
@ -2595,7 +2595,7 @@ static SaveOrLoadResult DoLoad(LoadFilter *reader, bool load_check)
* Therefore it is loaded, but never saved (or, it saves a 0 in any scenario). */
_sl_minor_version = (TO_BE32(hdr[1]) >> 8) & 0xFF;
DEBUG(sl, 1, "Loading savegame version %d", _sl_version);
Debug(sl, 1, "Loading savegame version {}", _sl_version);
/* Is the version higher than the current? */
if (_sl_version > SAVEGAME_VERSION) SlError(STR_GAME_SAVELOAD_ERROR_TOO_NEW_SAVEGAME);
@ -2775,7 +2775,7 @@ SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop,
}
if (fop == SLO_SAVE) { // SAVE game
DEBUG(desync, 1, "save: %08x; %02x; %s", _date, _date_fract, filename.c_str());
Debug(desync, 1, "save: {:08x}; {:02x}; {}", _date, _date_fract, filename);
if (_network_server || !_settings_client.gui.threaded_saves) threaded = false;
return DoSave(new FileWriter(fh), threaded);
@ -2783,14 +2783,14 @@ SaveOrLoadResult SaveOrLoad(const std::string &filename, SaveLoadOperation fop,
/* LOAD game */
assert(fop == SLO_LOAD || fop == SLO_CHECK);
DEBUG(desync, 1, "load: %s", filename.c_str());
Debug(desync, 1, "load: {}", filename);
return DoLoad(new FileReader(fh), fop == SLO_CHECK);
} catch (...) {
/* This code may be executed both for old and new save games. */
ClearSaveLoadState();
/* Skip the "colour" character */
if (fop != SLO_CHECK) DEBUG(sl, 0, "%s", GetSaveLoadErrorString() + 3);
if (fop != SLO_CHECK) Debug(sl, 0, "{}", GetSaveLoadErrorString());
/* A saver/loader exception!! reinitialize all variables to prevent crash! */
return (fop == SLO_LOAD) ? SL_REINIT : SL_ERROR;

@ -103,10 +103,10 @@ void MoveWaypointsToBaseStations()
/* Sometimes waypoint (sign) locations became disconnected from their actual location in
* the map array. If this is the case, try to locate the actual location in the map array */
if (!IsTileType(t, MP_RAILWAY) || GetRailTileType(t) != 2 /* RAIL_TILE_WAYPOINT */ || _m[t].m2 != wp.index) {
DEBUG(sl, 0, "Found waypoint tile %u with invalid position", t);
Debug(sl, 0, "Found waypoint tile {} with invalid position", t);
for (t = 0; t < MapSize(); t++) {
if (IsTileType(t, MP_RAILWAY) && GetRailTileType(t) == 2 /* RAIL_TILE_WAYPOINT */ && _m[t].m2 == wp.index) {
DEBUG(sl, 0, "Found actual waypoint position at %u", t);
Debug(sl, 0, "Found actual waypoint position at {}", t);
break;
}
}

@ -237,13 +237,13 @@ static bool MakeBMPImage(const char *name, ScreenshotCallback *callb, void *user
static void PNGAPI png_my_error(png_structp png_ptr, png_const_charp message)
{
DEBUG(misc, 0, "[libpng] error: %s - %s", message, (const char *)png_get_error_ptr(png_ptr));
Debug(misc, 0, "[libpng] error: {} - {}", message, (const char *)png_get_error_ptr(png_ptr));
longjmp(png_jmpbuf(png_ptr), 1);
}
static void PNGAPI png_my_warning(png_structp png_ptr, png_const_charp message)
{
DEBUG(misc, 1, "[libpng] warning: %s - %s", message, (const char *)png_get_error_ptr(png_ptr));
Debug(misc, 1, "[libpng] warning: {} - {}", message, (const char *)png_get_error_ptr(png_ptr));
}
/**
@ -444,7 +444,7 @@ static bool MakePCXImage(const char *name, ScreenshotCallback *callb, void *user
bool success;
if (pixelformat == 32) {
DEBUG(misc, 0, "Can't convert a 32bpp screenshot to PCX format. Please pick another format.");
Debug(misc, 0, "Can't convert a 32bpp screenshot to PCX format. Please pick another format.");
return false;
}
if (pixelformat != 8 || w == 0) return false;

@ -469,7 +469,7 @@ int64 ScriptList::Begin()
int64 ScriptList::Next()
{
if (this->initialized == false) {
DEBUG(script, 0, "Next() is invalid as Begin() is never called");
Debug(script, 0, "Next() is invalid as Begin() is never called");
return 0;
}
return this->sorter->Next();
@ -483,7 +483,7 @@ bool ScriptList::IsEmpty()
bool ScriptList::IsEnd()
{
if (this->initialized == false) {
DEBUG(script, 0, "IsEnd() is invalid as Begin() is never called");
Debug(script, 0, "IsEnd() is invalid as Begin() is never called");
return true;
}
return this->sorter->IsEnd();

@ -74,7 +74,7 @@
}
/* Also still print to debug window */
DEBUG(script, level, "[%d] [%c] %s", (uint)ScriptObject::GetRootCompany(), logc, log->lines[log->pos]);
Debug(script, level, "[{}] [{}] {}", (uint)ScriptObject::GetRootCompany(), logc, log->lines[log->pos]);
InvalidateWindowData(WC_AI_DEBUG, 0, ScriptObject::GetRootCompany());
}

@ -23,7 +23,7 @@ class ScriptLog : public ScriptObject {
public:
/**
* Log levels; The value is also feed to DEBUG() lvl.
* Log levels; The value is also feed to Debug() lvl.
* This has no use for you, as script writer.
* @api -all
*/

@ -85,7 +85,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
/* static */ void ScriptObject::SetLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
ScriptStorage *s = GetStorage();
DEBUG(script, 6, "SetLastCommand company=%02d tile=%06x p1=%08x p2=%08x cmd=%d", s->root_company, tile, p1, p2, cmd);
Debug(script, 6, "SetLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
s->last_tile = tile;
s->last_p1 = p1;
s->last_p2 = p2;
@ -95,7 +95,7 @@ ScriptObject::ActiveInstance::~ActiveInstance()
/* static */ bool ScriptObject::CheckLastCommand(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd)
{
ScriptStorage *s = GetStorage();
DEBUG(script, 6, "CheckLastCommand company=%02d tile=%06x p1=%08x p2=%08x cmd=%d", s->root_company, tile, p1, p2, cmd);
Debug(script, 6, "CheckLastCommand company={:02d} tile={:06x} p1={:08x} p2={:08x} cmd={}", s->root_company, tile, p1, p2, cmd);
if (s->last_tile != tile) return false;
if (s->last_p1 != p1) return false;
if (s->last_p2 != p2) return false;

@ -564,7 +564,7 @@ static void _DoCommandReturnSetOrderFlags(class ScriptInstance *instance)
/* Make sure we don't go into an infinite loop */
int retry = ScriptObject::GetCallbackVariable(3) - 1;
if (retry < 0) {
DEBUG(script, 0, "Possible infinite loop in SetOrderFlags() detected");
Debug(script, 0, "Possible infinite loop in SetOrderFlags() detected");
return false;
}
ScriptObject::SetCallbackVariable(3, retry);

@ -195,7 +195,7 @@
int index = 0;
const StationSpec *spec = StationClass::GetByGrf(file->grfid, res, &index);
if (spec == nullptr) {
DEBUG(grf, 1, "%s returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
Debug(grf, 1, "{} returned an invalid station ID for 'AI construction/purchase selection (18)' callback", file->filename);
} else {
/* We might have gotten an usable station spec. Try to build it, but if it fails we'll fall back to the original station. */
if (ScriptObject::DoCommand(tile, p1, p2 | spec->cls_id | index << 8, CMD_BUILD_RAIL_STATION)) return true;

@ -124,7 +124,7 @@ bool ScriptInstance::LoadCompatibilityScripts(const char *api_version, Subdirect
if (this->engine->LoadScript(buf.c_str())) return true;
ScriptLog::Error("Failed to load API compatibility script");
DEBUG(script, 0, "Error compiling / running API compatibility script: %s", buf.c_str());
Debug(script, 0, "Error compiling / running API compatibility script: {}", buf);
return false;
}
@ -152,7 +152,7 @@ void ScriptInstance::Continue()
void ScriptInstance::Died()
{
DEBUG(script, 0, "The script died unexpectedly.");
Debug(script, 0, "The script died unexpectedly.");
this->is_dead = true;
this->in_shutdown = true;
@ -692,7 +692,7 @@ bool ScriptInstance::DoCommandCallback(const CommandCost &result, TileIndex tile
ScriptObject::ActiveInstance active(this);
if (!ScriptObject::CheckLastCommand(tile, p1, p2, cmd)) {
DEBUG(script, 1, "DoCommandCallback terminating a script, last command does not match expected command");
Debug(script, 1, "DoCommandCallback terminating a script, last command does not match expected command");
return false;
}

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save