Skip to content

Commit

Permalink
Path fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
devw4r committed Jul 27, 2024
1 parent abc092d commit d50bbf2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
11 changes: 5 additions & 6 deletions MapBuilder/FileExist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ bool map_files_exist(const std::string& outputPath, const std::string& mapName)
return fs::exists(outputPath + "/" + mapName + ".map");
}

bool wow_exist_at_root(const std::string& rootPath)
{
bool wow_exist_at_root(const std::string& rootPath) {
return fs::exists(rootPath + "/" + "WoW.exe");
}

} // namespace file_exist

namespace dir_exist {

bool output_dir_exist() {
return fs::exists("./Output");
bool output_dir_exist(const std::string& outputPath) {
return fs::exists(outputPath);
}

} // namespace dir_exist

namespace files {

void create_output_directory() {
fs::create_directory("./Output");
void create_output_directory(const std::string& outputPath) {
fs::create_directory(outputPath);
}

void create_bvh_output_directory(const std::filesystem::path& outputPath) {
Expand Down
4 changes: 2 additions & 2 deletions MapBuilder/FileExist.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ bool wow_exist_at_root(const std::string& rootPath);

namespace dir_exist {

bool output_dir_exist();
bool output_dir_exist(const std::string& rootPath);

} // namespace dir_exist

namespace files {

void create_output_directory();
void create_output_directory(const std::string& rootPath);

void create_bvh_output_directory(const std::filesystem::path& outputPath);

Expand Down
11 changes: 7 additions & 4 deletions MapBuilder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ int ExtractMap(const std::string& map, const std::string& dataPath,
int main(int argc, char* argv[])
{
std::string dataPath, map, outputPath, goCSVPath;
int adtX = -1, adtY = -1, threads = 1, logLevel;
int adtX = -1, adtY = -1, threads = 1, logLevel = 1;
bool bvh = false;
bool alpha = true;

Expand Down Expand Up @@ -282,14 +282,17 @@ int main(int argc, char* argv[])
outputPath = "./Output";

const std::filesystem::path root(dataPath);
if (!file_exist::wow_exist_at_root(root.parent_path().string()))
const std::string rootStr = root.parent_path().string();
if (!file_exist::wow_exist_at_root(rootStr))
{
std::cerr << "ERROR: MapBuilder must be placed inside the game root folder" << std::endl;
return EXIT_FAILURE;
}

if (!dir_exist::output_dir_exist())
files::create_output_directory();
const std::filesystem::path rootOutputPath(outputPath);
const std::string rootOutputPathStr = rootOutputPath.string();
if (!dir_exist::output_dir_exist(rootOutputPathStr))
files::create_output_directory(rootOutputPathStr);

if (ExtractBVH(goCSVPath, dataPath, outputPath, threads) == EXIT_FAILURE)
return EXIT_FAILURE;
Expand Down

0 comments on commit d50bbf2

Please sign in to comment.