From 75eb5c8ddf90d5c70acac26df6a8b5c5b5c6430e Mon Sep 17 00:00:00 2001 From: Mike Hoffert Date: Sat, 19 Jul 2014 16:52:53 -0600 Subject: [PATCH] Lootable resources now checks for dups --- source/glest_game/types/unit_type.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/source/glest_game/types/unit_type.cpp b/source/glest_game/types/unit_type.cpp index 75a31207..b8b07dff 100644 --- a/source/glest_game/types/unit_type.cpp +++ b/source/glest_game/types/unit_type.cpp @@ -591,8 +591,9 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, } } sortedItems.clear(); + hasDup = false; - // Lootable resources + // Lootable resources (resources given/lost on death) if(parametersNode->hasChild("resources-death")) { const XmlNode *deathResourcesNode= parametersNode->getChild("resources-death"); @@ -640,9 +641,13 @@ void UnitType::loaddd(int id,const string &dir, const TechTree *techTree, resource.setNegativeAllowed(false); } - lootableResources.push_back(resource); + // Figure out if there are duplicate resources. The value stored in the map is arbitrary, + // and exists solely because + if(std::find(lootableResources.begin(), lootableResources.end(), resource) != lootableResources.end()) { + printf("WARNING, unit type [%s] has one or more duplicate lootable resources\n", this->getName(false).c_str()); + } - // TODO: Add checks for duplicate resources + lootableResources.push_back(resource); } }