disappointing night commit

This commit is contained in:
Alex
2025-01-20 22:10:55 +00:00
parent 59cbaa6b02
commit b2e6117ccd
12 changed files with 21 additions and 76 deletions
+2 -1
View File
@@ -9,6 +9,7 @@ using Core.Servers;
using Core.Services;
using Core.Utils;
using Core.Utils.Cloners;
using SptCommon.Extensions;
namespace Core.Helpers;
@@ -67,7 +68,7 @@ public class QuestRewardHelper(
questDetails = ApplyMoneyBoost(questDetails, questMoneyRewardBonusMultiplier, state);
// e.g. 'Success' or 'AvailableForFinish'
var rewards = questDetails.Rewards[state.ToString()];
var rewards = questDetails.Rewards.GetByJsonProp<List<Reward>>(state.ToString());
return _rewardHelper.ApplyRewards(
rewards,
CustomisationSource.UNLOCKED_IN_GAME,
+4 -2
View File
@@ -9,6 +9,7 @@ using Core.Models.Utils;
using Core.Servers;
using Core.Services;
using Core.Utils;
using SptCommon.Extensions;
namespace Core.Helpers;
@@ -127,8 +128,9 @@ public class TraderHelper(
}
var pmcData = fullProfile.CharacterData.PmcData;
ProfileTraderTemplate rawProfileTemplate =
profiles[fullProfile.ProfileInfo.Edition][pmcData.Info.Side.ToLower()].Trader;
ProfileTraderTemplate rawProfileTemplate = profiles.GetByJsonProp<ProfileSides>(fullProfile.ProfileInfo.Edition)
.GetByJsonProp<TemplateSide>(pmcData.Info.Side.ToLower())
.Trader;
var newTraderData = new TraderInfo
{
@@ -1,5 +1,7 @@
using System.Text.Json.Serialization;
using Core.Models.Common;
using Core.Utils.Json;
using Core.Utils.Json.Converters;
namespace Core.Models.Eft.Common;
@@ -494,13 +496,13 @@ public record BossLocationSpawn
public bool? IgnoreMaxBots { get; set; }
[JsonPropertyName("Supports")]
public BossSupport[] Supports { get; set; }
public List<BossSupport> Supports { get; set; }
[JsonPropertyName("sptId")]
public string? SptId { get; set; }
[JsonPropertyName("SpawnMode")]
public string[] SpawnMode { get; set; }
public List<string> SpawnMode { get; set; }
}
public record BossSupport
@@ -509,7 +511,8 @@ public record BossSupport
public string? BossEscortAmount { get; set; }
[JsonPropertyName("BossEscortDifficult")]
public string[] BossEscortDifficulty { get; set; }
[JsonConverter(typeof(ListOrTConverterFactory))]
public ListOrT<string> BossEscortDifficulty { get; set; }
[JsonPropertyName("BossEscortType")]
public string? BossEscortType { get; set; }
@@ -58,19 +58,6 @@ public record Appearance
[JsonPropertyName("voice")]
[JsonConverter(typeof(ArrayToObjectFactoryConverter))]
public Dictionary<string, double>? Voice { get; set; }
public Dictionary<string, double> this[string propName]
{
get
{
var matchingProp = GetType()
.GetProperties()
.SingleOrDefault(p => p.GetJsonName() == propName)
?.GetValue(this);
return (Dictionary<string, double>)matchingProp;
}
}
}
public record Chances
@@ -32,14 +32,6 @@ public record ProfileTemplates
[JsonPropertyName("SPT Zero to hero")]
public ProfileSides? SPTZeroToHero { get; set; }
public ProfileSides? this[string? lookupKey]
{
get
{
return (ProfileSides?) GetType().GetProperties().SingleOrDefault(p => p.GetJsonName() == lookupKey)?.GetValue(this);
}
}
}
public record ProfileSides
@@ -52,14 +44,6 @@ public record ProfileSides
[JsonPropertyName("bear")]
public TemplateSide? Bear { get; set; }
public TemplateSide this[string toLower]
{
get
{
return (TemplateSide?) GetType().GetProperties().SingleOrDefault(p => p.GetJsonName() == toLower)?.GetValue(this);
}
}
}
public record TemplateSide
@@ -493,17 +493,4 @@ public record QuestRewards
[JsonPropertyName("Expired")]
public List<Reward>? Expired { get; set; }
public List<Reward> this[string propName]
{
get
{
var matchingProp = GetType()
.GetProperties()
.SingleOrDefault(p => p.GetJsonName() == propName)
?.GetValue(this);
return (List<Reward>)matchingProp;
}
}
}
@@ -25,7 +25,7 @@ public record KarmaLevel
public Dictionary<string, GenerationData> ItemLimits { get; set; }
[JsonPropertyName("equipmentBlacklist")]
public Dictionary<EquipmentSlots, string[]> EquipmentBlacklist { get; set; }
public Dictionary<EquipmentSlots, List<string>> EquipmentBlacklist { get; set; }
[JsonPropertyName("labsAccessCardChancePercent")]
public double? LabsAccessCardChancePercent { get; set; }
@@ -63,27 +63,6 @@ public record Locations
[JsonPropertyName("base")]
public LocationsBase? Base { get; set; }
public Eft.Common.Location? this[string key]
{
get
{
return (Eft.Common.Location?)GetType()
.GetProperties()
.First(p => string.Equals(p.Name, _locationMappings[key], StringComparison.CurrentCultureIgnoreCase))
.GetGetMethod()?
.Invoke(this, null) ?? null;
}
set
{
GetType()
.GetProperties()
.First(p => string.Equals(p.Name, key, StringComparison.CurrentCultureIgnoreCase))
.GetSetMethod()
?
.Invoke(this, [value]);
}
}
private Dictionary<string, Eft.Common.Location>? _locationDictionaryCache;
/// <summary>
@@ -460,7 +460,7 @@ public class BotEquipmentFilterService
{
foreach (var poolAdjustmentKvP in weightingAdjustments.Add)
{
var locationToUpdate = botItemPool[poolAdjustmentKvP.Key];
var locationToUpdate = botItemPool.GetByJsonProp<Dictionary<string, double>>(poolAdjustmentKvP.Key);
foreach (var itemToAddKvP in poolAdjustmentKvP.Value)
{
locationToUpdate[itemToAddKvP.Key] = itemToAddKvP.Value;
@@ -472,7 +472,7 @@ public class BotEquipmentFilterService
{
foreach (var poolAdjustmentKvP in weightingAdjustments.Edit)
{
var locationToUpdate = botItemPool[poolAdjustmentKvP.Key];
var locationToUpdate = botItemPool.GetByJsonProp<Dictionary<string, double>>(poolAdjustmentKvP.Key);
foreach (var itemToEditKvP in poolAdjustmentKvP.Value)
{
// Only make change if item exists as we're editing, not adding
@@ -11,6 +11,7 @@ using Core.Routers;
using Core.Servers;
using Core.Utils;
using Core.Utils.Cloners;
using SptCommon.Extensions;
namespace Core.Services;
@@ -37,7 +38,7 @@ public class CreateProfileService(
public string CreateProfile(string sessionId, ProfileCreateRequestData request)
{
var account = _saveServer.GetProfile(sessionId).ProfileInfo;
var profileTemplate = _cloner.Clone(_databaseService.GetProfiles()?[account.Edition]?[request.Side.ToLower()]);
var profileTemplate = _cloner.Clone(_databaseService.GetProfiles()?.GetByJsonProp<ProfileSides>(account.Edition)?.GetByJsonProp<TemplateSide>(request.Side.ToLower()));
var pmcData = profileTemplate.Character;
// Delete existing profile
+2 -1
View File
@@ -8,6 +8,7 @@ using Core.Models.Spt.Templates;
using Core.Models.Utils;
using Core.Servers;
using Core.Utils;
using SptCommon.Extensions;
using Hideout = Core.Models.Spt.Hideout.Hideout;
using Locations = Core.Models.Spt.Server.Locations;
@@ -105,7 +106,7 @@ public class DatabaseService(
public Location GetLocation(string locationId)
{
var locations = GetLocations();
var desiredLocation = locations[locationId.ToLower()];
var desiredLocation = locations.GetByJsonProp<Location>(locationId.ToLower());
if (desiredLocation == null) throw new Exception(_localisationService.GetText("database-no_location_found_with_id", locationId));
return desiredLocation;
+2 -2
View File
@@ -54,12 +54,12 @@ public static class Program
var app = serviceProvider.GetService<App>();
app?.Run().Wait();
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive);
GC.Collect(GC.MaxGeneration, GCCollectionMode.Aggressive, true, true);
var httpConfig = serviceProvider.GetService<ConfigServer>()?.GetConfig<HttpConfig>();
// When we application gets started by the HttpServer it will add into the AppContext the WebApplication
// object, which we can use here to start the webapp.
if (httpConfig != null)
(appContext?.GetLatestValue(ContextVariableType.WEB_APPLICATION)?.GetValue<WebApplication>())?.Run($"http://{httpConfig.Ip}:{httpConfig.Port}");
appContext?.GetLatestValue(ContextVariableType.WEB_APPLICATION)?.GetValue<WebApplication>().Run($"http://{httpConfig.Ip}:{httpConfig.Port}");
}
catch (Exception ex)
{