Forums WoW Modding Support Archives WoWModding Support Archives [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)?

[DiscordArchive] in ADT mcnk chunk, how can you convert holes_high_res (uint64) to holes_low_res (uint16)?

rektbyfaith
Administrator
0
07-03-2024, 11:07 PM
#1
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)?
rektbyfaith
07-03-2024, 11:07 PM #1

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)?

rektbyfaith
Administrator
0
07-04-2024, 12:04 AM
#2
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
rektbyfaith
07-04-2024, 12:04 AM #2

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

Recently Browsing
 1 Guest(s)
Recently Browsing
 1 Guest(s)