mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-03 08:26:01 +00:00
Merge pull request #32 from SamZahreddine/v3
fix game hanging on launcher error
This commit is contained in:
commit
9c02be7612
@ -27,4 +27,5 @@ class BeamNG {
|
|||||||
// static int GetTickCount_D(void* GEState, void* Param2, void* Param3, void*
|
// static int GetTickCount_D(void* GEState, void* Param2, void* Param3, void*
|
||||||
// Param4);
|
// Param4);
|
||||||
static void IPCListener();
|
static void IPCListener();
|
||||||
|
static uint32_t IPCSender(void* LP);
|
||||||
};
|
};
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
#include "Memory/Memory.h"
|
#include "Memory/Memory.h"
|
||||||
#include "atomic_queue.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) {
|
int BeamNG::lua_open_jit_D(lua_State* State) {
|
||||||
Memory::Print("Got lua State");
|
Memory::Print("Got lua State");
|
||||||
@ -17,7 +17,8 @@ int BeamNG::lua_open_jit_D(lua_State* State) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BeamNG::EntryPoint() {
|
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();
|
uint32_t PID = Memory::GetPID();
|
||||||
auto status = MH_Initialize();
|
auto status = MH_Initialize();
|
||||||
if (status != MH_OK)
|
if (status != MH_OK)
|
||||||
@ -31,6 +32,8 @@ void BeamNG::EntryPoint() {
|
|||||||
OpenJITDetour->Enable();
|
OpenJITDetour->Enable();
|
||||||
IPCFromLauncher = std::make_unique<IPC>(PID, 0x1900000);
|
IPCFromLauncher = std::make_unique<IPC>(PID, 0x1900000);
|
||||||
IPCToLauncher = std::make_unique<IPC>(PID + 1, 0x1900000);
|
IPCToLauncher = std::make_unique<IPC>(PID + 1, 0x1900000);
|
||||||
|
CreateThread(nullptr, 0, LPTHREAD_START_ROUTINE(IPCSender), nullptr, 0,
|
||||||
|
nullptr);
|
||||||
IPCListener();
|
IPCListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +63,7 @@ int Game(lua_State* L) {
|
|||||||
|
|
||||||
int LuaPop(lua_State* L) {
|
int LuaPop(lua_State* L) {
|
||||||
std::string MSG;
|
std::string MSG;
|
||||||
if (Queue->try_pop(MSG)) {
|
if (RCVQueue->try_pop(MSG)) {
|
||||||
GELua::lua_push_fstring(L, "%s", MSG.c_str());
|
GELua::lua_push_fstring(L, "%s", MSG.c_str());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -78,7 +81,7 @@ void BeamNG::RegisterGEFunctions() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BeamNG::SendIPC(const std::string& Data) {
|
void BeamNG::SendIPC(const std::string& Data) {
|
||||||
IPCToLauncher->send(Data);
|
if (SendQueue->size() < 800 || !RCVQueue->empty()) { SendQueue->push(Data); }
|
||||||
}
|
}
|
||||||
|
|
||||||
void BeamNG::IPCListener() {
|
void BeamNG::IPCListener() {
|
||||||
@ -87,9 +90,23 @@ void BeamNG::IPCListener() {
|
|||||||
IPCFromLauncher->receive();
|
IPCFromLauncher->receive();
|
||||||
if (!IPCFromLauncher->receive_timed_out()) {
|
if (!IPCFromLauncher->receive_timed_out()) {
|
||||||
TimeOuts = 0;
|
TimeOuts = 0;
|
||||||
Queue->push(IPCFromLauncher->msg());
|
RCVQueue->push(IPCFromLauncher->msg());
|
||||||
IPCFromLauncher->confirm_receive();
|
IPCFromLauncher->confirm_receive();
|
||||||
} else TimeOuts++;
|
} 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
|
#define WIN32_LEAN_AND_MEAN
|
||||||
#include "Memory/IPC.h"
|
#include "Memory/IPC.h"
|
||||||
|
#include "Memory/Memory.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
||||||
IPC::IPC(uint32_t ID, size_t Size) noexcept : Size_(Size) {
|
IPC::IPC(uint32_t ID, size_t Size) noexcept : Size_(Size) {
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
#include <wx/tipwin.h>
|
#include <wx/tipwin.h>
|
||||||
#include "Launcher.h"
|
#include "Launcher.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
|
#include <thread>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/////////// Inherit App class ///////////
|
/////////// Inherit App class ///////////
|
||||||
@ -293,7 +294,7 @@ MyAccountFrame::MyAccountFrame() : wxFrame(nullptr, wxID_ANY, "Account Manager",
|
|||||||
wxStaticBitmap *image;
|
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));
|
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)));
|
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));
|
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 ///////////
|
/////////// OnClick Launch Event ///////////
|
||||||
void MyMainFrame::OnClickLaunch(wxCommandEvent& event WXUNUSED(event)) {
|
void MyMainFrame::OnClickLaunch(wxCommandEvent& event WXUNUSED(event)) {
|
||||||
static bool FirstTime = true;
|
static bool FirstTime = true;
|
||||||
/* if (Launcher::EntryThread.joinable()) Launcher::EntryThread.join();
|
if (Launcher::EntryThread.joinable()) Launcher::EntryThread.join();
|
||||||
Launcher::EntryThread = std::thread([&]() {
|
Launcher::EntryThread = std::thread([&]() {
|
||||||
entry();
|
entry();
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||||
txtStatusResult->SetLabelText(wxT("Online"));
|
txtStatusResult->SetLabelText(wxT("Online"));
|
||||||
txtStatusResult->SetForegroundColour("green");
|
txtStatusResult->SetForegroundColour("green");
|
||||||
btnLaunch->Enable();
|
btnLaunch->Enable();
|
||||||
});
|
});
|
||||||
txtStatusResult->SetLabelText(wxT("In-Game"));
|
txtStatusResult->SetLabelText(wxT("In-Game"));
|
||||||
txtStatusResult->SetForegroundColour("purple");
|
txtStatusResult->SetForegroundColour("purple");
|
||||||
btnLaunch->Disable();*/
|
btnLaunch->Disable();
|
||||||
|
|
||||||
if(FirstTime) {
|
if(FirstTime) {
|
||||||
wxMessageBox("Please launch BeamNG.drive manually in case of Steam issues.", "Alert");
|
wxMessageBox("Please launch BeamNG.drive manually in case of Steam issues.", "Alert");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user