MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / loadCreatureDefinitions

Method loadCreatureDefinitions

source/utils/ConfigManager.cpp:624–672  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

622}
623
624bool ConfigManager::loadCreatureDefinitions(const std::string& fileName)
625{
626 OD_LOG_INF("Load creature definition file: " + fileName);
627 std::stringstream defFile;
628 if(!Helper::readFileWithoutComments(fileName, defFile))
629 {
630 OD_LOG_ERR("Couldn't read " + fileName);
631 return false;
632 }
633
634 std::string nextParam;
635 // Read in the creature class descriptions
636 defFile >> nextParam;
637 if (nextParam != "[CreatureDefinitions]")
638 {
639 OD_LOG_ERR("Invalid Creature classes start format. Line was " + nextParam);
640 return false;
641 }
642
643 while(defFile.good())
644 {
645 if(!(defFile >> nextParam))
646 break;
647
648 if (nextParam == "[/CreatureDefinitions]")
649 break;
650
651 if (nextParam == "[/Creature]")
652 continue;
653
654 // Seek the [Creature] tag
655 if (nextParam != "[Creature]")
656 {
657 OD_LOG_ERR("Invalid Creature classes start format. Line was " + nextParam);
658 return false;
659 }
660
661 // Load the creature definition until a [/Creature] tag is found
662 CreatureDefinition* creatureDef = CreatureDefinition::load(defFile, mCreatureDefs);
663 if (creatureDef == nullptr)
664 {
665 OD_LOG_ERR("Invalid Creature classes start format");
666 return false;
667 }
668 mCreatureDefs.emplace(creatureDef->getClassName(), creatureDef);
669 }
670
671 return true;
672}
673
674bool ConfigManager::loadEquipements(const std::string& fileName)
675{

Callers

nothing calls this directly

Calls 1

readFileWithoutCommentsFunction · 0.85

Tested by

no test coverage detected