mirror of
https://github.com/kwsch/NHSE.git
synced 2026-09-29 05:16:33 -05:00
Add logic to upgrade/downgrade item layers
Allows seamless imports of old maps on new saves, and vice versa.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user