Changeset - r28014:ef700ef0b0eb
[Not reviewed]
master
0 2 0
Peter Nelson - 14 months ago 2023-10-10 18:26:00
peter1138@openttd.org
Codechange: Move initialization of group-type to CreateGroup function.
2 files changed with 7 insertions and 6 deletions:
0 comments (0 inline, 0 general)
src/ini_load.cpp
Show inline comments
 
@@ -48,16 +48,13 @@ void IniItem::SetValue(const std::string
 
 * @param parent the file we belong to
 
 * @param name   the name of the group
 
 */
 
IniGroup::IniGroup(IniLoadFile *parent, const std::string &name) : next(nullptr), type(IGT_VARIABLES), item(nullptr)
 
IniGroup::IniGroup(IniLoadFile *parent, const std::string &name, IniGroupType type) : next(nullptr), type(type), item(nullptr)
 
{
 
	this->name = StrMakeValid(name);
 

	
 
	this->last_item = &this->item;
 
	*parent->last_group = this;
 
	parent->last_group = &this->next;
 

	
 
	if (std::find(parent->list_group_names.begin(), parent->list_group_names.end(), name) != parent->list_group_names.end()) this->type = IGT_LIST;
 
	if (std::find(parent->seq_group_names.begin(), parent->seq_group_names.end(), name) != parent->seq_group_names.end()) this->type = IGT_SEQUENCE;
 
}
 

	
 
/** Free everything we loaded. */
 
@@ -195,7 +192,11 @@ IniGroup &IniLoadFile::GetOrCreateGroup(
 
 */
 
IniGroup &IniLoadFile::CreateGroup(const std::string &name)
 
{
 
	IniGroup *group = new IniGroup(this, name);
 
	IniGroupType type = IGT_VARIABLES;
 
	if (std::find(this->list_group_names.begin(), this->list_group_names.end(), name) != this->list_group_names.end()) type = IGT_LIST;
 
	if (std::find(this->seq_group_names.begin(), this->seq_group_names.end(), name) != this->seq_group_names.end()) type = IGT_SEQUENCE;
 

	
 
	IniGroup *group = new IniGroup(this, name, type);
 
	group->comment = "\n";
 
	return *group;
 
}
src/ini_type.h
Show inline comments
 
@@ -41,7 +41,7 @@ struct IniGroup {
 
	std::string name;    ///< name of group
 
	std::string comment; ///< comment for group
 

	
 
	IniGroup(struct IniLoadFile *parent, const std::string &name);
 
	IniGroup(struct IniLoadFile *parent, const std::string &name, IniGroupType type);
 
	~IniGroup();
 

	
 
	IniItem *GetItem(const std::string &name) const;
0 comments (0 inline, 0 general)