clang warnings fix + minor refactor

This commit is contained in:
MihailRis
2024-04-15 12:16:04 +03:00
parent 3ebd8f3062
commit adf54b8a38
8 changed files with 53 additions and 49 deletions
-22
View File
@@ -29,8 +29,6 @@
#define WORLD_FORMAT_MAGIC ".VOXWLD"
const size_t BUFFER_SIZE_UNKNOWN = -1;
WorldFiles::WorldFiles(fs::path directory) : directory(directory), regions(directory) {
}
@@ -51,26 +49,6 @@ void WorldFiles::createDirectories() {
fs::create_directories(directory / fs::path("content"));
}
/// @brief Extract X and Z from 'X_Z.bin' region file name.
/// @param name source region file name
/// @param x parsed X destination
/// @param z parsed Z destination
/// @return false if std::invalid_argument or std::out_of_range occurred
bool WorldFiles::parseRegionFilename(const std::string& name, int& x, int& z) {
size_t sep = name.find('_');
if (sep == std::string::npos || sep == 0 || sep == name.length()-1)
return false;
try {
x = std::stoi(name.substr(0, sep));
z = std::stoi(name.substr(sep+1));
} catch (std::invalid_argument& err) {
return false;
} catch (std::out_of_range& err) {
return false;
}
return true;
}
fs::path WorldFiles::getPlayerFile() const {
return directory/fs::path("player.json");
}