Skip to content

Commit

Permalink
add rpc file open support / mesa 23.1 workaround
Browse files Browse the repository at this point in the history
  • Loading branch information
ChristopherHX committed Jun 2, 2023
1 parent efcdc74 commit 830459e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 2 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ git_commit_hash(${CMAKE_CURRENT_SOURCE_DIR} CLIENT_GIT_COMMIT_HASH)
configure_file(src/build_info.h.in ${CMAKE_CURRENT_BINARY_DIR}/build_info/build_info.h)

add_executable(mcpelauncher-client src/main.cpp src/main.h src/window_callbacks.cpp src/window_callbacks.h src/xbox_live_helper.cpp src/xbox_live_helper.h src/splitscreen_patch.cpp src/splitscreen_patch.h src/cll_upload_auth_step.cpp src/cll_upload_auth_step.h src/gl_core_patch.cpp src/gl_core_patch.h src/hbui_patch.cpp src/hbui_patch.h src/utf8_util.h src/shader_error_patch.cpp src/shader_error_patch.h src/jni/jni_descriptors.cpp src/jni/java_types.h src/jni/main_activity.cpp src/jni/main_activity.h src/jni/store.cpp src/jni/store.h src/jni/cert_manager.cpp src/jni/cert_manager.h src/jni/http_stub.cpp src/jni/http_stub.h src/jni/package_source.cpp src/jni/package_source.h src/jni/jni_support.h src/jni/jni_support.cpp src/fake_looper.cpp src/fake_looper.h src/fake_window.cpp src/fake_window.h src/fake_assetmanager.cpp src/fake_assetmanager.h src/fake_egl.cpp src/fake_egl.h src/fake_inputqueue.cpp src/fake_inputqueue.h src/symbols.cpp src/symbols.h src/text_input_handler.cpp src/text_input_handler.h src/jni/xbox_live.cpp src/jni/xbox_live.h src/core_patches.cpp src/core_patches.h src/thread_mover.cpp src/thread_mover.h src/jni/lib_http_client.cpp src/jni/lib_http_client.h src/jni/lib_http_client_websocket.cpp src/jni/lib_http_client_websocket.h src/jni/accounts.cpp src/jni/accounts.h src/jni/arrays.cpp src/jni/arrays.h src/jni/ecdsa.cpp src/jni/ecdsa.h src/jni/jbase64.cpp src/jni/jbase64.h src/jni/locale.cpp src/jni/locale.h src/jni/securerandom.cpp src/jni/securerandom.h src/jni/shahasher.cpp src/jni/shahasher.h src/jni/signature.cpp src/jni/signature.h src/jni/uuid.cpp src/jni/uuid.h src/jni/webview.cpp src/jni/webview.h src/util.cpp src/util.h src/xal_webview_factory.cpp src/xal_webview_factory.h src/xal_webview.h)
target_link_libraries(mcpelauncher-client logger properties-parser mcpelauncher-core gamewindow filepicker msa-daemon-client cll-telemetry argparser baron android-support-headers libc-shim OpenSSL::Crypto ${CURL_LIBRARIES})
target_link_libraries(mcpelauncher-client logger properties-parser mcpelauncher-core gamewindow filepicker msa-daemon-client daemon-server-utils cll-telemetry argparser baron android-support-headers libc-shim OpenSSL::Crypto ${CURL_LIBRARIES})
target_include_directories(mcpelauncher-client PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/build_info/ ${CURL_INCLUDE_DIRS})

if (IS_ARM_BUILD)
Expand Down
5 changes: 5 additions & 0 deletions src/fake_egl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,11 @@ void FakeEGL::setupGLOverrides() {
#ifdef USE_ARMHF_SUPPORT
ArmhfSupport::install(fake_egl::hostProcOverrides);
#endif
// MESA 23.1 blackscreen Workaround Start for 1.18.30+, bgfy will disable the extension and the game works
fake_egl::hostProcOverrides["glDrawElementsInstancedOES"] = nullptr;
fake_egl::hostProcOverrides["glDrawArraysInstancedOES"] = nullptr;
fake_egl::hostProcOverrides["glVertexAttribDivisorOES"] = nullptr;
// MESA 23.1 blackscreen Workaround End
fake_egl::hostProcOverrides["glInvalidateFramebuffer"] = (void *)+[]() {}; // Stub for a NVIDIA bug
if(FakeEGL::enableTexturePatch) {
// Minecraft Intel/Amd Texture Bug 1.16.210-1.17.2 and beyond
Expand Down
34 changes: 33 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@
#include <fstream>
// For getpid
#include <unistd.h>
#include <simpleipc/client/service_client.h>
#include <daemon_utils/auto_shutdown_service.h>

struct RpcCallbackServer : daemon_utils::auto_shutdown_service {
RpcCallbackServer(const std::string &path) : daemon_utils::auto_shutdown_service(path, daemon_utils::shutdown_policy::never) {
add_handler_async("mcpelauncher-client/sendfile", [this](simpleipc::connection& conn, std::string const& method, nlohmann::json const& data, result_handler const& cb) {
std::vector<std::string> files = data;
cb(simpleipc::rpc_json_result::response({}));
});
}
};

static size_t base;
LauncherOptions options;
Expand All @@ -46,7 +57,22 @@ void printVersionInfo();
bool checkFullscreen();

int main(int argc, char* argv[]) {
auto windowManager = GameWindowManager::getManager();
if(argc == 2 && argv[1][0] != '-') {
Log::info("Sendfile", "sending file");
simpleipc::client::service_client sc(PathHelper::getPrimaryDataDirectory() + "/file_handler");
std::vector<std::string> files = { argv[1] };
static std::mutex mlock;
mlock.lock();
auto call = simpleipc::client::rpc_call<int>(sc.rpc("mcpelauncher-client/sendfile", files), [](const nlohmann::json &res) {
Log::info("Sendfile", "success");
mlock.unlock();
return 0;
});
call.call();
mlock.lock();
return 0;
}

CrashHandler::registerCrashHandler();
MinecraftUtils::workaroundLocaleBug();

Expand Down Expand Up @@ -84,6 +110,8 @@ int main(int argc, char* argv[]) {
options.useStdinImport = stdinImpt;

FakeEGL::enableTexturePatch = texturePatch.get();

auto defaultDataDir = PathHelper::getPrimaryDataDirectory();
if(!gameDir.get().empty())
PathHelper::setGameDir(gameDir);
if(!dataDir.get().empty())
Expand All @@ -102,8 +130,12 @@ int main(int argc, char* argv[]) {
}
#endif

RpcCallbackServer server(defaultDataDir + "/file_handler");
Log::trace("Launcher", "Loading hybris libraries");
linker::init();
Log::trace("Launcher", "linker loaded");
auto windowManager = GameWindowManager::getManager();

// Fix saving to internal storage without write access to /data/*
// TODO research how this path is constructed
auto pid = getpid();
Expand Down

2 comments on commit 830459e

@GameParrot
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't mcpelauncher-ui-qt be the file client, not mcpelauncher-client?

@ChristopherHX
Copy link
Member Author

Choose a reason for hiding this comment

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

mcpelauncher-ui-manifest doesn't have the dependencies checked in for simple-ipc and this allows mcpelauncher-client to be used standalone for importing files while the game is running. Without using stdin.

Please sign in to comment.