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
Robb6d 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
AngryBeaver6d 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
Robb6d ago
this mod's code is Very Creative
AngryBeaver
AngryBeaver6d ago
but solid F's is a -1, so I usually look for botched math as a where things are coming from
Robb
Robb6d 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
Robb6d ago
it seems like the cause of the crash is the !self->mManufacturingButton->IsButtonHeld() check
Robb
Robb6d 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