Fixed hideout area upgrades softlocking client when upgrading areas with containers
Removed unused injections Renamed field to `_areasWithResources` and converted into hashset
This commit is contained in:
@@ -25,11 +25,9 @@ public class HideoutController(
|
||||
HashUtil _hashUtil,
|
||||
TimeUtil _timeUtil,
|
||||
DatabaseService _databaseService,
|
||||
RandomUtil _randomUtil,
|
||||
InventoryHelper _inventoryHelper,
|
||||
ItemHelper _itemHelper,
|
||||
SaveServer _saveServer,
|
||||
PlayerService _playerService,
|
||||
PresetHelper _presetHelper,
|
||||
PaymentHelper _paymentHelper,
|
||||
EventOutputHolder _eventOutputHolder,
|
||||
@@ -47,7 +45,7 @@ public class HideoutController(
|
||||
{
|
||||
public const string NameTaskConditionCountersCraftingId = "673f5d6fdd6ed700c703afdc";
|
||||
|
||||
protected List<HideoutAreas> _hideoutAreas =
|
||||
protected readonly HashSet<HideoutAreas> _areasWithResources =
|
||||
[
|
||||
HideoutAreas.AirFilteringUnit,
|
||||
HideoutAreas.WaterCollector,
|
||||
@@ -55,7 +53,7 @@ public class HideoutController(
|
||||
HideoutAreas.BitcoinFarm,
|
||||
];
|
||||
|
||||
protected HideoutConfig _hideoutConfig = _configServer.GetConfig<HideoutConfig>();
|
||||
protected readonly HideoutConfig _hideoutConfig = _configServer.GetConfig<HideoutConfig>();
|
||||
|
||||
/// <summary>
|
||||
/// Handle HideoutUpgrade event
|
||||
@@ -155,7 +153,7 @@ public class HideoutController(
|
||||
|
||||
var timestamp = _timeUtil.GetTimeStamp();
|
||||
|
||||
profileHideoutArea.CompleteTime = (int)Math.Round(timestamp + ctime.Value);
|
||||
profileHideoutArea.CompleteTime = (int) Math.Round(timestamp + ctime.Value);
|
||||
profileHideoutArea.Constructing = true;
|
||||
}
|
||||
}
|
||||
@@ -303,7 +301,7 @@ public class HideoutController(
|
||||
{
|
||||
// Add key/value to `hideoutAreaStashes` dictionary - used to link hideout area to inventory stash by its id
|
||||
// Key is the enums value stored as a string, e.g. "27" for cultist circle
|
||||
var keyForHideoutAreaStash = ((int)dbHideoutArea.Type).ToString();
|
||||
var keyForHideoutAreaStash = ((int) dbHideoutArea.Type).ToString();
|
||||
if (!pmcData.Inventory.HideoutAreaStashes.ContainsKey(keyForHideoutAreaStash))
|
||||
{
|
||||
if (
|
||||
@@ -333,24 +331,13 @@ public class HideoutController(
|
||||
);
|
||||
}
|
||||
|
||||
// Don't inform client when upgraded area is hall of fame or equipment stand, BSG doesn't inform client this specific upgrade has occurred
|
||||
// will break client if sent
|
||||
|
||||
if (
|
||||
ShouldAddContainerUpgradeToClientResponse(
|
||||
dbHideoutArea,
|
||||
profileParentHideoutArea.Level.GetValueOrDefault(1)
|
||||
)
|
||||
)
|
||||
{
|
||||
AddContainerUpgradeToClientOutput(
|
||||
sessionId,
|
||||
keyForHideoutAreaStash,
|
||||
dbHideoutArea,
|
||||
hideoutStage,
|
||||
output
|
||||
);
|
||||
}
|
||||
AddContainerUpgradeToClientOutput(
|
||||
sessionId,
|
||||
keyForHideoutAreaStash,
|
||||
dbHideoutArea,
|
||||
hideoutStage,
|
||||
output
|
||||
);
|
||||
|
||||
// Some hideout areas (Gun stand) have child areas linked to it
|
||||
var childDbArea = _databaseService
|
||||
@@ -363,7 +350,7 @@ public class HideoutController(
|
||||
}
|
||||
|
||||
// Add key/value to `hideoutAreaStashes` dictionary - used to link hideout area to inventory stash by its id
|
||||
var childAreaTypeKey = ((int)childDbArea.Type).ToString();
|
||||
var childAreaTypeKey = ((int) childDbArea.Type).ToString();
|
||||
if (pmcData.Inventory.HideoutAreaStashes.GetValueOrDefault(childAreaTypeKey) is null)
|
||||
{
|
||||
pmcData.Inventory.HideoutAreaStashes[childAreaTypeKey] = childDbArea.Id;
|
||||
@@ -403,22 +390,6 @@ public class HideoutController(
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should the newly completed hideout area container upgrade/addition be included in client response
|
||||
/// Deny when: area is place of fame + we're upgrading to level 1
|
||||
/// </summary>
|
||||
/// <param name="dbHideoutArea">Hideout area upgraded</param>
|
||||
/// <param name="areaLevel">Level of area upgraded to</param>
|
||||
/// <returns>True = it should be included</returns>
|
||||
private bool ShouldAddContainerUpgradeToClientResponse(HideoutArea dbHideoutArea, int areaLevel)
|
||||
{
|
||||
HashSet<HideoutAreas> areaBlacklist = [HideoutAreas.PlaceOfFame];
|
||||
var isOnAreaBlacklist = areaBlacklist.Contains(dbHideoutArea.Type ?? HideoutAreas.NotSet);
|
||||
var isFirstStage = areaLevel == 1;
|
||||
|
||||
return isOnAreaBlacklist && !isFirstStage;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add an inventory item to profile from a hideout area stage data
|
||||
/// </summary>
|
||||
@@ -605,7 +576,7 @@ public class HideoutController(
|
||||
}
|
||||
|
||||
// Handle areas that have resources that can be placed in/taken out of slots from the area
|
||||
if (_hideoutAreas.Contains(hideoutArea.Type ?? HideoutAreas.NotSet))
|
||||
if (_areasWithResources.Contains(hideoutArea.Type ?? HideoutAreas.NotSet))
|
||||
{
|
||||
var response = RemoveResourceFromArea(sessionID, pmcData, request, output, hideoutArea);
|
||||
|
||||
@@ -778,7 +749,7 @@ public class HideoutController(
|
||||
// Tools don't have a count
|
||||
if (requirement.Type != "Tool")
|
||||
{
|
||||
requirement.Count -= (int)itemToDelete.Count;
|
||||
requirement.Count -= (int) itemToDelete.Count;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -863,7 +834,7 @@ public class HideoutController(
|
||||
|
||||
pmcData.Hideout.Production[request.RecipeId] = _hideoutHelper.InitProduction(
|
||||
request.RecipeId,
|
||||
(int)(_profileHelper.IsDeveloperAccount(sessionID) ? 40 : modifiedScavCaseTime),
|
||||
(int) (_profileHelper.IsDeveloperAccount(sessionID) ? 40 : modifiedScavCaseTime),
|
||||
false
|
||||
);
|
||||
pmcData.Hideout.Production[request.RecipeId].SptIsScavCase = true;
|
||||
@@ -1091,7 +1062,7 @@ public class HideoutController(
|
||||
var multiplierCrafting = Math.Floor(
|
||||
hoursCrafting.Value / _hideoutConfig.HoursForSkillCrafting
|
||||
);
|
||||
craftingExpAmount += (int)(1 * multiplierCrafting);
|
||||
craftingExpAmount += (int) (1 * multiplierCrafting);
|
||||
hoursCrafting -= _hideoutConfig.HoursForSkillCrafting * multiplierCrafting;
|
||||
}
|
||||
|
||||
@@ -1160,7 +1131,7 @@ public class HideoutController(
|
||||
{
|
||||
_profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.Crafting, craftingExpAmount);
|
||||
|
||||
var intellectAmountToGive = 0.5 * Math.Round((double)(craftingExpAmount / 15));
|
||||
var intellectAmountToGive = 0.5 * Math.Round((double) (craftingExpAmount / 15));
|
||||
if (intellectAmountToGive > 0)
|
||||
{
|
||||
_profileHelper.AddSkillPointsToPlayer(
|
||||
@@ -1587,7 +1558,7 @@ public class HideoutController(
|
||||
var improvementDetails = new HideoutImprovement
|
||||
{
|
||||
Completed = false,
|
||||
ImproveCompleteTimestamp = (long)(timestamp + improvement.ImprovementTime),
|
||||
ImproveCompleteTimestamp = (long) (timestamp + improvement.ImprovementTime),
|
||||
};
|
||||
output.ProfileChanges[sessionId].Improvements[improvement.Id] = improvementDetails;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user