Skip to content

Commit

Permalink
Fix for post long event error thrown on loading with certain mods
Browse files Browse the repository at this point in the history
  • Loading branch information
bbradson committed May 4, 2024
1 parent 67f178a commit 1996405
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 6 deletions.
Binary file modified 1.4/Assemblies/AdaptiveStorageFramework.dll
Binary file not shown.
Binary file modified 1.4/Assemblies/AdaptiveStorageFramework.pdb
Binary file not shown.
Binary file modified 1.5/Assemblies/AdaptiveStorageFramework.dll
Binary file not shown.
Binary file modified 1.5/Assemblies/AdaptiveStorageFramework.pdb
Binary file not shown.
3 changes: 2 additions & 1 deletion Source/Directory.Build.Props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<RootNamespace>AdaptiveStorage</RootNamespace>
<Authors>Bradson</Authors>
<Copyright>Copyright (c) 2023 Bradson</Copyright>
<Version>1.1.1</Version>
<Version>1.1.2</Version>
<TargetFramework>net48</TargetFramework>
<LangVersion>preview</LangVersion>
<Nullable>enable</Nullable>
Expand Down Expand Up @@ -43,6 +43,7 @@
<Publicize Include="Assembly-CSharp:Verse.MapDrawer.sections" />
<Publicize Include="Assembly-CSharp:Verse.SectionLayer_ThingsGeneral.TakePrintFrom" />
<Publicize Include="Assembly-CSharp:Verse.Text.tmpTextGUIContent" />
<Publicize Include="Assembly-CSharp:Verse.Thing.mapIndexOrState" />
<Publicize Include="Assembly-CSharp:Verse.ThingFilter.categories" />
<Publicize Include="Assembly-CSharp:Verse.ThingWithComps.Comps_PostDraw" />
<Publicize Include="Assembly-CSharp:Verse.WidgetRow.curY" />
Expand Down
13 changes: 10 additions & 3 deletions Source/ExtensionMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
// If a copy of the license was not distributed with this file,
// You can obtain one at https://opensource.org/licenses/MIT/.

using AdaptiveStorage.Pools;
#if V1_4
using System.Runtime.CompilerServices;
#endif
using AdaptiveStorage.Pools;

namespace AdaptiveStorage;

Expand Down Expand Up @@ -166,6 +164,15 @@ public static void SetPosition(this ref Matrix4x4 matrix, in Vector3 position)

public static Vector3 GetPosition(this in Matrix4x4 matrix)
=> default(Vector3) with { x = matrix.m03, y = matrix.m13, z = matrix.m23 };

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Map? TryGetMap(this Thing thing)
{
var maps = Current.Game.Maps;
var mapIndex = (uint)thing.mapIndexOrState;

return mapIndex < (uint)maps.Count ? maps[(int)mapIndex] : null;
}

public static TextureAtlasGroup GetAtlasGroup(this Thing thing) => thing.def.category.ToAtlasGroup();

Expand Down
8 changes: 6 additions & 2 deletions Source/StorageRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,14 @@ public void FreeThingGraphic(Thing newItem, SectionLayer? layer, bool updateOthe

public void TryDirtyParentMapMesh()
{
if (!Parent.Spawned || Time.frameCount == _lastMapMeshDirtyFrame)
if (Parent.TryGetMap() is not { } map
|| Time.frameCount == _lastMapMeshDirtyFrame
|| map.mapDrawer is not { sections: not null})
{
return;
}

Parent.DirtyMapMesh(Parent.Map);
Parent.DirtyMapMesh(map);
_lastMapMeshDirtyFrame = Time.frameCount;
}

Expand Down

0 comments on commit 1996405

Please sign in to comment.