Fix HHP acres display in FieldItemEditor. (#607)

Co-authored-by: MyShiLingStar <MyShiLingStar@STARLIGHT>
This commit is contained in:
MyShiLingStar 2022-07-21 13:42:18 +09:00 committed by GitHub
parent f6756e9cb5
commit 8bf246aac9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 6 deletions

View File

@ -6,9 +6,9 @@ public static class AcreTileColor
{
public static readonly byte[] AcreTiles = ResourceUtil.GetBinaryResource("outside.bin");
public static int GetAcreTileColor(byte acre, int x, int y)
public static int GetAcreTileColor(ushort acre, int x, int y)
{
if (acre > (byte)OutsideAcre.FldOutSBridge01)
if (acre > (ushort)OutsideAcre.FldOutNGardenRFront00)
return Color.Transparent.ToArgb();
var baseOfs = acre * 32 * 32 * 4;

View File

@ -1,4 +1,5 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
namespace NHSE.Core
{
@ -151,14 +152,14 @@ public int GetTileColor(int x, in int y)
return TerrainTileColor.GetTileColor(tile).ToArgb();
}
private byte GetTileAcre(int x, int y)
private ushort GetTileAcre(int x, int y)
{
var acreX = 1 + (x / 16);
var acreY = 1 + (y / 16);
var acreIndex = ((AcreWidth + 2) * acreY) + acreX;
var ofs = acreIndex * 2;
return BaseAcres[ofs]; // u16 array, never > 255
return BitConverter.ToUInt16(BaseAcres, ofs);
}
}
}

View File

@ -1011,7 +1011,9 @@ private void CB_MapAcreSelect_SelectedValueChanged(object sender, EventArgs e)
var oldValue = Map.Terrain.BaseAcres[index * 2];
if (value == oldValue)
return;
Map.Terrain.BaseAcres[index * 2] = (byte)value;
byte[] ValueBytes = BitConverter.GetBytes(value);
Map.Terrain.BaseAcres[index * 2] = ValueBytes[0];
Map.Terrain.BaseAcres[index * 2 + 1] = ValueBytes[1];
ReloadBuildingsTerrain();
}