Skip to content

Commit

Permalink
Added command line parameter for the launcher to run legacy binaries …
Browse files Browse the repository at this point in the history
…(to be used by the Launchpad).
  • Loading branch information
DaloLorn authored Jan 7, 2025
1 parent b0f0afc commit 2075683
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
21 changes: 15 additions & 6 deletions StarRuler2.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,24 @@ else
fi
cd "$(dirname "$script_loc")"

# TODO: Strip out --legacy parameter before passing args to the game.
# It's ugly, but as with the C equivalent, I'm not quite comfortable enough
# with Bash to be comfortable trying it myself. --Dalo
if [[ $ == *--legacy* ]]; then
bin_folder="bin_legacy"
else
bin_folder="bin"
fi

#Execute the right binary for this architecture
if [ `uname` == "Darwin" ]; then
chmod +x ./bin/osx64/StarRuler2.bin
DYLD_LIBRARY_PATH="./bin/osx64/:$DYLD_LIBRARY_PATH" exec ./bin/osx64/StarRuler2.bin $@
chmod +x ./$bin_folder/osx64/StarRuler2.bin
DYLD_LIBRARY_PATH="./$bin_folder/osx64/:$DYLD_LIBRARY_PATH" exec ./$bin_folder/osx64/StarRuler2.bin $@
elif [ `uname -m` = "x86_64" ]; then
chmod +x ./bin/lin64/StarRuler2.bin
LD_LIBRARY_PATH="./bin/lin64/:$LD_LIBRARY_PATH" exec ./bin/lin64/StarRuler2.bin $@
chmod +x ./$bin_folder/lin64/StarRuler2.bin
LD_LIBRARY_PATH="./$bin_folder/lin64/:$LD_LIBRARY_PATH" exec ./$bin_folder/lin64/StarRuler2.bin $@
else
chmod +x ./bin/lin32/StarRuler2.bin
LD_LIBRARY_PATH="./bin/lin32/:$LD_LIBRARY_PATH" exec ./bin/lin32/StarRuler2.bin $@
chmod +x ./$bin_folder/lin32/StarRuler2.bin
LD_LIBRARY_PATH="./$bin_folder/lin32/:$LD_LIBRARY_PATH" exec ./$bin_folder/lin32/StarRuler2.bin $@
fi;
# vim: set ff=unix:
13 changes: 12 additions & 1 deletion source/loader/main.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <Windows.h>
#include <string.h>

static inline __forceinline __declspec(allocator) wchar_t* wstrdup(const wchar_t *_String) {
size_t i = 0;
Expand Down Expand Up @@ -35,7 +36,17 @@ DWORD __stdcall mainCRTStartup(LPVOID p) {
PROCESS_INFORMATION process;
SecureZeroMemory(&process, sizeof(process));

if(CreateProcessW(L"bin\\win64\\Star Ruler 2.exe", wstrdup(cmdline), NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &startup, &process) != FALSE) {
wchar_t path;

if(strstr(cmdline, "--legacy"))
path = L"bin_legacy\\win64\\Star Ruler 2.exe";
else
path = L"bin\\win64\\Star Ruler 2.exe";

// TODO: Don't pass -legacy parameter to game client.
// It's ugly, but I'm not quite C-savvy enough to be comfortable
// writing - or more likely copy-pasting - a substring remover... --Dalo
if(CreateProcessW(path, wstrdup(cmdline), NULL, NULL, FALSE, DETACHED_PROCESS, NULL, NULL, &startup, &process) != FALSE) {
CloseHandle(process.hProcess);
CloseHandle(process.hThread);
}
Expand Down

0 comments on commit 2075683

Please sign in to comment.