Skip to content

Commit

Permalink
Added app_blacklist option for Steam
Browse files Browse the repository at this point in the history
  • Loading branch information
acidicoala committed Apr 17, 2021
1 parent cc58689 commit cbda647
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 13 deletions.
1 change: 1 addition & 0 deletions Common/src/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ void from_json(const json& j, SteamPlatform& p)
from_json(j, (Platform&) p);
j["unlock_shared_library"].get_to(p.unlock_shared_library);
j["unlock_dlc"].get_to(p.unlock_dlc);
j["app_blacklist"].get_to(p.app_blacklist);
}

NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE(Platforms, Steam, EpicGames, Origin, EADesktop, UplayR1)
Expand Down
1 change: 1 addition & 0 deletions Common/src/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ struct SteamPlatform : Platform
{
bool unlock_dlc = true;
bool unlock_shared_library = false;
vector<string> app_blacklist;
};

struct Platforms
Expand Down
2 changes: 1 addition & 1 deletion Common/src/constants.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

constexpr auto VERSION = "1.5.1";
constexpr auto VERSION = "1.5.2";

constexpr auto INTEGRATION_64 = L"Integration64.dll";
constexpr auto INTEGRATION_32 = L"Integration32.dll";
Expand Down
5 changes: 4 additions & 1 deletion Config.jsonc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"config_version": 5, // DO NOT EDIT THIS VALUE
"config_version": 6, // DO NOT EDIT THIS VALUE
"log_level": "debug",
"platforms": {
"Steam": {
Expand All @@ -8,6 +8,9 @@
"replicate": false,
"unlock_dlc": true,
"unlock_shared_library": false,
"app_blacklist": [
"976310" // Mortal Kombat 11
],
"blacklist": [ // Get App ID from SteamDB
"22618", // Alien Breed: Impact - PL Check [Do not force polish language]
"67379" // Darkness II Low Violence [Do not censor violence]
Expand Down
2 changes: 1 addition & 1 deletion IntegrationWizard/src/winmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void askForAction(
LR"(🌐 <a href="{0}">Open latest release page</a> ({0})
📂 <a href="{1}">Open config directory</a> ({1}))"
, L"https://github.com/acidicoala/Koalageddon/releases", getConfigPath().parent_path().wstring());
, L"https://github.com/acidicoala/Koalageddon/releases/latest", getConfigPath().parent_path().wstring());

tdc.hInstance = hInstance;
tdc.dwFlags = TDF_ALLOW_DIALOG_CANCELLATION | TDF_USE_COMMAND_LINKS | TDF_EXPAND_FOOTER_AREA | TDF_ENABLE_HYPERLINKS;
Expand Down
55 changes: 46 additions & 9 deletions Unlocker/src/platforms/steam_client/steam_client_hooks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,74 @@
#include "Logger.h"
#include "steam_client_hooks.h"

#define GET_ORIGINAL_FUNC(NAME) PLH::FnCast(BasePlatform::trampolineMap[#NAME], NAME)

// Utility functions

auto isBlacklistedInSteam(int dlcID)
{
return vectorContains(config->platformRefs.Steam.blacklist, std::to_string(dlcID));
}

auto isAppBlacklisted(int appID)
{
return vectorContains(config->platformRefs.Steam.app_blacklist, std::to_string(appID));
}

/// DLC Unlocking hooks

HOOK_SPEC(bool) IsAppDLCEnabled(PARAMS(int appID, int dlcID))
{
auto enabled = !isBlacklistedInSteam(dlcID);
bool enabled;

if(isAppBlacklisted(appID))
{
logger->debug("IsAppDLCEnabled -> Blacklisted AppID. Redirecting to original.");
static auto original = GET_ORIGINAL_FUNC(IsAppDLCEnabled);
enabled = original(ARGS(appID, dlcID));
}
else
{
enabled = !isBlacklistedInSteam(dlcID);
}

logger->debug("IsAppDLCEnabled -> AppID: {}, DLC ID: {}. Enabled: {}", appID, dlcID, enabled);
return enabled;
}

HOOK_SPEC(bool) IsSubscribedApp(PARAMS(int appID))
{
auto subscribed = !isBlacklistedInSteam(appID);
bool subscribed;
if(isAppBlacklisted(appID))
{
logger->debug("GetDLCDataByIndex -> Blacklisted AppID. Redirecting to original.");
static auto original = GET_ORIGINAL_FUNC(IsSubscribedApp);
subscribed = original(ARGS(appID));
}
else
{
subscribed = !isBlacklistedInSteam(appID);
}

logger->debug("IsSubscribedApp -> AppID: {}. Subscribed: {}", appID, subscribed);
return subscribed;
}

HOOK_SPEC(bool) GetDLCDataByIndex(PARAMS(int appID, int index, int* pDlcID , bool* pbAvailable, char* pchName, int bufferSize))
HOOK_SPEC(bool) GetDLCDataByIndex(PARAMS(int appID, int index, int* pDlcID, bool* pbAvailable, char* pchName, int bufferSize))
{
auto result = PLH::FnCast(
BasePlatform::trampolineMap[__func__],
GetDLCDataByIndex
)(ARGS(appID, index, pDlcID, pbAvailable, pchName, bufferSize));
static auto original = GET_ORIGINAL_FUNC(GetDLCDataByIndex);
auto result = original(ARGS(appID, index, pDlcID, pbAvailable, pchName, bufferSize));

logger->info("GetDLCDataByIndex -> index: {}, DLC ID: {}, available: {}, name: '{}'", index, *pDlcID, *pbAvailable, pchName);
if(isAppBlacklisted(appID))
{
logger->debug("GetDLCDataByIndex -> Blacklisted AppID. Skipping any modifications.");
}
else if(result)
{
*pbAvailable = !isBlacklistedInSteam(*pDlcID);
}

*pbAvailable = !isBlacklistedInSteam(*pDlcID);
logger->info("GetDLCDataByIndex -> index: {}, DLC ID: {}, available: {}, name: '{}'", index, *pDlcID, *pbAvailable, pchName);

return result;
}
Expand Down
2 changes: 1 addition & 1 deletion inno_setup.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Koalageddon"
#define MyAppVersion "1.5.1"
#define MyAppVersion "1.5.2"
#define MyAppPublisher "acidicoala"
#define MyAppURL "https://github.com/acidicoala/Koalageddon"
#define MyAppExeName "IntegrationWizard32.exe"
Expand Down

0 comments on commit cbda647

Please sign in to comment.