Skip to content

Commit 73c2473

Browse files
committed
version 5.15
1 parent 7281f44 commit 73c2473

File tree

3 files changed

+36
-14
lines changed

3 files changed

+36
-14
lines changed

JG/JohnnyGuitarNVSE.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ HMODULE JohnnyHandle;
4949
_CaptureLambdaVars CaptureLambdaVars;
5050
_UncaptureLambdaVars UncaptureLambdaVars;
5151
NiTMap<const char*, TESForm*>** g_gameFormEditorIDsMap = reinterpret_cast<NiTMap<const char*, TESForm*>**>(0x11C54C8);
52-
#define JG_VERSION 514
52+
#define JG_VERSION 515
5353
void MessageHandler(NVSEMessagingInterface::Message* msg) {
5454
switch (msg->type) {
5555
case NVSEMessagingInterface::kMessage_NewGame:
@@ -105,7 +105,6 @@ void MessageHandler(NVSEMessagingInterface::Message* msg) {
105105
ResetVanityWheel();
106106
}
107107
}
108-
109108
}
110109

111110
break;
@@ -120,6 +119,7 @@ void MessageHandler(NVSEMessagingInterface::Message* msg) {
120119
g_currentSky = (Sky**)0x11DEA20;
121120
g_gameTimeGlobals = (GameTimeGlobals*)0x11DE7B8;
122121
g_VATSCameraData = (VATSCameraData*)0x11F2250;
122+
g_mapAllForms = *(NiTPointerMap<TESForm>**)0x11C54C0;
123123
g_initialTickCount = GetTickCount();
124124
DumpModules();
125125
Console_Print("JohnnyGuitar version: %.2f", ((float)JG_VERSION / 100));

JG/JohnnyGuitarNVSE.h

Lines changed: 33 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ DataHandler* g_dataHandler = nullptr;
5757
BSAudioManager* g_audioManager = nullptr;
5858
GameTimeGlobals* g_gameTimeGlobals = nullptr;
5959
StatsMenu* g_statsMenu = nullptr;
60+
NiTPointerMap<TESForm>* g_mapAllForms = nullptr;
6061
UInt8 recalculateStatFilters = 0;
6162
Sky** g_currentSky = nullptr;
6263
void(__thiscall* OriginalBipedModelUpdateWeapon)(ValidBip01Names*, TESObjectWEAP*, int) = (void(__thiscall*)(ValidBip01Names*, TESObjectWEAP*, int)) 0x4AB400;
@@ -429,20 +430,35 @@ namespace hk_BarterHook {
429430

430431

431432
template <uintptr_t a_addr>
432-
class hk_SleepOneInterCall {
433+
class hk_QuestObjectiveIsDisplayedCall {
433434
private:
434-
static inline uintptr_t hookCall = a_addr;
435+
static inline uintptr_t hPreviousAddressHook = 0;
435436
public:
436-
static uintptr_t __cdecl hk_SleepOneInterCallHook() {
437-
auto res = CdeclCall<uintptr_t>(hookCall);
438-
Sleep(1);
439-
return res;
440-
}
441-
hk_SleepOneInterCall() {
442-
uintptr_t hk_hookPoint = hookCall;
443-
hookCall = *(uintptr_t*)(hk_hookPoint + 1);
444-
SafeWrite32((hk_hookPoint + 1), (uintptr_t)hk_SleepOneInterCallHook);
437+
static uintptr_t __thiscall hookObjectiveDisplayed(BGSQuestObjective* pObjective) {
438+
DWORD result = 0;
439+
if (hPreviousAddressHook)
440+
{
441+
result = ThisStdCall<uintptr_t>(hPreviousAddressHook, pObjective);
442+
}
443+
if (result)
444+
{
445+
result = pObjective->status & BGSQuestObjective::eQObjStatus_displayed;
446+
auto questObjectiveDisplayStr = pObjective->displayText.CStr();
447+
auto questDisplayStr = pObjective->quest->GetFullName()->name.CStr();
448+
if (!(questObjectiveDisplayStr && questDisplayStr && *questObjectiveDisplayStr && *questDisplayStr))
449+
{
450+
result = 0;
451+
}
452+
}
445453

454+
return result;
455+
}
456+
hk_QuestObjectiveIsDisplayedCall() {
457+
if (*(char*)a_addr == 0xE9) //there's a jump here, so detour it
458+
{
459+
hPreviousAddressHook = GetRelJumpAddr(a_addr);
460+
}
461+
WriteRelJump((a_addr), (uintptr_t)hookObjectiveDisplayed);
446462
}
447463

448464
};
@@ -1637,6 +1653,11 @@ bool __cdecl IsCurrentFurnitureRefHook(TESObjectREFR* apRef, void* apComparedRef
16371653
return true;
16381654
}
16391655

1656+
1657+
1658+
1659+
1660+
16401661
void HandleFixes() {
16411662
// use available ammo in inventory instead of NULL when default ammo isn't present
16421663
WriteRelJump(0x70809E, (UInt32)InventoryAmmoHook);
@@ -1721,6 +1742,7 @@ void HandleFixes() {
17211742
NPCAccuracy::CreateHook();
17221743
hk_DialogueTopicResponseManageHook::InitHooks();
17231744
hk_EmotionOverrideUndo< 0x0617D59>();
1745+
hk_QuestObjectiveIsDisplayedCall<0x05A5E70>();
17241746
}
17251747

17261748
void HandleIniOptions() {

JG/misc/EditorIDs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ const char* TESForm::hk_GetName() {
7474
std::lock_guard<std::mutex> lock(g_NameMapLock);
7575
auto itr = g_EditorNameMap.find(GetId());
7676

77-
if (itr != g_EditorNameMap.end())
77+
if (itr != g_EditorNameMap.end() && *itr->second) //add failsafe
7878
return *itr->second;
7979

8080
// By default the game returns an empty string

0 commit comments

Comments
 (0)