Changeset - r27170:15b64ff90913
[Not reviewed]
master
0 4 0
Rubidium - 17 months ago 2023-04-19 18:37:21
rubidium@openttd.org
Codechange: replace text-buf printf with fmt::format
4 files changed with 6 insertions and 20 deletions:
0 comments (0 inline, 0 general)
src/network/network_chat_gui.cpp
Show inline comments
 
@@ -28,7 +28,6 @@
 

	
 
#include "table/strings.h"
 

	
 
#include <stdarg.h> /* va_list */
 
#include <deque>
 

	
 
#include "../safeguards.h"
 
@@ -429,9 +428,9 @@ struct NetworkChatWindow : public Window
 

	
 
				/* Change to the found name. Add ': ' if we are at the start of the line (pretty) */
 
				if (pre_buf == tb_buf) {
 
					this->message_editbox.text.Print("%s: ", cur_name);
 
					this->message_editbox.text.Assign(fmt::format("{}: ", cur_name));
 
				} else {
 
					this->message_editbox.text.Print("%s %s", pre_buf, cur_name);
 
					this->message_editbox.text.Assign(fmt::format("{} {}", pre_buf, cur_name));
 
				}
 

	
 
				this->SetDirty();
src/newgrf_debug_gui.cpp
Show inline comments
 
@@ -403,7 +403,7 @@ struct NewGRFInspectWindow : Window {
 
		offset -= this->vscroll->GetPosition();
 
		if (offset < 0 || offset >= this->vscroll->GetCapacity()) return;
 

	
 
		::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), buf, TC_BLACK);
 
		::DrawString(r.Shrink(WidgetDimensions::scaled.frametext).Shrink(0, offset * this->resize.step_height, 0, 0), string, TC_BLACK);
 
	}
 

	
 
	/**
src/textbuf.cpp
Show inline comments
 
@@ -400,21 +400,9 @@ void Textbuf::Assign(StringID string)
 
 * Copy a string into the textbuffer.
 
 * @param text Source.
 
 */
 
void Textbuf::Assign(const char *text)
 
void Textbuf::Assign(const std::string_view text)
 
{
 
	strecpy(this->buf, text, &this->buf[this->max_bytes - 1]);
 
	this->UpdateSize();
 
}
 

	
 
/**
 
 * Print a formatted string into the textbuffer.
 
 */
 
void Textbuf::Print(const char *format, ...)
 
{
 
	va_list va;
 
	va_start(va, format);
 
	vseprintf(this->buf, &this->buf[this->max_bytes - 1], format, va);
 
	va_end(va);
 
	strecpy(this->buf, text.data(), &this->buf[this->max_bytes - 1]);
 
	this->UpdateSize();
 
}
 

	
src/textbuf_type.h
Show inline comments
 
@@ -47,8 +47,7 @@ struct Textbuf {
 
	~Textbuf();
 

	
 
	void Assign(StringID string);
 
	void Assign(const char *text);
 
	void CDECL Print(const char *format, ...) WARN_FORMAT(2, 3);
 
	void Assign(const std::string_view text);
 

	
 
	void DeleteAll();
 
	bool InsertClipboard();
0 comments (0 inline, 0 general)