Mercurial > mm7
changeset 2364:94e5a9740727
OutdoorLocation::UpdateDiscoveredArea cleaned up
author | Grumpy7 |
---|---|
date | Sun, 11 May 2014 22:49:19 +0200 |
parents | 7966fc2949a7 |
children | 65789351a537 |
files | Outdoor.cpp Outdoor.h SaveLoad.cpp |
diffstat | 3 files changed, 21 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/Outdoor.cpp Thu May 01 12:59:50 2014 +0200 +++ b/Outdoor.cpp Sun May 11 22:49:19 2014 +0200 @@ -2051,9 +2051,9 @@ //v108 = (int)".odm"; //v83 = strlen(pContainer); //strcpy((char *)v141 + v83, (const char *)v108); - memcpy(uUndiscoveredArea, pSrc, 0x3C8); + memcpy(uFullyRevealedCellOnMap, pSrc, 0x3C8); //v84 = (const void *)(v74 + 968); - memcpy(uDicovered_area, pSrc + 0x3C8, 0x3C8); + memcpy(uPartiallyRevealedCellOnMap, pSrc + 0x3C8, 0x3C8); pSrc += 2 * 0x3C8; //v85 = (char *)v84 + 968; @@ -2061,8 +2061,8 @@ if ( *(int *)thisa ) { - memcpy(uUndiscoveredArea, Dst, 0x3C8u); - memcpy(uDicovered_area, Src, 0x3C8u); + memcpy(uFullyRevealedCellOnMap, Dst, 0x3C8u); + memcpy(uPartiallyRevealedCellOnMap, Src, 0x3C8u); } for (uint i = 0; i < uNumBModels; ++i) @@ -2378,43 +2378,26 @@ //----- (0047EF60) -------------------------------------------------------- int OutdoorLocation::UpdateDiscoveredArea(int X_grid_pos, int Y_grid_poa, int a4) { - int v4; // ecx@1 - int v5; // edx@2 - int v6; // edi@2 - int v9; // ebx@4 - int v10; // eax@5 -// int v12; // esi@12 - char v13; // al@12 - int v15; // [sp+4h] [bp-14h]@7 - - v4 = Y_grid_poa - 10; - if ( v4 < Y_grid_poa + 10 ) + for (int i = -10; i < 10; i++) { - v5 = v4 - Y_grid_poa; - v6 = (Y_grid_poa - 30); - for ( int i = 0; i < Y_grid_poa + 10 - v4; i++) + int currYpos = Y_grid_poa + i - 20; + for (int j = -10; j < 10; j++) { - v9 = X_grid_pos - 10; - v10 = v9 - X_grid_pos; - for ( v9; v9 < X_grid_pos + 10; ++v9 ) + int currXpos = X_grid_pos + j - 20; + int distanceSquared = i * i + j * j; + if ( distanceSquared <= 100 && currYpos >= 0 && currYpos <= 87 && currXpos >= 0 && currXpos <= 87 ) { - v15 = abs(v10) * abs(v10) + abs(v5) * abs(v5); - if ( v15 <= 100 && v9 >= 20 && v9 <= 107 && v6 >= 0 && v6 <= 87 ) - { - v13 = 1 << (7 - (v9 - 20) % 8); - this->uDicovered_area[v6][(v9 - 20)/8] |= v13; - if ( v15 <= 49 ) - this->uUndiscoveredArea[v6][(v9 - 20)/8] |= v13; - } - ++v10; + unsigned char v13 = 1 << (7 - currXpos % 8); + this->uPartiallyRevealedCellOnMap[currYpos][currXpos / 8] |= v13; + if ( distanceSquared <= 49 ) + this->uFullyRevealedCellOnMap[currYpos][currXpos / 8] |= v13; } - ++v6; - ++v5; } } return 1; } + //----- (0047F04C) -------------------------------------------------------- bool OutdoorLocation::_47F04C(signed int x_pos, signed int y_pos) { @@ -2423,7 +2406,7 @@ if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 ) result = 0; else - result = (uUndiscoveredArea[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0; + result = (uFullyRevealedCellOnMap[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0; return result; } @@ -2435,7 +2418,7 @@ if ( x_pos < 0 || x_pos >= 88 || y_pos < 0 || y_pos >= 88 ) result = 0; else - result = (uDicovered_area[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0; + result = (uPartiallyRevealedCellOnMap[y_pos][x_pos/8] & (unsigned __int8)(1 << (7 - (x_pos) % 8))) != 0; return result; }
--- a/Outdoor.h Thu May 01 12:59:50 2014 +0200 +++ b/Outdoor.h Sun May 11 22:49:19 2014 +0200 @@ -200,8 +200,8 @@ //int day_fogrange_1; //int day_fogrange_2; // char field_510[24]; - unsigned char uUndiscoveredArea[88][11];//968 - unsigned char uDicovered_area[88][11];//[968] + unsigned char uFullyRevealedCellOnMap[88][11];//968 the inner array is 11 bytes long, because every bit is used for a separate cell, so in the end it's 11 * 8 bits = 88 values + unsigned char uPartiallyRevealedCellOnMap[88][11];//[968] int field_CB8; int max_terrain_dimming_level; int field_CC0;
--- a/SaveLoad.cpp Thu May 01 12:59:50 2014 +0200 +++ b/SaveLoad.cpp Sun May 11 22:49:19 2014 +0200 @@ -426,9 +426,9 @@ pOutdoor->ddm.uNumDecorations = uNumLevelDecorations; memcpy(data_write_pos, &pOutdoor->ddm, sizeof(DDM_DLV_Header));//0x28 data_write_pos += sizeof(DDM_DLV_Header); - memcpy(data_write_pos, pOutdoor->uUndiscoveredArea, 0x3C8); + memcpy(data_write_pos, pOutdoor->uFullyRevealedCellOnMap, 0x3C8); data_write_pos += 968; - memcpy(data_write_pos, pOutdoor->uDicovered_area, 0x3C8); + memcpy(data_write_pos, pOutdoor->uPartiallyRevealedCellOnMap, 0x3C8); data_write_pos += 968; for (int i = 0; i < pOutdoor->uNumBModels ; ++i) for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j)