Code:
int CMapObj__GetGroup(int a1, int a2, int a3){
log(LOG_MEMORY, @" CMapObj__GetGroup(0x%X, 0x%X, 0x%X)", a1, a2, a3);
MemoryAccess *memory = [[Controller sharedInstance] wowMemoryAccess];
int result;
if ( !([memory readByte:a1 + 0xC] & 0x40) || (result = [memory readInt:a1 + 4 * a2 + 0x34], !([memory readByte:result + 0xC] & 0x40)) && !a3 )
result = 0;
return result;
}
signed int CMapStaticEntity__GetMapObjAndGroup(int baseAddressPlusC8, int *a2, int *a3, int *a4, int *a5, int a6){
MemoryAccess *memory = [[Controller sharedInstance] wowMemoryAccess];
int v6; // esi@1
int v7; // ebx@1
int v9; // eax@8
int v10; // eax@12
int v11; // edx@13
int v12; // eax@13
int v13; // eax@18
int v14; // eax@19
int v15; // edx@19
int v16; // eax@19
int v17; // eax@20
v6 = baseAddressPlusC8 + 20;
v7 = [memory readInt:baseAddressPlusC8 + 28];
if ( v7 & 1 || !v7 )
v7 = 0;
if ( a6 )
{
while ( !(v7 & 1) && v7 )
{
v9 = [memory readInt:v7 + 8];
if ( [memory readByte:v9 + 8] & 0x20 )
{
*a4 = v9;
v10 = [memory readInt:v9 + 16];
*a2 = v10;
if ( !([memory readByte:v10 + 13] & 2) )
{
v11 = [memory readInt:v10 + 44];
*a3 = v11;
v12 = CMapObj__GetGroup(v11, [memory readInt:[memory readInt:*a4] + 60], 0);
*a5 = v12;
if ( v12 )
return 1;
}
}
if ( v7 )
v7 = [memory readInt:[memory readInt:v6] + v7 + 4];
else
v7 = [memory readInt:baseAddressPlusC8 + 28];
}
}
else
{
while ( !(v7 & 1) && v7 )
{
v13 = [memory readInt:v7 + 8];
if ( [memory readByte:v13 + 8] & 0x20 )
{
*a4 = v13;
v14 = [memory readInt:v13 + 16];
*a2 = v14;
v15 = [memory readInt:v14 + 44];
*a3 = v15;
v16 = CMapObj__GetGroup(v15, [memory readInt:[memory readInt:*a4] + 60], 0);
*a5 = v16;
if ( v16 )
return 1;
}
v17 = baseAddressPlusC8 + 24;
if ( v7 )
v17 = [memory readInt:v6] + v7;
v7 = [memory readInt:v17 + 4];
}
}
return 0;
}
// we're passing structs here!
typedef struct WMOAreaTableRec
{
int32_t m_ID;
int32_t m_WMOID;
int32_t m_NameSetID;
int32_t m_WMOGroupID;
int32_t m_SoundProviderPref;
int32_t m_SoundProviderPrefUnderwater;
int32_t m_AmbienceID;
int32_t m_ZoneMusic;
int32_t m_IntroSound;
int32_t m_flags;
int32_t m_AreaTableID;
int32_t m_AreaName_lang;
int32_t m_field12; // added in 4.x
int32_t m_field13; // added in 4.x
int32_t m_field14; // added in 4.x
}WMOAreaTableRec;
typedef struct WoWClientDB{
void *funcTable;
int numRows;
int maxIndex;
int minIndex;
void *stringTable;
void *FirstRow;
void **Rows;
} WoWClientDB;
int BattleNetLogin__vFunc48(WMOAreaTableRec *a1, WMOAreaTableRec *ptr2)
{
int result; // eax@1
// load a2
WMOAreaTableRec a2;
MemoryAccess *memory = [[Controller sharedInstance] wowMemoryAccess];
[memory loadDataForObject:nil atAddress:(unsigned int)ptr2 Buffer:(Byte *)&a2 BufLength:sizeof(a2)];
//log(LOG_MEMORY, @" BattleNetLogin__vFunc48(0x%X, 0x%X)", a1, ptr2);
result = a1->m_WMOID - a2.m_WMOID;
if ( a1->m_WMOID == a2.m_WMOID )
{
result = a1->m_NameSetID - a2.m_NameSetID;
if ( a1->m_NameSetID == a2.m_NameSetID )
result = a1->m_WMOGroupID - a2.m_WMOGroupID;
}
return result;
}
void *SDBWMOAreaTableLookup(int WMOID, int NameSetID, int WMOGroupID){
WMOAreaTableRec rec;
rec.m_WMOID = WMOID;
rec.m_NameSetID = NameSetID;
rec.m_WMOGroupID = WMOGroupID;
//log(LOG_MEMORY, @" GetWMOAreaRec(0x%X, 0x%X, 0x%X)", WMOID, NameSetID, WMOGroupID);
// get our WMOAreaTableDBTable struct
WoWClientDB db;
MemoryAccess *memory = [[Controller sharedInstance] wowMemoryAccess];
if ( [memory loadDataForObject:nil atAddress:0xF85A94 Buffer:(Byte *)&db BufLength:sizeof(db)] && db.numRows > 0 ){
unsigned int firstRow = (unsigned int)db.FirstRow;
return bsearch(&rec, (const void *)firstRow, db.numRows, 0x3Cu, (int (*)(const void *, const void *))BattleNetLogin__vFunc48);
}
return 0;
}
union dword{
float f32;
uint32_t u32;
int32_t i32;
};
int CMap__QueryAreaIdTerrain(int a1, int a2){
MemoryAccess *memory = [[Controller sharedInstance] wowMemoryAccess];
union dword v2; // xmm0@1 // __m128
signed int v3; // edx@1
union dword v4; // xmm0@1 // __m128
signed int v5; // eax@1
int v6; // edx@1
int v7; // eax@1
signed int v8; // esi@1
int v9; // ecx@1
int v10; // edi@5
int v11; // eax@7
int v12; // edx@9
int v13; // eax@10
int result; // eax@11
char v15; // [sp+Ch] [bp-2Ch]@1
int memConst = 0x80000000; // [memory readInt:0xD76860];
// load v2 and v3
[memory loadDataForObject:nil atAddress:a2 + 4 Buffer:(Byte*)&v2 BufLength:sizeof(v2)];
v2.f32 = v2.f32 - 17066.666;
v2.i32 = v2.i32 ^ memConst;
v3 = (signed int)floor(v2.f32 * 0.030000001);
v15 = v3;
[memory loadDataForObject:nil atAddress:a2 Buffer:(Byte*)&v4 BufLength:sizeof(v4)];
v5 = v3;
v6 = [memory readInt:a1 + 0x470];
v7 = (v5 >> 4) & 0x3F;
// load v4
v4.f32 = v4.f32 - 17066.666;
v4.i32 = v4.i32 ^ memConst;
v8 = (signed int)floor(v2.f32 * 0.030000001);
v9 = (v8 >> 4) & 0x3F;
if ( v6
&& [memory readInt:a1 + 1140]
&& v7 >= [memory readInt:a1 + 1124]
&& v7 <= [memory readInt:a1 + 1132]
&& (v10 = [memory readInt:a1 + 1120], v9 >= v10)
&& v9 <= [memory readInt:a1 + 1128]
&& (v11 = [memory readInt:a1 + 1152] + 8 * (v7 - [memory readInt:a1 + 1124] + (v9 - v10) * v6)) != 0
&& [memory readByte:v11] & 2
&& (v12 = [memory readInt:v11 + 4]) != 0
&& (v13 = [memory readInt:v12 + 4 * (16 * (v8 & 0xF) + (v15 & 0xF)) + 240]) != 0 ){
result = [memory readInt:v13 + 0x98];
}
else
result = 0;
return result;
}
signed int CWorldMap__QueryOutdoors(int baseAddressPlusC8){
MemoryAccess *memory = [[Controller sharedInstance] wowMemoryAccess];
int v1; // ecx@2
union dword v2; // xmm0@2 // __m128
signed int v3; // esi@2
union dword v4; // xmm0@2 // __m128
signed int v5; // ebx@2
int v6; // eax@3
int dbIndex; // eax@5
int dbIndex2;
int dbMinIndex; // eax@5
int rowPtr; // eax@7
int m_SoundProviderPref; // eax@8
signed int v15; // edx@16
int v16; // eax@18
int v17; // ebx@22
int v18; // eax@24
int v19; // eax@25
char v20; // [sp+40h] [bp-28h]@1
int v21; // [sp+44h] [bp-24h]@1
int v22; // [sp+48h] [bp-20h]@1
int v23; // [sp+4Ch] [bp-1Ch]@1
WoWClientDB db;
[memory loadDataForObject:nil atAddress:0xF85A94 Buffer:(Byte *)&db BufLength:sizeof(db)];
v23 = 0;
BOOL res = CMapStaticEntity__GetMapObjAndGroup(baseAddressPlusC8, &v22, &v21, &v20, &v23, 0);
log(LOG_MEMORY, @"%d CMapStaticEntity__GetMapObjAndGroup(0x%X, 0x%X, 0x%X, 0x%X, 0x%X, 0)", res, baseAddressPlusC8, v22, v21, v20, v23);
if ( !res )
{
int memConst = 0x80000000; // [memory readInt:0xD775E0];
v1 = [memory readInt:baseAddressPlusC8 + 0x10];
// load v2 and v3
[memory loadDataForObject:nil atAddress:baseAddressPlusC8 + 0x74 Buffer:(Byte*)&v2 BufLength:sizeof(v2)];
v2.f32 = v2.f32 - 17066.666;
v2.i32 = v2.i32 ^ memConst;
v3 = (signed int)floor(v2.f32 * 0.0018750001);
// load v4 and v5
[memory loadDataForObject:nil atAddress:baseAddressPlusC8 + 0x70 Buffer:(Byte*)&v4 BufLength:sizeof(v4)];
v4.f32 = v4.f32 - 17066.666;
v4.i32 = v4.i32 ^ memConst;
v5 = (signed int)floor(v4.f32 * 0.0018750001);
if ( [memory readInt:v1 + 4] ){
v6 = [memory readInt:v1 + 0xC];
}
else
{
if ( ![memory readInt:v1 + 76]
|| ![memory readInt:v1 + 80]
|| v3 < [memory readInt:v1 + 64]
|| v3 > [memory readInt:v1 + 72]
|| (v15 = [memory readInt:v1 + 60], v5 < v15)
|| v5 > [memory readInt:v1 + 68]
|| (v16 = [memory readInt:v1 + 0x5C] + 2 * (v3 - [memory readInt:v1 + 64] + [memory readInt:v1 + 76] * (v5 - v15)) == 0
|| ![memory readByte:v16] & 1) ){
goto LABEL_21;
log(LOG_GENERAL, @"jumping LABEL_21");
}
v6 = [memory readInt:v1 + 4 * [memory readByte:v16 + 1] + 12];
}
log(LOG_GENERAL, @"v6 = 0x%X", v6);
if ( v6 )
{
dbIndex = CMap__QueryAreaIdTerrain(v6, baseAddressPlusC8 + 0x70);
log(LOG_GENERAL, @"Index: 0x%X", dbIndex);
dbIndex2 = dbIndex;
dbMinIndex = db.minIndex;
if ( dbIndex2 >= dbMinIndex )
{
LABEL_6:
if ( dbIndex2 <= db.maxIndex )
{
rowPtr = [memory readInt:(unsigned int)db.Rows + 4 * (dbIndex2 - dbMinIndex)];
if ( rowPtr ){
m_SoundProviderPref = [memory readInt:rowPtr + 0x10];
log(LOG_MEMORY, @"Sound: 0x%X Water: 0x%X", m_SoundProviderPref, [memory readInt:rowPtr + 0x14]);
if ( !(m_SoundProviderPref & 0x4000000) ){
if ( m_SoundProviderPref & 0x2000000 ){
log(LOG_GENERAL, @"0");
return 0;
}
}
}
}
}
log(LOG_GENERAL, @"1");
return 1;
}
LABEL_21:
log(LOG_GENERAL, @"at LABEL_21");
dbIndex2 = 0;
dbMinIndex = db.minIndex;
if ( dbMinIndex <= 0 ){
log(LOG_GENERAL, @"Jumping to LABEL_6");
goto LABEL_6;
}
log(LOG_GENERAL, @"11");
//return 1;
}
v17 = ([memory readInt:v23 + 96] >> 3) & 1;
v18 = (unsigned int)SDBWMOAreaTableLookup([memory readInt:[memory readInt:v21 + 2396] + 32], [memory readInt:v22 + 276], [memory readInt:v23 + 112]);
if ( !v18 )
return v17;
v19 = [memory readInt:v18 + 36];
if ( v19 & 4 ){
log(LOG_GENERAL, @"111");
return 1;
}
if ( v19 & 2 ){
log(LOG_GENERAL, @"000");
return 0;
}
return v17;
log(LOG_GENERAL, @"00000");
return 0;
}