Skip to content

Commit

Permalink
🐛 fix deadlock when retrieving applied glp
Browse files Browse the repository at this point in the history
  • Loading branch information
Roms1383 committed Apr 28, 2024
1 parent c55678f commit ecf2297
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 12 additions & 1 deletion scripts/Addicted/Effectors.reds
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,25 @@ module Addicted
import Addicted.System.AddictedSystem
import Addicted.Utils.F

// prevents deadlock on System.CalculateConsumptionModifier (GLPS.GetAppliedPackages)
public class ContraindicationCallback extends DelayCallback {
public let system: wref<AddictedSystem>;
public func Call() -> Void {
this.system.OnContraindication(ItemID.FromTDBID(t"Items.ripperdoc_med_contraindication"));
}
}

public class IncreaseNeuroBlockerEffector extends Effector {
protected func ActionOn(owner: ref<GameObject>) -> Void {
let system = AddictedSystem.GetInstance(owner.GetGame());
let scheduler = GameInstance.GetDelaySystem(owner.GetGame());
// use a fake ID to differentiate, see:
// - Generic.IsNeuroBlocker
// - Generic.IsContraindicated
// - Consumptions.Items
// - NeuroBlockerTweaks
system.OnContraindication(ItemID.FromTDBID(t"Items.ripperdoc_med_contraindication"));
let callback: ref<ContraindicationCallback> = new ContraindicationCallback();
callback.system = system;
scheduler.DelayCallbackNextFrame(callback);
}
}
4 changes: 1 addition & 3 deletions scripts/Addicted/System.reds
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,7 @@ public class AddictedSystem extends ScriptableSystem {
this.updateSymtomsID = this.delaySystem.DelayCallback(callback, 600., true);
}
/// deadlock on packages.GetAppliedPackages
private func CalculateConsumptionModifier(identifier: TweakDBID) -> Float {
return 1.0; // until method fixed
let applied: array<TweakDBID>;
let stimuli: array<wref<StatModifier_Record>> = [];
let package: wref<GameplayLogicPackage_Record>;
Expand All @@ -198,6 +195,7 @@ public class AddictedSystem extends ScriptableSystem {
if !Generic.IsNeuroBlocker(identifier) { return 1.0; }
let packages = GameInstance.GetGameplayLogicPackageSystem(this.player.GetGame());
// should NEVER be called DIRECTLY from inside a GameplayLogicPackage (deadlock)
packages.GetAppliedPackages(this.player, applied);
while i < ArraySize(applied) {
id = applied[i];
Expand Down

0 comments on commit ecf2297

Please sign in to comment.