Skip to content

Commit

Permalink
Merge pull request #724 from zymex22/issue723
Browse files Browse the repository at this point in the history
#723 Added Error handeling checks
  • Loading branch information
Sn1p3rr3c0n authored Jul 20, 2023
2 parents f4b6d79 + ee92e6b commit 11d5d6b
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions Source/ProjectRimFactory/AutoMachineTool/Building_BeltConveyor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,23 @@ public override bool AcceptsThing(Thing newThing, IPRF_Building giver = null)
}
else
{
var target = this.State == WorkingState.Working ? this.Working : this.products[0];
//Product must be empty for that error

Thing target;
if (this.State == WorkingState.Working)
{
target = this.Working;
}
else
{
if(this.products.Count == 0)
{
Log.Error("PRF Belt - products List is Empty");
this.Reset();
}
target = this.products[0];
}

Debug.Message(Debug.Flag.Conveyors, " but busy with " + target +
". Will try to absorb");
return target.TryAbsorbStack(newThing, true);
Expand Down Expand Up @@ -491,8 +507,16 @@ public bool CanAcceptNow(Thing thing)
return false;
}
}
protected bool ThisCanAcceptThat(Thing t1, Thing t2) =>
t1.CanStackWith(t2) && t1.stackCount < t1.def.stackLimit;
protected bool ThisCanAcceptThat(Thing t1, Thing t2)
{
if(t1 == null || t2 == null)
{
Log.Error($"PRF ThisCanAcceptThat On thing is Null! t1: {t1} t2: {t2}");
return false;
}
return t1.CanStackWith(t2) && t1.stackCount < t1.def.stackLimit;
}

// We (LWM) are mean and don't allow conveyors to change the "Obey Storage Filters"
// setting. Maybe if zymex is really nice we can change this....
public override PRFBSetting SettingsOptions
Expand Down Expand Up @@ -702,6 +726,11 @@ private void NotifyAroundSender()

protected override bool WorkInterruption(Thing working)
{
if (working == null)
{
Log.Error("PRF - WorkInterruption Null Thing");
return true;
}
return working.holdingOwner != thingOwnerInt;
}

Expand Down

0 comments on commit 11d5d6b

Please sign in to comment.