| 789 | } |
| 790 | |
| 791 | bool getMapInfo(const std::string& fileName, LevelInfo& levelInfo) |
| 792 | { |
| 793 | // Prepare an invalid level reference |
| 794 | std::stringstream levelFile; |
| 795 | if(!Helper::readFileWithoutComments(fileName, levelFile)) |
| 796 | return false; |
| 797 | |
| 798 | std::string nextParam; |
| 799 | // Read in the version number from the level file |
| 800 | levelFile >> nextParam; |
| 801 | if (nextParam.compare(ODApplication::VERSIONSTRING) != 0) |
| 802 | return false; |
| 803 | |
| 804 | levelFile >> nextParam; |
| 805 | if (nextParam != "[Info]") |
| 806 | return false; |
| 807 | |
| 808 | std::stringstream mapInfo; |
| 809 | |
| 810 | // Read in the seats from the level file |
| 811 | while (true) |
| 812 | { |
| 813 | if(!levelFile.good()) |
| 814 | return false; |
| 815 | // Information can contain spaces. We need to use std::getline to get content |
| 816 | std::getline(levelFile, nextParam); |
| 817 | std::string param; |
| 818 | if (nextParam == "[/Info]") |
| 819 | { |
| 820 | break; |
| 821 | } |
| 822 | |
| 823 | param = "Name\t"; |
| 824 | if (nextParam.compare(0, param.size(), param) == 0) |
| 825 | { |
| 826 | levelInfo.mLevelName = nextParam.substr(param.size()); |
| 827 | mapInfo << levelInfo.mLevelName << std::endl << std::endl; |
| 828 | continue; |
| 829 | } |
| 830 | |
| 831 | param = "Description\t"; |
| 832 | if (nextParam.compare(0, param.size(), param) == 0) |
| 833 | { |
| 834 | mapInfo << nextParam.substr(param.size()) << std::endl << std::endl; |
| 835 | continue; |
| 836 | } |
| 837 | |
| 838 | } |
| 839 | |
| 840 | levelFile >> nextParam; |
| 841 | if (nextParam != "[Seats]") |
| 842 | { |
| 843 | levelInfo.mLevelDescription = mapInfo.str(); |
| 844 | return true; |
| 845 | } |
| 846 | |
| 847 | // Read in the seats from the level file |
| 848 | int playerSeatNumber = 0; |
no test coverage detected