Beco: Difference between revisions
no edit summary
imported>Leoetlino No edit summary |
imported>Leoetlino No edit summary |
||
Line 43: | Line 43: | ||
=== Getting the custom data for a given coordinate === | === Getting the custom data for a given coordinate === | ||
{{ | {{expand section}} | ||
At 0x7100E41C40 in Switch 1.5.0: | |||
<syntaxhighlight lang="c++"> | |||
unsigned int __fastcall eco::getCurrentAreaNum(float posX, float posZ, Ecosystem *ecosystem, EcoMapInfo *info) | |||
{ | |||
float _x; // s2 | |||
float _z; // s0 | |||
int divisor; // w10 | |||
int numEntries; // w12 | |||
float v8; // s4 | |||
signed int c_x; // w8 | |||
float v10; // s0 | |||
float v11; // s1 | |||
int c_z; // w9 | |||
int idx; // w9 | |||
u32 *v14; // x9 | |||
__int64 v15; // x10 | |||
__int64 v16; // x11 | |||
EcoMapEntry *tables; // x12 | |||
EcoMapEntry *_entryEnd; // x11 | |||
EcoMapEntry *_entry; // x10 | |||
signed int totalLength; // w9 | |||
unsigned int result; // w0 | |||
_x = -5000.0; | |||
if ( posX >= -5000.0 ) | |||
{ | |||
_x = posX; | |||
if ( posX > 4999.0 ) | |||
_x = 4999.0; | |||
} | |||
_z = -4000.0; | |||
if ( posZ >= -4000.0 ) | |||
{ | |||
_z = posZ; | |||
if ( posZ > 4000.0 ) | |||
_z = 4000.0; | |||
} | |||
divisor = info->map->divisor; | |||
numEntries = info->map->numTables - 2; | |||
if ( (float)(_x + 5000.0) < 0.0 ) | |||
v8 = -0.5; | |||
else | |||
v8 = 0.5; | |||
c_x = (signed int)(float)((float)(_x + 5000.0) + v8); | |||
v10 = _z + 4000.0; | |||
if ( v10 < 0.0 ) | |||
v11 = -0.5; | |||
else | |||
v11 = 0.5; | |||
c_z = (signed int)(float)(v10 + v11) / divisor; | |||
if ( c_z <= numEntries ) | |||
numEntries = (signed int)(float)(v10 + v11) / divisor; | |||
if ( c_z >= 0 ) | |||
idx = numEntries; | |||
else | |||
idx = 0; | |||
v14 = &info->tableOffsets[idx]; | |||
if ( divisor == 0xA ) | |||
c_x = (0x66666667LL * c_x >> 0x22) + ((unsigned __int64)(0x66666667LL * c_x) >> 0x3F); | |||
v15 = (signed int)*v14; | |||
v16 = (signed int)v14[1]; | |||
if ( (signed int)v15 >= (signed int)v16 ) | |||
return 0xFFFFFFFF; | |||
tables = info->tables; | |||
_entryEnd = (EcoMapEntry *)((char *)tables + 2 * v16); | |||
_entry = (EcoMapEntry *)((char *)tables + 2 * v15); | |||
totalLength = 0; | |||
result = 0xFFFFFFFF; | |||
while ( 1 ) | |||
{ | |||
totalLength += _entry->length; | |||
if ( c_x < totalLength ) | |||
break; | |||
++_entry; | |||
if ( _entry >= _entryEnd ) | |||
return result; | |||
} | |||
return _entry->value; | |||
} | |||
</syntaxhighlight> | |||
[[Category:File formats]] | [[Category:File formats]] | ||
[[Category:File extensions]] | [[Category:File extensions]] |