feature/84-character-creation #88

Merged
rainote merged 60 commits from feature/84-character-creation into master 2023-11-17 07:29:21 +00:00
Showing only changes of commit 3602d74eb4 - Show all commits

View file

@ -10,7 +10,7 @@ namespace Server.Services;
public class ItemObjectPoolService : IHostedService public class ItemObjectPoolService : IHostedService
{ {
readonly ConcurrentDictionary<uint, ItemObject> _itemObjectPool = new(); readonly ConcurrentDictionary<uint, ItemObject> _itemObjectPool;
private readonly ItemReader _itemReader; private readonly ItemReader _itemReader;
private readonly ILogger<ItemObjectPoolService> _logger; private readonly ILogger<ItemObjectPoolService> _logger;
@ -19,6 +19,8 @@ public class ItemObjectPoolService : IHostedService
_logger = logger; _logger = logger;
_itemReader = new ItemReader(configuration.GetSection("Game").GetSection("Data").GetValue<string>("Path") ?? _itemReader = new ItemReader(configuration.GetSection("Game").GetSection("Data").GetValue<string>("Path") ??
string.Empty); string.Empty);
_itemObjectPool = new ConcurrentDictionary<uint, ItemObject>();
} }
public Task StartAsync(CancellationToken cancellationToken) public Task StartAsync(CancellationToken cancellationToken)
@ -30,7 +32,7 @@ public class ItemObjectPoolService : IHostedService
var result = _itemObjectPool.TryAdd(itemObject.ItemID, itemObject); var result = _itemObjectPool.TryAdd(itemObject.ItemID, itemObject);
if (!result) if (!result)
{ {
throw new Exception($"Failed to add item {itemObject.ItemID} to the item object pool"); throw new KeyNotFoundException($"Failed to add item {itemObject.ItemID} to the item object pool");
} }
_logger.LogTrace("Item with {ID} has been added", itemObject.ItemID); _logger.LogTrace("Item with {ID} has been added", itemObject.ItemID);
@ -43,7 +45,6 @@ public class ItemObjectPoolService : IHostedService
public Task StopAsync(CancellationToken cancellationToken) public Task StopAsync(CancellationToken cancellationToken)
{ {
return Task.CompletedTask; return Task.CompletedTask;
} }