Mercurial > mm7
diff mm7_3.cpp @ 1410:38df78aba732
deleted stru220.h and stru220 (bezier terrain stuff)
stru167 -> TrailParticle
stru167warp -> TrailParticleGenerator
author | Nomad |
---|---|
date | Fri, 26 Jul 2013 22:19:29 +0200 |
parents | 3161094869e0 |
children | 2423bc2af692 |
line wrap: on
line diff
--- a/mm7_3.cpp Fri Jul 26 21:16:51 2013 +0200 +++ b/mm7_3.cpp Fri Jul 26 22:19:29 2013 +0200 @@ -42,7 +42,6 @@ #include "Time.h" #include "IconFrameTable.h" #include "TurnEngine.h" -#include "stru220.h" #include "Events2D.h" #include "stru176.h" #include "stru298.h" @@ -5611,8 +5610,8 @@ //int v5; // eax@8 //SpawnPointMM7 *v6; // edx@14 size_t v7; // eax@19 - char *v8; // eax@19 - char *v9; // eax@21 + //char *v8; // eax@19 + //char *v9; // eax@21 char Source[120]; // [sp+Ch] [bp-84h]@19 const char *pFilename; // [sp+84h] [bp-Ch]@1 //unsigned int v12; // [sp+88h] [bp-8h]@12 @@ -5621,7 +5620,7 @@ pFilename = pLevelFilename; thisa->AllocSoftwareDrawBuffers(); pOutdoorCamera->_485F64(); - pWeather->bRenderSnow = 0; + pWeather->bRenderSnow = false; pRenderer->ClearZBuffer(0, 479); thisa = (OutdoorCamera *)1; GetAlertStatus(); @@ -5691,22 +5690,16 @@ pOutdoor->UpdateSunlightVectors(); pOutdoorCamera->int_fov_rad = (signed __int64)pIndoorCamera->flt_1C_fov; pOutdoorCamera->int_fov_rad_inv = (signed __int64)pIndoorCamera->flt_20_inv_1C; - v8 = (char *)&array_77EC08[0].ptr_38; - do - { - *(int *)v8 = (int)&stru_8019C8; - v8 += 268; - } - while ( (signed int)v8 < (signed int)&unk_801A00 ); - v9 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v9 - 1) = 0; - *(int *)v9 = 0; - *((int *)v9 - 5) = 0; - v9 += 268; - } - while ( (signed int)v9 < (signed int)&unk_801A0C ); + + for (int i = 0; i < 20000; ++i) + { + array_77EC08[i].ptr_38 = &stru_8019C8; + + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + array_77EC08[i].ptr_48 = nullptr; + } + MM7Initialization(); } @@ -5748,139 +5741,33 @@ return v1; } -//----- (0047BC6F) -------------------------------------------------------- -unsigned __int16 *__fastcall GetBillboardPalette(RenderBillboard *a1, int a2, signed int a3, int a4) -{ - int v4; // ebx@1 - int v6; // edx@4 - int v7; // ecx@5 - signed int v8; // eax@6 - signed __int64 v9; // qtt@11 - signed int v10; // eax@12 - int v11; // esi@17 - signed __int64 v12; // qtt@19 - double v13; // ST10_8@19 - int v14; // edi@25 - signed int v15; // edx@26 - signed __int64 v16; // qtt@29 - signed int v17; // eax@30 - int v18; // [sp+10h] [bp-8h]@1 - float a3a; // [sp+20h] [bp+8h]@19 - - v4 = a2; - v18 = a2; - if ( pParty->armageddon_timer ) - return PaletteManager::Get(a2); - if ( !pWeather->bNight ) - { - if (day_attrib & DAY_ATTRIB_FOG) - { - v14 = day_fogrange_1 << 16; - if ( a3 >= day_fogrange_1 << 16 ) - { - if ( a3 <= day_fogrange_2 << 16 ) - { - LODWORD(v16) = (a3 - v14) << 16; - HIDWORD(v16) = (a3 - v14) >> 16; - v15 = (unsigned __int64)(27 * v16 / ((day_fogrange_2 - day_fogrange_1) << 16)) >> 16; - } - else - { - v15 = 27; - } - } - else - { - v15 = 0; - } - v17 = _43F55F_get_billboard_light_level(a1, v15); - if ( v17 > 27 ) - v17 = 27; - if ( !a3 ) - v17 = 27; - v7 = v18; - v6 = v17; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); - } - v11 = a4; - if ( a4 < 0 ) - v11 = 0; - LODWORD(v12) = a3 << 16; - HIDWORD(v12) = a3 >> 16; - a3a = (double)(signed int)(((unsigned __int64)(11 * v12 / (pOutdoorCamera->shading_dist_shade << 16)) >> 16) + 20) - * pOutdoor->fFogDensity; - v13 = a3a + 6.7553994e15; - v10 = _43F55F_get_billboard_light_level(a1, LODWORD(v13) + v11); - if ( v10 > 27 ) - v10 = 27; - if ( v10 < a4 ) - v10 = a4; - if ( v10 > pOutdoor->max_terrain_dimming_level ) - v10 = pOutdoor->max_terrain_dimming_level; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v6 = 0; - if (pWeather->bNight) - { - v8 = 67108864; - if ( (signed __int64)pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uExpireTime > 0 ) - v8 = pParty->pPartyBuffs[PARTY_BUFF_TORCHLIGHT].uPower << 26; - if ( a3 <= v8 ) - { - if ( a3 > 0 ) - { - LODWORD(v9) = a3 << 16; - HIDWORD(v9) = a3 >> 16; - v6 = (unsigned __int64)(27 * v9 / v8) >> 16; - } - } - else - { - v6 = 27; - } - v10 = _43F55F_get_billboard_light_level(a1, v6); - if ( v10 > 27 || !a3 ) - v10 = 27; - return PaletteManager::Get_Dark_or_Red_LUT(v4, v10, 1); - } - v7 = 0; - return (unsigned __int16 *)PaletteManager::Get_Mist_or_Red_LUT(v7, v6, 1); -} //----- (0047C370) -------------------------------------------------------- -unsigned int __cdecl GetLevelFogColor() +unsigned int GetLevelFogColor() { - unsigned int result; // eax@2 signed __int64 v1; // qax@5 int v2; // eax@6 - if ( bUnderwater ) - { - result = 0xFF258F5C; - } - else - { - if (day_attrib & DAY_ATTRIB_FOG) - { + if (bUnderwater) + return 0xFF258F5C; + + if (day_attrib & DAY_ATTRIB_FOG) + { if ( pWeather->bNight ) // night-time fog { - __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad + __debugbreak(); // decompilation can be inaccurate, please send savegame to Nomad v2 = -(pWeather->bNight != 1); - result = (v2 & 0xE0E0E1) - 0xE0E0E1; + return (v2 & 0xE0E0E1) - 0xE0E0E1; } else { v1 = (signed __int64)((1.0 - pOutdoor->fFogDensity) * 200.0 + pOutdoor->fFogDensity * 31.0); - result = v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); + return v1 | (((unsigned int)v1 | (((unsigned int)v1 | 0xFFFFFF00) << 8)) << 8); } - } - else - return 0; - } - return result; + } + + return 0; } -// 6BE030: using guessed type int day_attrib; -// 6BE3C4: using guessed type char bUnderwater; //----- (0047C3D7) -------------------------------------------------------- int __fastcall sub_47C3D7_get_fog_related_stuff(int a1, int a2, float a3) @@ -6112,56 +5999,6 @@ return (64 - a1) << 9; } -//----- (0047F4D3) -------------------------------------------------------- -void __fastcall sub_47F4D3(int band1, int band2, int band3) -{ - int v3; // edi@1 - //stru220 *v4; // esi@1 - double v5; // ST2C_8@3 - double v6; // st7@3 - //double v7; // [sp+18h] [bp-28h]@3 - //double v8; // [sp+20h] [bp-20h]@2 - int v9; // [sp+34h] [bp-Ch]@1 - int v10; // [sp+38h] [bp-8h]@1 - //signed int band3a; // [sp+48h] [bp+8h]@2 - - v9 = band2 * 512; - pOutdoorCamera->outdoor_grid_band_3 = band3; - v10 = band1 * 512; - v3 = band3 * 512; - pOutdoorCamera->uPickDepth = band3 * 512; - //v4 = stru_76E5C8; // v4: 0 -> 65536 - for (uint i = 0; i < 16384; ++i) - //do - { - auto v4 = stru_76E5C8[i]; - //band3a = 256; - //v8 = (double)(signed int)((char *)v4 + 256 - (int)stru_76E5C8); - for (uint j = 0; j < 128; ++j) // band3a: 0 -> 128 - { - v5 = pow(j * 512 + 256, 2.0); - v6 = pow(i * 4 + 256, 2.0); - //*((float *)&v5 + 1) = sqrt(v6 + v5); - int v7 = floorf(sqrtf(v5 + v6) + 0.5f);//*((float *)&v5 + 1) + 6.7553994e15; - if (v7 >= v10) - { - if (v7 >= v9) - v4.field_0 = ((v7 >= v3) - 1) & 2; - else - v4.field_0 = 2; - } - else - { - v4.field_0 = 1; - } - //band3a += 512; - v4.distance = v7; - //++v4; - } - //while ( band3a < 65792 ); - } - //while ( (signed int)v4 < (signed int)arary_77E5C8 ); -} //----- (004811A3) -------------------------------------------------------- void Polygon::DrawBorderTiles() @@ -6178,24 +6015,15 @@ //----- (00481EB7) -------------------------------------------------------- -void __cdecl ResetPolygons() +void ResetPolygons() { - int v0; // ecx@1 - char *v1; // eax@2 - - v0 = pOutdoorCamera->uNumPolygons; - if ( pOutdoorCamera->uNumPolygons > 0 ) - { - v1 = (char *)&array_77EC08[0].prolly_tail; - do - { - *((int *)v1 - 1) = 0; - *(int *)v1 = 0; - *((int *)v1 - 5) = 0; - v1 += 268; - --v0; - } - while ( v0 ); + for (auto i = 0; i < pOutdoorCamera->uNumPolygons; ++i) + { + array_77EC08[i].prolly_head = nullptr; + array_77EC08[i].prolly_tail = nullptr; + + array_77EC08[i].flags = 0; + array_77EC08[i].field_32 = 0; } } @@ -6211,70 +6039,6 @@ pOutdoorCamera->field_44 = 0; } -//----- (00481EFA) -------------------------------------------------------- -bool __fastcall sub_481EFA(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, RenderVertexSoft *a4, int a5) -{ - RenderVertexSoft *v5; // esi@1 - RenderVertexSoft *v6; // edx@1 - bool v7; // edi@2 - bool v8; // ecx@5 - bool v9; // esi@8 - bool v10; // eax@11 - double v11; // st7@14 - signed int v12; // esi@15 - signed int v13; // edx@18 - signed int v14; // ecx@21 - signed int v15; // eax@24 - RenderVertexSoft *v17; // [sp+Ch] [bp-8h]@1 - - v5 = a2; - v6 = a1; - v17 = v5; - v7 = a1->vWorldViewPosition.x < 8.0; - v8 = v5->vWorldViewPosition.x < 8.0; - v9 = a3->vWorldViewPosition.x < 8.0; - v10 = a4->vWorldViewPosition.x < 8.0; - return !(v8 & v9 & v10 & v7) - && ((v11 = (double)pOutdoorCamera->shading_dist_mist, v11 > v6->vWorldViewPosition.x) ? (v12 = 0) : (v12 = 1), - v11 > v17->vWorldViewPosition.x ? (v13 = 0) : (v13 = 1), - v11 > a3->vWorldViewPosition.x ? (v14 = 0) : (v14 = 1), - v11 > a4->vWorldViewPosition.x ? (v15 = 0) : (v15 = 1), - !(v13 & v14 & v15 & v12)); -} - -//----- (00481FC9) -------------------------------------------------------- -int __fastcall sub_481FC9(RenderVertexSoft *a1, RenderVertexSoft *a2, RenderVertexSoft *a3, struct Polygon *a4)//Rotate camera -{ - float arg_0, arg_4, var_4, var_8, var_c, var_10, var_14; - - if (a1->vWorldPosition.y == a2->vWorldPosition.y && a2->vWorldPosition.y == a3->vWorldPosition.y) - a4->flags |= 0x10; - var_c = a1->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_14 = a1->vWorldViewPosition.y - a2->vWorldViewPosition.y; - arg_0 = a1->vWorldViewPosition.z - a2->vWorldViewPosition.z; - var_10 = a3->vWorldViewPosition.x - a2->vWorldViewPosition.x; - var_8 = a3->vWorldViewPosition.y - a2->vWorldViewPosition.y; - var_4 = a3->vWorldViewPosition.z - a2->vWorldViewPosition.z; - arg_4 = a3->vWorldPosition.y - a2->vWorldPosition.y; - if (((a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.x - a2->vWorldPosition.x) - (a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.y - a2->vWorldPosition.y)) * (pIndoorCamera->pos.y - a2->vWorldPosition.z) + - ((a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.y - a2->vWorldPosition.y) - (a3->vWorldPosition.y - a2->vWorldPosition.y) * (a1->vWorldPosition.z - a2->vWorldPosition.z)) * (pIndoorCamera->pos.x - a2->vWorldPosition.x) + - ((a3->vWorldPosition.x - a2->vWorldPosition.x) * (a1->vWorldPosition.z - a2->vWorldPosition.z) - (a3->vWorldPosition.z - a2->vWorldPosition.z) * (a1->vWorldPosition.x - a2->vWorldPosition.x)) * (pIndoorCamera->pos.z - a2->vWorldPosition.y) < 0) - { - arg_4 = var_4 * var_14 - var_8 * arg_0; - a4->v_18.x = floorf(arg_4 + 0.5f); - arg_4 = var_10 * arg_0 - var_4 * var_c; - a4->v_18.y = floorf(arg_4 + 0.5f); - arg_4 = var_8 * var_c - var_10 * var_14; - a4->v_18.z = floorf(arg_4 + 0.5f); - a4->_486089_normalize_v_18(); - arg_4 = -(a4->v_18.x * a2->vWorldViewPosition.x) - a4->v_18.y * a2->vWorldViewPosition.y - a4->v_18.z * a2->vWorldViewPosition.z; - a4->field_24 = floorf(arg_4 + 0.5f); - return true; - } - else - return false; -} - //----- (004823F4) -------------------------------------------------------- bool IsTerrainSlopeTooHigh(int pos_x, int pos_z) { @@ -6469,50 +6233,28 @@ } //----- (00486089) -------------------------------------------------------- -void Polygon::_486089_normalize_v_18() +void Polygon::_normalize_v_18() { - //Polygon *v1; // esi@1 double v2; // st7@1 double v3; // st6@1 - float v4; // ST18_4@2 double v5; // st5@1 - float v6; // ST14_4@2 - double v7; // st7@1 - float v8; // ST24_4@2 - float v9; // ST20_4@2 - double v10; // ST0C_8@2 - float v11; // ST18_4@2 - double v12; // ST0C_8@2 - float v13; // ST14_4@2 - double v14; // ST0C_8@2 - float v15; // [sp+20h] [bp-8h]@1 //v1 = this; v2 = (double)this->v_18.x; - v15 = v2; v3 = (double)this->v_18.y; v5 = (double)this->v_18.z; - v7 = sqrt(v5 * v5 + v3 * v3 + v2 * v2); - if ( v7 == 0.0 ) - { - this->v_18.x = 0; - this->v_18.y = 0; - this->v_18.z = 65536; + float len = sqrt(v5 * v5 + v3 * v3 + v2 * v2); + if (fabsf(len) < 1e-6f) + { + v_18.x = 0; + v_18.y = 0; + v_18.z = 65536; } else { - v8 = 1.0 / v7; - v9 = v8 * v15 * 65536.0; - v10 = v9 + 6.7553994e15; - this->v_18.x = LODWORD(v10); - v4 = v3; - v11 = v8 * v4 * 65536.0; - v12 = v11 + 6.7553994e15; - this->v_18.y = LODWORD(v12); - v6 = v5; - v13 = v8 * v6 * 65536.0; - v14 = v13 + 6.7553994e15; - this->v_18.z = LODWORD(v14); + v_18.x = round(v2 / len * 65536.0); + v_18.y = round(v3 / len * 65536.0); + v_18.y = round(v5 / len * 65536.0); } } @@ -6651,58 +6393,6 @@ return result; } - -//----- (00440DF5) -------------------------------------------------------- -int stru167_wrap::Push(__int16 a2, __int16 a3, __int16 a4, int a5, __int16 bgr) -{ - int result; // eax@1 - - pElements[uNumElements].field_6_rnd_value = a2; - pElements[uNumElements].field_8_rnd_value = a3; - pElements[uNumElements].field_A_rnd_value = a4; - pElements[uNumElements].field_C_time_left = rand() % 64 + 256; - pElements[uNumElements].field_E_time_to_live = pElements[uNumElements].field_C_time_left; - result = 3 * uNumElements; - pElements[uNumElements++].bgr16 = bgr; - if (uNumElements >= 100 ) - uNumElements = 0; - return result; -} - -//----- (00440E91) -------------------------------------------------------- -void stru167_wrap::_440E91(__int16 x, int y, int z, int a5, __int16 bgr) -{ - stru167_wrap *v6; // edi@1 - int i; // esi@1 - int v8; // ST08_4@2 - int v9; // ST04_4@2 - int v10; // eax@2 - - v6 = this; - for ( i = 0; i < rand() % 6 + 5; ++i ) - { - v8 = z + rand() % 33; - v9 = rand() % 33 + y - 16; - v10 = rand(); - Push(v10 % 33 + x - 16, v9, v8, a5, bgr); - } -} - -//----- (00440F07) -------------------------------------------------------- -void stru167_wrap::_440F07() -{ - for (uint i = 0; i < 100; ++i) - { - if (pElements[i].field_C_time_left > 0) - { - pElements[i].field_A_rnd_value += rand() % 5 + 4; - pElements[i].field_6_rnd_value += rand() % 5 - 2; - pElements[i].field_8_rnd_value += rand() % 5 - 2; - pElements[i].field_C_time_left -= (short)pEventTimer->uTimeElapsed; - } - } -} - //----- (0044100D) -------------------------------------------------------- bool sub_44100D() {