Skip to content

Commit

Permalink
Merge branch 'asf-update' into 2.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Citrinate committed Mar 18, 2024
2 parents bd24e4e + 9f39d8b commit b50f4fa
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 31 deletions.
2 changes: 1 addition & 1 deletion BoosterManager/BoosterManager.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<Authors>Citrinate</Authors>
<AssemblyVersion>2.8.6</AssemblyVersion>
<AssemblyVersion>2.8.7</AssemblyVersion>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TargetFramework>net8.0</TargetFramework>
Expand Down
32 changes: 3 additions & 29 deletions BoosterManager/Handlers/InventoryHandler.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using ArchiSteamFarm.Localization;
using ArchiSteamFarm.Steam;
Expand Down Expand Up @@ -54,13 +53,7 @@ internal static async Task<string> SendItemToMultipleBots(Bot sender, List<(Bot
return (true, "Successfully sent nothing!");
}

HashSet<Asset>? itemsToGive;
try {
itemsToGive = GetItemsFromStacks(sender, itemStacks, amountToSend, amountToSkip);
} catch (Exception e) {
return (false, e.Message);
}

HashSet<Asset>? itemsToGive = GetItemsFromStacks(sender, itemStacks, amountToSend, amountToSkip);
if (itemsToGive == null) {
return (false, "Not enough to send!");
}
Expand Down Expand Up @@ -139,13 +132,7 @@ internal static async Task<string> SendMultipleItemsToMultipleBots(Bot sender, H
// Allow for partial trades, but not partial amounts of individual items.
// If user is trying to send: 3 of ItemA and 2 of ItemB. Yet they have: 3 of ItemA and 1 of ItemB. This will send only: 3 of ItemA and 0 of ItemB
foreach ((HashSet<Asset> itemStacks, ItemIdentifier itemIdentifier, uint amount) in itemStacksWithAmounts) {
HashSet<Asset>? itemsToGive;
try {
itemsToGive = GetItemsFromStacks(sender, itemStacks, amount, amount * numRecieversProcessed);
} catch (Exception e) {
return (false, e.Message);
}

HashSet<Asset>? itemsToGive = GetItemsFromStacks(sender, itemStacks, amount, amount * numRecieversProcessed);
if (itemsToGive == null) {
sender.ArchiLogger.LogGenericInfo(String.Format("Not enough of {0} to send!", itemIdentifier.ToString()));
responses.Add(String.Format("Not enough of {0} to send :steamthumbsdown:", itemIdentifier.ToString()));
Expand Down Expand Up @@ -200,20 +187,7 @@ internal static async Task<string> SendMultipleItemsToMultipleBots(Bot sender, H
break;
}

if (itemStack.Amount != amountToTakeFromStack) {
// This asset has an amount greater than 1 (such as in the case of gems)
// We only want to send some, but not all of this amount
PropertyInfo? propertyInfo = itemStack.GetType().GetProperty("Amount");
if (propertyInfo == null) {
bot.ArchiLogger.LogGenericError("Couldn't find Asset.Amount");

throw new Exception("Plugin error, please report this");
}

propertyInfo.SetValue(itemStack, amountToTakeFromStack);
}

items.Add(itemStack);
items.Add(new Asset(appID: itemStack.AppID, contextID: itemStack.ContextID, classID: itemStack.ClassID, assetID: itemStack.AssetID, amount: amountToTakeFromStack));
amountTaken += amountToTakeFromStack;
}

Expand Down

0 comments on commit b50f4fa

Please sign in to comment.