warnings fixed in inventoryController
This commit is contained in:
@@ -48,6 +48,7 @@ public class GameController(
|
||||
protected RagfairConfig _ragfairConfig = _configServer.GetConfig<RagfairConfig>();
|
||||
protected HideoutConfig _hideoutConfig = _configServer.GetConfig<HideoutConfig>();
|
||||
protected BotConfig _botConfig = _configServer.GetConfig<BotConfig>();
|
||||
protected double _deviation = 0.0001;
|
||||
|
||||
/// <summary>
|
||||
/// Handle client/game/start
|
||||
@@ -373,7 +374,7 @@ public class GameController(
|
||||
.Aggregate(0d, (sum, bonus) => sum + (bonus.Value!.Value));
|
||||
|
||||
// Player has energy deficit
|
||||
if (pmcProfile.Health?.Energy?.Current != pmcProfile.Health?.Energy?.Maximum)
|
||||
if (Math.Abs((pmcProfile.Health?.Energy?.Current - pmcProfile.Health?.Energy?.Maximum) ?? 1) <= _deviation)
|
||||
{
|
||||
// Set new value, whatever is smallest
|
||||
pmcProfile.Health!.Energy!.Current += Math.Round(energyRegenPerHour * (diffSeconds!.Value / 3600));
|
||||
@@ -384,7 +385,7 @@ public class GameController(
|
||||
}
|
||||
|
||||
// Player has hydration deficit
|
||||
if (pmcProfile.Health?.Hydration?.Current != pmcProfile.Health?.Hydration?.Maximum)
|
||||
if (Math.Abs((pmcProfile.Health?.Hydration?.Current - pmcProfile.Health?.Hydration?.Maximum) ?? 1) <= _deviation)
|
||||
{
|
||||
pmcProfile.Health!.Hydration!.Current += Math.Round(hydrationRegenPerHour * (diffSeconds!.Value / 3600));
|
||||
if (pmcProfile.Health.Hydration.Current > pmcProfile.Health.Hydration.Maximum)
|
||||
|
||||
@@ -39,7 +39,7 @@ public class InventoryController(
|
||||
{
|
||||
public void MoveItem(PmcData pmcData, InventoryMoveRequestData moveRequest, string sessionID, ItemEventRouterResponse output)
|
||||
{
|
||||
if (output.Warnings.Count > 0)
|
||||
if (output.Warnings?.Count > 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ public class InventoryController(
|
||||
}
|
||||
|
||||
// Check for item in inventory before allowing internal transfer
|
||||
var originalItemLocation = ownerInventoryItems.From.FirstOrDefault((item) => item.Id == moveRequest.Item);
|
||||
var originalItemLocation = ownerInventoryItems.From?.FirstOrDefault((item) => item.Id == moveRequest.Item);
|
||||
if (originalItemLocation is null)
|
||||
{
|
||||
// Internal item move but item never existed, possible dupe glitch
|
||||
@@ -64,9 +64,9 @@ public class InventoryController(
|
||||
return;
|
||||
}
|
||||
|
||||
var originalLocationSlotId = originalItemLocation?.SlotId;
|
||||
var originalLocationSlotId = originalItemLocation.SlotId;
|
||||
|
||||
var moveResult = _inventoryHelper.MoveItemInternal(pmcData, ownerInventoryItems.From, moveRequest, out var errorMessage);
|
||||
var moveResult = _inventoryHelper.MoveItemInternal(pmcData, ownerInventoryItems.From ?? [], moveRequest, out var errorMessage);
|
||||
if (!moveResult)
|
||||
{
|
||||
_httpResponseUtil.AppendErrorToOutput(output, errorMessage);
|
||||
@@ -74,14 +74,14 @@ public class InventoryController(
|
||||
}
|
||||
|
||||
// Item is moving into or out of place of fame dogtag slot
|
||||
if (moveRequest.To.Container.StartsWith("dogtag") || originalLocationSlotId.StartsWith("dogtag"))
|
||||
if (moveRequest.To?.Container != null && (moveRequest.To.Container.StartsWith("dogtag") || originalLocationSlotId!.StartsWith("dogtag")))
|
||||
{
|
||||
_hideoutHelper.ApplyPlaceOfFameDogtagBonus(pmcData);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_inventoryHelper.MoveItemToProfile(ownerInventoryItems.From, ownerInventoryItems.To, moveRequest);
|
||||
_inventoryHelper.MoveItemToProfile(ownerInventoryItems.From ?? [], ownerInventoryItems.To ?? [], moveRequest);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -248,7 +248,7 @@ public class InventoryHelper(
|
||||
/// <returns>OwnerInventoryItems with inventory of player/scav to adjust</returns>
|
||||
public OwnerInventoryItems GetOwnerInventoryItems(
|
||||
InventoryBaseActionRequestData request,
|
||||
string item,
|
||||
string? item,
|
||||
string sessionId)
|
||||
{
|
||||
var pmcItems = _profileHelper.GetPmcProfile(sessionId).Inventory.Items;
|
||||
|
||||
Reference in New Issue
Block a user