Skip to content

Commit f33cae4

Browse files
committed
Improve error handling and logging for asset loading
Enhanced logging in SharedProcessorState to warn and skip when location assets fail to load, including asset names and exception details. Updated GlobalPlayerKeysProcessor to only log MapViewDistance warnings when the distance is greater than zero, preventing unnecessary messages.
1 parent 1f78f41 commit f33cae4

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

ValheimServersideQoL/Processors/GlobalPlayerKeysProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public override void Initialize(bool firstTime)
2626
if (Config.MapTables.MapViewDistance is not null)
2727
{
2828
_mapTableRangeSqr = Config.MapTables.MapViewDistance.Value * Config.MapTables.MapViewDistance.Value;
29-
if (!ZoneSystem.instance.GetGlobalKey(GlobalKeys.NoMap))
29+
if (_mapTableRangeSqr > 0 && !ZoneSystem.instance.GetGlobalKey(GlobalKeys.NoMap))
3030
{
3131
_mapTableRangeSqr = 0;
3232
Logger.LogWarning($"[{Config.MapTables.MapViewDistance.Definition.Section}].[{Config.MapTables.MapViewDistance.Definition.Key}] has no effect unless the {GlobalKeys.NoMap} global key is set");

ValheimServersideQoL/Processors/SharedProcessorState.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,12 +104,18 @@ sealed record PieceTableInfo(HashSet<PieceTable> PieceTables, Dictionary<string,
104104
try { location.m_prefab.Load(); }
105105
catch(Exception ex)
106106
{
107-
Main.Instance.Logger.LogError(ex);
107+
Main.Instance.Logger.LogWarning($"Loading location asset {location.m_prefabName} failed: {ex}");
108108
continue;
109109
}
110110

111-
var bowl = location.m_prefab.Asset.GetComponentInChildren<OfferingBowl>();
112-
if (includeDungeons && bowl is null && location.m_prefab.Asset.GetComponentInChildren<DungeonGenerator>() is { } dungeonGen)
111+
if (location.m_prefab.Asset is not { } asset)
112+
{
113+
Main.Instance.Logger.LogWarning($"Loading location asset {location.m_prefabName} failed");
114+
continue;
115+
}
116+
117+
var bowl = asset.GetComponentInChildren<OfferingBowl>();
118+
if (includeDungeons && bowl is null && asset.GetComponentInChildren<DungeonGenerator>() is { } dungeonGen)
113119
{
114120
foreach (var roomRef in dungeonGen.GetAvailableRoomPrefabs())
115121
{

0 commit comments

Comments
 (0)