mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
fix game hanging on launcher error
This commit is contained in:
parent
5d885240b6
commit
3810e0eb0b
@ -27,4 +27,5 @@ class BeamNG {
|
||||
// static int GetTickCount_D(void* GEState, void* Param2, void* Param3, void*
|
||||
// Param4);
|
||||
static void IPCListener();
|
||||
static uint32_t IPCSender(void* LP);
|
||||
};
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "Memory/Memory.h"
|
||||
#include "atomic_queue.h"
|
||||
|
||||
std::unique_ptr<atomic_queue<std::string, 1000>> Queue;
|
||||
std::unique_ptr<atomic_queue<std::string, 1000>> RCVQueue, SendQueue;
|
||||
|
||||
int BeamNG::lua_open_jit_D(lua_State* State) {
|
||||
Memory::Print("Got lua State");
|
||||
@ -17,7 +17,8 @@ int BeamNG::lua_open_jit_D(lua_State* State) {
|
||||
}
|
||||
|
||||
void BeamNG::EntryPoint() {
|
||||
Queue = std::make_unique<atomic_queue<std::string, 1000>>();
|
||||
RCVQueue = std::make_unique<atomic_queue<std::string, 1000>>();
|
||||
SendQueue = std::make_unique<atomic_queue<std::string, 1000>>();
|
||||
uint32_t PID = Memory::GetPID();
|
||||
auto status = MH_Initialize();
|
||||
if (status != MH_OK)
|
||||
@ -31,6 +32,8 @@ void BeamNG::EntryPoint() {
|
||||
OpenJITDetour->Enable();
|
||||
IPCFromLauncher = std::make_unique<IPC>(PID, 0x1900000);
|
||||
IPCToLauncher = std::make_unique<IPC>(PID + 1, 0x1900000);
|
||||
CreateThread(nullptr, 0, LPTHREAD_START_ROUTINE(IPCSender), nullptr, 0,
|
||||
nullptr);
|
||||
IPCListener();
|
||||
}
|
||||
|
||||
@ -60,7 +63,7 @@ int Game(lua_State* L) {
|
||||
|
||||
int LuaPop(lua_State* L) {
|
||||
std::string MSG;
|
||||
if (Queue->try_pop(MSG)) {
|
||||
if (RCVQueue->try_pop(MSG)) {
|
||||
GELua::lua_push_fstring(L, "%s", MSG.c_str());
|
||||
return 1;
|
||||
}
|
||||
@ -78,7 +81,7 @@ void BeamNG::RegisterGEFunctions() {
|
||||
}
|
||||
|
||||
void BeamNG::SendIPC(const std::string& Data) {
|
||||
IPCToLauncher->send(Data);
|
||||
if (SendQueue->size() < 800 || !RCVQueue->empty()) { SendQueue->push(Data); }
|
||||
}
|
||||
|
||||
void BeamNG::IPCListener() {
|
||||
@ -87,9 +90,23 @@ void BeamNG::IPCListener() {
|
||||
IPCFromLauncher->receive();
|
||||
if (!IPCFromLauncher->receive_timed_out()) {
|
||||
TimeOuts = 0;
|
||||
Queue->push(IPCFromLauncher->msg());
|
||||
RCVQueue->push(IPCFromLauncher->msg());
|
||||
IPCFromLauncher->confirm_receive();
|
||||
} else TimeOuts++;
|
||||
}
|
||||
Memory::Print("IPC System shutting down");
|
||||
Memory::Print("IPC Listener System shutting down");
|
||||
}
|
||||
|
||||
uint32_t BeamNG::IPCSender(void* LP) {
|
||||
std::string result;
|
||||
int TimeOuts = 0;
|
||||
while (TimeOuts < 20) {
|
||||
if (SendQueue->try_pop(result)) {
|
||||
IPCToLauncher->send(result);
|
||||
if (!IPCToLauncher->send_timed_out()) TimeOuts = 0;
|
||||
else TimeOuts++;
|
||||
}
|
||||
}
|
||||
Memory::Print("IPC Sender System shutting down");
|
||||
return 0;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include "Memory/IPC.h"
|
||||
#include "Memory/Memory.h"
|
||||
#include <windows.h>
|
||||
|
||||
IPC::IPC(uint32_t ID, size_t Size) noexcept : Size_(Size) {
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include <wx/tipwin.h>
|
||||
#include "Launcher.h"
|
||||
#include "Logger.h"
|
||||
#include <thread>
|
||||
#endif
|
||||
|
||||
/////////// Inherit App class ///////////
|
||||
@ -293,7 +294,7 @@ MyAccountFrame::MyAccountFrame() : wxFrame(nullptr, wxID_ANY, "Account Manager",
|
||||
wxStaticBitmap *image;
|
||||
image = new wxStaticBitmap( this, wxID_ANY, wxBitmapBundle(wxImage("icons/BeamMP_black.png", wxBITMAP_TYPE_PNG).Scale(120,120, wxIMAGE_QUALITY_HIGH)), wxPoint(180,20), wxSize(120, 120));
|
||||
|
||||
if (!isSignedIn()) {
|
||||
if (isSignedIn()) {
|
||||
image->SetBitmap(wxBitmapBundle(wxImage("icons/default.png", wxBITMAP_TYPE_PNG).Scale(120,120, wxIMAGE_QUALITY_HIGH)));
|
||||
|
||||
auto* txtName = new wxStaticText(this, wxID_ANY, wxT("Username: BeamMP"), wxPoint(180, 200));
|
||||
@ -430,16 +431,17 @@ void MyAccountFrame::OnClickLogout(wxCommandEvent& event WXUNUSED(event)) {
|
||||
/////////// OnClick Launch Event ///////////
|
||||
void MyMainFrame::OnClickLaunch(wxCommandEvent& event WXUNUSED(event)) {
|
||||
static bool FirstTime = true;
|
||||
/* if (Launcher::EntryThread.joinable()) Launcher::EntryThread.join();
|
||||
if (Launcher::EntryThread.joinable()) Launcher::EntryThread.join();
|
||||
Launcher::EntryThread = std::thread([&]() {
|
||||
entry();
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
txtStatusResult->SetLabelText(wxT("Online"));
|
||||
txtStatusResult->SetForegroundColour("green");
|
||||
btnLaunch->Enable();
|
||||
});
|
||||
txtStatusResult->SetLabelText(wxT("In-Game"));
|
||||
txtStatusResult->SetForegroundColour("purple");
|
||||
btnLaunch->Disable();*/
|
||||
btnLaunch->Disable();
|
||||
|
||||
if(FirstTime) {
|
||||
wxMessageBox("Please launch BeamNG.drive manually in case of Steam issues.", "Alert");
|
||||
|
Loading…
x
Reference in New Issue
Block a user