2023-12-10 20:10:58 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace MapMarkerPlacement
|
|
|
|
{
|
|
|
|
struct IsFastTravelEnabled
|
|
|
|
{
|
|
|
|
static bool thunk(RE::PlayerCharacter* a_this, bool a_hideNotification)
|
|
|
|
{
|
|
|
|
const auto enabled = func(a_this, a_hideNotification);
|
|
|
|
if (!enabled) {
|
|
|
|
if (const auto mapMenu = RE::UI::GetSingleton()->GetMenu<RE::MapMenu>(); mapMenu) {
|
|
|
|
mapMenu->PlaceMarker();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return enabled;
|
|
|
|
}
|
|
|
|
static inline REL::Relocation<decltype(thunk)> func;
|
|
|
|
};
|
|
|
|
|
2023-12-11 01:44:41 +00:00
|
|
|
// Based on powerofthree's Tweaks 1.8.1 by powerofthree (MIT)
|
2023-12-10 20:10:58 +00:00
|
|
|
void InstallPlacementDiscoveredFix()
|
|
|
|
{
|
|
|
|
// Place a marker, if a location has been discovered and fast travel is disabled
|
|
|
|
|
|
|
|
REL::Relocation<std::uintptr_t> target{ REL::RelocationID(52208, 53095), REL::Relocate(0x2C5, 0x328, 0x358) };
|
|
|
|
auto& trampoline = SKSE::GetTrampoline();
|
|
|
|
|
|
|
|
SKSE::AllocTrampoline(14);
|
|
|
|
IsFastTravelEnabled::func = trampoline.write_call<5>(target.address(), IsFastTravelEnabled::thunk);
|
|
|
|
|
|
|
|
logger::info("Applied discovered map marker placement fix"sv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void InstallPlacementUndiscoveredFix()
|
|
|
|
{
|
|
|
|
// Place a marker without asking, if a location isn't discovered yet
|
|
|
|
|
|
|
|
REL::Relocation<std::uintptr_t> target2{ REL::RelocationID(52208, 53095), REL::Relocate(0x17A, 0x183) };
|
2023-12-18 13:04:00 +00:00
|
|
|
std::uint8_t code[] = { 0xB0, 0x01, REL::NOP, REL::NOP, REL::NOP };
|
|
|
|
REL::safe_write(target2.address(), code, sizeof(code));
|
2023-12-10 20:10:58 +00:00
|
|
|
|
|
|
|
logger::info("Applied undiscovered map marker placement fix"sv);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Install()
|
|
|
|
{
|
|
|
|
if (GetLoadInterface()->GetPluginInfo("DisableFastTravel")) {
|
|
|
|
logger::info("Detected Disable Fast Travel SKSE, skipping discovered map marker placement fix");
|
|
|
|
} else if (!GetLoadInterface()->GetPluginInfo("po3_Tweaks")) {
|
|
|
|
InstallPlacementDiscoveredFix();
|
|
|
|
} else if (std::filesystem::exists("Data/SKSE/Plugins/po3_Tweaks.ini")) {
|
|
|
|
CSimpleIniA ini;
|
|
|
|
ini.SetMultiKey(false);
|
|
|
|
ini.LoadFile("Data/SKSE/Plugins/po3_Tweaks.ini");
|
|
|
|
if (!ini.GetBoolValue("Fixes", "Map Marker Placement Fix", false)) {
|
|
|
|
logger::info("Detected po3's Tweaks with disabled discovered Map Marker Placement Fix");
|
|
|
|
InstallPlacementDiscoveredFix();
|
|
|
|
} else {
|
|
|
|
logger::info("Detected po3's Tweaks with enabled discovered Map Marker Placement Fix");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
InstallPlacementUndiscoveredFix();
|
|
|
|
}
|
|
|
|
}
|