diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-01-06 12:26:11 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-01-06 12:26:11 +0300 |
commit | 2e5ea73d5f0792863a1093de7daf21092b233d98 (patch) | |
tree | 20b3a541716285e5151670c1a2c906efda8a40b7 /src/resources | |
parent | 408da061e6098c6562f69b50d16353c7efc5cdf2 (diff) | |
download | plus-2e5ea73d5f0792863a1093de7daf21092b233d98.tar.gz plus-2e5ea73d5f0792863a1093de7daf21092b233d98.tar.bz2 plus-2e5ea73d5f0792863a1093de7daf21092b233d98.tar.xz plus-2e5ea73d5f0792863a1093de7daf21092b233d98.zip |
dont leak memory if exists npc duplicate with same id.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/db/npcdb.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp index 486f63952..7c983160c 100644 --- a/src/resources/db/npcdb.cpp +++ b/src/resources/db/npcdb.cpp @@ -80,14 +80,20 @@ void NPCDB::loadXmlFile(const std::string &fileName) continue; const int id = XML::getProperty(npcNode, "id", 0); + BeingInfo *currentInfo = nullptr; if (id == 0) { logger->log("NPC Database: NPC with missing ID in %s!", paths.getStringValue("npcsFile").c_str()); continue; } - - BeingInfo *const currentInfo = new BeingInfo; + else if (mNPCInfos.find(id) != mNPCInfos.end()) + { + logger->log("NpcDB: Redefinition of npc ID %d", id); + currentInfo = mNPCInfos[id]; + } + if (!currentInfo) + currentInfo = new BeingInfo; currentInfo->setTargetSelection(XML::getBoolProperty(npcNode, "targetSelection", true)); |