Fix bug with chemical reactions which cause other reactions (#475)
SolutionComponent.CheckForReaction only checks for a reaction once, meaning that if a reaction generates reagents that create a solution that's valid for another reaction, that second reaction doesn't occur. This fixes that by repeatedly checking for a reaction until no more occur.
This commit is contained in:
committed by
Pieter-Jan Briers
parent
6df5028d7a
commit
4cf8e18d1f
@@ -191,6 +191,9 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
}
|
||||
|
||||
private void CheckForReaction()
|
||||
{
|
||||
bool checkForNewReaction = false;
|
||||
while (true)
|
||||
{
|
||||
//Check the solution for every reaction
|
||||
foreach (var reaction in _reactions)
|
||||
@@ -198,9 +201,19 @@ namespace Content.Server.GameObjects.Components.Chemistry
|
||||
if (SolutionValidReaction(reaction, out int unitReactions))
|
||||
{
|
||||
PerformReaction(reaction, unitReactions);
|
||||
break; //Only perform one reaction per solution per update.
|
||||
checkForNewReaction = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Check for a new reaction if a reaction occurs, run loop again.
|
||||
if (checkForNewReaction)
|
||||
{
|
||||
checkForNewReaction = false;
|
||||
continue;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public bool TryAddReagent(string reagentId, int quantity, out int acceptedQuantity, bool skipReactionCheck = false, bool skipColor = false)
|
||||
|
||||
Reference in New Issue
Block a user