Beautify ConnectProtocol a bit.
This commit is contained in:
parent
23c7828506
commit
5574aea293
@ -67,25 +67,22 @@ namespace Components
|
||||
LONG openRes = RegOpenKeyEx(HKEY_CURRENT_USER, "SOFTWARE\\Classes\\iw4x\\shell\\open\\command", 0, KEY_ALL_ACCESS, &hKey);
|
||||
if (openRes == ERROR_SUCCESS)
|
||||
{
|
||||
//Insert Check of the Key Value here, so the protocol will work even if the game was moved.
|
||||
// Check if the game has been moved.
|
||||
openRes = RegQueryValueEx(hKey, 0, 0, 0, reinterpret_cast<BYTE*>(regred), &dwsize);
|
||||
if (openRes == ERROR_SUCCESS)
|
||||
{
|
||||
char* endPt = strstr(regred, "\" \"%1\"");
|
||||
if (endPt != NULL)
|
||||
char* endPtr = strstr(regred, "\" \"%1\"");
|
||||
if (endPtr != NULL)
|
||||
{
|
||||
*endPt = 0;
|
||||
*endPtr = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
char* regredPtr = regred;
|
||||
regredPtr++;
|
||||
|
||||
RegCloseKey(hKey);
|
||||
if (strcmp(regredPtr, ownPth))
|
||||
if (strcmp(regred + 1, ownPth))
|
||||
{
|
||||
openRes = RegDeleteKey(HKEY_CURRENT_USER, "SOFTWARE\\Classes\\iw4x");
|
||||
}
|
||||
@ -179,26 +176,22 @@ namespace Components
|
||||
if (ConnectProtocol::ConnectContainer.Evaluated) return;
|
||||
ConnectProtocol::ConnectContainer.Evaluated = true;
|
||||
|
||||
char* args = GetCommandLine();
|
||||
char* substr = strstr(args, "iw4x://");
|
||||
std::string cmdLine = GetCommandLine();
|
||||
|
||||
if (!substr || substr == args)
|
||||
auto pos = cmdLine.find("iw4x://");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
return;
|
||||
cmdLine = cmdLine.substr(pos + 7);
|
||||
pos = cmdLine.find_first_of("/");
|
||||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
cmdLine = cmdLine.substr(0, pos);
|
||||
}
|
||||
|
||||
substr += 7;
|
||||
char* substr2 = strstr(substr, "/");
|
||||
if (substr2 != NULL)
|
||||
{
|
||||
*substr2 = 0;
|
||||
ConnectProtocol::ConnectContainer.ConnectString = cmdLine;
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ConnectProtocol::ConnectContainer.ConnectString = substr;
|
||||
}
|
||||
|
||||
ConnectProtocol::ConnectProtocol()
|
||||
|
Loading…
Reference in New Issue
Block a user