summaryrefslogtreecommitdiff
path: root/src/ini_load.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2011-03-03 20:55:06 +0000
committeralberth <alberth@openttd.org>2011-03-03 20:55:06 +0000
commit6a88af662bdca19e1a9cc90f0a00c80496d79b98 (patch)
tree55e357be64c4829e4c5a03f350c21d45ebee2801 /src/ini_load.cpp
parent722296e79747610b7822c07f2edd908563456d92 (diff)
downloadopenttd-6a88af662bdca19e1a9cc90f0a00c80496d79b98.tar.xz
(svn r22169) -Add: Add parameter to disable automatic group creation in IniLoadFile::GetGroup().
Diffstat (limited to 'src/ini_load.cpp')
-rw-r--r--src/ini_load.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/ini_load.cpp b/src/ini_load.cpp
index 62bec51d5..4ce33405b 100644
--- a/src/ini_load.cpp
+++ b/src/ini_load.cpp
@@ -132,13 +132,14 @@ IniLoadFile::~IniLoadFile()
}
/**
- * Get the group with the given name, and if it doesn't exist
- * create a new group.
+ * Get the group with the given name. If it doesn't exist
+ * and \a create_new is \c true create a new group.
* @param name name of the group to find.
- * @param len the maximum length of said name.
- * @return the requested group.
+ * @param len the maximum length of said name (\c 0 means length of the string).
+ * @param create_new Allow creation of group if it does not exist.
+ * @return The requested group if it exists or was created, else \c NULL.
*/
-IniGroup *IniLoadFile::GetGroup(const char *name, size_t len)
+IniGroup *IniLoadFile::GetGroup(const char *name, size_t len, bool create_new)
{
if (len == 0) len = strlen(name);
@@ -149,6 +150,8 @@ IniGroup *IniLoadFile::GetGroup(const char *name, size_t len)
}
}
+ if (!create_new) return NULL;
+
/* otherwise make a new one */
IniGroup *group = new IniGroup(this, name, len);
group->comment = strdup("\n");