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

Add Native Linux Support #63

Merged
merged 0 commits into from
May 29, 2024
Merged

Add Native Linux Support #63

merged 0 commits into from
May 29, 2024

Conversation

gamingdoom
Copy link
Contributor

@gamingdoom gamingdoom commented Oct 18, 2023

This PR allows BeamMP to be compiled natively for Linux for use with the native version of the game, while making no changes to the Windows version.

Currently, the Linux version of BeamMP:

  • Only works with the Steam version of the game (no registry on linux)
  • Doesn't support Discord RPC

This PR also:

  • Adds a GitHub actions manifest to build the Linux version.
  • Renames network.h to network.hpp (it imports string so it is cpp)
  • Adds extra error handling when parsing responses from server (necessary for proper function on Linux rapidjson)
  • Adds vdf file parser (needed to find game) from https://github.com/TinyTinni/ValveFileVDF

@@ -27,7 +30,7 @@ std::string Comp(std::string Data){
deflateEnd(&defstream);
int TO = defstream.total_out;
std::string Ret(TO,0);
memcpy_s(&Ret[0],TO,C,TO);
memcpy(&Ret[0],C,TO);
Copy link
Contributor Author

@gamingdoom gamingdoom Oct 18, 2023

Choose a reason for hiding this comment

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

Annex K functions are not necessary here and they aren't portable.

struct passwd *pw = getpwuid(getuid());
std::string homeDir = pw->pw_dir;

std::string Path = homeDir + "/.local/share/BeamNG.drive/";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

~/.local/share/BeamNG.drive is the default user folder.

except("(Core) Code : " + std::string(strerror(errno)));
}
#endif

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made this code more readable.

GameDir = folderInfo.second->attribs["path"] + "/steamapps/common/BeamNG.drive/";
break;
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This only works for steam as it uses the steam libraryfolders.vdf to find the game. There is no registry on Linux so it would be difficult to find the game otherwise.

PublicKey = d["public_key"].GetString();
}
info("Authentication successful!");
}else info("Authentication failed!");
if(!d["message"].IsNull()){
if(d.HasMember("message") && !d["message"].IsNull()){
Copy link
Contributor Author

Choose a reason for hiding this comment

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

rapidjson errors on linux when you get a member that doesn't exist. We check if the member exists first.

@gamingdoom gamingdoom changed the title [PR] Add Linux Support [PR] Add Native Linux Support Oct 23, 2023
@lionkor
Copy link
Member

lionkor commented Jan 15, 2024

Hi, thanks for the contribution. Currently, we're in the process of making significant changes to the launcher, so this will not be merged at this time.

Changes include a rework of the protocol.

@thevbw
Copy link

thevbw commented Jan 15, 2024

merge, coward

@BeamMP BeamMP locked as resolved and limited conversation to collaborators Jan 15, 2024
@lionkor
Copy link
Member

lionkor commented Jan 15, 2024

I'd happily introduce some of these ideas to the new version, but as you saw from the code, the current launcher is not in an acceptable state. I've locked the conversation for now, @thevbw please direct your comments to /dev/null

@lionkor lionkor changed the title [PR] Add Native Linux Support Add Native Linux Support Feb 24, 2024
@lionkor lionkor changed the base branch from master to linux May 29, 2024 09:07
@lionkor lionkor merged commit 35ad09d into BeamMP:linux May 29, 2024
@lionkor
Copy link
Member

lionkor commented May 29, 2024

Will fix this up ourselves :) @gamingdoom you ok with licensing your code AGPL-3.0?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants