47 static std::string mSettingsFile;
48 static std::set<std::string> mIncludedFiles;
50 static bool loadFile(
const std::string &filename);
68 if (!loadFile(
"settings.xml"))
71 loadFile(
"paths.xml");
72 loadFile(
"items.xml");
73 loadFile(
"monsters.xml");
75 loadFile(
"emotes.xml");
76 loadFile(
"status-effects.xml");
77 loadFile(
"itemcolors.xml");
78 loadFile(
"units.xml");
114 static bool loadFile(
const std::string &filename)
116 Log::info(
"Loading game settings from %s", filename.c_str());
122 mIncludedFiles.insert(filename);
127 Log::info(
"Settings Manager: %s is not a valid settings file!", filename.c_str());
131 if (node.
name() ==
"monsters")
140 for (
auto childNode : node.children())
142 if (childNode.name() ==
"include")
145 std::string includeFile = childNode.getProperty(
"file", std::string());
147 if (!includeFile.empty())
156 includeFile = childNode.getProperty(
"name", std::string());
160 if (!includeFile.empty())
163 if (mIncludedFiles.find(includeFile) != mIncludedFiles.end())
165 Log::warn(
"Circular include loop detecting while including %s from %s", includeFile.c_str(), filename.c_str());
169 loadFile(includeFile);
174 Log::warn(
"<include> element without 'file' or 'name' attribute in %s", filename.c_str());
177 else if (childNode.name() ==
"option")
180 std::string name = childNode.getProperty(
"name", std::string());
181 std::string value = childNode.getProperty(
"value", std::string());
186 Log::warn(
"option without a name found in %s", filename.c_str());
188 else if (childNode.name() ==
"attribute")
192 else if (childNode.name() ==
"points")
196 else if (childNode.name() ==
"color")
200 else if (childNode.name() ==
"list")
204 const std::string name = childNode.getProperty(
"name", std::string());
207 for (
auto hairColorNode : childNode.children())
209 if (hairColorNode.name() ==
"color")
214 else if (childNode.name() ==
"item")
218 else if (childNode.name() ==
"monster")
222 else if (childNode.name() ==
"ability")
226 else if (childNode.name() ==
"npc")
230 else if (childNode.name() ==
"var")
234 else if (childNode.name() ==
"emote")
238 else if (childNode.name() ==
"status-effect")
242 else if (childNode.name() ==
"unit")
248 mIncludedFiles.erase(filename);
void clear()
Re-sets all data in the configuration.
void setValue(const std::string &key, const std::string &value)
Sets an option using a string value.
void readHairColorNode(XML::Node node, const std::string &filename)
void unload()
Clear the color data.
virtual void checkStatus()=0
virtual void readItemNode(XML::Node node, const std::string &filename)=0
virtual void unload()
Frees item data.
static void checkStatus()
static void readStatusEffectNode(XML::Node node, const std::string &filename)
static void readUnitNode(XML::Node node, const std::string &filename)
static void checkStatus()
A helper class for parsing an XML document, which also cleans it up again (RAII).
std::string_view name() const
int getProperty(const char *name, int def) const
bool hasAttribute(const char *name) const
HairDB hairDB
Hair styles and colors info database.
Configuration paths
XML default paths information reader.
ItemDB * itemDb
Items info database.
void readAbilityNode(XML::Node node, const std::string &filename)
void readPointsNode(XML::Node node, const std::string &filename)
Read points node.
void checkStatus()
Check if all the data loaded by readPointsNode and readAttributeNode is ok.
void readAttributeNode(XML::Node node, const std::string &filename)
Read attribute node.
void readEmoteNode(XML::Node node, const std::string &filename)
void warn(const char *log_text,...) LOG_PRINTF_ATTR
void info(const char *log_text,...) LOG_PRINTF_ATTR
void init()
Initialize MonsterDB.
void setMonsterIdOffset(int offset)
void readMonsterNode(XML::Node node, const std::string &filename)
Read <monster> node from settings.
void checkStatus()
Check if everything was loaded correctly.
void readNPCNode(XML::Node node, const std::string &filename)
ServerType getNetworkType()
void readQuestVarNode(XML::Node node, const std::string &filename)
std::string cleanPath(const std::string &path)
Removes relative elements from the path.
std::string_view path(std::string_view fullFilePath)
Returns the path without the file name.
std::string joinPaths(std::string_view path1, std::string_view path2)
Join two path elements into one.