LS-RP Mode

This commit is contained in:
Silent 2019-03-06 21:51:21 +01:00
parent cabd0c999a
commit 6b2ad034cb
No known key found for this signature in database
GPG key ID: AE53149BB0C45AF1

View file

@ -5,6 +5,7 @@
#include <Shlwapi.h> #include <Shlwapi.h>
#include <ShlObj.h> #include <ShlObj.h>
#include <ShellAPI.h> #include <ShellAPI.h>
#include <cinttypes>
#include "ScriptSA.h" #include "ScriptSA.h"
#include "GeneralSA.h" #include "GeneralSA.h"
@ -71,6 +72,60 @@ namespace ModCompat
FreeLibrary( stdStreamModule ); FreeLibrary( stdStreamModule );
return aware; return aware;
} }
bool LSRPMode = false;
void DetectPlayingOnLSRP()
{
struct IPv4
{
uint8_t ip[4];
uint16_t port;
bool operator== ( const IPv4& right )
{
return std::make_tuple( this->ip[0], this->ip[1], this->ip[2], this->ip[3], this->port ) == std::make_tuple( right.ip[0], right.ip[1], right.ip[2], right.ip[3], right.port );
}
};
constexpr IPv4 LSRP = { 149, 56, 123, 148, 7777 };
IPv4 myIP = {};
// Obtain IP and check if it's LS-RP
int numArgs = 0;
LPWSTR* cmdLine = CommandLineToArgvW( GetCommandLineW(), &numArgs );
if ( cmdLine != nullptr )
{
for ( auto it = cmdLine + 1, end = cmdLine + numArgs; it != end; ++it )
{
if ( _wcsicmp( *it, L"-h" ) == 0 )
{
auto ipIt = std::next( it );
if ( ipIt != end )
{
swscanf_s( *ipIt, L"%" SCNu8 ".%" SCNu8 ".%" SCNu8 ".%" SCNu8, &myIP.ip[0], &myIP.ip[1], &myIP.ip[2], &myIP.ip[3] );
it = ipIt;
}
continue;
}
if ( _wcsicmp( *it, L"-p") == 0 )
{
auto portIt = std::next( it );
if ( portIt != end )
{
swscanf_s( *portIt, L"%" SCNu16 , &myIP.port );
it = portIt;
}
continue;
}
}
LocalFree( cmdLine );
}
LSRPMode = myIP == LSRP;
}
} }
#pragma warning(disable:4733) #pragma warning(disable:4733)
@ -2370,6 +2425,11 @@ BOOL InjectDelayedPatches_10()
const bool bSARender = moduleList.Get(L"SARender") != nullptr; const bool bSARender = moduleList.Get(L"SARender") != nullptr;
const bool bOutfit = moduleList.Get(L"outfit") != nullptr; const bool bOutfit = moduleList.Get(L"outfit") != nullptr;
if ( bSAMP )
{
ModCompat::DetectPlayingOnLSRP();
}
const HMODULE skygfxModule = moduleList.Get( L"skygfx" ); const HMODULE skygfxModule = moduleList.Get( L"skygfx" );
const HMODULE modloaderModule = moduleList.Get( L"modloader" ); const HMODULE modloaderModule = moduleList.Get( L"modloader" );
@ -2379,6 +2439,13 @@ BOOL InjectDelayedPatches_10()
const bool bHasDebugMenu = DebugMenuLoad(); const bool bHasDebugMenu = DebugMenuLoad();
#ifdef _DEBUG
if ( bHasDebugMenu )
{
DebugMenuAddVar( "SilentPatch", "LS-RP Mode", &ModCompat::LSRPMode, nullptr );
}
#endif
if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 ) if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 )
{ {
// PS2 sun - more // PS2 sun - more
@ -2780,6 +2847,11 @@ BOOL InjectDelayedPatches_11()
bool bSARender = moduleList.Get(L"SARender") != nullptr; bool bSARender = moduleList.Get(L"SARender") != nullptr;
const bool bOutfit = moduleList.Get(L"outfit") != nullptr; const bool bOutfit = moduleList.Get(L"outfit") != nullptr;
if ( bSAMP )
{
ModCompat::DetectPlayingOnLSRP();
}
ReadRotorFixExceptions(wcModulePath); ReadRotorFixExceptions(wcModulePath);
if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 ) if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 )
@ -2950,6 +3022,11 @@ BOOL InjectDelayedPatches_Steam()
bool bSARender = moduleList.Get(L"SARender") != nullptr; bool bSARender = moduleList.Get(L"SARender") != nullptr;
const bool bOutfit = moduleList.Get(L"outfit") != nullptr; const bool bOutfit = moduleList.Get(L"outfit") != nullptr;
if ( bSAMP )
{
ModCompat::DetectPlayingOnLSRP();
}
ReadRotorFixExceptions(wcModulePath); ReadRotorFixExceptions(wcModulePath);
if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 ) if ( GetPrivateProfileIntW(L"SilentPatch", L"SunSizeHack", -1, wcModulePath) == 1 )