Merge pull request #626 from diamante0018/fix/main-checks
[Main]: Improve error message
This commit is contained in:
commit
fb68e59e08
@ -56,7 +56,7 @@ namespace Components
|
|||||||
|
|
||||||
UIScript::Add("visitWebsite", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
|
UIScript::Add("visitWebsite", []([[maybe_unused]] const UIScript::Token& token, [[maybe_unused]] const Game::uiInfo_s* info)
|
||||||
{
|
{
|
||||||
Utils::OpenUrl(Utils::Cache::GetStaticUrl(""));
|
Utils::OpenUrl(Utils::Cache::GetUrl(Utils::Cache::Urls[1], {}));
|
||||||
});
|
});
|
||||||
|
|
||||||
Localization::Set("MPUI_CHANGELOG_TEXT", "Loading...");
|
Localization::Set("MPUI_CHANGELOG_TEXT", "Loading...");
|
||||||
|
@ -50,20 +50,6 @@ namespace Components
|
|||||||
this->lastRequest.reset();
|
this->lastRequest.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Node::LoadNodeRemotePreset()
|
|
||||||
{
|
|
||||||
std::string nodes = Utils::Cache::GetFile("/iw4/nodes.txt");
|
|
||||||
if (nodes.empty()) return;
|
|
||||||
|
|
||||||
auto nodeList = Utils::String::Split(nodes, '\n');
|
|
||||||
for (auto& node : nodeList)
|
|
||||||
{
|
|
||||||
Utils::String::Replace(node, "\r", "");
|
|
||||||
Utils::String::Trim(node);
|
|
||||||
Node::Add(node);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Node::LoadNodePreset()
|
void Node::LoadNodePreset()
|
||||||
{
|
{
|
||||||
Proto::Node::List list;
|
Proto::Node::List list;
|
||||||
@ -350,14 +336,6 @@ namespace Components
|
|||||||
|
|
||||||
Scheduler::OnGameInitialized(loadNodes, Scheduler::Pipeline::MAIN);
|
Scheduler::OnGameInitialized(loadNodes, Scheduler::Pipeline::MAIN);
|
||||||
|
|
||||||
Network::OnStart([]
|
|
||||||
{
|
|
||||||
std::thread([]
|
|
||||||
{
|
|
||||||
Node::LoadNodeRemotePreset();
|
|
||||||
}).detach();
|
|
||||||
});
|
|
||||||
|
|
||||||
Command::Add("listnodes", [](Command::Params*)
|
Command::Add("listnodes", [](Command::Params*)
|
||||||
{
|
{
|
||||||
Logger::Print("Nodes: {}\n", Node::Nodes.size());
|
Logger::Print("Nodes: {}\n", Node::Nodes.size());
|
||||||
|
@ -41,8 +41,6 @@ namespace Components
|
|||||||
static void RunFrame();
|
static void RunFrame();
|
||||||
static void Synchronize();
|
static void Synchronize();
|
||||||
|
|
||||||
static void LoadNodeRemotePreset();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::recursive_mutex Mutex;
|
static std::recursive_mutex Mutex;
|
||||||
static std::vector<Entry> Nodes;
|
static std::vector<Entry> Nodes;
|
||||||
|
@ -55,24 +55,27 @@ BOOL APIENTRY DllMain(HINSTANCE /*hinstDLL*/, DWORD fdwReason, LPVOID /*lpvReser
|
|||||||
|
|
||||||
#ifndef DISABLE_BINARY_CHECK
|
#ifndef DISABLE_BINARY_CHECK
|
||||||
// Ensure we're working with our desired binary
|
// Ensure we're working with our desired binary
|
||||||
auto* _module = reinterpret_cast<char*>(0x400000);
|
|
||||||
auto hash1 = Utils::Cryptography::JenkinsOneAtATime::Compute(_module + 0x1000, 0x2D531F); // .text
|
#ifndef DEBUG_BINARY_CHECK
|
||||||
auto hash2 = Utils::Cryptography::JenkinsOneAtATime::Compute(_module + 0x2D75FC, 0xBDA04); // .rdata
|
const auto* binary = reinterpret_cast<const char*>(0x6F9358);
|
||||||
if ((hash1 != 0x54684DBE
|
if (binary == nullptr || std::strcmp(binary, BASEGAME_NAME) != 0)
|
||||||
#ifdef DEBUG
|
|
||||||
&& hash1 != 0x8AADE716
|
|
||||||
#endif
|
#endif
|
||||||
) || hash2 != 0x8030ec53)
|
|
||||||
{
|
{
|
||||||
|
MessageBoxA(nullptr,
|
||||||
|
"Failed to load game binary.\n"
|
||||||
|
"You did not install the iw4x-rawfiles!\n"
|
||||||
|
"Please use the XLabs launcher to run the game. For support please visit https://xlabs.dev/support_iw4x_client",
|
||||||
|
"ERROR",
|
||||||
|
MB_ICONERROR
|
||||||
|
);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DWORD oldProtect;
|
|
||||||
VirtualProtect(_module + 0x1000, 0x2D6000, PAGE_EXECUTE_READ, &oldProtect); // Protect the .text segment
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef DEBUG_BINARY_CHECK
|
||||||
// Install entry point hook
|
// Install entry point hook
|
||||||
Utils::Hook(0x6BAC0F, Main::EntryPoint, HOOK_JUMP).install()->quick();
|
Utils::Hook(0x6BAC0F, Main::EntryPoint, HOOK_JUMP).install()->quick();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else if (fdwReason == DLL_PROCESS_DETACH)
|
else if (fdwReason == DLL_PROCESS_DETACH)
|
||||||
{
|
{
|
||||||
|
@ -173,6 +173,7 @@ using namespace std::literals;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define BASEGAME "iw4x"
|
#define BASEGAME "iw4x"
|
||||||
|
#define BASEGAME_NAME "iw4mp_ceg.exe"
|
||||||
#define CLIENT_CONFIG "iw4x_config.cfg"
|
#define CLIENT_CONFIG "iw4x_config.cfg"
|
||||||
|
|
||||||
// Resource stuff
|
// Resource stuff
|
||||||
|
@ -11,11 +11,6 @@ namespace Utils
|
|||||||
std::string Cache::ValidUrl;
|
std::string Cache::ValidUrl;
|
||||||
std::mutex Cache::CacheMutex;
|
std::mutex Cache::CacheMutex;
|
||||||
|
|
||||||
std::string Cache::GetStaticUrl(const std::string& path)
|
|
||||||
{
|
|
||||||
return Urls[0] + path;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Cache::GetUrl(const std::string& url, const std::string& path)
|
std::string Cache::GetUrl(const std::string& url, const std::string& path)
|
||||||
{
|
{
|
||||||
return url + path;
|
return url + path;
|
||||||
|
@ -5,13 +5,13 @@ namespace Utils
|
|||||||
class Cache
|
class Cache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::string GetStaticUrl(const std::string& path);
|
static const char* Urls[];
|
||||||
|
|
||||||
|
static std::string GetUrl(const std::string& url, const std::string& path);
|
||||||
static std::string GetFile(const std::string& path, int timeout = 5000, const std::string& useragent = "IW4x");
|
static std::string GetFile(const std::string& path, int timeout = 5000, const std::string& useragent = "IW4x");
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::mutex CacheMutex;
|
static std::mutex CacheMutex;
|
||||||
static const char* Urls[];
|
|
||||||
static std::string ValidUrl;
|
static std::string ValidUrl;
|
||||||
static std::string GetUrl(const std::string& url, const std::string& path);
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ namespace Utils
|
|||||||
return Compute(data.data(), data.size());
|
return Compute(data.data(), data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int JenkinsOneAtATime::Compute(const char *key, size_t len)
|
unsigned int JenkinsOneAtATime::Compute(const char *key, std::size_t len)
|
||||||
{
|
{
|
||||||
unsigned int hash, i;
|
unsigned int hash, i;
|
||||||
for (hash = i = 0; i < len; ++i)
|
for (hash = i = 0; i < len; ++i)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user