Changeset - r27529:197f49219ae3
[Not reviewed]
master
0 6 0
Rubidium - 15 months ago 2023-05-30 17:35:27
rubidium@openttd.org
Codechange: replace seprintf with C++ style formatting
6 files changed with 12 insertions and 17 deletions:
0 comments (0 inline, 0 general)
src/console_cmds.cpp
Show inline comments
 
@@ -2269,9 +2269,7 @@ DEF_CONSOLE_CMD(ConNewGRFProfile)
 
				started++;
 

	
 
				if (!grfids.empty()) grfids += ", ";
 
				char grfidstr[12]{ 0 };
 
				seprintf(grfidstr, lastof(grfidstr), "[%08X]", BSWAP32(pr.grffile->grfid));
 
				grfids += grfidstr;
 
				fmt::format_to(std::back_inserter(grfids), "[{%:08X}]", BSWAP32(pr.grffile->grfid));
 
			}
 
		}
 
		if (started > 0) {
src/framerate_gui.cpp
Show inline comments
 
@@ -1058,7 +1058,7 @@ void ConPrintFramerate()
 
		"AI/GS scripts total",
 
		"Game script",
 
	};
 
	char ai_name_buf[128];
 
	std::string ai_name_buf;
 

	
 
	static const PerformanceElement rate_elements[] = { PFE_GAMELOOP, PFE_DRAWING, PFE_VIDEO };
 

	
 
@@ -1077,11 +1077,11 @@ void ConPrintFramerate()
 
	for (PerformanceElement e = PFE_FIRST; e < PFE_MAX; e++) {
 
		auto &pf = _pf_data[e];
 
		if (pf.num_valid == 0) continue;
 
		const char *name;
 
		std::string_view name;
 
		if (e < PFE_AI0) {
 
			name = MEASUREMENT_NAMES[e];
 
		} else {
 
			seprintf(ai_name_buf, lastof(ai_name_buf), "AI %d %s", e - PFE_AI0 + 1, GetAIName(e - PFE_AI0)),
 
			ai_name_buf = fmt::format("AI {} {}", e - PFE_AI0 + 1, GetAIName(e - PFE_AI0));
 
			name = ai_name_buf;
 
		}
 
		IConsolePrint(TC_LIGHT_BLUE, "{} times: {:.2f}ms  {:.2f}ms  {:.2f}ms",
src/network/core/address.cpp
Show inline comments
 
@@ -215,8 +215,7 @@ SOCKET NetworkAddress::Resolve(int famil
 
	hints.ai_socktype = socktype;
 

	
 
	/* The port needs to be a string. Six is enough to contain all characters + '\0'. */
 
	char port_name[6];
 
	seprintf(port_name, lastof(port_name), "%u", this->GetPort());
 
	std::string port_name = std::to_string(this->GetPort());
 

	
 
	bool reset_hostname = false;
 
	/* Setting both hostname to nullptr and port to 0 is not allowed.
 
@@ -231,7 +230,7 @@ SOCKET NetworkAddress::Resolve(int famil
 

	
 
	static bool _resolve_timeout_error_message_shown = false;
 
	auto start = std::chrono::steady_clock::now();
 
	int e = getaddrinfo(this->hostname.empty() ? nullptr : this->hostname.c_str(), port_name, &hints, &ai);
 
	int e = getaddrinfo(this->hostname.empty() ? nullptr : this->hostname.c_str(), port_name.c_str(), &hints, &ai);
 
	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)) {
src/network/core/os_abstraction.cpp
Show inline comments
 
@@ -83,9 +83,10 @@ const std::string &NetworkError::AsStrin
 
		char buffer[512];
 
		if (FormatMessageA(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, this->error,
 
			MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer), NULL) == 0) {
 
			seprintf(buffer, lastof(buffer), "Unknown error %d", this->error);
 
			this->message.assign(fmt::format("Unknown error {}", this->error));
 
		} else {
 
			this->message.assign(buffer);
 
		}
 
		this->message.assign(buffer);
 
#else
 
		/* Make strerror thread safe by locking access to it. There is a thread safe strerror_r, however
 
		 * the non-POSIX variant is available due to defining _GNU_SOURCE meaning it is not portable.
src/network/core/tcp_connect.cpp
Show inline comments
 
@@ -233,14 +233,13 @@ void TCPConnecter::Resolve()
 
	hints.ai_flags = AI_ADDRCONFIG;
 
	hints.ai_socktype = SOCK_STREAM;
 

	
 
	char port_name[6];
 
	seprintf(port_name, lastof(port_name), "%u", address.GetPort());
 
	std::string port_name = std::to_string(address.GetPort());
 

	
 
	static bool getaddrinfo_timeout_error_shown = false;
 
	auto start = std::chrono::steady_clock::now();
 

	
 
	addrinfo *ai;
 
	int error = getaddrinfo(address.GetHostname().c_str(), port_name, &hints, &ai);
 
	int error = getaddrinfo(address.GetHostname().c_str(), port_name.c_str(), &hints, &ai);
 

	
 
	auto end = std::chrono::steady_clock::now();
 
	auto duration = std::chrono::duration_cast<std::chrono::seconds>(end - start);
src/saveload/saveload.cpp
Show inline comments
 
@@ -2974,9 +2974,7 @@ static SaveOrLoadResult DoLoad(LoadFilte
 

	
 
	/* loader for this savegame type is not implemented? */
 
	if (fmt->init_load == nullptr) {
 
		char err_str[64];
 
		seprintf(err_str, lastof(err_str), "Loader for '%s' is not available.", fmt->name);
 
		SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, err_str);
 
		SlError(STR_GAME_SAVELOAD_ERROR_BROKEN_INTERNAL_ERROR, fmt::format("Loader for '{}' is not available.", fmt->name));
 
	}
 

	
 
	_sl.lf = fmt->init_load(_sl.lf);
0 comments (0 inline, 0 general)