Hook crashing on save load in unexpected manner

Mod: https://github.com/budak7273/FasterManualCraftingRedux troublesome hook (narrowed down to this via commenting the others out)
SUBSCRIBE_METHOD_VIRTUAL(UFGWorkBench::TickComponent, workBenchCDO, [](auto& scope, UFGWorkBench* self, float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) {
if (self->mManufacturingButton && !self->mManufacturingButton->IsButtonHeld())
GetProducedCountRef(self) = 0;
});
SUBSCRIBE_METHOD_VIRTUAL(UFGWorkBench::TickComponent, workBenchCDO, [](auto& scope, UFGWorkBench* self, float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) {
if (self->mManufacturingButton && !self->mManufacturingButton->IsButtonHeld())
GetProducedCountRef(self) = 0;
});
crash attached
Solution:
it seems like the cause of the crash is the !self->mManufacturingButton->IsButtonHeld() check
Jump to solution
7 Replies
Robb
RobbOP3mo ago
not sure why MovementComponent is even invovled in the crash, maybe the hook is being too generous? this is one of the ones Turtlefight set up ages ago so I don't quite follow what it's doing
AngryBeaver
AngryBeaver3mo ago
it could be that the player movmeent and interaction are linked but uh this line reeks of code smell GetProducedCountRef(self) = 0; even if it's right I hate it ❤️
Robb
RobbOP3mo ago
this mod's code is Very Creative
AngryBeaver
AngryBeaver3mo ago
but solid F's is a -1, so I usually look for botched math as a where things are coming from
Robb
RobbOP3mo ago
uint16& FFasterManualCraftingReduxModule::GetProducedCountRef(UFGWorkBench* bench) {
bool* offset = &bench->mIsFatigueEnabled;
return *reinterpret_cast<uint16*>(offset + 1);
}
uint16& FFasterManualCraftingReduxModule::GetProducedCountRef(UFGWorkBench* bench) {
bool* offset = &bench->mIsFatigueEnabled;
return *reinterpret_cast<uint16*>(offset + 1);
}
yes, it is reusing extra space in that bool (unreal allocates a lot of space for bools) to store an int I have been taking the "don't touch what isn't broken" approach to maintaining this mod
Solution
Robb
Robb3mo ago
it seems like the cause of the crash is the !self->mManufacturingButton->IsButtonHeld() check
Robb
RobbOP3mo ago
ehhh, the mod still moooostly works without that check. it just means that pausing crafting no longer resets the speed bonus I have found other things that don't crash but also don't work and am partially questioning how the mod worked in the first place... I think I'll just release it as is. I think this breaking will enable people to keep their speed bonus when depot crafting something that trickles in, whereas that wouldn't have worked if this hadn't broken
Want results from more Discord servers?
Add your server