mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-25 10:52:19 -05:00
Fix: Repair working directory on Mac and use app directory for extractor search paths (#3359)
* fix otr regen on mac release * linux args
This commit is contained in:
parent
460b3d02f5
commit
959b307b9e
@ -219,12 +219,14 @@ if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then
|
|||||||
*)
|
*)
|
||||||
osascript -e 'display notification "One or more invalid ROM provided" with title "Ship Of Harkinian"'
|
osascript -e 'display notification "One or more invalid ROM provided" with title "Ship Of Harkinian"'
|
||||||
rm -r "$ASSETDIR"
|
rm -r "$ASSETDIR"
|
||||||
|
cd "$SNAME"
|
||||||
continue;
|
continue;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Only generate OTR if we don't have on of this type yet
|
# Only generate OTR if we don't have on of this type yet
|
||||||
if [ -e "$SHIP_HOME"/"$OTRNAME" ]; then
|
if [ -e "$SHIP_HOME"/"$OTRNAME" ]; then
|
||||||
rm -r "$ASSETDIR"
|
rm -r "$ASSETDIR"
|
||||||
|
cd "$SNAME"
|
||||||
continue;
|
continue;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -234,6 +236,7 @@ if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then
|
|||||||
osascript -e 'display notification "OTR successfully generated" with title "Ship Of Harkinian"'
|
osascript -e 'display notification "OTR successfully generated" with title "Ship Of Harkinian"'
|
||||||
cp "$ASSETDIR"/oot.otr "$SHIP_HOME"/"$OTRNAME"
|
cp "$ASSETDIR"/oot.otr "$SHIP_HOME"/"$OTRNAME"
|
||||||
rm -r "$ASSETDIR"
|
rm -r "$ASSETDIR"
|
||||||
|
cd "$SNAME"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
@ -243,6 +246,8 @@ if [ ! -e "$SHIP_HOME"/oot.otr ] || [ ! -e "$SHIP_HOME"/oot-mq.otr ]; then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cd "$SNAME"
|
||||||
|
|
||||||
arch_name="$(uname -m)"
|
arch_name="$(uname -m)"
|
||||||
launch_arch="arm64"
|
launch_arch="arm64"
|
||||||
if [ "${arch_name}" = "x86_64" ] && [ "$(sysctl -in sysctl.proc_translated)" != "1" ]; then
|
if [ "${arch_name}" = "x86_64" ] && [ "$(sysctl -in sysctl.proc_translated)" != "1" ]; then
|
||||||
|
@ -225,7 +225,7 @@ void Extractor::GetRoms(std::vector<std::string>& roms) {
|
|||||||
//}
|
//}
|
||||||
#elif unix
|
#elif unix
|
||||||
// Open the directory of the app.
|
// Open the directory of the app.
|
||||||
DIR* d = opendir(".");
|
DIR* d = opendir(mSearchPath.c_str());
|
||||||
struct dirent* dir;
|
struct dirent* dir;
|
||||||
|
|
||||||
if (d != NULL) {
|
if (d != NULL) {
|
||||||
@ -248,7 +248,7 @@ void Extractor::GetRoms(std::vector<std::string>& roms) {
|
|||||||
}
|
}
|
||||||
closedir(d);
|
closedir(d);
|
||||||
#else
|
#else
|
||||||
for (const auto& file : std::filesystem::directory_iterator("./")) {
|
for (const auto& file : std::filesystem::directory_iterator(mSearchPath)) {
|
||||||
if (file.is_directory())
|
if (file.is_directory())
|
||||||
continue;
|
continue;
|
||||||
if ((file.path().extension() == ".n64") || (file.path().extension() == ".z64") ||
|
if ((file.path().extension() == ".n64") || (file.path().extension() == ".z64") ||
|
||||||
@ -297,7 +297,7 @@ bool Extractor::GetRomPathFromBox() {
|
|||||||
}
|
}
|
||||||
mCurrentRomPath = nameBuffer;
|
mCurrentRomPath = nameBuffer;
|
||||||
#else
|
#else
|
||||||
auto selection = pfd::open_file("Select a file", ".", { "N64 Roms", "*.z64 *.n64 *.v64" }).result();
|
auto selection = pfd::open_file("Select a file", mSearchPath, { "N64 Roms", "*.z64 *.n64 *.v64" }).result();
|
||||||
|
|
||||||
if (selection.empty()) {
|
if (selection.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -430,10 +430,12 @@ bool Extractor::ManuallySearchForRomMatchingType(RomSearchMode searchMode) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Extractor::Run(RomSearchMode searchMode) {
|
bool Extractor::Run(std::string searchPath, RomSearchMode searchMode) {
|
||||||
std::vector<std::string> roms;
|
std::vector<std::string> roms;
|
||||||
std::ifstream inFile;
|
std::ifstream inFile;
|
||||||
|
|
||||||
|
mSearchPath = searchPath;
|
||||||
|
|
||||||
GetRoms(roms);
|
GetRoms(roms);
|
||||||
FilterRoms(roms, searchMode);
|
FilterRoms(roms, searchMode);
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@ enum class RomSearchMode {
|
|||||||
class Extractor {
|
class Extractor {
|
||||||
std::unique_ptr<unsigned char[]> mRomData = std::make_unique<unsigned char[]>(MB64);
|
std::unique_ptr<unsigned char[]> mRomData = std::make_unique<unsigned char[]>(MB64);
|
||||||
std::string mCurrentRomPath;
|
std::string mCurrentRomPath;
|
||||||
|
std::string mSearchPath;
|
||||||
size_t mCurRomSize = 0;
|
size_t mCurRomSize = 0;
|
||||||
|
|
||||||
bool GetRomPathFromBox();
|
bool GetRomPathFromBox();
|
||||||
@ -58,7 +59,7 @@ class Extractor {
|
|||||||
static void ShowErrorBox(const char* title, const char* text);
|
static void ShowErrorBox(const char* title, const char* text);
|
||||||
bool IsMasterQuest() const;
|
bool IsMasterQuest() const;
|
||||||
|
|
||||||
bool Run(RomSearchMode searchMode = RomSearchMode::Both);
|
bool Run(std::string searchPath, RomSearchMode searchMode = RomSearchMode::Both);
|
||||||
bool CallZapd(std::string installPath, std::string exportdir);
|
bool CallZapd(std::string installPath, std::string exportdir);
|
||||||
const char* GetZapdStr();
|
const char* GetZapdStr();
|
||||||
std::string Mkdtemp();
|
std::string Mkdtemp();
|
||||||
|
@ -890,7 +890,7 @@ void DetectOTRVersion(std::string fileName, bool isMQ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Extractor extract;
|
Extractor extract;
|
||||||
if (!extract.Run(isMQ ? RomSearchMode::MQ : RomSearchMode::Vanilla)) {
|
if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName), isMQ ? RomSearchMode::MQ : RomSearchMode::Vanilla)) {
|
||||||
Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting...");
|
Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting...");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -932,7 +932,8 @@ extern "C" void InitOTR() {
|
|||||||
#elif defined(__WIIU__)
|
#elif defined(__WIIU__)
|
||||||
LUS::WiiU::Init(appShortName);
|
LUS::WiiU::Init(appShortName);
|
||||||
#endif
|
#endif
|
||||||
#ifdef _WIN32
|
|
||||||
|
#ifdef _WIN32
|
||||||
char* tempVar = getenv("TEMP");
|
char* tempVar = getenv("TEMP");
|
||||||
std::filesystem::path tempPath;
|
std::filesystem::path tempPath;
|
||||||
try {
|
try {
|
||||||
@ -985,7 +986,7 @@ extern "C" void InitOTR() {
|
|||||||
bool generatedOtrIsMQ = false;
|
bool generatedOtrIsMQ = false;
|
||||||
if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) {
|
if (Extractor::ShowYesNoBox("No OTR Files", "No OTR files found. Generate one now?") == IDYES) {
|
||||||
Extractor extract;
|
Extractor extract;
|
||||||
if (!extract.Run()) {
|
if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName))) {
|
||||||
Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting...");
|
Extractor::ShowErrorBox("Error", "An error occured, no OTR file was generated.\n\nExiting...");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@ -996,7 +997,7 @@ extern "C" void InitOTR() {
|
|||||||
}
|
}
|
||||||
if (Extractor::ShowYesNoBox("Extraction Complete", "ROM Extracted. Extract another?") == IDYES) {
|
if (Extractor::ShowYesNoBox("Extraction Complete", "ROM Extracted. Extract another?") == IDYES) {
|
||||||
Extractor extract;
|
Extractor extract;
|
||||||
if (!extract.Run(generatedOtrIsMQ ? RomSearchMode::Vanilla : RomSearchMode::MQ)) {
|
if (!extract.Run(LUS::Context::GetAppDirectoryPath(appShortName), generatedOtrIsMQ ? RomSearchMode::Vanilla : RomSearchMode::MQ)) {
|
||||||
Extractor::ShowErrorBox("Error", "An error occured, an OTR file may have been generated by a different step.\n\nContinuing...");
|
Extractor::ShowErrorBox("Error", "An error occured, an OTR file may have been generated by a different step.\n\nContinuing...");
|
||||||
} else {
|
} else {
|
||||||
extract.CallZapd(installPath, LUS::Context::GetAppDirectoryPath(appShortName));
|
extract.CallZapd(installPath, LUS::Context::GetAppDirectoryPath(appShortName));
|
||||||
|
Loading…
Reference in New Issue
Block a user