[DiscordArchive] in ADT mcnk chunk, how can you convert holes_high_res (uint64) to holes_low_res (uint16)?
[DiscordArchive] in ADT mcnk chunk, how can you convert holes_high_res (uint64) to holes_low_res (uint16)?
Archived author: Deleted User • Posted: 2024-07-03T23:07:57.455000+00:00
Original source
in ADT mcnk chunk, how can you convert holes_high_res (uint64) to holes_low_res (uint16)?
Archived author: Deleted User • Posted: 2024-07-04T00:04:34.649000+00:00
Original source
figured it out heres the solution:
```cpp
private ushort ConvertHighResToLowRes(ulong hole)
{
if (hole == 0)
return 0;
ushort low = 0;
for (int i = 0; i < 64; ++i)
{
if ((hole >> i & 0x1) != 0)
{
int x = i % 8 / 2;
int y = i / 16;
low |= (ushort)(1 << x + y * 4);
}
}
byte[] bytes = BitConverter.GetBytes(low);
Array.Reverse(bytes);
return BitConverter.ToUInt16(bytes, 0);
}
```
my problem was not converting the endianness