Make lobby_connect work on Linux.

Fix a bug with it not finding rich presence.

Code is all open source now so no need to ship the lobby connect source in the release.
This commit is contained in:
Mr_Goldberg 2019-04-16 17:58:08 -04:00
parent 52cad2114d
commit fb7c8ea35b
No known key found for this signature in database
GPG key ID: 8597D87419DEF278
6 changed files with 39 additions and 19 deletions

View file

@ -7,4 +7,3 @@ Most steam games also let you join lobbies in game without having started the ga
Just run this tool and follow the instructions then pick the exe of the game. Make sure that you have installed my emu on the game first and that it works or it won't work. Just run this tool and follow the instructions then pick the exe of the game. Make sure that you have installed my emu on the game first and that it works or it won't work.
If you want to help me improve it, the source can be found in the source folder.

View file

@ -1,7 +1,11 @@
set -e
rm -rf linux rm -rf linux
mkdir -p linux/x86 mkdir -p linux/x86
mkdir -p linux/x86_64 mkdir -p linux/x86_64
mkdir -p linux/lobby_connect
../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto ../protobuf/prefix_x86/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32 g++ -m32 -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -std=c++11 && echo built32
g++ -m32 -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x86 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix_x86/include/ -L../protobuf/prefix_x86/lib/ -lprotobuf-lite -lpthread -std=c++11 && echo built_lobby_connect32
../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto ../protobuf/prefix/bin/protoc -I./dll/ --cpp_out=./dll/ ./dll/*.proto
g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64 g++ -shared -fPIC -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -s -o linux/x86_64/libsteam_api.so dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -std=c++11 && echo built64
g++ -fvisibility=hidden -Wl,--exclude-libs,ALL -DGNUC -DEMU_RELEASE_BUILD -DNDEBUG -DNO_DISK_WRITES -DLOBBY_CONNECT -s -o linux/lobby_connect/lobby_connect_x64 lobby_connect.cpp dll/*.cpp dll/*.cc -Wno-return-type -I../protobuf/prefix/include/ -L../protobuf/prefix/lib/ -lprotobuf-lite -lpthread -std=c++11 && echo built_lobby_connect64

View file

@ -4,9 +4,7 @@ call build_set_protobuf_directories.bat
%PROTOBUF_X86_DIRECTORY%%PROTOC_DIRECTORY% -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto %PROTOBUF_X86_DIRECTORY%%PROTOC_DIRECTORY% -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
call build_env_x86.bat call build_env_x86.bat
cl dll/rtlgenrandom.c dll/rtlgenrandom.def cl dll/rtlgenrandom.c dll/rtlgenrandom.def
cl /DNO_DISK_WRITES /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ lobby_connect.cpp dll/*.cpp dll/*.cc %PROTOBUF_X86_DIRECTORY%%PROTOBUF_LIBRARY% Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Comdlg32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\lobby_connect\lobby_connect.exe cl /DNO_DISK_WRITES /DLOBBY_CONNECT /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ lobby_connect.cpp dll/*.cpp dll/*.cc %PROTOBUF_X86_DIRECTORY%%PROTOBUF_LIBRARY% Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib Comdlg32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\lobby_connect\lobby_connect.exe
del /Q /S release\lobby_connect\*.lib del /Q /S release\lobby_connect\*.lib
del /Q /S release\lobby_connect\*.exp del /Q /S release\lobby_connect\*.exp
copy Readme_lobby_connect.txt release\lobby_connect\Readme.txt copy Readme_lobby_connect.txt release\lobby_connect\Readme.txt
mkdir release\lobby_connect\source\
copy lobby_connect.cpp release\lobby_connect\source\

View file

@ -43,6 +43,11 @@ class Settings {
std::vector<struct DLC_entry> DLCs; std::vector<struct DLC_entry> DLCs;
std::vector<struct Mod_entry> mods; std::vector<struct Mod_entry> mods;
public: public:
#ifdef LOBBY_CONNECT
static const bool is_lobby_connect = true;
#else
static const bool is_lobby_connect = false;
#endif
static std::string sanitize(std::string name); static std::string sanitize(std::string name);
Settings(CSteamID steam_id, CGameID game_id, std::string name, std::string language); Settings(CSteamID steam_id, CGameID game_id, std::string name, std::string language);
CSteamID get_local_steam_id(); CSteamID get_local_steam_id();

View file

@ -75,10 +75,10 @@ void rich_presence_updated(CSteamID id, AppId_t appid)
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data)); callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
} }
bool isSameAppId(Friend *f) bool isAppIdCompatible(Friend *f)
{ {
//in my emu 0 appid is the same as any appid, it's useful for things like my lobby connect program if (settings->is_lobby_connect) return true;
if (!settings->get_local_game_id().AppID()) return true; if (f == &us) return true;
return settings->get_local_game_id().AppID() == f->appid(); return settings->get_local_game_id().AppID() == f->appid();
} }

View file

@ -1,15 +1,21 @@
/* Copyright (C) 2019 Mr Goldberg
This file is part of the Goldberg Emulator
The Goldberg Emulator is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 3 of the License, or (at your option) any later version.
The Goldberg Emulator is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the Goldberg Emulator; if not, see
<http://www.gnu.org/licenses/>. */
/* /*
This is the source code for the lobby_connect.exe program.
If you want to build it, just dl the steam sdk and link it to the steam api dll
Then to execute it just use my emu dll instead of the steam sdk dll.
If you make any improvements and want to share them post your code in the thread and if it improves it I'll use it.
You can also use this code to add this functionality to your launchers.
Note if you use my steam emu dll: When I build my lobby_connect.exe I static link it to a build of my emu that has reading from disk disabled.
This means that it's a good idea for you to use local_save.txt so that your launcher doesn't conflict with running
games by having the same steam user id. There must also be no steam_appid.txt or else you will only see games with that appid.
*/ */
#include "sdk_includes/steam_api.h" #include "sdk_includes/steam_api.h"
@ -20,8 +26,12 @@ games by having the same steam user id. There must also be no steam_appid.txt or
#include <thread> #include <thread>
#include <string> #include <string>
#include <vector> #include <vector>
#include <windows.h>
#ifdef _WIN32
#include <windows.h>
#else
#endif
int main() { int main() {
if (SteamAPI_Init()) { if (SteamAPI_Init()) {
//Set appid to: LOBBY_CONNECT_APPID //Set appid to: LOBBY_CONNECT_APPID
@ -75,6 +85,7 @@ top:
if (choice >= arguments.size()) goto top; if (choice >= arguments.size()) goto top;
#ifdef _WIN32
std::cout << "starting the game with: " << arguments[choice] << std::endl << "Please select the game exe" << std::endl; std::cout << "starting the game with: " << arguments[choice] << std::endl << "Please select the game exe" << std::endl;
OPENFILENAMEA ofn; OPENFILENAMEA ofn;
@ -106,5 +117,8 @@ top:
&lpProcessInfo &lpProcessInfo
); );
} }
#else
std::cout << "Please launch the game with these arguments: " << arguments[choice] << std::endl;
#endif
} }
} }