fix(map): Fixes map diffs (Old Haven/Minax) (#720)

* Fixes reading map/static diffs.
This commit is contained in:
Kamron Batman 2021-08-22 23:35:18 -07:00 • committed by GitHub
parent 0bcf7a8d01
commit 9729b5a7b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 54 additions and 157 deletions

View file

@ -1,3 +1,4 @@
using System;
using System.IO;
using System.Runtime.CompilerServices;
@ -41,9 +42,8 @@ namespace Server
public static void Configure()
{
// Using this requires the old mapDif files to be present. Only needed to support Clients < 6.0.0.0
PatchLandEnabled = ServerConfiguration.GetOrUpdateSetting("maps.enableMapDiffPatches", false);
PatchStaticsEnabled = ServerConfiguration.GetOrUpdateSetting("maps.enableStaticsDiffPatches", false);
PatchLandEnabled = ServerConfiguration.GetOrUpdateSetting("maps.enableMapDiffPatches", !Core.HS);
PatchStaticsEnabled = ServerConfiguration.GetOrUpdateSetting("maps.enableStaticsDiffPatches", true);
}
[MethodImpl(MethodImplOptions.Synchronized)]
@ -51,15 +51,14 @@ namespace Server
{
using var fsData = new FileStream(dataPath, FileMode.Open, FileAccess.Read, FileShare.Read);
using var fsIndex = new FileStream(indexPath, FileMode.Open, FileAccess.Read, FileShare.Read);
var indexReader = new BinaryReader(fsIndex);
using var indexReader = new BinaryReader(fsIndex);
var count = (int)(indexReader.BaseStream.Length / 4);
for (var i = 0; i < count; ++i)
for (var i = 0; i < count; i++)
{
var blockID = indexReader.ReadInt32();
var x = blockID / matrix.BlockHeight;
var y = blockID % matrix.BlockHeight;
var x = Math.DivRem(blockID, matrix.BlockHeight, out var y);
fsData.Seek(4, SeekOrigin.Current);
@ -73,8 +72,6 @@ namespace Server
matrix.SetLandBlock(x, y, tiles);
}
indexReader.Close();
return count;
}