diff --git a/LSLib/VirtualTextures/VirtualTexture.cs b/LSLib/VirtualTextures/VirtualTexture.cs index 32a1688c..4021b420 100644 --- a/LSLib/VirtualTextures/VirtualTexture.cs +++ b/LSLib/VirtualTextures/VirtualTexture.cs @@ -383,12 +383,12 @@ public void LoadFromStream(Stream fs, BinaryReader reader, bool loadThumbnails) TileSetLevels = new GTSTileSetLevel[Header.NumLevels]; BinUtils.ReadStructs(reader, TileSetLevels); - PerLevelFlatTileIndices = new List(); + PerLevelFlatTileIndices = new List(); foreach (var level in TileSetLevels) { fs.Position = (uint)level.FlatTileIndicesOffset; - var tileIndices = new Int32[level.Height * level.Width * Header.NumLayers]; - BinUtils.ReadStructs(reader, tileIndices); + var tileIndices = new UInt32[level.Height * level.Width * Header.NumLayers]; + BinUtils.ReadStructs(reader, tileIndices); PerLevelFlatTileIndices.Add(tileIndices); } @@ -485,7 +485,7 @@ public void SaveToStream(Stream fs, BinaryWriter writer) var tileIndices = PerLevelFlatTileIndices[i]; Debug.Assert(tileIndices.Length == level.Height * level.Width * Header.NumLayers); - BinUtils.WriteStructs(writer, tileIndices); + BinUtils.WriteStructs(writer, tileIndices); } Header.LevelsOffset = (ulong)fs.Position; @@ -568,7 +568,7 @@ public bool GetTileInfo(int level, int layer, int x, int y, ref GTSFlatTileInfo { var tileIndices = PerLevelFlatTileIndices[level]; var tileIndex = tileIndices[layer + Header.NumLayers * (x + y * TileSetLevels[level].Width)]; - if (tileIndex >= 0) + if ((tileIndex & 0x80000000) == 0) { tile = FlatTileInfos[tileIndex]; return true;