Added error helper file.

This commit is contained in:
David Benepe
2022-03-25 18:23:17 -04:00
parent b601228245
commit 0268767da1
58 changed files with 272 additions and 160 deletions
+4 -1
View File
@@ -16,7 +16,10 @@ COMPILE_ASSETS ?= 0
$(eval $(call validate-option,COMPILE_ASSETS,0 1))
ifeq ($(COMPILE_ASSETS),1)
DUMMY != ./tools/dkr_assets_tool -c ./assets $(VERSION)
DUMMY != ./tools/dkr_assets_tool -c $(VERSION) ./assets >&2 || echo FAIL
ifeq ($(DUMMY),FAIL)
$(error Failed to compile assets)
endif
endif
ifeq ($(VERSION),us_1.0)
+7 -6
View File
@@ -1,26 +1,27 @@
#!/bin/bash
if [[ $# == 0 || (($1 != "us_1.0") && ($1 != "us_1.1") && ($1 != "eu_1.0") && ($1 != "eu_1.1") && ($1 != "jp"))]]; then
echo 'Usage: ./extract.sh <version>'
echo 'Acceptable versions: us_1.0, us_1.1, eu_1.0, eu_1.1, jp'
exit 1
echo 'No valid version specified, defaulting to us_1.0...'
VER="us_1.0"
else
VER=$1
fi
echo 'Extracting Assets...'
# Remove assets directory if it exists.
ASSETS_DIR="./assets/vanilla/$1"
ASSETS_DIR="./assets/vanilla/$VER"
if [ -d "$ASSETS_DIR" ]; then
rm -r $ASSETS_DIR
fi
# Remove ucode directory if it exists.
UCODE_DIR="./ucode/$1"
UCODE_DIR="./ucode/$VER"
if [ -d "$UCODE_DIR" ]; then
rm -r $UCODE_DIR
fi
if ! ./tools/dkr_assets_tool -e "$1" ./assets ./extract-ver ./baseroms . ; then
if ! ./tools/dkr_assets_tool -e "$VER" ./assets ./extract-ver ./baseroms . ; then
exit 1
fi
+3 -5
View File
@@ -1,7 +1,5 @@
/n64crc
/dkr_decompressor
/dkr_cheats_encryptor
/dkr_extractor
/dkr_texbuilder
/dkr_assets_tool
/dkr_assets_tool_classes/_build
/binutils
/ido5.3_recomp
/ido5.3_recomp
Binary file not shown.
+11 -27
View File
@@ -52,11 +52,6 @@ typedef enum _CurrentParseOption {
PO_TYPE
} CurrentParseOption;
template <class T>
void invalid_arg_error(T arg) {
std::cout << "Error: Invalid argument \"" << arg << "\"" << std::endl;
}
std::string get_cmd_from_parse_option(ToolType type) {
switch(type) {
case TT_EXTRACT: return "-e";
@@ -84,8 +79,7 @@ bool parse_options(int argc, char *argv[]) {
for (size_t i = 1; i < args.size(); ++i) {
if(args[i][0] == '-') {
if(parsingCmd) {
std::cout << "Error: Not enough args for the current command \""
<< get_cmd_from_parse_option(options.type) << "\"" << std::endl;
display_error("Not enough args for the current command \"", get_cmd_from_parse_option(options.type), "\"");
return false;
}
if(args[i] == "-e") {
@@ -121,14 +115,13 @@ bool parse_options(int argc, char *argv[]) {
} else if(args[i] == "-h") {
return false;
} else {
std::cout << "Error: Invalid option " << args[i] << std::endl;
display_error("Invalid option \"", args[i], "\"");
return false;
}
curOptionArgs = 0;
} else {
if(!parsingCmd) {
std::cout << "Error: Too many args for the current command \""
<< get_cmd_from_parse_option(options.type) << "\"" << std::endl;
display_error("Too many args for the current command \"", get_cmd_from_parse_option(options.type), "\"");
return false;
}
switch(curOption) {
@@ -199,16 +192,14 @@ bool parse_options(int argc, char *argv[]) {
}
break;
default: // This should hopefully never get called
std::cout << "Error: You should not be seeing this message." << std::endl;
return false;
display_error_and_abort("Invalid dkr_assets_tool option. You should not be seeing this message!");
}
curOptionArgs++;
}
}
if(parsingCmd) {
std::cout << "Error: Not enough args for the current command \""
<< get_cmd_from_parse_option(options.type) << "\"" << std::endl;
display_error("Not enough args for the current command \"", get_cmd_from_parse_option(options.type), "\"");
return false;
}
@@ -274,7 +265,7 @@ int main(int argc, char *argv[]) {
set_assets_folder_path(assetsDir);
set_version(version);
AssetCompiler compiler();
AssetCompiler compiler;
}
break;
case TT_ASSET_COMPRESS_FILE:
@@ -285,26 +276,19 @@ int main(int argc, char *argv[]) {
std::string outputFilename = options.paths[1];
std::vector<uint8_t> inputBinary, outputBinary;
if(compression.readBinaryFile(inputBinary, inputFilename))
{
if(compression.readBinaryFile(inputBinary, inputFilename)) {
if(inputBinary.size() == 0) {
compression.writeBinaryFile(inputBinary, outputFilename);
} else {
if (options.type == TT_ASSET_COMPRESS_FILE)
{
if (options.type == TT_ASSET_COMPRESS_FILE) {
outputBinary = compression.compressBuffer(inputBinary);
}
else if (options.type == TT_ASSET_DECOMPRESS_FILE)
{
} else if (options.type == TT_ASSET_DECOMPRESS_FILE) {
outputBinary = compression.decompressBuffer(inputBinary);
}
compression.writeBinaryFile(outputBinary, outputFilename);
}
}
else
{
std::cout << "Could not read file: " << inputFilename << std::endl;
return 1;
} else {
display_error_and_abort("Could not read file: ", inputFilename);
}
}
break;

Some files were not shown because too many files have changed in this diff Show More