Liquid Container: Let liquid object handle removing liquids

liquid_container
Mark 2016-02-26 22:11:11 +01:00
parent 8a49ae10c0
commit af8e681ec8
2 changed files with 8 additions and 17 deletions

View File

@ -263,12 +263,6 @@ func RemoveLiquid(string liquid_name, int amount, object destination)
FatalError(Format("You can remove positive amounts of liquid only, got %d", amount));
}
if (Contained() && Contained()->~IsLiquidContainer())
{
return Contained()->RemoveLiquid(liquid_name, amount, destination);
}
// default parameters if nothing is provided: the current material and level
liquid_name = liquid_name ?? IsLiquid();
amount = amount ?? GetLiquidAmount();

View File

@ -205,17 +205,14 @@ func RemoveLiquid(string liquid_name, int amount, object destination)
FatalError(Format("You can remove positive amounts of liquid only, got %d", amount));
}
// default parameters if nothing is provided: the current material and level
liquid_name = liquid_name ?? GetLiquidType();
amount = amount ?? GetLiquidFillLevel();
//Wrong material?
if (!WildcardMatch(GetLiquidType(), liquid_name))
return [GetLiquidType(), 0];
amount = Min(amount, GetLiquidFillLevel());
ChangeLiquidFillLevel(-amount);
return [liquid_name, amount];
if (GetLiquidItem())
{
return GetLiquidItem()->RemoveLiquid(liquid_name, amount, destination);
}
else
{
return [nil, 0];
}
}
/**