Skip to content

Commit

Permalink
Add antialiasing control
Browse files Browse the repository at this point in the history
  • Loading branch information
maximegmd committed Dec 16, 2020
1 parent ebd3262 commit fb5e911
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions src/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ Options::Options(HMODULE aModule)
this->PatchRemovePedestrians = config.value("remove_pedestrians", this->PatchRemovePedestrians);
this->PatchSkipStartMenu = config.value("skip_start_menu", this->PatchSkipStartMenu);
this->PatchAsyncCompute = config.value("disable_async_compute", this->PatchAsyncCompute);
this->PatchAntialiasing = config.value("disable_antialiasing", this->PatchAntialiasing);
}

nlohmann::json config;
Expand All @@ -64,6 +65,7 @@ Options::Options(HMODULE aModule)
config["remove_pedestrians"] = this->PatchRemovePedestrians;
config["skip_start_menu"] = this->PatchSkipStartMenu;
config["disable_async_compute"] = this->PatchAsyncCompute;
config["disable_antialiasing"] = this->PatchAntialiasing;

std::ofstream o(configPath);
o << config.dump(4) << std::endl;
Expand Down
1 change: 1 addition & 0 deletions src/Options.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ struct Options
bool PatchUnlockMenu{ false };
bool PatchRemovePedestrians{ false };
bool PatchAsyncCompute{ false };
bool PatchAntialiasing{ false };
bool PatchSkipStartMenu{ true };
float CPUMemoryPoolFraction{ 0.5f };
float GPUMemoryPoolFraction{ 1.f };
Expand Down
6 changes: 3 additions & 3 deletions src/dllmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void StringInitializerPatch(Image* apImage);
void SpinLockPatch(Image* apImage);
void StartScreenPatch(Image* apImage);
void RemovePedsPatch(Image* apImage);
void AsyncComputePatch(Image* apImage);
void OptionsPatch(Image* apImage);

void Initialize(HMODULE mod)
{
Expand Down Expand Up @@ -56,8 +56,8 @@ void Initialize(HMODULE mod)
if(options.PatchRemovePedestrians)
RemovePedsPatch(&image);

if(options.PatchAsyncCompute)
AsyncComputePatch(&image);
if(options.PatchAsyncCompute || options.PatchAntialiasing)
OptionsPatch(&image);

spdlog::default_logger()->flush();
}
Expand Down
20 changes: 12 additions & 8 deletions src/async_compute_patch.cpp → src/options_patch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,28 @@ static_assert(offsetof(GameProperty, pBoolean) == 0x30);

bool HookGamePropertyGetBoolean(GameProperty* apThis, uint8_t* apVariable, uint8_t aKind)
{
auto* pLocation = apThis->pBoolean;
if (!pLocation)
auto* pVariable = apThis->pBoolean;
if (!pVariable)
return false;

if (strcmp(apThis->pCategory, "Rendering/AsyncCompute") == 0)
if (Options::Get().PatchAsyncCompute && strcmp(apThis->pCategory, "Rendering/AsyncCompute") == 0)
{
*pLocation = false;
*pVariable = false;
}
else if (Options::Get().PatchAntialiasing && strcmp(apThis->pName, "Antialiasing") == 0)
{
*pVariable = false;
}

if (aKind != apThis->kind)
return false;

*apVariable = *pLocation;
*apVariable = *pVariable;

return true;
}

void AsyncComputePatch(Image* apImage)
void OptionsPatch(Image* apImage)
{
uint8_t* pLocation = FindSignature(apImage->pTextStart, apImage->pTextEnd,
{ 0x44, 0x3A, 0x41, 0x28, 0x75, 0x11, 0x48, 0x8B, 0x41, 0x30, 0x48, 0x85, 0xC0 });
Expand All @@ -64,8 +68,8 @@ void AsyncComputePatch(Image* apImage)
pLocation[11] = 0xE0;
VirtualProtect(pLocation, 32, oldProtect, nullptr);

spdlog::info("\tAsync compute patch: success");
spdlog::info("\tHidden options patch: success");
}
else
spdlog::info("\tAsync compute patch: failed");
spdlog::info("\tHidden options patch: failed");
}

1 comment on commit fb5e911

@bscout9956
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any possibility of adding this to menus?

Please sign in to comment.