split studio dll + realistic discord rpc checking
This commit is contained in:
parent
6731681fc4
commit
6cc6725e34
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
#include "Discord.h"
|
||||
|
||||
#ifndef SERVER
|
||||
#ifdef PLAYER
|
||||
|
||||
bool isRunning = false;
|
||||
std::string username;
|
||||
|
|
@ -10,19 +10,6 @@ int placeId;
|
|||
|
||||
void Discord::Initialize(const std::string joinScriptUrl)
|
||||
{
|
||||
// Check if Discord should be enabled by checking if the binary is the client as well as if the binary's containing folder contains a ".nodiscord" file
|
||||
std::string path = Helpers::getModulePath();
|
||||
|
||||
if (fs::path(path).stem() != "TadahPlayer")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (fs::exists(fs::path(path).parent_path() / ".nodiscord"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::pair<bool, std::map<std::string, std::string>> parsed = Helpers::parseURL(joinScriptUrl);
|
||||
|
||||
if (!parsed.first)
|
||||
|
|
@ -42,11 +29,21 @@ void Discord::Initialize(const std::string joinScriptUrl)
|
|||
return;
|
||||
}
|
||||
|
||||
if (query.find("discord") == query.end())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (query["ticket"].empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (query["discord"] == "0")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the username and placeId
|
||||
std::pair<bool, std::string> response = Helpers::httpGet(BASE_URL + std::string("/api/places/information?ticket=" + query["ticket"]));
|
||||
if (!response.first)
|
||||
|
|
|
|||
|
|
@ -6,10 +6,10 @@
|
|||
#include "Server.h"
|
||||
#endif
|
||||
|
||||
bool hasAuthUrlArg = false;
|
||||
bool hasAuthTicketArg = false;
|
||||
bool hasJoinArg = false;
|
||||
bool hasJobIdArg = false;
|
||||
bool hasAuthenticationUrl = false;
|
||||
bool hasAuthenticationTicket = false;
|
||||
bool hasJoinScriptUrl = false;
|
||||
bool hasJobId = false;
|
||||
|
||||
std::wstring authenticationUrl;
|
||||
std::wstring authenticationTicket;
|
||||
|
|
@ -28,19 +28,17 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this)
|
|||
|
||||
CApp* app = reinterpret_cast<CApp*>(CLASSLOCATION_CAPP);
|
||||
|
||||
#ifndef SERVER
|
||||
if (hasAuthUrlArg && hasAuthTicketArg && !authenticationUrl.empty() && !authenticationTicket.empty())
|
||||
if (hasAuthenticationUrl && hasAuthenticationTicket && !authenticationUrl.empty() && !authenticationTicket.empty())
|
||||
{
|
||||
CApp__RobloxAuthenticate(app, nullptr, authenticationUrl.c_str(), authenticationTicket.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
if (hasJoinArg && !joinScriptUrl.empty())
|
||||
if (hasJoinScriptUrl && !joinScriptUrl.empty())
|
||||
{
|
||||
try
|
||||
{
|
||||
CRobloxDoc* document = CRobloxApp__CreateDocument(_this);
|
||||
CWorkspace__ExecUrlScript(document->workspace, joinScriptUrl.c_str(), VARIANTARG(), VARIANTARG(), VARIANTARG(), VARIANTARG(), nullptr);
|
||||
CWorkspace__ExecUrlScript(document->workspace, joinScriptUrl.c_str(), VARIANT(), VARIANT(), VARIANT(), VARIANT(), nullptr);
|
||||
}
|
||||
catch (std::runtime_error)
|
||||
{
|
||||
|
|
@ -48,12 +46,26 @@ BOOL __fastcall CRobloxApp__InitInstance_hook(CRobloxApp* _this)
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef PLAYER
|
||||
if (!hasAuthUrl || !hasAuthTicket || !hasJoinScriptUrl)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
if (!hasAuthUrl || !hasAuthTicket || !hasJobId)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo* _this, void*, const char* pszParam, BOOL bFlag, BOOL bLast)
|
||||
{
|
||||
if (hasJoinArg && joinScriptUrl.empty())
|
||||
if (hasJoinScriptUrl && joinScriptUrl.empty())
|
||||
{
|
||||
int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0);
|
||||
joinScriptUrl.resize(size);
|
||||
|
|
@ -63,13 +75,12 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
|
|||
|
||||
CCommandLineInfo__ParseLast(_this, bLast);
|
||||
|
||||
#ifndef SERVER
|
||||
#ifdef PLAYER
|
||||
Discord::Initialize(Helpers::ws2s(joinScriptUrl));
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef SERVER
|
||||
if (hasAuthUrlArg && authenticationUrl.empty())
|
||||
if (hasAuthenticationUrl && authenticationUrl.empty())
|
||||
{
|
||||
int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0);
|
||||
authenticationUrl.resize(size);
|
||||
|
|
@ -79,7 +90,7 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
|
|||
return;
|
||||
}
|
||||
|
||||
if (hasAuthTicketArg && authenticationTicket.empty())
|
||||
if (hasAuthenticationTicket && authenticationTicket.empty())
|
||||
{
|
||||
int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0);
|
||||
authenticationTicket.resize(size);
|
||||
|
|
@ -88,10 +99,9 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
|
|||
CCommandLineInfo__ParseLast(_this, bLast);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef SERVER
|
||||
if (hasJobIdArg && jobId.empty())
|
||||
if (hasJobId && jobId.empty())
|
||||
{
|
||||
int size = MultiByteToWideChar(CP_ACP, 0, pszParam, strlen(pszParam), nullptr, 0);
|
||||
jobId.resize(size);
|
||||
|
|
@ -102,25 +112,23 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef SERVER
|
||||
if (bFlag && _stricmp(pszParam, "a") == 0)
|
||||
{
|
||||
hasAuthUrlArg = true;
|
||||
hasAuthenticationUrl = true;
|
||||
CCommandLineInfo__ParseLast(_this, bLast);
|
||||
return;
|
||||
}
|
||||
|
||||
if (bFlag && _stricmp(pszParam, "t") == 0)
|
||||
{
|
||||
hasAuthTicketArg = true;
|
||||
hasAuthenticationTicket = true;
|
||||
CCommandLineInfo__ParseLast(_this, bLast);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (bFlag && _stricmp(pszParam, "j") == 0)
|
||||
{
|
||||
hasJoinArg = true;
|
||||
hasJoinScriptUrl = true;
|
||||
CCommandLineInfo__ParseLast(_this, bLast);
|
||||
return;
|
||||
}
|
||||
|
|
@ -128,7 +136,7 @@ void __fastcall CRobloxCommandLineInfo__ParseParam_hook(CRobloxCommandLineInfo*
|
|||
#ifdef SERVER
|
||||
if (bFlag && _stricmp(pszParam, "jobId") == 0)
|
||||
{
|
||||
hasJobIdArg = true;
|
||||
hasJobId = true;
|
||||
CCommandLineInfo__ParseLast(_this, bLast);
|
||||
|
||||
Server::Initialize(jobId);
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
// This is commented out since our CI defines this automatically
|
||||
// #define SERVER
|
||||
// #define PLAYER
|
||||
|
||||
#define BASE_URL "https://tadah.rocks"
|
||||
#define DISCORD_APP_ID 923705431543668736
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
#include "Configuration.h"
|
||||
#include "Hooks/CRoblox.h"
|
||||
|
||||
#ifndef SERVER
|
||||
#ifdef PLAYER
|
||||
|
||||
class Discord {
|
||||
public:
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||
{
|
||||
curl_global_cleanup();
|
||||
|
||||
#ifndef SERVER
|
||||
#ifdef PLAYER
|
||||
Discord::Cleanup();
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue