Skip to content

Commit

Permalink
Update main.cpp
Browse files Browse the repository at this point in the history
- Wrap some directory create calls on TryCatch clause. This is mostly to give feedback about not having access rights to the selected output path but it could also throw on invalid path.
  • Loading branch information
devw4r committed Jul 27, 2024
1 parent 65d87ca commit 5310328
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions MapBuilder/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ void DisplayUsage(std::ostream& o)
o << " -t/--threads <thread count> -- How many worker threads to use\n";
o << " -l/--logLevel <log level> -- Log level (0 = none, 1 = "
"progress, 2 = warning, 3 = error)\n";
o << " -alpha/--alpha -- Automatically extract everything available for alpha client.\n";
o << " -a/--alpha -- Automatically extract everything available for alpha client.\n";
#ifdef _DEBUG
o << " -x/--adtX <x> -- X coordinate of individual ADT "
"to process\n";
Expand All @@ -50,8 +50,17 @@ void DisplayUsage(std::ostream& o)
int ExtractBVH(const std::string& goCSVPath, const std::string& dataPath,
const std::string& outputPath, int threads)
{
try
{
files::create_bvh_output_directory(outputPath);
}
catch (std::exception const& e) // Access denied.
{
std::cerr << "ERROR:" << e.what() << std::endl;
return EXIT_FAILURE;
}

auto lastStatus = static_cast<time_t>(0);
files::create_bvh_output_directory(outputPath);

if (!goCSVPath.empty())
{
Expand Down Expand Up @@ -226,8 +235,16 @@ int ExtractAlphaData(std::string& dataPath, std::string& outputPath,

const std::filesystem::path rootOutputPath(outputPath);
const std::string rootOutputPathStr = rootOutputPath.string();
if (!dir_exist::output_dir_exist(rootOutputPathStr))
files::create_output_directory(rootOutputPathStr);
try
{
if (!dir_exist::output_dir_exist(rootOutputPathStr))
files::create_output_directory(rootOutputPathStr);
}
catch (std::exception const& e) // Access denied.
{
std::cerr << "ERROR:" << e.what() << std::endl;
return EXIT_FAILURE;
}

if (ExtractBVH(goCSVPath, dataPath, outputPath, threads) == EXIT_FAILURE)
return EXIT_FAILURE;
Expand Down Expand Up @@ -283,7 +300,7 @@ int main(int argc, char* argv[])
DisplayUsage(std::cout);
return EXIT_SUCCESS;
}
else if (arg == "-alpha" || arg == "--alpha")
else if (arg == "-a" || arg == "--alpha")
{
alpha = true;
continue;
Expand Down Expand Up @@ -361,7 +378,16 @@ int main(int argc, char* argv[])
if (bvh)
return ExtractBVH(goCSVPath, dataPath, outputPath, threads);

files::create_nav_output_directory(outputPath);
try
{
files::create_nav_output_directory(outputPath);
}
catch (std::exception const& e) // Access denied.
{
std::cerr << "ERROR:" << e.what() << std::endl;
return EXIT_FAILURE;
}

// nav mesh generation requires that the MPQ manager be initialized for
// the main thread, whereas BVH generation does not.
parser::sMpqManager.Initialize(dataPath);
Expand Down

0 comments on commit 5310328

Please sign in to comment.