From 0f9ec2061c4ad6157c3186f1cab9c4d8558980b5 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Fri, 29 May 2015 14:30:20 +0300 Subject: Add strong typed int type BeingId. --- src/resources/db/monsterdb.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/resources/db/monsterdb.cpp') diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp index cfb7f4e92..de72f487f 100644 --- a/src/resources/db/monsterdb.cpp +++ b/src/resources/db/monsterdb.cpp @@ -88,10 +88,11 @@ void MonsterDB::loadXmlFile(const std::string &fileName) const int id = XML::getProperty(monsterNode, "id", 0); BeingInfo *currentInfo = nullptr; - if (mMonsterInfos.find(id + offset) != mMonsterInfos.end()) + if (mMonsterInfos.find(fromInt(id + offset, BeingId)) + != mMonsterInfos.end()) { logger->log("MonsterDB: Redefinition of monster ID %d", id); - currentInfo = mMonsterInfos[id + offset]; + currentInfo = mMonsterInfos[fromInt(id + offset, BeingId)]; } if (!currentInfo) currentInfo = new BeingInfo; @@ -139,7 +140,7 @@ void MonsterDB::loadXmlFile(const std::string &fileName) } currentInfo->setDisplay(display); - mMonsterInfos[id + offset] = currentInfo; + mMonsterInfos[fromInt(id + offset, BeingId)] = currentInfo; } } @@ -152,17 +153,18 @@ void MonsterDB::unload() } -BeingInfo *MonsterDB::get(const int id) +BeingInfo *MonsterDB::get(const BeingId id) { BeingInfoIterator i = mMonsterInfos.find(id); if (i == mMonsterInfos.end()) { - i = mMonsterInfos.find(id + OLD_TMWATHENA_OFFSET); + i = mMonsterInfos.find(fromInt(toInt( + id, int) + OLD_TMWATHENA_OFFSET, BeingId)); if (i == mMonsterInfos.end()) { logger->log("MonsterDB: Warning, unknown monster ID %d requested", - id); + toInt(id, int)); return BeingInfo::unknown; } else -- cgit v1.2.3-70-g09d2