Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove ns_startup_args*.txt functionality #517

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 0 additions & 61 deletions NorthstarDLL/core/hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,67 +218,6 @@ void MakeHook(LPVOID pTarget, LPVOID pDetour, void* ppOriginal, const char* pFun
spdlog::error("MH_CreateHook failed for function {}", pStrippedFuncName);
}

AUTOHOOK_ABSOLUTEADDR(_GetCommandLineA, (LPVOID)GetCommandLineA, LPSTR, WINAPI, ())
{
static char* cmdlineModified;
static char* cmdlineOrg;

if (cmdlineOrg == nullptr || cmdlineModified == nullptr)
{
cmdlineOrg = _GetCommandLineA();
bool isDedi = strstr(cmdlineOrg, "-dedicated"); // well, this one has to be a real argument
bool ignoreStartupArgs = strstr(cmdlineOrg, "-nostartupargs");

std::string args;
std::ifstream cmdlineArgFile;

// it looks like CommandLine() prioritizes parameters apprearing first, so we want the real commandline to take priority
// not to mention that cmdlineOrg starts with the EXE path
args.append(cmdlineOrg);
args.append(" ");

// append those from the file

if (!ignoreStartupArgs)
{

cmdlineArgFile = std::ifstream(!isDedi ? "ns_startup_args.txt" : "ns_startup_args_dedi.txt");

if (cmdlineArgFile)
{
std::stringstream argBuffer;
argBuffer << cmdlineArgFile.rdbuf();
cmdlineArgFile.close();

// if some other command line option includes "-northstar" in the future then you have to refactor this check to check with
// both either space after or ending with
if (!isDedi && argBuffer.str().find("-northstar") != std::string::npos)
MessageBoxA(
NULL,
"The \"-northstar\" command line option is NOT supposed to go into ns_startup_args.txt file!\n\nThis option is "
"supposed to go into Origin/Steam game launch options, and then you are supposed to launch the original "
"Titanfall2.exe "
"rather than NorthstarLauncher.exe to make use of it.",
"Northstar Warning",
MB_ICONWARNING);

args.append(argBuffer.str());
}
}

auto len = args.length();
cmdlineModified = new char[len + 1];
if (!cmdlineModified)
{
spdlog::error("malloc failed for command line");
return cmdlineOrg;
}
memcpy(cmdlineModified, args.c_str(), len + 1);
}

return cmdlineModified;
}

std::vector<std::string> calledTags;
void CallLoadLibraryACallbacks(LPCSTR lpLibFileName, HMODULE moduleAddress)
{
Expand Down
15 changes: 5 additions & 10 deletions NorthstarLauncher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,14 @@ int main(int argc, char* argv[])
{
PrependPath();

if (!fs::exists("ns_startup_args.txt"))
// NOTE [Fifty]: Functionality removed in https://github.com/R2Northstar/NorthstarLauncher/pull/517
if (fs::exists("ns_startup_args.txt"))
{
std::ofstream file("ns_startup_args.txt");
std::string defaultArgs = "-multiple";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR means we lose the functionality of these default args right?

If so, this could cause issues with the game complaining about multiple instances if an instance is stuck in the background or something

file.write(defaultArgs.c_str(), defaultArgs.length());
file.close();
std::cout << "[*] WARNING: 'ns_startup_args.txt' is no longer supported!" << std::endl;
}
if (!fs::exists("ns_startup_args_dedi.txt"))
if (fs::exists("ns_startup_args_dedi.txt"))
{
std::ofstream file("ns_startup_args_dedi.txt");
std::string defaultArgs = "+setplaylist private_match";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the behaviour for dedis when this functionality is lost?

Also, a number of dedis use ns_startup_args_dedi.txt to set up the server. If this gets merged we should warn server hosters about this no longer being supported

file.write(defaultArgs.c_str(), defaultArgs.length());
file.close();
std::cout << "[*] WARNING: 'ns_startup_args_dedi.txt' is no longer supported!" << std::endl;
}

std::cout << "[*] Loading tier0.dll" << std::endl;
Expand Down