Skip to content

Commit 00ccbfe

Browse files
author
hamstar0
committed
v1.1.3.5 - Added tile section cache resets between games (needed?)
1 parent cf24be7 commit 00ccbfe

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

MountedMagicMirrors/MyMod.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using HamstarHelpers.Classes.Tiles.TilePattern;
1010
using HamstarHelpers.Helpers.Debug;
1111
using HamstarHelpers.Helpers.TModLoader.Mods;
12+
using HamstarHelpers.Services.Hooks.LoadHooks;
1213
using HamstarHelpers.Services.Network;
1314
using MountedMagicMirrors.Tiles;
1415

@@ -69,6 +70,11 @@ void onTileSectionPacketGet( int tileX, int tileY, int width, int height, Binary
6970
//
7071

7172
Client.SubscribeToTileSectionPackets( onTileSectionPacketGet );
73+
74+
LoadHooks.AddPostWorldUnloadEachHook( () => {
75+
var myworld = ModContent.GetInstance<MMMWorld>();
76+
myworld?.UnregisterTileSections();
77+
} );
7278
}
7379

7480
public override void Unload() {

MountedMagicMirrors/MyWorld_TileSectionMap.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Collections.Concurrent;
34
using Terraria;
45
using Terraria.ModLoader;
56
using HamstarHelpers.Helpers.Debug;
@@ -8,7 +9,7 @@
89

910
namespace MountedMagicMirrors {
1011
partial class MMMWorld : ModWorld {
11-
private IDictionary<int, ISet<int>> TileSectionMapByTile = new Dictionary<int, ISet<int>>();
12+
private IDictionary<int, ISet<int>> TileSectionMapByTile = new ConcurrentDictionary<int, ISet<int>>();
1213

1314

1415

@@ -29,5 +30,12 @@ public bool IsTileLoaded( int tileX, int tileY ) {
2930

3031
return this.TileSectionMapByTile.Contains2D( sectionX, sectionY );
3132
}
33+
34+
35+
////////////////
36+
37+
public void UnregisterTileSections() {
38+
this.TileSectionMapByTile.Clear();
39+
}
3240
}
3341
}

MountedMagicMirrors/build.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
displayName = Mounted Magic Mirrors
22
author = hamstar
3-
version = 1.1.3.4
3+
version = 1.1.3.5
44
modReferences = HamstarHelpers@5.6.1.1
55
buildIgnore = *.csproj, *.user, *.bat, obj\*, bin\*, .vs\*, .git\*
66
homepage = https://forums.terraria.org/index.php?threads/mounted-magic-mirrors-fast-travel.83296/

0 commit comments

Comments
 (0)