Merge branch 'dev' of https://github.com/Regalis11/Barotrauma.git into unstable-tests
This commit is contained in:
@@ -23,7 +23,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
public void BuyBackSoldItems(Identifier storeIdentifier, List<SoldItem> itemsToBuy)
|
||||
public void BuyBackSoldItems(Identifier storeIdentifier, List<SoldItem> itemsToBuy, Client client)
|
||||
{
|
||||
var store = Location.GetStore(storeIdentifier);
|
||||
if (store == null) { return; }
|
||||
@@ -35,12 +35,12 @@ namespace Barotrauma
|
||||
int itemValue = sellValues[item.ItemPrefab];
|
||||
if (store.Balance < itemValue || item.Removed) { continue; }
|
||||
store.Balance += itemValue;
|
||||
campaign.Bank.TryDeduct(itemValue);
|
||||
campaign.GetWallet(client).TryDeduct(itemValue);
|
||||
storeSpecificItems.Remove(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void SellItems(Identifier storeIdentifier, List<SoldItem> itemsToSell)
|
||||
public void SellItems(Identifier storeIdentifier, List<SoldItem> itemsToSell, Client client)
|
||||
{
|
||||
var store = Location.GetStore(storeIdentifier);
|
||||
if (store == null) { return; }
|
||||
@@ -74,7 +74,7 @@ namespace Barotrauma
|
||||
}
|
||||
itemsSoldAtStore?.Add(item);
|
||||
store.Balance -= itemValue;
|
||||
campaign.Bank.Give(itemValue);
|
||||
campaign.GetWallet(client).Give(itemValue);
|
||||
GameAnalyticsManager.AddMoneyGainedEvent(itemValue, GameAnalyticsManager.MoneySource.Store, item.ItemPrefab.Identifier.Value);
|
||||
}
|
||||
OnSoldItemsChanged?.Invoke();
|
||||
|
||||
+46
-11
@@ -516,7 +516,9 @@ namespace Barotrauma
|
||||
{
|
||||
if (wallet.HasTransactions())
|
||||
{
|
||||
transactions.Add(wallet.DequeueAndMergeTransactions(id));
|
||||
NetWalletTransaction transaction = wallet.DequeueAndMergeTransactions(id);
|
||||
if (transaction.ChangedData.BalanceChanged.IsNone() && transaction.ChangedData.RewardDistributionChanged.IsNone()) { continue; }
|
||||
transactions.Add(transaction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -791,14 +793,14 @@ namespace Barotrauma
|
||||
}
|
||||
foreach (var store in prevBuyCrateItems)
|
||||
{
|
||||
foreach (var item in store.Value)
|
||||
foreach (var item in store.Value.ToList())
|
||||
{
|
||||
CargoManager.ModifyItemQuantityInBuyCrate(store.Key, item.ItemPrefab, -item.Quantity, sender);
|
||||
}
|
||||
}
|
||||
foreach (var store in buyCrateItems)
|
||||
{
|
||||
foreach (var item in store.Value)
|
||||
foreach (var item in store.Value.ToList())
|
||||
{
|
||||
CargoManager.ModifyItemQuantityInBuyCrate(store.Key, item.ItemPrefab, item.Quantity, sender);
|
||||
}
|
||||
@@ -816,7 +818,40 @@ namespace Barotrauma
|
||||
foreach (var store in purchasedItems)
|
||||
{
|
||||
CargoManager.PurchaseItems(store.Key, store.Value, false, sender);
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var (storeIdentifier, items) in CargoManager.PurchasedItems)
|
||||
{
|
||||
if (!prevPurchasedItems.ContainsKey(storeIdentifier))
|
||||
{
|
||||
CargoManager.OnNewItemsPurchased(storeIdentifier, items, sender);
|
||||
continue;
|
||||
}
|
||||
|
||||
List<PurchasedItem> newItems = new List<PurchasedItem>();
|
||||
List<PurchasedItem> prevItems = prevPurchasedItems[storeIdentifier];
|
||||
|
||||
foreach (PurchasedItem item in items)
|
||||
{
|
||||
PurchasedItem matching = prevItems.FirstOrDefault(ppi => ppi.ItemPrefab == item.ItemPrefab);
|
||||
if (matching is null)
|
||||
{
|
||||
newItems.Add(item);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (matching.Quantity < item.Quantity)
|
||||
{
|
||||
newItems.Add(new PurchasedItem(item.ItemPrefab, item.Quantity - matching.Quantity, sender));
|
||||
}
|
||||
}
|
||||
|
||||
if (newItems.Any())
|
||||
{
|
||||
CargoManager.OnNewItemsPurchased(storeIdentifier, newItems, sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool allowedToSellSubItems = AllowedToManageCampaign(sender, ClientPermissions.SellSubItems);
|
||||
if (allowedToSellSubItems)
|
||||
@@ -824,14 +859,14 @@ namespace Barotrauma
|
||||
var prevSubSellCrateItems = new Dictionary<Identifier, List<PurchasedItem>>(CargoManager.ItemsInSellFromSubCrate);
|
||||
foreach (var store in prevSubSellCrateItems)
|
||||
{
|
||||
foreach (var item in store.Value)
|
||||
foreach (var item in store.Value.ToList())
|
||||
{
|
||||
CargoManager.ModifyItemQuantityInSubSellCrate(store.Key, item.ItemPrefab, -item.Quantity, sender);
|
||||
}
|
||||
}
|
||||
foreach (var store in subSellCrateItems)
|
||||
{
|
||||
foreach (var item in store.Value)
|
||||
foreach (var item in store.Value.ToList())
|
||||
{
|
||||
CargoManager.ModifyItemQuantityInSubSellCrate(store.Key, item.ItemPrefab, item.Quantity, sender);
|
||||
}
|
||||
@@ -846,11 +881,11 @@ namespace Barotrauma
|
||||
var prevSoldItems = new Dictionary<Identifier, List<SoldItem>>(CargoManager.SoldItems);
|
||||
foreach (var store in prevSoldItems)
|
||||
{
|
||||
CargoManager.BuyBackSoldItems(store.Key, store.Value);
|
||||
CargoManager.BuyBackSoldItems(store.Key, store.Value.ToList(), sender);
|
||||
}
|
||||
foreach (var store in soldItems)
|
||||
{
|
||||
CargoManager.SellItems(store.Key, store.Value);
|
||||
CargoManager.SellItems(store.Key, store.Value.ToList(), sender);
|
||||
}
|
||||
}
|
||||
else if (allowedToSellInventoryItems || allowedToSellSubItems)
|
||||
@@ -859,7 +894,7 @@ namespace Barotrauma
|
||||
foreach (var store in prevSoldItems)
|
||||
{
|
||||
store.Value.RemoveAll(predicate);
|
||||
CargoManager.BuyBackSoldItems(store.Key, store.Value);
|
||||
CargoManager.BuyBackSoldItems(store.Key, store.Value.ToList(), sender);
|
||||
}
|
||||
foreach (var store in soldItems)
|
||||
{
|
||||
@@ -867,7 +902,7 @@ namespace Barotrauma
|
||||
}
|
||||
foreach (var store in soldItems)
|
||||
{
|
||||
CargoManager.SellItems(store.Key, store.Value);
|
||||
CargoManager.SellItems(store.Key, store.Value.ToList(), sender);
|
||||
}
|
||||
bool predicate(SoldItem i) => allowedToSellInventoryItems != (i.Origin == SoldItem.SellOrigin.Character);
|
||||
}
|
||||
@@ -899,7 +934,7 @@ namespace Barotrauma
|
||||
UpgradeManager.CancelItemSwap(item);
|
||||
item.PendingItemSwap = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ServerReadMoney(IReadMessage msg, Client sender)
|
||||
|
||||
@@ -1867,7 +1867,9 @@ namespace Barotrauma.Networking
|
||||
outmsg.Write(GameMain.NetLobbyScreen.SelectedSub.Name);
|
||||
outmsg.Write(GameMain.NetLobbyScreen.SelectedSub.MD5Hash.ToString());
|
||||
outmsg.Write(IsUsingRespawnShuttle());
|
||||
var selectedShuttle = gameStarted && respawnManager.UsingShuttle ? respawnManager.RespawnShuttle.Info : GameMain.NetLobbyScreen.SelectedShuttle;
|
||||
var selectedShuttle = gameStarted && respawnManager != null && respawnManager.UsingShuttle ?
|
||||
respawnManager.RespawnShuttle.Info :
|
||||
GameMain.NetLobbyScreen.SelectedShuttle;
|
||||
outmsg.Write(selectedShuttle.Name);
|
||||
outmsg.Write(selectedShuttle.MD5Hash.ToString());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user