Changeset - r27617:d4fc0012887c
[Not reviewed]
master
0 2 0
Rubidium - 12 months ago 2023-06-18 08:53:08
rubidium@openttd.org
Codechange: rename ClearTypeInformation so it can be used for preparing for the next run
2 files changed with 9 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/strings.cpp
Show inline comments
 
@@ -62,11 +62,15 @@ static uint64 _global_string_params_data
 
static WChar _global_string_params_type[20];      ///< Type of parameters stored in #_global_string_params
 
StringParameters _global_string_params(_global_string_params_data, 20, _global_string_params_type);
 

	
 
/** Reset the type array. */
 
void StringParameters::ClearTypeInformation()
 
/**
 
 * Prepare the string parameters for the next formatting run. This means
 
 * resetting the type information and resetting the offset to the begin.
 
 */
 
void StringParameters::PrepareForNextRun()
 
{
 
	assert(this->type != nullptr);
 
	MemSetT(this->type, 0, this->num_param);
 
	this->offset = 0;
 
}
 

	
 

	
 
@@ -313,8 +317,7 @@ void GetStringWithArgs(StringBuilder &bu
 
 */
 
std::string GetString(StringID string)
 
{
 
	_global_string_params.ClearTypeInformation();
 
	_global_string_params.offset = 0;
 
	_global_string_params.PrepareForNextRun();
 
	return GetStringWithArgs(string, _global_string_params);
 
}
 

	
 
@@ -907,7 +910,7 @@ static void FormatString(StringBuilder &
 
				bool sub_args_need_free[20];
 
				StringParameters sub_args(sub_args_data, 20, sub_args_type);
 

	
 
				sub_args.ClearTypeInformation();
 
				sub_args.PrepareForNextRun(); // Needed to reset the currently undefined types
 
				memset(sub_args_need_free, 0, sizeof(sub_args_need_free));
 

	
 
				char *p;
src/strings_internal.h
Show inline comments
 
@@ -57,7 +57,7 @@ public:
 
		}
 
	}
 

	
 
	void ClearTypeInformation();
 
	void PrepareForNextRun();
 
	void SetTypeOfNextParameter(WChar type) { this->next_type = type; }
 

	
 
	int64 GetInt64();
0 comments (0 inline, 0 general)