Skip to content

Commit dddb086

Browse files
committed
Fix heaptile field offsets
This allows heaptile to be used (since 1442 broke the hook), and allows worlds to be generated and loaded as intended. This previously would fail to generate worlds due to the invalid field offsets.
1 parent b24255f commit dddb086

2 files changed

Lines changed: 14 additions & 17 deletions

File tree

TerrariaServerAPI/TerrariaApi.Server/HeapTile.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,17 @@ public class HeapTile : Terraria.Tile
55
protected readonly int offset;
66
protected byte[] heap;
77

8-
public const int kHeapTileSize = 13;
8+
public const int kHeapTileSize = 14;
99

1010
public const int kHeapTileTypeOffset = 0;
1111
public const int kHeapTileWallOffset = 2;
12-
public const int kHeapTileLiquidOffset = 3;
13-
public const int kHeapTileSTileHeaderOffset = 4;
14-
public const int kHeapTileBTypeHeaderOffset = 6;
15-
public const int kHeapTileBTypeHeader2Offset = 7;
16-
public const int kHeapTileBTypeHeader3Offset = 8;
17-
public const int kHeapTileFrameXOffset = 9;
18-
public const int kHeapTileFrameYOffset = 11;
12+
public const int kHeapTileLiquidOffset = 4;
13+
public const int kHeapTileSTileHeaderOffset = 5;
14+
public const int kHeapTileBTypeHeaderOffset = 7;
15+
public const int kHeapTileBTypeHeader2Offset = 8;
16+
public const int kHeapTileBTypeHeader3Offset = 9;
17+
public const int kHeapTileFrameXOffset = 10;
18+
public const int kHeapTileFrameYOffset = 12;
1919

2020
internal int x;
2121
internal int y;
@@ -53,13 +53,13 @@ public override ushort wall
5353
{
5454
get
5555
{
56-
return heap[offset + kHeapTileWallOffset];
57-
}
56+
return (ushort)((heap[offset + kHeapTileWallOffset + 1] << 8) | heap[offset + kHeapTileWallOffset]);
57+
}
5858

59-
set
59+
set
6060
{
61-
heap[offset + kHeapTileSTileHeaderOffset + 1] = (byte)(value >> 8);
62-
heap[offset + kHeapTileSTileHeaderOffset] = (byte)(value & 0xFF);
61+
heap[offset + kHeapTileWallOffset + 1] = (byte)(value >> 8);
62+
heap[offset + kHeapTileWallOffset] = (byte)(value & 0xFF);
6363
}
6464
}
6565

TerrariaServerAPI/TerrariaApi.Server/HookManager.cs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ public void AttachOTAPIHooks(string[] args)
4343
if (args.Any(x => x == "-heaptile"))
4444
{
4545
ServerApi.LogWriter.ServerWriteLine($"Using {nameof(HeapTile)} for tile implementation", TraceLevel.Info);
46-
ModFramework.DefaultCollection<ITile>.OnCreateCollection += (int x, int y, string source) =>
47-
{
48-
return new TileProvider();
49-
};
46+
Terraria.Main.tile = new TileProvider();
5047
}
5148

5249
Hooking.GameHooks.AttachTo(this);

0 commit comments

Comments
 (0)