mirror of
https://github.com/islehorse/HISP.git
synced 2025-04-21 20:25:51 +12:00
Add Thread-Safe Lists, and make all list access thread-safe
This commit is contained in:
parent
900fe0d48a
commit
40c34ac030
24 changed files with 111 additions and 44 deletions
|
@ -8,7 +8,7 @@ namespace HISP.Game.Inventory
|
|||
public class HorseInventory
|
||||
{
|
||||
private User baseUser;
|
||||
private List<HorseInstance> horsesList = new List<HorseInstance>();
|
||||
private ThreadSafeList<HorseInstance> horsesList = new ThreadSafeList<HorseInstance>();
|
||||
public HorseInstance[] HorseList
|
||||
{
|
||||
get
|
||||
|
|
|
@ -1,21 +1,20 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using HISP.Game.Items;
|
||||
|
||||
using HISP.Game.Items;
|
||||
using HISP.Server;
|
||||
|
||||
namespace HISP.Game.Inventory
|
||||
{
|
||||
public class InventoryItem
|
||||
{
|
||||
public InventoryItem()
|
||||
{
|
||||
itemInstances = new List<ItemInstance>();
|
||||
itemInstances = new ThreadSafeList<ItemInstance>();
|
||||
Infinite = false;
|
||||
ItemId = 0;
|
||||
}
|
||||
|
||||
public int ItemId;
|
||||
public bool Infinite;
|
||||
private List<ItemInstance> itemInstances;
|
||||
private ThreadSafeList<ItemInstance> itemInstances;
|
||||
public void RemoveItem(ItemInstance itm)
|
||||
{
|
||||
itemInstances.Remove(itm);
|
||||
|
|
|
@ -13,10 +13,10 @@ namespace HISP.Game.Inventory
|
|||
|
||||
|
||||
public User BaseUser;
|
||||
private List<InventoryItem> inventoryItems;
|
||||
private ThreadSafeList<InventoryItem> inventoryItems;
|
||||
public PlayerInventory(User forUser)
|
||||
{
|
||||
inventoryItems = new List<InventoryItem>();
|
||||
inventoryItems = new ThreadSafeList<InventoryItem>();
|
||||
|
||||
BaseUser = forUser;
|
||||
ItemInstance[] instances = Database.GetPlayerInventory(BaseUser.Id).ToArray();
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace HISP.Game.Inventory
|
|||
public class ShopInventory : IInventory
|
||||
{
|
||||
private Shop baseShop;
|
||||
private List<InventoryItem> inventoryItems;
|
||||
private ThreadSafeList<InventoryItem> inventoryItems;
|
||||
public int Count
|
||||
{
|
||||
get
|
||||
|
@ -21,7 +21,7 @@ namespace HISP.Game.Inventory
|
|||
public ShopInventory(Shop shopkeeper)
|
||||
{
|
||||
baseShop = shopkeeper;
|
||||
inventoryItems = new List<InventoryItem>();
|
||||
inventoryItems = new ThreadSafeList<InventoryItem>();
|
||||
}
|
||||
|
||||
private void addItem(ItemInstance item, bool addToDatabase)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue