UPDATE:
Now, the first part of the code checks whether Y is in range 0x0~0xFF.
If it's larger than 0xFF, blockType is 0xFFFF. (sky?)
If it's smaller than 0x0, block Type is 0x000F. (ground that you can't dig further)
Then OMGWHATISTHIS1111111111
Code:
v4 = (X & 0xFFFFFFF0) - *(_DWORD *)(this + 4),
v5 = *(_DWORD *)(this + 0x14) * (((BYTE4(v4) & 0xF) + (signed int)v4) >> 4),
v6 = (Z & 0xFFFFFFF0) - *(_DWORD *)(this + 0xC),
v7 = *(_DWORD *)(*(_DWORD *)(this + 0x20)
+ 4
* ((Y & 0xFFFFFFF0) / 16
+ *(_DWORD *)(this + 0x18) * (((BYTE4(v6) & 0xF) + (signed int)v6) >> 4)
+ v5)))
//??? = 4 *((Y & 0xFFFFFFF0)/0x10 + ????)
//v7 = *(DWORD *)(*(DWORD *)(this+0x20) + 4*???)
Say X,Y,Z are the coordinates of the block.
Code:
mapDataAddress = *(DWORD *)(??? + 0x2C) + 8*( 0x100 *(Y&0xF) | 0x10*(Z&0xF) | (X&0xF) );
Now the ??? address is calculated in a complicated way so I'm stuck. Any ideas?
From IDA
Code:
signed __int16 __thiscall sub_9060E0(struct_mapBlockBase *this, int X, int Y, int Z)
{
__int64 v4; // qax@2
int v5; // ecx@2
__int64 v6; // qax@2
int mapBlockAddress; // eax@2
signed __int16 result; // ax@3
struct_mapBlockBase *mapBlockBase; // [sp+Ch] [bp-4h]@1
mapBlockBase = this;
if ( Y & 0xFFFFFF00
|| (v4 = (X & 0xFFFFFFF0) - this->nearX,
v5 = this->totalSize * (((BYTE4(v4) & 0xF) + v4) >> 4),
v6 = (Z & 0xFFFFFFF0) - mapBlockBase->nearZ,
(mapBlockAddress = *(mapBlockBase->baseAddress
+ 4 * ((Y & 0xFFFFFFF0) / 0x10u + mapBlockBase->diff * (((BYTE4(v6) & 0xF) + v6) >> 4) + v5))) == 0) )
{
result = 0xFu;
if ( Y >= 0 )
result = 0xFFFFu;
}
else
{
result = *(*(mapBlockAddress + 0x2C) + 8 * (X & 0xF | 16 * (Z & 0xF | 16 * (Y & 0xF))));
}
return result;
}
Caller function *(*v8 + 0x24)
Code:
v8 = *(this + 0x34);
byte_CB7E80[(*(*v8 + 0x24))(v19, v18, v17)]