0x6BC8F0: char __thiscall CGUnit_C__CanAttack(CGUnit_C *this, CGUnit_C *otherUnit)
Code:
char __thiscall CGUnit_C__CanAttack(CGUnit_C *this, CGUnit_C *otherUnit)
{
CGUnit_C *_this; // ebx@1
CGUnit_C *_otherUnit; // esi@4
DWORD v5; // eax@6
unsigned __int32 v6; // eax@9
char v7; // al@14
unsigned __int32 v8; // ecx@14
char v9; // al@18
sUnitFields *v10; // edi@18
DWORD v11; // eax@24
int v12; // ecx@25
DWORD v13; // eax@27
int v14; // edi@28
char v15; // al@36
sUnitFields *v16; // edi@36
int v17; // eax@45
int v18; // edi@45
int v19; // edi@47
int v20; // eax@48
unsigned __int8 v21; // al@51
char v22; // zf@53
unsigned __int8 v23; // cl@54
char v24; // [sp+Fh] [bp+Bh]@44
_this = this;
if ( (this->ObjectInfo.ObjectDescriptors->OBJECT_FIELD_TYPE >> 4) & 1 && (*(_DWORD *)(this->Unk2[964] + 8) >> 19) & 1 )
return 0;
_otherUnit = otherUnit;
if ( (otherUnit->ObjectInfo.ObjectDescriptors->OBJECT_FIELD_TYPE >> 4) & 1 )
{
if ( (*(_DWORD *)(otherUnit->Unk2[964] + 8) >> 4) & 1 )
{
v5 = this->Unk2[539];
if ( !v5 || !(*(_BYTE *)(v5 + 12) & 2) )
return 0;
}
}
v6 = otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS;
if ( (v6 >> 1) & 1
|| (v6 >> 20) & 1
|| (v6 >> 7) & 1
|| (v6 >> 16) & 1
|| (v6 >> 25) & 1
|| (v8 = this->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS,
(v7 = (_this->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS >> 3) & 1) != 0)
&& (LOWORD(otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS) >> 8) & 1
|| !v7 && (otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS >> 9) & 1
|| (v10 = otherUnit->ObjectInfo.UnitDescriptors, (v9 = (v10->UNIT_FIELD_FLAGS >> 3) & 1) != 0) && BYTE1(v8) & 1
|| !v9 && (v8 >> 9) & 1
|| (BYTE2(_this->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS_2) & 1 || BYTE2(v10->UNIT_FIELD_FLAGS_2) & 1)
&& ((v11 = _this->Unk2[921], !v11) ? (v12 = 0) : (v12 = *(_DWORD *)(v11 + 12)),
(v13 = otherUnit->Unk2[921], !v13) ? (v14 = 0) : (v14 = *(_DWORD *)(v13 + 12)),
v12 && *(_DWORD *)(v12 + 4) & 0x20000000 && sub_6DF920(otherUnit, _this) == _this
|| v14 && *(_DWORD *)(v14 + 4) & 0x20000000 && sub_6DF920(_this, otherUnit) == otherUnit) )
return 0;
v16 = _this->ObjectInfo.UnitDescriptors;
v15 = (v16->UNIT_FIELD_FLAGS >> 3) & 1;
if ( v15 || (otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS >> 3) & 1 )
{
if ( v15 && (otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS >> 3) & 1 )
{
v24 = 0;
if ( !sub_4B9B60((int)_this, (int)_otherUnit) )
{
v18 = sub_6ABF80(_this);
v17 = sub_6ABF80(_otherUnit);
if ( v18 && v17 )
{
v19 = *(_DWORD *)(v18 + 4104);
if ( *(_DWORD *)(v19 + 32) )
{
v20 = *(_DWORD *)(v17 + 4104);
if ( *(_DWORD *)(v20 + 32) )
{
if ( *(_DWORD *)v19 == *(_DWORD *)v20 && *(_DWORD *)(v19 + 4) == *(_DWORD *)(v20 + 4) )
return 1;
}
}
v21 = _otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_BYTES_2[1];
if ( v21 & 1 )
{
if ( _this->ObjectInfo.UnitDescriptors->UNIT_FIELD_BYTES_2[1] & 8 )
return v24;
v22 = (v21 & 8) == 0;
}
else
{
v23 = _this->ObjectInfo.UnitDescriptors->UNIT_FIELD_BYTES_2[1];
if ( v23 & 4 && v21 & 4 )
return 1;
if ( !(v23 & 2) && !(v21 & 2) || v23 & 8 )
return v24;
v22 = (v21 & 8) == 0;
}
}
else
{
if ( _this->ObjectInfo.UnitDescriptors->UNIT_FIELD_BYTES_2[1] & 8 )
return v24;
v22 = (_otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_BYTES_2[1] & 8) == 0;
}
if ( v22 )
return 1;
}
return v24;
}
if ( (!v15 || !(otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_BYTES_2[1] & 8))
&& (!((otherUnit->ObjectInfo.UnitDescriptors->UNIT_FIELD_FLAGS >> 3) & 1) || !(v16->UNIT_FIELD_BYTES_2[1] & 8)) )
return sub_4B9B60((int)_this, (int)otherUnit) == 0;
return 0;
}
return sub_4B9B90((int)_this, (int)otherUnit) || sub_4B9B90((int)otherUnit, (int)_this);
}