| 807 | } |
| 808 | |
| 809 | bool ConfigManager::loadFactions(const std::string& fileName) |
| 810 | { |
| 811 | OD_LOG_INF("Load factions file: " + fileName); |
| 812 | std::stringstream defFile; |
| 813 | if(!Helper::readFileWithoutComments(fileName, defFile)) |
| 814 | { |
| 815 | OD_LOG_ERR("Couldn't read " + fileName); |
| 816 | return false; |
| 817 | } |
| 818 | |
| 819 | std::string nextParam; |
| 820 | // Read in the creature class descriptions |
| 821 | defFile >> nextParam; |
| 822 | if (nextParam != "[Factions]") |
| 823 | { |
| 824 | OD_LOG_ERR("Invalid factions start format. Line was " + nextParam); |
| 825 | return false; |
| 826 | } |
| 827 | |
| 828 | while(defFile.good()) |
| 829 | { |
| 830 | if(!(defFile >> nextParam)) |
| 831 | break; |
| 832 | |
| 833 | if (nextParam == "[/Factions]") |
| 834 | break; |
| 835 | |
| 836 | if (nextParam != "[Faction]") |
| 837 | { |
| 838 | OD_LOG_ERR("Invalid faction. Line was " + nextParam); |
| 839 | return false; |
| 840 | } |
| 841 | |
| 842 | std::string factionName; |
| 843 | std::string workerClass; |
| 844 | while(defFile.good()) |
| 845 | { |
| 846 | if(!(defFile >> nextParam)) |
| 847 | break; |
| 848 | |
| 849 | if (nextParam == "[/Faction]") |
| 850 | break; |
| 851 | |
| 852 | if (nextParam == "[/Factions]") |
| 853 | break; |
| 854 | |
| 855 | if (nextParam == "Name") |
| 856 | { |
| 857 | defFile >> factionName; |
| 858 | continue; |
| 859 | } |
| 860 | if(factionName.empty()) |
| 861 | { |
| 862 | OD_LOG_ERR("Empty or missing faction name is not allowed"); |
| 863 | return false; |
| 864 | } |
| 865 | |
| 866 | if (nextParam == "WorkerClass") |
nothing calls this directly
no test coverage detected