| 3740 | } |
| 3741 | |
| 3742 | int physfsLoadMapFile(int levelToLoad, Uint32 seed, bool useRandSeed, int* checkMapHash) |
| 3743 | { |
| 3744 | std::string mapsDirectory; // store the full file path here. |
| 3745 | std::string line = ""; |
| 3746 | if ( loadCustomNextMap.compare("") != 0 ) |
| 3747 | { |
| 3748 | line = "map: " + loadCustomNextMap; |
| 3749 | loadCustomNextMap = ""; |
| 3750 | } |
| 3751 | else |
| 3752 | { |
| 3753 | if ( !secretlevel ) |
| 3754 | { |
| 3755 | mapsDirectory = PHYSFS_getRealDir(LEVELSFILE); |
| 3756 | mapsDirectory.append(PHYSFS_getDirSeparator()).append(LEVELSFILE); |
| 3757 | } |
| 3758 | else |
| 3759 | { |
| 3760 | mapsDirectory = PHYSFS_getRealDir(SECRETLEVELSFILE); |
| 3761 | mapsDirectory.append(PHYSFS_getDirSeparator()).append(SECRETLEVELSFILE); |
| 3762 | } |
| 3763 | printlog("Maps directory: %s", mapsDirectory.c_str()); |
| 3764 | std::vector<std::string> levelsList = getLinesFromDataFile(mapsDirectory); |
| 3765 | line = levelsList.front(); |
| 3766 | int levelsCounted = 0; |
| 3767 | if ( levelToLoad > 0 ) // if level == 0, then load up the first map. |
| 3768 | { |
| 3769 | for ( std::vector<std::string>::const_iterator i = levelsList.begin(); i != levelsList.end() && levelsCounted <= levelToLoad; ++i ) |
| 3770 | { |
| 3771 | // process i, iterate through all the map levels until currentlevel. |
| 3772 | line = *i; |
| 3773 | if ( line[0] == '\n' ) |
| 3774 | { |
| 3775 | continue; |
| 3776 | } |
| 3777 | ++levelsCounted; |
| 3778 | } |
| 3779 | } |
| 3780 | } |
| 3781 | std::size_t found = line.find(' '); |
| 3782 | char tempstr[1024]; |
| 3783 | if ( found != std::string::npos ) |
| 3784 | { |
| 3785 | std::string mapType = line.substr(0, found); |
| 3786 | std::string mapName; |
| 3787 | mapName = line.substr(found + 1, line.find('\n')); |
| 3788 | std::size_t carriageReturn = mapName.find('\r'); |
| 3789 | if ( carriageReturn != std::string::npos ) |
| 3790 | { |
| 3791 | mapName.erase(carriageReturn); |
| 3792 | printlog("%s", mapName.c_str()); |
| 3793 | } |
| 3794 | if ( mapType.compare("map:") == 0 ) |
| 3795 | { |
| 3796 | strncpy(tempstr, mapName.c_str(), mapName.length()); |
| 3797 | tempstr[mapName.length()] = '\0'; |
| 3798 | mapName = physfsFormatMapName(tempstr); |
| 3799 | if ( useRandSeed ) |
no test coverage detected