Add logic to upgrade/downgrade item layers

Allows seamless imports of old maps on new saves, and vice versa.
This commit is contained in:
Kurt
2026-01-16 22:16:36 -06:00
parent f443add432
commit f60a7e60e8
3 changed files with 139 additions and 24 deletions

View File

@@ -41,15 +41,15 @@ public static bool ImportToLayerAcreAll(FieldItemLayer layer)
var path = ofd.FileName;
var fi = new FileInfo(path);
int expect = layer.TileInfo.TotalCount * Item.SIZE;
if (fi.Length != expect)
var expect = layer.TileInfo.TotalCount * Item.SIZE;
if (fi.Length != expect && !FieldItemUpgrade.IsUpdateNeeded(fi.Length, expect))
{
WinFormsUtil.Error(string.Format(MessageStrings.MsgDataSizeMismatchImport, fi.Length, expect));
return false;
}
var data = File.ReadAllBytes(path);
FieldItemUpgrade.DetectUpdate(ref data, expect);
layer.ImportAll(data);
return true;
}