Mercurial > mm7
changeset 105:56e11be29db1
Слияние
author | Ritor1 |
---|---|
date | Tue, 05 Feb 2013 19:08:52 +0600 |
parents | 41145af69341 (current diff) 7bdf8f1150eb (diff) |
children | efece1632349 |
files | Outdoor.cpp Render.cpp |
diffstat | 21 files changed, 1494 insertions(+), 1053 deletions(-) [+] |
line wrap: on
line diff
--- a/Actor.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/Actor.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -1435,7 +1435,7 @@ void Actor::_43AC45(unsigned int uActorID, int a2) { Actor *v2; // esi@1 - char *v3; // edi@4 + Actor *v3; // edi@4 int v4; // ebx@8 int v5; // ST1C_4@8 int v6; // eax@8 @@ -1451,29 +1451,29 @@ v9 = 0; if ( (signed int)uNumActors > 0 ) { - v3 = (char *)&pActors[0].vPosition.y; + v3 = pActors; do { - if ( ((Actor *)(v3 - 144))->CanAct() ) + if ( v3->CanAct() ) { if ( v9 != uActorID_ ) { - if ( Actor::_43ABB0(v2, (Actor *)(v3 - 144)) ) + if ( Actor::_43ABB0(v2, v3) ) { - v4 = abs(*((short *)v3 - 1) - v2->vPosition.x); - v5 = abs(*(short *)v3 - v2->vPosition.y); - v6 = abs(*((short *)v3 + 1) - v2->vPosition.z); + v4 = abs(v3->vPosition.x - v2->vPosition.x); + v5 = abs(v3->vPosition.y - v2->vPosition.y); + v6 = abs(v3->vPosition.z - v2->vPosition.z); if ( (double)sub_4621DA(v4, v5, v6) < 4096.0 ) { - *(v3 - 83) = 4; + v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)4; if ( v7 == 1 ) - *(v3 - 106) |= 8u; + BYTE2(v3->uAttributes) |= 8u; } } } } ++v9; - v3 += 836; + ++v3; } while ( v9 < (signed int)uNumActors ); } @@ -3026,7 +3026,7 @@ signed int v6; // edx@2 ActorJob *v7; // eax@2 signed int v8; // edi@2 - char *v9; // ecx@2 + ActorJob *v9; // ecx@2 __int16 v10; // cx@15 signed int v12; // [sp+8h] [bp-4h]@1 @@ -3039,16 +3039,16 @@ v6 = 65535; v7 = &v4->pScheduledJobs[v3]; v8 = 7; - v9 = (char *)&v7[7].uHour; - while ( !(*(v9 - 3) & 1) || (unsigned __int8)*v9 > v12 ) + v9 = &v7[7];//(char *)&v7[7].uHour; + while ( !(v9->uAttributes & 1) || v9->uHour > v12 ) { --v8; - v9 -= 12; + --v9; if ( v8 < 0 ) - goto LABEL_8; + break; } - v6 = v8; -LABEL_8: + if( v8 >= 0 ) + v6 = v8; if ( !v8 && v6 == 65535 ) v6 = 7; v5 = &v7[v6]; @@ -3692,7 +3692,7 @@ unsigned int v4; // ebx@1 int v5; // ecx@1 unsigned int v6; // eax@1 - char *v7; // edi@2 + Actor *v7; // edi@2 __int16 v8; // ax@3 int v9; // eax@10 signed int v10; // eax@13 @@ -3728,25 +3728,25 @@ v26 = 0; if ( (signed int)uNumActors <= 0 ) goto LABEL_26; - v7 = (char *)&pActors[0].uAIState; + v7 = pActors; do { - v8 = *(short *)v7; - if ( *(short *)v7 == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) + v8 = v7->uAIState; + if ( v7->uAIState == 5 || v8 == 4 || v8 == 11 || v8 == 17 || v8 == 19 || v22 == v5 ) goto LABEL_23; if ( v24 == v4 || (v9 = 8 * v5, LOBYTE(v9) = 8 * v5 | 3, v24 != v9) ) goto LABEL_13; - if ( ((Actor *)(v7 - 176))->IsAlive() == 1 ) + if ( v7->IsAlive() == 1 ) { v24 = v4; v3->uLastCharacterIDToHit = v4; LABEL_13: - v10 = v3->GetActorsRelation((Actor *)(v7 - 176)); + v10 = v3->GetActorsRelation(v7); if ( v10 == v4 ) goto LABEL_23; goto LABEL_14; } - v18 = *((unsigned int *)v7 + 133); + v18 = v7->uGroup; if ( (v18 != v4 || v3->uGroup != v4) && v18 == v3->uGroup ) goto LABEL_23; v10 = 4; @@ -3754,9 +3754,9 @@ if ( v3->pMonsterInfo.uHostilityType ) v10 = pMonsterStats->pInfos[v3->pMonsterInfo.uID].uHostilityType; v11 = dword_4DF380[v10]; - v23 = abs(v3->vPosition.x - *((short *)v7 - 17)); - v27 = abs(v3->vPosition.y - *((short *)v7 - 16)); - v12 = abs(v3->vPosition.z - *((short *)v7 - 15)); + v23 = abs(v3->vPosition.x - v7->vPosition.x); + v27 = abs(v3->vPosition.y - v7->vPosition.y); + v12 = abs(v3->vPosition.z - v7->vPosition.z); v19 = v12; if ( v23 <= v11 && v27 <= v11 @@ -3769,7 +3769,7 @@ } v4 = 0; LABEL_23: - v7 += 836; + ++v7; v5 = v26++ + 1; } while ( v26 < (signed int)uNumActors );
--- a/AudioPlayer.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/AudioPlayer.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -1797,7 +1797,7 @@ { //AudioPlayer *v3; // esi@1 int v4; // ecx@1 - char *v5; // edi@4 + AudioPlayer_3DSample *v5; // edi@4 int v6; // ebx@12 MixerChannel *pChannel; // edi@14 //_STREAM *v8; // esi@23 @@ -1812,16 +1812,16 @@ v9 = 0; if ( uNum3DSamples > 0 ) { - v5 = (char *)&p3DSamples[0].field_8; + v5 = p3DSamples;//;(char *)&p3DSamples[0].field_8; do { if ( (uStartChannel == -1 || v4 < uStartChannel || v4 > uEndChannel) - && *(int *)v5 - && pSoundList->pSounds[*(int *)v5].eType != SOUND_DESC_SYSTEM) + && v5->field_8 + && pSoundList->pSounds[v5->field_8].eType != SOUND_DESC_SYSTEM) { - AIL_end_3D_sample(*((int **)v5 - 2)); - _4ABF23((AudioPlayer_3DSample *)(v5 - 8)); - *((int *)v5 - 1) = 0; + AIL_end_3D_sample(v5->hSample); + _4ABF23(v5); + v5->field_4 = 0; v4 = v9; } ++v4;
--- a/GUIWindow.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/GUIWindow.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -20,6 +20,7 @@ #include "FactionTable.h" #include "StorylineTextTable.h" #include "Events2D.h" +#include "Autonotes.h" #include "mm7_data.h" @@ -477,7 +478,7 @@ dword_506524 = 0; dword_506528 = 0; dword_50651C = 0; - dword_506520 = 0; + dword_506520 = 0; if ( v1->ptr_1C == (void *)177 ) { byte_506360 = 0; @@ -562,11 +563,11 @@ memset(&pStru179, 0, 0xFA0u); for ( i = dword_506528; i < 512; ++i ) { - v14 = (&dword_722F10)[4 * i]; + v14 = (char *)pQuestTable[i-1];//(&dword_722F10)[4 * i]; if ( (unsigned __int16)_449B57_test_bit(pParty->_award_bits, i) && v14 ) { v15 = dword_506520++; - pStru179->field_0[v15] = i; + pStru179.field_0[v15] = i; } } } @@ -613,15 +614,16 @@ dword_506520 = 0; while ( v10 < 196 ) { - if ( dword_506568 == dword_72371C[2 * v10] ) + if ( dword_506568 == pAutonoteTxt[v10-1].eType)//dword_72371C[2 * v10] ) { - v25 = (&dword_723718_autonote_related)[8 * (signed __int16)v10]; + //v25 = (&dword_723718_autonote_related)[8 * (signed __int16)v10]; + v25 = (char *)pAutonoteTxt[v10-1].pText; if ( (short)v10 ) { if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v10) && v25 ) { v11 = dword_506520++; - pStru179->field_0[v11] = (signed __int16)v10; + pStru179.field_0[v11] = (signed __int16)v10; } } }
--- a/IndoorCameraD3D.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/IndoorCameraD3D.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -1701,7 +1701,7 @@ float *v5; // ecx@2 v3 = uStripType; - result = 3.4028235e38; + result = 3.402823466385289e38; if ( (signed int)uStripType > 0 ) { v5 = &pVertices->vWorldPosition.z;
--- a/LightmapBuilder.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/LightmapBuilder.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -1024,9 +1024,9 @@ // 4E94D2: using guessed type char _4E94D2_light_type; //----- (0045D036) -------------------------------------------------------- -bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a3, RenderVertexSoft *a1, unsigned int uStripType, bool bLightBackfaces) +bool LightmapBuilder::StackLights_TerrainFace(Vec3_float_ *pNormal, float *a2, RenderVertexSoft *a3, unsigned int uStripType, bool bLightBackfaces) { - int v6; // esi@1 + /*int v6; // esi@1 //LightmapBuilder *v7; // edi@1 MobileLight *v8; // ebx@2 int v9; // esi@5 @@ -1067,7 +1067,32 @@ } stru_F8AD28.uNumLightsApplied = a7; + return true;*/ +// bool __stdcall sub_45D036(struct Vec3<float> *pNormal, int a2, struct RenderVertex *a3, int a4, signed int X) +//{ + float v6; // ebx@2 + unsigned int v10; // [sp+Ch] [bp-4h]@1 + int i; + + v10 = 0; + stru_F8AD28.uCurrentAmbientLightLevel = pOutdoor->field_CBC_terrain_triangles_shade_type; + for (i = 0; i < pMobileLightsStack->uNumLightsActive; ++i) + { + if ( v10 >= 20 ) + break; + StackLight_TerrainFace((StationaryLight *)&pMobileLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10); + } + + for (i = 0; i < pStationaryLightsStack->uNumLightsActive; ++i) + { + if ( v10 >= 20 ) + break; + StackLight_TerrainFace(&pStationaryLightsStack->pLights[i], pNormal, a2, a3, uStripType, bLightBackfaces, &v10); + } + + stru_F8AD28.uNumLightsApplied = v10; return true; + } // 519AB4: using guessed type int uNumStationaryLightsApplied; @@ -1136,8 +1161,8 @@ result = pLight->uRadius; v63 = pLight->uRadius; if ( result <= 0 ) - goto LABEL_27; - v10 = uStripType; + return 0; + //v10 = uStripType; v11 = a1; if ( uStripType == 4 ) { @@ -1168,22 +1193,21 @@ LABEL_5: v64 = v13; LABEL_11: - v60 = v10; + //v60 = v10; v59 = (const char *)v11; - v14 = pGame->pIndoorCameraD3D->GetPolygonMinZ(v11, v10); - v60 = v10; - minz = v14; - maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v11, v10); + v60 = uStripType; + minz = pGame->pIndoorCameraD3D->GetPolygonMinZ(v11, uStripType); + maxz = pGame->pIndoorCameraD3D->GetPolygonMaxZ(v11, uStripType); result = v8->vPosition.x; *((float *)&v61 + 1) = maxz; v16 = (double)result; *(float *)&X = (double)v63; v17 = *(float *)&pLight - *(float *)&X; //UNDEF(v18); - v19 = v16 < v17; + //v19 = v16 < v17; v20 = 0; - v21 = v16 == v17; -// BYTE1(result) = HIBYTE(v18); + //v21 = v16 == v17; +/* BYTE1(result) = HIBYTE(v18); if ( v16 <= v17 || (v22 = *(float *)&X + *(float *)&uStripType, //UNDEF(v23), @@ -1238,25 +1262,22 @@ result = LODWORD(v61), X = LODWORD(v61), v52 = v63, - SLODWORD(v61) > v63) ) - { -LABEL_27: - LOBYTE(result) = 0; - return result; - } + SLODWORD(v61) > v63) )*/ + if (0) + return 0; v53 = pSlot; v60 = X; stru_F8AD28._blv_lights_radii[*pSlot] = v63; - stru_F8AD28._blv_lights_inv_radii[*v53] = 65536 / v52; + stru_F8AD28._blv_lights_inv_radii[*v53] = 65536 / v63; stru_F8AD28._blv_lights_xs[*v53] = v8->vPosition.x; stru_F8AD28._blv_lights_ys[*v53] = v8->vPosition.y; stru_F8AD28._blv_lights_zs[*v53] = v8->vPosition.z; a3 = (float *)v8->uLightColorR; - stru_F8AD28._blv_lights_rs[*v53] = (double)(signed int)a3 * 0.0039215689; + stru_F8AD28._blv_lights_rs[*v53] = (double)(signed int)a3 * 0.003921568859368563; a3 = (float *)v8->uLightColorG; - stru_F8AD28._blv_lights_gs[*v53] = (double)(signed int)a3 * 0.0039215689; + stru_F8AD28._blv_lights_gs[*v53] = (double)(signed int)a3 * 0.003921568859368563; a3 = (float *)v8->uLightColorB; - stru_F8AD28._blv_lights_bs[*v53] = (double)(signed int)a3 * 0.0039215689; + stru_F8AD28._blv_lights_bs[*v53] = (double)(signed int)a3 * 0.003921568859368563; v54 = abs(v60); v55 = pRenderer->bUsingSpecular; stru_F8AD28._blv_lights_light_dot_faces[*v53] = v54; @@ -1272,16 +1293,15 @@ if ( stru_F8AD28._blv_lights_types[*v53] & 4 ) { *(float *)((char *)stru_F8AD28._blv_lights_rs + result) = *(float *)((char *)stru_F8AD28._blv_lights_rs + result) - * 0.33000001; + * 0.3300000131130219; *(float *)((char *)stru_F8AD28._blv_lights_gs + result) = *(float *)((char *)stru_F8AD28._blv_lights_gs + result) - * 0.33000001; + * 0.3300000131130219; *(float *)((char *)stru_F8AD28._blv_lights_bs + result) = *(float *)((char *)stru_F8AD28._blv_lights_bs + result) - * 0.33000001; + * 0.3300000131130219; } } ++*v53; - LOBYTE(result) = 1; - return result; + return 1; } // 4E94D2: using guessed type char _4E94D2_light_type;
--- a/Outdoor.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/Outdoor.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -89,27 +89,27 @@ if ( !pRenderer->pRenderD3D ) { pRenderer->OnOutdoorRedrawSW(); - goto LABEL_16; } - //goto LABEL_14; - pRenderer->DrawSkyD3D(); - pRenderer->DrawBuildingsD3D(); - pRenderer->DrawBezierTerrain(); - goto LABEL_16; + else + { + pRenderer->DrawSkyD3D(); + pRenderer->DrawBuildingsD3D(); + pRenderer->DrawBezierTerrain(); + } } - if ( pRenderer->pRenderD3D ) + else if ( pRenderer->pRenderD3D ) { -//LABEL_14: pRenderer->DrawSkyD3D(); pRenderer->DrawBuildingsD3D(); pRenderer->DrawBezierTerrain();// Ritor1: sometimes crash - goto LABEL_16; } - pRenderer->DrawBuildingsSW(); - pRenderer->DrawBezierTerrain(); - sr_sub_486F92_MessWithEdgesAndSpans(); - pOutdoorCamera->_487355(); -LABEL_16: + else + { + pRenderer->DrawBuildingsSW(); + pRenderer->DrawBezierTerrain(); + sr_sub_486F92_MessWithEdgesAndSpans(); + pOutdoorCamera->_487355(); + } pMobileLightsStack->uNumLightsActive = 0; pStationaryLightsStack->uNumLightsActive = 0; if ( !pRenderer->pRenderD3D ) @@ -1772,7 +1772,7 @@ for (uint i = 0; i < uNumBModels; ++i) { //v48 = 0; - auto model = pBModels + i; + auto model = &pBModels[i]; model->pVertices.pVertices = nullptr; model->pFaces = nullptr; @@ -1856,7 +1856,7 @@ //v149 = 0; //Str2 = (char *)ptr; - auto face = model->pFaces + j; + auto *face = &model->pFaces[j]; //pFilename = (char *)v149 + (unsigned int)v60[v48].pFaces; if (~face->uAttributes & 0x40) { @@ -2130,16 +2130,16 @@ //v151 = 0; for (uint i = 0; i < uNumBModels; ++i) { - auto model = pBModels + i; + auto model = pBModels[i]; //pNumItems = 0; //do //{ //v86 = pBModels; //thisa = 0; //v87 = (unsigned int)((char *)v86 + pNumItems); - for (uint j = 0; j < model->uNumFaces; ++j) + for (uint j = 0; j < model.uNumFaces; ++j) { - auto face = model->pFaces + j; + auto face = model.pFaces[j]; //if ( *(int *)(v87 + 76) > 0 ) //{ @@ -2147,7 +2147,7 @@ //do //{ //v106 = (char *)&File->uAttributes + *(int *)(v87 + 84); - memcpy(&face->uAttributes, pSrc, 4); + memcpy(&face.uAttributes, pSrc, 4); pSrc += 4; //v88 = pBModels; //++File; @@ -2160,20 +2160,20 @@ //v89 = pBModels; //thisa = 0; - for (uint j = 0; j < model->uNumFaces; ++j) + for (uint j = 0; j < model.uNumFaces; ++j) { - auto face = model->pFaces + j; + auto face = model.pFaces[j]; //pFilename = 0; //do //{ //v90 = (ODMFace *)&pFilename[*(unsigned int *)((char *)&v89->pFaces + pNumItems)]; //File = v90; - if (face->sCogTriggeredID) + if (face.sCogTriggeredID) { - if (face->HasEventHint()) - BYTE2(face->uAttributes) |= 0x10u; + if (face.HasEventHint()) + BYTE2(face.uAttributes) |= 0x10u; else - BYTE2(face->uAttributes) &= 0xEFu; + BYTE2(face.uAttributes) &= 0xEFu; } //++thisa; //v89 = pBModels; @@ -2789,7 +2789,7 @@ bool OutdoorLocation::InitalizeActors(int a1) { int v2; // ebx@1 - char *v3; // esi@2 + Actor *v3; // esi@2 int v4; // eax@3 __int16 v5; // ax@11 int v8; // [sp+348h] [bp-8h]@1 @@ -2800,50 +2800,67 @@ v9 = 0; if ( (signed int)uNumActors > 0 ) { - v3 = (char *)&pActors[0].uAttributes; - while ( 1 ) - { - v4 = *(int *)v3; - if ( !(v4 & 0x100000) ) - break; - if ( a1 == v2 ) - goto LABEL_8; - if ( v8 != v2 ) - goto LABEL_9; - *((short *)v3 + 70) = 19; - *(int *)v3 = v4 | 0x10000; - v8 = GetAlertStatus(); -LABEL_17: - ++v9; - v3 += 836; - if ( v9 >= (signed int)uNumActors ) - goto LABEL_18; - } - if ( v8 != 1 ) + v3 = pActors;//[0].uAttributes; + while ( v9 < (signed int)uNumActors ) { -LABEL_9: - *((int *)v3 + 37) = v2; - *((short *)v3 + 62) = v2; - if ( v4 & 0x10000 ) - *((short *)v3 + 70) = 19; - v5 = *((short *)v3 + 70); - if ( v5 != 11 && v5 != 19 && (*((short *)v3 + 2) == (short)v2 || *((int *)v3 + 18) == v2) ) - *((short *)v3 + 70) = 5; - *((short *)v3 + 56) = v2; - *((short *)v3 + 57) = v2; - *((short *)v3 + 58) = v2; - ((Actor *)(v3 - 36))->UpdateAnimation(); - v3[25] = 0; - ((Actor *)(v3 - 36))->PrepareSprites(0); - v2 = 0; - goto LABEL_17; + v4 = v3->uAttributes; + if ( !(v4 & 0x100000) ) + { + if ( v8 != 1 ) + { + v3->uCurrentActionTime = v2; + v3->uCurrentActionLength = v2; + if ( v4 & 0x10000 ) + v3->uAIState = (AIState) 19; + v5 = v3->uAIState; + if ( v5 != 11 && v5 != 19 && (v3->sCurrentHP == (short)v2 || v3->pMonsterInfo.uHP == v2) ) + v3->uAIState = (AIState) 5; + v3->vVelocity.x = v2; + v3->vVelocity.y = v2; + v3->vVelocity.z = v2; + v3->UpdateAnimation(); + v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; + v3->PrepareSprites(0); + v2 = 0; + } + else + { + v3->uAIState = (AIState) 19; + v3->uAttributes = v4 | 0x10000; + } + } + else if ( a1 == v2 ) + { + v3->uAIState = (AIState) 19; + v3->uAttributes = v4 | 0x10000; + } + else if ( v8 != v2 ) + { + v3->uCurrentActionTime = v2; + v3->uCurrentActionLength = v2; + if ( v4 & 0x10000 ) + v3->uAIState = (AIState) 19; + v5 = v3->uAIState; + if ( v5 != 11 && v5 != 19 && (v3->sCurrentHP == (short)v2 || v3->pMonsterInfo.uHP == v2) ) + v3->uAIState = (AIState) 5; + v3->vVelocity.x = v2; + v3->vVelocity.y = v2; + v3->vVelocity.z = v2; + v3->UpdateAnimation(); + v3->pMonsterInfo.uHostilityType = (MonsterInfo::HostilityRadius)0; + v3->PrepareSprites(0); + v2 = 0; + } + else + { + v3->uAIState = (AIState) 19; + v3->uAttributes = v4 | 0x10000; + v8 = GetAlertStatus(); + } + ++v9; + ++v3; } -LABEL_8: - *((short *)v3 + 70) = 19; - *(int *)v3 = v4 | 0x10000; - goto LABEL_17; } -LABEL_18: pGameLoadingUI_ProgressBar->Progress(); Actor thisa; @@ -2876,7 +2893,7 @@ unsigned int OutdoorLocation::DrawActors() { unsigned int result; // eax@1 - char *v1; // edi@2 + Actor *v1; // edi@2 __int16 v2; // ax@3 int v3; // esi@5 float v4; // ST48_4@8 @@ -2944,23 +2961,23 @@ if ( (signed int)uNumActors > 0 ) { v54 = 0; - v1 = (char *)&pActors[0].vPosition.z; + v1 = pActors;//[0].vPosition.z; do { - v2 = *((short *)v1 + 15); - *(int *)(v1 - 110) &= 0xFFFFFFF7u; + v2 = v1->uAIState; + v1->uAttributes &= 0xFFFFFFF7u; if ( v2 == 11 || v2 == 19 ) goto LABEL_58; - v3 = *(short *)v1; + v3 = v1->vPosition.z; v49 = 0; - x = *((short *)v1 - 2); - y = *((short *)v1 - 1); - v61 = *(short *)v1; + x = v1->vPosition.x; + y = v1->vPosition.y; + v61 = v1->vPosition.z; if ( v2 == 17 ) { - if ( (v1[666] & 7) != 3 || pActors[*(int *)(v1 + 666) >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) + if ( (v1->uSummonerID & 7) != 3 || pActors[v1->uSummonerID >> 3].pMonsterInfo.uSpecialAbilityDamageDiceSides != 1 ) { - v6 = (double)*((short *)v1 - 4) * 0.5; + v6 = (double)v1->uActorHeight * 0.5; v7 = v6 + 6.7553994e15; v3 += LODWORD(v7); v61 = v3; @@ -2968,31 +2985,31 @@ else { v49 = 1; - pGame->pStru6Instance->_4A7F74(*((short *)v1 - 2), *((short *)v1 - 1), v3); + pGame->pStru6Instance->_4A7F74(v1->vPosition.x, v1->vPosition.y, v3); v4 = (1.0 - (double)*(signed int *)(v1 + 38) / (double)*((short *)v1 + 7)) - * (double)(2 * (signed int)*((short *)v1 - 4)); + * (double)(2 * (signed int)v1->uActorHeight); v5 = v4 + 6.7553994e15; v3 -= LODWORD(v5); v61 = v3; - if ( v3 > *(short *)v1 ) + if ( v3 > v1->vPosition.z ) { - v61 = *(short *)v1; - v3 = *(short *)v1; + v61 = v1->vPosition.z; + v3 = v1->vPosition.z; } } } v8 = stru_5C6E00->Atan2( - *((short *)v1 - 2) - pIndoorCamera->pos.x, - *((short *)v1 - 1) - pIndoorCamera->pos.y); - LOWORD(v9) = *((short *)v1 + 4); + v1->vPosition.x - pIndoorCamera->pos.x, + v1->vPosition.y - pIndoorCamera->pos.y); + LOWORD(v9) = v1->uYawAngle; v41 = ((signed int)(stru_5C6E00->uIntegerPi + ((signed int)stru_5C6E00->uIntegerPi >> 3) + v9 - v8) >> 8) & 7; - v10 = *((short *)v1 + 16); + v10 = v1->uCurrentActionAnimation; if ( pParty->bTurnBasedModeOn ) { if ( v10 != 1 ) { LABEL_17: - v12 = *(int *)(v1 + 38); + v12 = v1->uCurrentActionTime; goto LABEL_18; } v11 = pMiscTimer->uTotalGameTimeElapsed; @@ -3005,9 +3022,9 @@ } v12 = v54 + v11; LABEL_18: - if ( *(_QWORD *)(v1 + 146) > 0i64 || *(_QWORD *)(v1 + 162) > 0i64 ) + if ( (signed __int64)v1->pActorBuffs[5].uExpireTime > 0 || (signed __int64)v1->pActorBuffs[6].uExpireTime > 0 ) v12 = 0; - v13 = *((short *)v1 + 15); + v13 = v1->uAIState; if ( v13 == 17 && !v49 ) { v40 = v12; @@ -3017,7 +3034,7 @@ goto LABEL_25; } v40 = v12; - v39 = *(short *)&v1[2 * v10 + 42]; + v39 = v1->pSpriteIDs[v10]; if ( v13 != 16 ) goto LABEL_24; v14 = pSpriteFrameTable->GetFrameBy_x(v39, v12); @@ -3094,20 +3111,20 @@ return result; ++uNumBillboardsToDraw; ++uNumSpritesDrawnThisFrame; - *(int *)(v1 - 110) |= 8u; + v1->uAttributes |= 8u; v28->uHwSpriteID = v15->pHwSpriteIDs[v41]; v29 = v15->uPaletteIndex; v28->uIndoorSectorID = 0; v28->uPalette = v29; v28->field_0 = (unsigned __int64)(v15->scale * (signed __int64)v58) >> 16; - v30 = *(int *)(v1 + 118) == 0; - v31 = *(int *)(v1 + 118) < 0; + v30 = HIDWORD(v1->pActorBuffs[3].uExpireTime) == 0; + v31 = SHIDWORD(v1->pActorBuffs[3].uExpireTime) < 0; v28->field_4 = (unsigned __int64)(v15->scale * (signed __int64)v57) >> 16; - if ( v31 || v31 | v30 && *(int *)(v1 + 114) <= 0u ) + if ( v31 || v31 | v30 && LODWORD(v1->pActorBuffs[3].uExpireTime) <= 0u ) { - if ( *(_QWORD *)(v1 + 226) > 0i64 ) + if ( (signed __int64)v1->pActorBuffs[10].uExpireTime > 0i64 ) { - v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F((Actor *)(v1 - 146)) + v52 = (unsigned __int64)(pGame->pStru6Instance->_4A806F(v1) * (signed __int64)v28->field_4) >> 16; LABEL_53: LOWORD(v27) = v43; @@ -3116,10 +3133,10 @@ } else { - v32 = *((short *)v1 + 61); + v32 = v1->pActorBuffs[3].uPower; if ( v32 ) { - v33 = *((short *)v1 + 61); + v33 = v1->pActorBuffs[3].uPower; v28->field_0 = (unsigned __int64)(65536 / (unsigned __int16)v32 * (signed __int64)v28->field_0) >> 16; v52 = (unsigned __int64)(65536 / v33 * (signed __int64)v28->field_4) >> 16; goto LABEL_53; @@ -3136,20 +3153,20 @@ v28->sZValue = v34 + (8 * v59 | 3); v28->field_14 = v59; v35 = pMonsterList->pMonsters; - v36 = *((short *)v1 - 25); - v37 = *(int *)(v1 + 150) == 0; - v38 = *(int *)(v1 + 150) < 0; + v36 = v1->pMonsterInfo.uID; + v37 = HIDWORD(v1->pActorBuffs[5].uExpireTime) == 0; + v38 = SHIDWORD(v1->pActorBuffs[5].uExpireTime) < 0; v28->field_1E = v62 | 0x200; v28->pSpriteFrame = v15; v28->uTintColor = *((int *)&v35[v36] - 36); - if ( !v38 && (!(v38 | v37) || *(int *)(v1 + 146)) ) + if ( !v38 && (!(v38 | v37) || LODWORD(v1->pActorBuffs[5].uExpireTime)) ) v28->field_1E = v62 | 0x200; } LABEL_58: ++v59; v54 += 32; result = v59; - v1 += 836; + ++v1; } while ( v59 < (signed int)uNumActors ); }
--- a/Party.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/Party.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -870,13 +870,13 @@ //----- (004909F4) -------------------------------------------------------- void Party::_4909F4() { - char *v1; // esi@2 + Player *v1; // esi@2 unsigned int v2; // eax@3 __int16 v3; // cx@5 int v4; // edx@27 signed int v5; // eax@52 PlayerFrame *v6; // edx@53 - char *v7; // esi@60 + NPCData *v7; // esi@60 signed int v8; // ebp@61 int v9; // ebx@62 unsigned int v10; // edi@62 @@ -885,21 +885,21 @@ if ( dword_A75070 != stru_51076C.field_8 ) { dword_A75070 = stru_51076C.field_8; - v1 = (char *)&this->pPlayers[0].uExpressionID; + v1 = this->pPlayers;//(char *)&this->pPlayers[0].uExpressionID; v11 = 4; do { - v2 = ((Player *)(v1 - 6812))->GetMajorConditionIdx(); + v2 = v1->GetMajorConditionIdx(); if ( v2 == 18 || v2 == 17 ) { - *((short *)v1 + 1) += LOWORD(pMiscTimer->uTimeElapsed); - if ( *((short *)v1 + 1) >= *((short *)v1 + 2) ) + v1->uExpressionTimePassed += LOWORD(pMiscTimer->uTimeElapsed); + if ( (unsigned __int16)v1->uExpressionTimePassed >= v1->uExpressionTimeLength ) { - if ( *(short *)v1 != 1 || rand() % 5 ) + if ( v1->uExpressionID != 1 || rand() % 5 ) { - *((short *)v1 + 1) = 0; - *(short *)v1 = 1; - *((short *)v1 + 2) = rand() % 256 + 32; + v1->uExpressionTimePassed = 0; + v1->uExpressionID = 1; + v1->uExpressionTimeLength = rand() % 256 + 32; } else { @@ -927,67 +927,67 @@ if ( v4 >= 82 ) { if ( v4 >= 88 ) - *(short *)v1 = (v4 >= 94) + 29; + v1->uExpressionID = (v4 >= 94) + 29; else - *(short *)v1 = 57; + v1->uExpressionID = 57; } else { - *(short *)v1 = 56; + v1->uExpressionID = 56; } } else { - *(short *)v1 = 55; + v1->uExpressionID = 55; } } else { - *(short *)v1 = 54; + v1->uExpressionID = 54; } } else { - *(short *)v1 = 20; + v1->uExpressionID = 20; } } else { - *(short *)v1 = 19; + v1->uExpressionID = 19; } } else { - *(short *)v1 = 18; + v1->uExpressionID = 18; } } else { - *(short *)v1 = 17; + v1->uExpressionID = 17; } } else { - *(short *)v1 = 16; + v1->uExpressionID = 16; } } else { - *(short *)v1 = 15; + v1->uExpressionID = 15; } } else { - *(short *)v1 = 14; + v1->uExpressionID = 14; } } else { - *(short *)v1 = 13; + v1->uExpressionID = 13; } v5 = 0; - *((short *)v1 + 1) = 0; - if ( (signed int)pPlayerFrameTable->uNumFrames <= 0 ) + v1->uExpressionTimePassed = 0; + if ( (signed int)pPlayerFrameTable->uNumFrames <= 0 ) { LABEL_56: v5 = 0; @@ -995,7 +995,7 @@ else { v6 = pPlayerFrameTable->pFrames; - while ( v6->uSequenceID != *(short *)v1 ) + while ( v6->uSequenceID != v1->uExpressionID ) { ++v5; ++v6; @@ -1003,62 +1003,62 @@ goto LABEL_56; } } - *((short *)v1 + 2) = 8 * pPlayerFrameTable->pFrames[v5].uAnimLength; + v1->uExpressionTimeLength = 8 * pPlayerFrameTable->pFrames[v5].uAnimLength; } } } else { - v3 = *(short *)v1; - if ( *(short *)v1 != 34 && v3 != 35 && v3 != 36 - || (signed int)(pMiscTimer->uTimeElapsed + *((short *)v1 + 1)) >= *((short *)v1 + 2) ) + v3 = v1->uExpressionID; + if ( v1->uExpressionID != 34 && v3 != 35 && v3 != 36 + || (signed int)(pMiscTimer->uTimeElapsed + v1->uExpressionTimePassed) >= v1->uExpressionTimeLength ) { - *((short *)v1 + 2) = 0; - *((short *)v1 + 1) = 0; + v1->uExpressionTimeLength = 0; + v1->uExpressionTimePassed = 0; switch ( v2 ) { case 0xEu: - *(short *)v1 = 98; + v1->uExpressionID = 98; break; case 0xFu: - *(short *)v1 = 12; + v1->uExpressionID = 12; break; case 0x10u: - *(short *)v1 = 99; + v1->uExpressionID = 99; break; case 0u: - *(short *)v1 = 2; + v1->uExpressionID = 2; break; case 1u: - *(short *)v1 = 3; + v1->uExpressionID = 3; break; case 2u: - *(short *)v1 = 4; + v1->uExpressionID = 4; break; case 3u: - *(short *)v1 = 5; + v1->uExpressionID = 5; break; case 4u: - *(short *)v1 = 6; + v1->uExpressionID = 6; break; case 5u: - *(short *)v1 = 7; + v1->uExpressionID = 7; break; case 6u: case 8u: case 0xAu: - *(short *)v1 = 8; + v1->uExpressionID = 8; break; case 7u: case 9u: case 0xBu: - *(short *)v1 = 9; + v1->uExpressionID = 9; break; case 0xCu: - *(short *)v1 = 10; + v1->uExpressionID = 10; break; case 0xDu: - *(short *)v1 = 11; + v1->uExpressionID = 11; break; default: break; @@ -1066,38 +1066,38 @@ } else { - *((short *)v1 + 1) += LOWORD(pMiscTimer->uTimeElapsed); - } + v1->uExpressionTimePassed += LOWORD(pMiscTimer->uTimeElapsed); + } } - v1 += 6972; + ++v1; --v11; } while ( v11 ); - v7 = (char *)&pParty->pHirelings[0].evtb; + v7 = pParty->pHirelings;//(char *)&pParty->pHirelings[0].evtb; do { - v8 = *((int *)v7 + 1); + v8 = v7->evtc; if ( v8 ) { - v9 = *((int *)v7 - 1); - v10 = pMiscTimer->uTimeElapsed + *(int *)v7; + v9 = v7->bDrawSomeAnim; + v10 = pMiscTimer->uTimeElapsed + v7->evtb; if ( (signed int)v10 >= v8 ) { v9 = 0; v8 = 0; v10 = 0; - memset(v7 - 44, 0, 0x4Cu); + memset(v7, 0, 0x4Cu); pParty->field_709 = 0; //sub_44A56A();Ritor1: it's temporarily viewparams->bRedrawGameUI = 1; } - *(int *)v7 = v10; - *((int *)v7 + 1) = v8; - *((int *)v7 - 1) = v9; + v7->evtb = v10; + v7->evtc = v8; + v7->bDrawSomeAnim = v9; } - v7 += 76; + ++v7; } - while ( (signed int)v7 < (signed int)&pParty->field_777C[1] ); + while ( v7 <= &pParty->pHirelings[1] ); } } // A75070: using guessed type int dword_A75070; @@ -1111,7 +1111,7 @@ SpellBuff *v4; // edi@4 int v5; // eax@9 char v6; // zf@9 - char *v7; // eax@10 + ItemGen *v7; // eax@10 signed int v8; // ecx@10 int v9; // eax@18 int v10; // eax@25 @@ -1163,13 +1163,13 @@ if ( v6 ) { v14 = 0; - v7 = &v2->pInventoryItems[0].field_1A; + v7 = v2->pInventoryItems;//[0].field_1A; v8 = 138; do { - if ( *(int *)(v7 - 26) == 601 && (unsigned __int8)*v7 == v15 + 1 ) + if ( v7->uItemID == 601 && (unsigned __int8)v7->field_1A== v15 + 1 ) v14 = 1; - v7 += 36; + ++v7; --v8; } while ( v8 );
--- a/Player.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/Player.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -18,7 +18,8 @@ #include "Events2D.h" #include "Outdoor.h" #include "StorylineTextTable.h" - +#include "Autonotes.h" +#include "Awards.h" #include "mm7_data.h" @@ -8413,12 +8414,13 @@ if ( var == VAR_AutoNotes ) { if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pParty->_autonote_bits[((signed __int16)a3 - 1) >> 3]) - && (&dword_723718_autonote_related)[8 * a3] ) + //&& (&dword_723718_autonote_related)[8 * a3] ) + && pAutonoteTxt[a3-1].pText ) { v20 = pPlayers[v3 + 1]; v30 = 1; v20->PlaySound(96, 0); - v21 = dword_72371C[2 * a3]; + v21 = pAutonoteTxt[a3-1].eType;// dword_72371C[2 * a3]; bFlashAutonotesBook = 1; dword_506568 = v21; } @@ -8482,7 +8484,8 @@ return; case VAR_Award: if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pPlayers[v3 + 1]->field_152[((signed __int16)a3 - 1) >> 3]) - && dword_723E80_award_related[2 * a3] ) + //&& dword_723E80_award_related[2 * a3] ) + && pAwards[a3-1].pText ) { v12 = pPlayers[v3 + 1]; v30 = 1; @@ -8496,7 +8499,8 @@ goto LABEL_124; case VAR_QBits_QuestsDone: if ( !((unsigned __int8)(0x80u >> ((signed __int16)a3 - 1) % 8) & pParty->_award_bits[((signed __int16)a3 - 1) >> 3]) - && (&dword_722F10)[4 * a3] ) + // && (&dword_722F10)[4 * a3] ) + && pQuestTable[a3-1] ) { v14 = pPlayers[v3 + 1]; bFlashQuestBook = 1; @@ -8909,7 +8913,8 @@ v13 = pPlayers[uPlayerIdx + 1]; v33 = 0x80u >> ((signed __int16)val - 1) % 8; if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & v13->field_152[((signed __int16)val - 1) >> 3]) - && dword_723E80_award_related[2 * val] ) + //&& dword_723E80_award_related[2 * val] ) + && pAwards[val-1].pText ) { v14 = pPlayers[uPlayerIdx + 1]; v34 = 1; @@ -8927,7 +8932,8 @@ goto _play_anim_and_exit; case VAR_QBits_QuestsDone: if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_award_bits[((signed __int16)val - 1) >> 3]) - && (&dword_722F10)[4 * val] ) + //&& (&dword_722F10)[4 * val] ) + && pQuestTable[val-1] ) { v17 = pPlayers[uPlayerIdx + 1]; bFlashQuestBook = 1; @@ -9191,12 +9197,13 @@ goto _play_sound; } if ( !((unsigned __int8)(0x80u >> ((signed __int16)val - 1) % 8) & pParty->_autonote_bits[((signed __int16)val - 1) >> 3]) - && (&dword_723718_autonote_related)[8 * val] ) + //&& (&dword_723718_autonote_related)[8 * val] ) + && pAutonoteTxt[val-1].pText ) { v23 = pPlayers[uPlayerIdx + 1]; v34 = 1; v23->PlaySound(96, 0); - v24 = dword_72371C[2 * val]; + v24 = pAutonoteTxt[val-1].eType;//dword_72371C[2 * val]; bFlashAutonotesBook = 1; dword_506568 = v24; }
--- a/Render.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/Render.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -908,8 +908,8 @@ //__debugbreak();Ritor1: it's temporarily //return 0; - unsigned int v0; // ebx@1 - unsigned int v1; // edi@1 + unsigned int pDirectionIndicator1; // ebx@1 + unsigned int pDirectionIndicator2; // edi@1 unsigned int v2; // eax@1 int v3; // eax@3 int v4; // edi@3 @@ -981,11 +981,11 @@ int v70; // edi@178 int v71; // eax@178 int v72; // ecx@178 - int v73; // ebx@180 + int x; // ebx@180 int v74; // eax@182 int v75; // eax@184 IndoorCameraD3D *pIndoorCameraD3D_3; // ecx@184 - int v77; // ecx@184 + int uStartZ; // ecx@184 int v79; // ebx@185 int v127; // esi@185 int v86; // edi@196 @@ -1005,7 +1005,7 @@ } v102; int v105; // [sp+1Ch] [bp-58h]@1 int v106; // [sp+20h] [bp-54h]@3 - int v107; // [sp+24h] [bp-50h]@3 + int uEndZ; // [sp+24h] [bp-50h]@3 int v108; // [sp+28h] [bp-4Ch]@9 int v109; // [sp+2Ch] [bp-48h]@9 int v110; // [sp+30h] [bp-44h]@9 @@ -1026,13 +1026,11 @@ int v125; // [sp+6Ch] [bp-8h]@9 int v126; // [sp+70h] [bp-4h]@9 - v105 = pIndoorCamera->sRotationY / (stru_5C6E00->uIntegerHalfPi / 2); - v0 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 - v1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + v0);//512 - v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->SinCos( - stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + v0))) >> 16; - v123 = ((pIndoorCamera->uMapGridCellZ << 16) - + 3 * stru_5C6E00->SinCos(v1 - stru_5C6E00->uIntegerHalfPi)) >> 16; + v105 = pIndoorCamera->sRotationY / ((signed int)stru_5C6E00->uIntegerHalfPi / 2); + pDirectionIndicator1 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerDoublePi - pIndoorCamera->sRotationY);//1536 + pDirectionIndicator2 = stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1);//512 + v124 = ((pIndoorCamera->uMapGridCellX << 16) + 3 * stru_5C6E00->SinCos(stru_5C6E00->uDoublePiMask & (stru_5C6E00->uIntegerPi + pDirectionIndicator1))) >> 16; + v123 = ((pIndoorCamera->uMapGridCellZ << 16) + 3 * stru_5C6E00->SinCos(pDirectionIndicator2 - stru_5C6E00->uIntegerHalfPi)) >> 16; v120 = pOutdoorCamera->outdoor_grid_band_3 + v124;//+- range X v119 = pOutdoorCamera->outdoor_grid_band_3 + v123; v2 = pOutdoorCamera->uCameraFovInDegrees + 15; @@ -1042,10 +1040,10 @@ if ( v2 > 90 ) v2 = 90; v3 = (v2 << 11) / 720; - v4 = stru_5C6E00->uDoublePiMask & (v0 - v3); - v5 = stru_5C6E00->uDoublePiMask & (v3 + v0); + v4 = stru_5C6E00->uDoublePiMask & (pDirectionIndicator1 - v3); + v5 = stru_5C6E00->uDoublePiMask & (v3 + pDirectionIndicator1); v106 = stru_5C6E00->SinCos(v4); - v107 = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi); + uEndZ = stru_5C6E00->SinCos(v4 - stru_5C6E00->uIntegerHalfPi); v111 = stru_5C6E00->SinCos(v5); v6 = stru_5C6E00->SinCos(v5 - stru_5C6E00->uIntegerHalfPi); v7 = v4 & stru_5C6E00->uPiMask; @@ -1070,8 +1068,8 @@ v110 = (v106 >= 0 ? 1: -1);//2 * (v106 >= 0) - 1; v126 = v124; v118 = v123; - v109 = (v107 >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; - v107 = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; + v109 = (uEndZ >= 0 ? 1: -1);//2 * (v107 >= 0) - 1; + uEndZ = (v111 >= 0 ? 1: -1);//2 * (v111 >= 0) - 1; terrain_76E1C8[0] = 65535; //v116 = 1; v106 = (v6 >= 0 ? 1: -1);//2 * (v6 >= 0) - 1; @@ -1118,7 +1116,7 @@ v114 += v111;// if ( v111 + v114 >= 65536 ) { - v126 += v107; + v126 += uEndZ; v114 = (unsigned __int16)v114;// } v118 += v106; @@ -1126,7 +1124,7 @@ else { v125 += v108; - v126 += v107; + v126 += uEndZ; if ( v125 >= 65536 ) { v118 += v106; @@ -1573,52 +1571,41 @@ for ( i = v69; i >= 1; --i ) { //v70 = i; - v71 = terrain_76D7C8[i]; - v72 = terrain_76DBC8[i]; + v71 = terrain_76D7C8[i];//88 + v72 = terrain_76DBC8[i];//0 if ( v71 < v72 )//swap { terrain_76DBC8[i] = v71; terrain_76D7C8[i] = v72; } - v73 = terrain_76DBC8[i]; + x = terrain_76DBC8[i];//0 v111 = 0; - if ( v73 <= 0 ) - v73 = -v73; + if ( x <= 0 ) + x = -x; v74 = terrain_76D7C8[i]; if ( v74 <= 0 ) v74 = -v74; v75 = v74 + 2; //pIndoorCameraD3D_3 = pGame->pIndoorCameraD3D; - v107 = v75; + uEndZ = v75; //pIndoorCameraD3D_4 = pIndoorCameraD3D_3; - v77 = v73 - 2; - if ( v73 - 2 < v75 ) + uStartZ = x - 2; + if ( x - 2 < v75 ) { v127 = 0; //v79 = (v73 - 66) << 9; //v116 = v77; //pHeight = v79; - v111 = v75 - v77; - for (int j = v77; j < v107; ++j) - {// - /* *(float *)&v106 = (double)pHeight; - *(float *)((char *)&ptr_801A08->vWorldPosition.x + v127) = *(float *)&v106;//x - pHeight = (64 - *(int *)((char *)terrain_76D9C8 + v70)) << 9; - *(float *)((char *)&ptr_801A08->vWorldPosition.y + v127) = (double)pHeight;//y - pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70)); - *(float *)((char *)&ptr_801A08->vWorldPosition.z + v127) = (double)pHeight;//z*/ - ptr_801A08[v127].vWorldPosition.x = (v73 - 66 + v127) * 512; + v111 = v75 - uStartZ; + for (int z = uStartZ; z < uEndZ; ++z) + { + ptr_801A08[v127].vWorldPosition.x = (-64 + x) * 512; ptr_801A08[v127].vWorldPosition.y = (64 - terrain_76D9C8[i]) * 512; - ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( j, terrain_76D9C8[i]); - - /* *(float *)((char *)&ptr_801A04->vWorldPosition.x + v127) = *(float *)&v106;//x - pHeight = (63 - *(int *)((char *)terrain_76D9C8 + v70)) << 9; - *(float *)((char *)&ptr_801A04->vWorldPosition.y + v127) = (double)pHeight;//y - pHeight = pOutdoor->GetHeightOnTerrain(v112, *(int *)((char *)terrain_76D9C8 + v70) + 1); - *(float *)((char *)&ptr_801A04->vWorldPosition.z + v127) = (double)pHeight;//z */ - ptr_801A04[v127].vWorldPosition.x = (v73 - 66 + v127) * 512; + ptr_801A08[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i]); + + ptr_801A04[v127].vWorldPosition.x = (-64 + x) * 512; ptr_801A04[v127].vWorldPosition.y = (63 - terrain_76D9C8[i]) * 512; - ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( j, terrain_76D9C8[i] + 1); + ptr_801A04[v127].vWorldPosition.z = pOutdoor->GetHeightOnTerrain( z, terrain_76D9C8[i] + 1); if ( !byte_4D864C || !(pGame->uFlags & 0x80) ) { @@ -1637,7 +1624,7 @@ v102.v103 = abs((int)pIndoorCamera->uMapGridCellZ - terrain_76D9C8[i]); v102.v104 = abs((int)pIndoorCamera->uMapGridCellX - terrain_76DBC8[i]); if ( pRenderer->pRenderD3D )//Ritor1: do comment to test - Render::DrawTerrainD3D(v111, 1, (int)&v102); + Render::RenderTerrainD3D();//Render::DrawTerrainD3D(v111, 0, (int)&v102); else Render::DrawTerrainSW(v111, 0, (int)&v102); } @@ -1714,7 +1701,253 @@ // 47FFC4: inconsistent fpu stack // 4D864C: using guessed type char byte_4D864C; - +void Render::RenderTerrainD3D() // New function. It's temporary +{ + char result; // al@3 + //int v1; // eax@3 + //int v2; // ebx@4 + //struct ODMFace *v4; // esi@6 + int v6; // ecx@8 + //int v7; // ecx@8 + struct stru148 *v8; // ebx@8 + //char v11; // zf@8 + struct stru148 *v16; + unsigned int v18; // edi@22 + //int v20; // edi@34 + //int v28; // eax@50 + //int v29; // ecx@55 + //int v30; // eax@57 + int v31; // eax@57 + int v35; // edi@63 + int v37; // eax@73 + int v39; // eax@80 + char v40; // [sp-18h] [bp-70h]@2 + int v41; // [sp-14h] [bp-6Ch]@2 + int v42; // [sp-10h] [bp-68h]@2 + int v43; // [sp-Ch] [bp-64h]@2 + const char *v44; // [sp-8h] [bp-60h]@2 + int v45; // [sp-4h] [bp-5Ch]@2 + //float v48; // [sp+14h] [bp-44h]@8 + //void *v52; // [sp+24h] [bp-34h]@3 + bool v54; // [sp+2Ch] [bp-2Ch]@10 + int v55; // [sp+30h] [bp-28h]@34 + int v56; + int v57; // [sp+38h] [bp-20h]@36 + int v58; // [sp+3Ch] [bp-1Ch]@8 + int v63; // [sp+50h] [bp-8h]@3 + int v64; // [sp+57h] [bp-1h]@2 + int v62; + + v63 = 0; + + // basic optimizations + unsigned int uStartX, uEndX, + uStartZ, uEndZ; + if (pIndoorCamera->sRotationY >= 0 && pIndoorCamera->sRotationY <= 1024) + { + /* CAMERA + /2 512 + ^ + \ | / + \ | / + _____\|/______ + 0 + 1024 | x 0 + | + - y + 3/2 1536 + */ + uStartX = 0, uEndX = 128; + uStartZ = 0, uEndZ = 64 + 16; + } + else if (pIndoorCamera->sRotationY >= 512 && pIndoorCamera->sRotationY <= 1536) + { + /* /2 512 + + y + \ | + \ | +CAMERA _____\| ______ + 0 + 1024 /| x 0 + / | + / - y + 3/2 1536 + */ + uStartX = 0, uEndX = 64 + 16; + uStartZ = 0, uEndZ = 128; + } + else if (pIndoorCamera->sRotationY >= 1536 || pIndoorCamera->sRotationY <= 512) + { + /* /2 512 + + y + | / + | / + _____ |/______ + 0 CAMERA + 1024 |\ x 0 + | \ + - y \ + 3/2 1536 + */ + uStartX = 64 - 16, uEndX = 128; + uStartZ = 0, uEndZ = 128; + } + else + { + uStartX = 0, uEndX = 128; + uStartZ = 64 - 16, uEndZ = 128; + } + +// uStartX = 0, uEndX = 128; +// uStartZ = 0, uEndZ = 128; + + + static RenderVertexSoft pTerrainVertices[128 * 128]; + for (unsigned int z = uStartZ; z < uEndZ; ++z) + for (unsigned int x = uStartX; x < uEndX; ++x) + { + pTerrainVertices[z * 128 + x].vWorldPosition.x = (-64 + (signed)x) * 512; + pTerrainVertices[z * 128 + x].vWorldPosition.y = (64 - (signed)z) * 512; + pTerrainVertices[z * 128 + x].vWorldPosition.z = 32 * pOutdoor->pTerrain.pHeightmap[z * 128 + x]; + + struct IndoorCameraD3D *pIndoorCameraD3D = pGame->pIndoorCameraD3D; + pIndoorCameraD3D->ViewTransform(&pTerrainVertices[z * 128 + x], 1); + pIndoorCameraD3D->Project(&pTerrainVertices[z * 128 + x], 1, 0); + } + + + + for (unsigned int z = uStartZ; z < uEndZ - 1; ++z) + for (unsigned int x = uStartX; x < uEndX - 1; ++x) + { + v8 = &array_77EC08[pOutdoorCamera->numStru148s]; + v8->flags = 0; + v8->field_32 = 0; + + //unsigned int uTileID = pOutdoor->pTerrain.pTilemap[z * 128 + x]; + //struct TileDesc *pTile = pOutdoor->pTerrain->pTileTable->GetTileById(uTileID); + v8->uTileBitmapID = pOutdoor->DoGetTileTexture(x, z); + /*if (uTileID == 1 || //dirttyl BitmapID 88 + uTileID == 2 || //dirt1 BitmapID 126 + uTileID == 3 || //dirttyl BitmapID 88 + uTileID == 4 || //dirt2 BitmapID 127 + uTileID == 11 || //dirttyl BitmapID 127 + + uTileID == 90 || //grastyl BitmapID 110 + uTileID == 92 || //grastyl BitmapID 110 + + uTileID == 102 || //grdrtNE BitmapID 128 + uTileID == 104 || //grdrtNW BitmapID 130 + uTileID == 105 || //grdrtSW BitmapID 131 + uTileID == 106 || //grdrtE BitmapID 132 + uTileID == 107 || //grdrtW BitmapID 133 + uTileID == 108 || //grdrtN BitmapID 134 + uTileID == 109 || //grdrtS BitmapID 135 + uTileID == 110 || //grdrtXNE BitmapID 136 + uTileID == 112 || //grdrtXNW BitmapID 138 + uTileID == 113 || //grdrtXSW BitmapID 139 + + uTileID == 126 || uTileID == 127 || uTileID == 128 || uTileID == 129 || + uTileID == 130 || //wtrtyl BitmapID 89 + uTileID == 131 || //wtrtyl BitmapID 89 + uTileID == 132 || //wtrtyl BitmapID 89 + uTileID == 133 || //wtrtyl BitmapID 89 + uTileID == 134 || //wtrtyl BitmapID 89 + uTileID == 135 || //wtrtyl BitmapID 89 + uTileID == 136 || //wtrtyl BitmapID 89 + uTileID == 137 || //wtrtyl BitmapID 89 + + uTileID == 139 || //wtrdrSE BitmapID 141 + uTileID == 141 || //wrtdrSW BitmapID 143 + uTileID == 142 || //wrtdrE BitmapID 144 + uTileID == 143 || //wrtdrW BitmapID 145 + uTileID == 145 || //wtrdrS BitmapID 147 + uTileID == 147 || //wtrdrXSE BitmapID 149 + uTileID == 149 ) //wtrdrXSW BitmapID 151 + continue;*/ + + /*if (uTileID == 199 || //dirttyl BitmapID 0 + uTileID == 200 || //dirttyl BitmapID 0 + uTileID == 201 || //dirttyl BitmapID 0 + uTileID == 202 || //dirttyl BitmapID 0 + uTileID == 203 || //dirttyl BitmapID 0 + uTileID == 204 || //dirttyl BitmapID 0 + uTileID == 212 || //dirttyl BitmapID 0 + uTileID == 217) //dirttyl BitmapID 0 + continue;*/ + + v6 = v8->uTileBitmapID; + v8->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v6]; + + if (v8->uTileBitmapID == 0xFFFF) + continue; + + v8->sTextureDeltaU = 0; + v8->sTextureDeltaV = 0; + + +/* world coordinates, z -> height + 32767 + +y + + -32768 -x +x 32767 + + -y + -32768 +*/ + + memcpy(array_73D150 + 0, &pTerrainVertices[z * 128 + x], sizeof(RenderVertexSoft)); + array_73D150[0].u = 0; + array_73D150[0].v = 0; + + memcpy(array_73D150 + 1, &pTerrainVertices[z * 128 + x + 1], sizeof(RenderVertexSoft)); + array_73D150[1].u = 1; + array_73D150[1].v = 0; + + memcpy(array_73D150 + 2, &pTerrainVertices[(z + 1) * 128 + x + 1], sizeof(RenderVertexSoft)); + array_73D150[2].u = 1; + array_73D150[2].v = 1; + + memcpy(array_73D150 + 3, &pTerrainVertices[(z + 1) * 128 + x], sizeof(RenderVertexSoft)); + array_73D150[3].u = 0; + array_73D150[3].v = 1; + + + v55 = 0; + v54 = false; + v58 = 0; + + if (v58 == 4) // if all y == first y; primitive in xz plane + v8->field_32 |= 0x0001; + + v8->pODMFace = nullptr; + v8->uNumVertices = 4; + v8->field_59 = 5; + + v8->field_58 = 0; + + ++pOutdoorCamera->numStru148s; + ++pOutdoorCamera->field_44; + + + + v8->uBModelID = 0; + v8->uBModelFaceID = 0; + v31 = (8 * (0 | (0 << 6))); + v8->field_50 = v31 | 6; + + for (unsigned int k = 0; k < 4; ++k) + { + memcpy(&array_50AC10[k], &array_73D150[k], sizeof(struct RenderVertexSoft)); + array_50AC10[k].flt_20 = 1.0 / (array_73D150[k].vWorldViewPosition.x + 0.0000001000000011686097); + } + + + pRenderer->DrawTerrainPolygon(v8, pBitmaps_LOD->pHardwareTextures[v6]); + + --pOutdoorCamera->numStru148s; + --pOutdoorCamera->field_44; + + } + + } //----- (0048034E) -------------------------------------------------------- void Render::DrawTerrainD3D(int a1, int a2, int a3) @@ -1758,7 +1991,7 @@ stru148 *v38; // ecx@55 unsigned int v39; // eax@59 stru148 *v40; // ebx@62 - unsigned __int16 v41; // ax@62 + unsigned __int16 pTileBitmapsID; // ax@62 int v42; // eax@63 LightmapBuilder *v43; // ecx@63 int v44; // eax@63 @@ -1788,7 +2021,7 @@ double v68; // st5@120 double v69; // st7@133 int v70; // edi@138 - RenderVertexSoft *v71; // esi@147 + stru148 *v71; // esi@147 unsigned int v72; // ecx@147 unsigned int v73; // eax@150 int v74; // eax@154 @@ -1881,464 +2114,432 @@ && !sub_481EFA(v8, v9, v101, pVertices, 1)) )*/ if ( !&stru_76E5C8[(v5 << 7) + v6] ) goto LABEL_162; - v8 = &pVerticesSR_806210[v4]; pVertices2 = &pVerticesSR_801A10[v4 + 1]; v102 = v8; if (!v82) { - pVertices = &pVerticesSR_801A10[v4]; - v101 = &pVerticesSR_806210[v4 + 1]; + pVertices = &pVerticesSR_801A10[v4]; + v101 = &pVerticesSR_806210[v4 + 1]; } else { - pVertices = &pVerticesSR_801A10[v4 + 1]; - v101 = &pVerticesSR_806210[v4]; - } - + pVertices = &pVerticesSR_801A10[v4 + 1]; + v101 = &pVerticesSR_806210[v4]; + } sX = floorf(v8->vWorldPosition.x + 0.5f); sY = floorf(v8->vWorldPosition.z + 0.5f); - v89 = WorldPosToGridCellX(floorf((v101->vWorldPosition.x + v8->vWorldPosition.x) / 2 + 0.5f)); v97 = WorldPosToGridCellZ(floorf((pVertices->vWorldPosition.z + v8->vWorldPosition.z) / 2 + 0.5f)); WorldPosToGridCellX(sX); WorldPosToGridCellZ(sY); - if ((!byte_4D864C || !(pGame->uFlags & 0x80)) && !sub_481EFA(v8, pVertices, v101, pVertices2, 1)) - if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) + if ( v8->vWorldPosition.y != pVertices->vWorldPosition.y || pVertices->vWorldPosition.y != pVertices2->vWorldPosition.y + || pVertices2->vWorldPosition.y != v101->vWorldPosition.y ) break; v16 = &array_77EC08[pOutdoorCamera->numStru148s]; v16->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v16->uTileBitmapID != -1 ) - { - v19 = v97; - v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); - v16->field_32 = 0; - v20 = v93; - v16->field_59 = 1; - v16->field_5D = (char)v19; - v16->field_34 = *(_WORD *)(v20 + 2); - v21 = v89; - v16->field_5C = v89; - v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; - if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) - v23 = 0; - else - v23 = &pTerrainNormals[v22]; - v24 = v92 * v23->y; - //v99 = v23; - thisf = 20.0 - (-v24 - v91 * v23->z - v90 * v23->x) * 20.0; - //v25 = thisf + 6.7553994e15; - //v27 = pOutdoorCamera->numStru148s > 1999; - //v26 = pOutdoorCamera->numStru148s - 1999 < 0; - v16->field_58 = floorf(thisf + 0.5f); - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - if ( !sub_481FC9(v8, pVertices, v101, v16) ) + if ( v16->uTileBitmapID != -1 ) + { + v19 = v97; + v16->flags = 0x8010 |pOutdoor->GetSomeOtherTileInfo(sX, sY); + v16->field_32 = 0; + v20 = v93; + v16->field_59 = 1; + v16->field_5D = (char)v19; + v16->field_34 = *(_WORD *)(v20 + 2); + v21 = v89; + v16->field_5C = v89; + v22 = pTerrainNormalIndices[2 * (v19 + 128 * v21) + 1]; + if ( v22 < 0 || v22 > uNumTerrainNormals - 1 ) + v23 = 0; + else + v23 = &pTerrainNormals[v22]; + v24 = v92 * v23->y; + //v99 = v23; + thisf = 20.0 - (-v24 - v91 * v23->z - v90 * v23->x) * 20.0; + //v25 = thisf + 6.7553994e15; + //v27 = pOutdoorCamera->numStru148s > 1999; + //v26 = pOutdoorCamera->numStru148s - 1999 < 0; + v16->field_58 = floorf(thisf + 0.5f); + if ( pOutdoorCamera->numStru148s >= 1999 ) + return; + ++pOutdoorCamera->numStru148s; + if ( !sub_481FC9(v8, pVertices, v101, v16) ) //goto LABEL_126; { - --pOutdoorCamera->numStru148s; - goto LABEL_162; - } - v28 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0].flt_20 = v28; - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - v29 = pVertices->vWorldViewPosition.x + 0.0000001000000011686097; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / v29; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - v30 = pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / v30; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - v31 = v101->vWorldViewPosition.x + 0.0000001000000011686097; - memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); - array_50AC10[3].flt_20 = 1.0 / v31; - array_50AC10[3].u = 1.0; - array_50AC10[3].v = 0.0; - - /*if ( !(byte_76D5C0 & 1) ) - { - byte_76D5C0 |= 1u; - stru154(stru_76D5A8); - atexit(loc_481199); - }*/ - v32 = (struct8 *)array_50AC10; - v97 = (int)pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v99, &v95, array_50AC10, 4, 1); - pDecalBuilder->_49BE8A(v16, *(float *)&v99, (int)&v95, array_50AC10, 4u, 1); - a5 = 4; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisa = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) + --pOutdoorCamera->numStru148s; goto LABEL_162; - thisa->ViewTransform(array_50AC10, a5); - thisa->Project(array_50AC10, a5, 0); - } - this_3 = v102->vWorldViewPosition.x < 8.0 - || pVertices->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0 - || pVertices2->vWorldViewPosition.x < 8.0; - v3a = (double)pOutdoorCamera->shading_dist_mist; - v108 = v3a < v102->vWorldViewPosition.x - || v3a < pVertices->vWorldViewPosition.x - || v3a < v101->vWorldViewPosition.x - || v3a < pVertices2->vWorldViewPosition.x; - v33 = 0; - pGame->pLightmapBuilder->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3 ) - v33 = 3; - else - v33 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_154._49B0C9(v99, v95); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v16->field_58, - 4, - &static_sub_0048034E_stru_154, - a5, - array_50AC10, - 0, - *(float *)&v33, - -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); - v34 = a5; - //v35 = byte_4D864C == 0; - v16->uNumVertices = a5; - if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) - { - if ( this_3 ) + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1].flt_20 = 1.0 / (pVertices->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2].flt_20 = 1.0 / (pVertices2->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + memcpy(&array_50AC10[3], v101, sizeof(array_50AC10[3])); + array_50AC10[3].flt_20 = 1.0 / (v101->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[3].u = 1.0; + array_50AC10[3].v = 0.0; + /*if ( !(byte_76D5C0 & 1) ) + { + byte_76D5C0 |= 1u; + stru154(stru_76D5A8); + atexit(loc_481199); + }*/ + v32 = (struct8 *)array_50AC10; + v97 = (int)pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v23, &v95, array_50AC10, 4, 1); + pDecalBuilder->_49BE8A(v16, *(float *)&v23, (int)&v95, array_50AC10, 4, 1); + a5 = 4; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisa = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &a5, 0) == 1 && !a5 ) + goto LABEL_162; + thisa->ViewTransform(array_50AC10, a5); + thisa->Project(array_50AC10, a5, 0); + } + this_3 = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v3a = (double)pOutdoorCamera->shading_dist_mist; + v108 = v3a < v102->vWorldViewPosition.x || v3a < pVertices->vWorldViewPosition.x + || v3a < v101->vWorldViewPosition.x || v3a < pVertices2->vWorldViewPosition.x; + v33 = 0; + pGame->pLightmapBuilder->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) { - v36 = sr_424CD7(v34); - v16->uNumVertices = v36; - OutdoorCamera::Project(v36); + if ( this_3 ) + v33 = 3; + else + v33 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_154._49B0C9(v23, v95); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v16->field_58, 4, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, *(float *)&v33, -1); } - if ( v108 ) - { - v36 = sr_424EE0_MakeFanFromTriangle(v34); - v16->uNumVertices = v36; - OutdoorCamera::Project(v36); - } - } - //v37 = *(int *)&v16->flags; - if ( ~v16->flags & 1 ) - { - if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + if ( stru_F8AD28.uNumLightsApplied > 0 ) + pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_154, a5, array_50AC10, 0, v33); + v34 = a5; + //v35 = byte_4D864C == 0; + v16->uNumVertices = a5; + if ( !byte_4D864C || ~pGame->uFlags & 0x80 ) { - v80 = false; - v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; - } - else - { - v39 = v16->uTileBitmapID; - v80 = true; + if ( this_3 ) + { + v36 = sr_424CD7(v34); + v16->uNumVertices = v36; + OutdoorCamera::Project(v36); + } + if ( v108 ) + { + v36 = sr_424EE0_MakeFanFromTriangle(v34); + v16->uNumVertices = v36; + OutdoorCamera::Project(v36); + } } - //v79 = 0; - v78 = pBitmaps_LOD->pHardwareTextures[v39]; - v77 = (int)v16; - v76 = v16->uNumVertices; + //v37 = *(int *)&v16->flags; + if ( ~v16->flags & 1 ) + { + if ( v16->flags & 2 && v16->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + { + v80 = false; + v39 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + } + else + { + v39 = v16->uTileBitmapID; + v80 = true; + } + //v79 = 0; + //v78 = pBitmaps_LOD->pHardwareTextures[v39]; + v16->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v39];// Ritor1: It's temporary + v77 = (int)v16; + //v76 = v16->uNumVertices; //LABEL_161: - pRenderer->DrawTerrainPolygon(v76, v16, v78, false, v80); - goto LABEL_162; - } - v38 = v16; + pRenderer->DrawTerrainPolygon(v16, pBitmaps_LOD->pHardwareTextures[v39]);//pRenderer->DrawTerrainPolygon(v16->uNumVertices, v16, pBitmaps_LOD->pHardwareTextures[v39], false, v80); + goto LABEL_162; + } + v38 = v16; LABEL_56: - v38->_4811A3(); - } + v38->_4811A3(); + } LABEL_162: - v4 = v88 + 1; - if ( ++v88 >= v84 ) + v4 = v88 + 1; + if ( ++v88 >= v84 ) + return; + } + v40 = &array_77EC08[pOutdoorCamera->numStru148s]; + v40->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v40->uTileBitmapID == -1 ) + goto LABEL_162; + v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); + BYTE1(v42) |= 0x80u; + v43 = pGame->pLightmapBuilder; + *(int *)&v40->flags = v42; + v44 = v93; + v40->field_59 = 1; + v40->field_5D = (char)v43; + v40->field_34 = *(_WORD *)(v44 + 2); + v45 = v89; + v40->field_5C = v89; + v46 = 4 * ((char)v43 + (v45 << 7)); + v85 = v46; + v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; + if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) + v48 = 0; + else + v48 = &pTerrainNormals[v47]; + v49 = v92 * v48->y; + //v99 = v48; + thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; + v50 = thisg + 6.755399441055744e15; + v40->field_58 = LOBYTE(v50); + if ( LOBYTE(v50) < 0 ) + v40->field_58 = 0; + if ( pOutdoorCamera->numStru148s >= 1999 ) return; - } - v40 = &array_77EC08[pOutdoorCamera->numStru148s]; - v41 = pOutdoor->GetTileTexture(sX, sY); - v40->uTileBitmapID = v41; - if ( v41 == -1 ) - goto LABEL_162; - v42 = pOutdoor->GetSomeOtherTileInfo(sX, sY); - BYTE1(v42) |= 0x80u; - v43 = pGame->pLightmapBuilder; - *(int *)&v40->flags = v42; - v44 = v93; - v40->field_59 = 1; - v40->field_5D = (char)v43; - v40->field_34 = *(_WORD *)(v44 + 2); - v45 = v89; - v40->field_5C = v89; - v46 = 4 * ((char)v43 + (v45 << 7)); - v85 = v46; - v47 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v46 + 2);// v47 = pTerrainNormalIndices[v46 + 1]; - if ( v47 < 0 || v47 > (signed int)(uNumTerrainNormals - 1) ) - v48 = 0; - else - v48 = &pTerrainNormals[v47]; - v49 = v92 * v48->y; - //v99 = v48; - thisg = 20.0 - (-v49 - v91 * v48->z - v90 * v48->x) * 20.0; - v50 = thisg + 6.755399441055744e15; - v40->field_58 = LOBYTE(v50); - if ( LOBYTE(v50) < 0 ) - v40->field_58 = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) - //goto LABEL_77; - { + ++pOutdoorCamera->numStru148s; + /*if ( !sub_481FC9(pVertices, pVertices2, v8, v40) ) // Ritor1: It's temporary + //goto LABEL_77; + { + --pOutdoorCamera->numStru148s; + goto LABEL_112; + }*/ + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); + array_50AC10[1].flt_20 = 1.0 / pVertices->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 0.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); + array_50AC10[2].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 1.0; + static stru154 static_sub_0048034E_stru_76D590; + /*static bool __init_flag2 = false; + if (!__init_flag2) + { + __init_flag2 = true; + stru154::stru154(&static_sub_0048034E_stru_76D590); + }*/ + /*if ( !(byte_76D5C0 & 2) ) + { + byte_76D5C0 |= 2; + stru148(stru_76D590); + atexit(loc_48118F); + }*/ + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v48, (float *)&a4, array_50AC10, 3, 0); + pDecalBuilder->_49BE8A(v40, *(float *)&v48, (int)&a4, array_50AC10, 3, 0); + uNumVertices = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisb = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) + { +//LABEL_77: + --pOutdoorCamera->numStru148s; + goto LABEL_112; + } + thisb->ViewTransform(array_50AC10, uNumVertices); + thisb->Project(array_50AC10, uNumVertices, 0); + } + this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; + v54 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; + pVertices = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3a ) + pVertices = (RenderVertexSoft *)3; + else + pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); + //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); + static_sub_0048034E_stru_76D590._49B0C9(v48, *(float *)&a4); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); + v55 = uNumVertices; + //v35 = byte_4D864C == 0; + v40->uNumVertices = uNumVertices; + if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) + { + if ( this_3a ) + { + v56 = sr_424CD7(v55); + } + else + { + if ( !v108 ) + goto LABEL_105; + v56 = sr_424EE0_MakeFanFromTriangle(v55); + } + v40->uNumVertices = v56; + OutdoorCamera::Project(v56); + } +LABEL_105: + v57 = *(int *)&v40->flags; + if ( BYTE1(v57) & 1 ) + { + v40->_4811A3(); + } + else + { + if ( v57 & 2 && v40->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + { + v81 = 0; + v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + } + else + { + v58 = v40->uTileBitmapID; + v81 = 1; + } + pRenderer->DrawTerrainPolygon(v40, pBitmaps_LOD->pHardwareTextures[v58]); + } +LABEL_112: + v59 = &array_77EC08[pOutdoorCamera->numStru148s]; + //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; + v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); + if ( v59->uTileBitmapID == -1 ) + goto LABEL_162; + *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); + v61 = v93; + v59->field_59 = 1; + v59->field_34 = *(_WORD *)(v61 + 2); + v59->field_5C = v89; + v59->field_5D = v97; + v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); + if ( v62 > (signed int)(uNumTerrainNormals - 1) ) + v63 = 0; + else + v63 = &pTerrainNormals[v62]; + v64 = v92 * v63->y; + //v99 = v63; + thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; + v59->field_58 = floorf(thish + 0.5f); + if ( v59->field_58 < 0 ) + v59->field_58 = 0; + if ( pOutdoorCamera->numStru148s >= 1999 ) + return; + ++pOutdoorCamera->numStru148s; + if ( !sub_481FC9(v101, v102, pVertices2, v59) ) + { +//LABEL_126: --pOutdoorCamera->numStru148s; - goto LABEL_112; - } - v51 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0].flt_20 = v51; - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - v52 = pVertices->vWorldViewPosition.x + 0.0000001000000011686097; - memcpy(&array_50AC10[1], pVertices, sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / v52; - array_50AC10[1].u = 0.0; - array_50AC10[1].v = 1.0; - v53 = pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - memcpy(&array_50AC10[2], pVertices2, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / v53; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 1.0; - - static stru154 static_sub_0048034E_stru_76D590; - /*static bool __init_flag2 = false; - if (!__init_flag2) - { - __init_flag2 = true; - - stru154::stru154(&static_sub_0048034E_stru_76D590); - }*/ - /*if ( !(byte_76D5C0 & 2) ) - { - byte_76D5C0 |= 2; - stru148(stru_76D590); - atexit(loc_48118F); - }*/ - v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v99, (float *)&a4, array_50AC10, 3, 0); - pDecalBuilder->_49BE8A(v40, *(float *)&v99, (int)&a4, array_50AC10, 3, 0); - uNumVertices = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisb = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, &uNumVertices, 0) == 1 && !uNumVertices ) - { -//LABEL_77: - --pOutdoorCamera->numStru148s; - goto LABEL_112; - } - thisb->ViewTransform(array_50AC10, uNumVertices); - thisb->Project(array_50AC10, uNumVertices, 0); - } - this_3a = v102->vWorldViewPosition.x < 8.0 || pVertices->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0; - v54 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v54 < v102->vWorldViewPosition.x || v54 < pVertices->vWorldViewPosition.x || v54 < pVertices2->vWorldViewPosition.x; - pVertices = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3a ) - pVertices = (RenderVertexSoft *)3; - else - pVertices = (RenderVertexSoft *)(v108 != 0 ? 5 : 0); - //a8 = (RenderVertexSoft *)(this_3a ? 3 : v108 != 0 ? 5 : 0); - static_sub_0048034E_stru_76D590._49B0C9(v99, *(float *)&a4); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D590, uNumVertices, array_50AC10, 0, (char)pVertices); - v55 = uNumVertices; - //v35 = byte_4D864C == 0; - v40->uNumVertices = uNumVertices; - if ( !byte_76D5C0 || !(pGame->uFlags & 0x80) ) - { - if ( this_3a ) - { - v56 = sr_424CD7(v55); + goto LABEL_162; + } + memcpy(&array_50AC10[0], v102, 0x30u); + array_50AC10[0].flt_20 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); + array_50AC10[0].u = 0.0; + array_50AC10[0].v = 0.0; + memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); + array_50AC10[1].flt_20 = 1.0 / pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[1].u = 1.0; + array_50AC10[1].v = 1.0; + memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); + array_50AC10[2].flt_20 = 1.0 / v101->vWorldViewPosition.x + 0.0000001000000011686097; + array_50AC10[2].u = 1.0; + array_50AC10[2].v = 0.0; + static stru154 static_sub_0048034E_stru_76D578; + /*static bool __init_flag1 = false; + if (!__init_flag1) + { + __init_flag1 = true; + stru154::stru154(&static_sub_0048034E_stru_76D578); + }*/ + v96 = pGame->pLightmapBuilder; + pGame->pLightmapBuilder->StackLights_TerrainFace(v63, &v87, array_50AC10, 3, 1); + pDecalBuilder->_49BE8A(v40, *(float *)&v63, (int)&v87, array_50AC10, 3, 1); + v100 = 3; + if ( byte_4D864C && pGame->uFlags & 0x80 ) + { + thisc = pGame->pIndoorCameraD3D; + if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) + //goto LABEL_126; + { + --pOutdoorCamera->numStru148s; + goto LABEL_162; + } + thisc->ViewTransform(array_50AC10, v100); + thisc->Project(array_50AC10, v100, 0); + } + this_3b = v102->vWorldViewPosition.x < 8.0 || pVertices2->vWorldViewPosition.x < 8.0 + || v101->vWorldViewPosition.x < 8.0; + v69 = (double)pOutdoorCamera->shading_dist_mist; + v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; + v70 = 0; + v96->std__vector_000004_size = 0; + if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) + { + if ( this_3b ) + v70 = 3; + else + v70 = v108 != 0 ? 5 : 0; + static_sub_0048034E_stru_76D578._49B0C9(v63, v87); + if ( pDecalBuilder->uNumDecals > 0 ) + pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); + } + if ( stru_F8AD28.uNumLightsApplied > 0 ) + v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); + v71 = v59; + v72 = v100; + //v35 = byte_4D864C == 0; + v59->uNumVertices = v100;//??? + if ( !byte_4D864C && pGame->uFlags & 0x80 ) + goto LABEL_154; + if ( this_3b ) + { + v73 = sr_424CD7(v72); } else { if ( !v108 ) - goto LABEL_105; - v56 = sr_424EE0_MakeFanFromTriangle(v55); - } - v40->uNumVertices = v56; - OutdoorCamera::Project(v56); - } -LABEL_105: - v57 = *(int *)&v40->flags; - if ( BYTE1(v57) & 1 ) - { - v40->_4811A3(); - } - else - { - if ( v57 & 2 && v40->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) - { - v81 = 0; - v58 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; - } - else - { - v58 = v40->uTileBitmapID; - v81 = 1; - } - pRenderer->DrawTerrainPolygon(v40->uNumVertices, v40, pBitmaps_LOD->pHardwareTextures[v58], 0, v81); - } -LABEL_112: - v59 = &array_77EC08[pOutdoorCamera->numStru148s]; - //a8 = (RenderVertexSoft *)&array_77EC08[pOutdoorCamera->numStru148s]; - v59->uTileBitmapID = pOutdoor->GetTileTexture(sX, sY); - if ( v59->uTileBitmapID == -1 ) - goto LABEL_162; - *(int *)&v59->flags = pOutdoor->GetSomeOtherTileInfo(sX, sY); - v61 = v93; - v59->field_59 = 1; - v59->field_34 = *(_WORD *)(v61 + 2); - v59->field_5C = v89; - v59->field_5D = v97; - v62 = *(unsigned __int16 *)((char *)pTerrainNormalIndices + v85); - if ( v62 > (signed int)(uNumTerrainNormals - 1) ) - v63 = 0; - else - v63 = &pTerrainNormals[v62]; - v64 = v92 * v63->y; - //v99 = v63; - thish = 20.0 - (-v64 - v91 * v63->y - v90 * v63->x) * 20.0; - v59->field_58 = floorf(thish + 0.5f); - if ( v59->field_58 < 0 ) - v59->field_58 = 0; - if ( pOutdoorCamera->numStru148s >= 1999 ) - return; - ++pOutdoorCamera->numStru148s; - if ( !sub_481FC9(v101, v102, pVertices2, v59) ) - { -//LABEL_126: - --pOutdoorCamera->numStru148s; - goto LABEL_162; - } - v66 = 1.0 / (v102->vWorldViewPosition.x + 0.0000001000000011686097); - memcpy(&array_50AC10[0], v102, 0x30u); - array_50AC10[0].flt_20 = v66; - array_50AC10[0].u = 0.0; - array_50AC10[0].v = 0.0; - v67 = pVertices2->vWorldViewPosition.x + 0.0000001000000011686097; - memcpy(&array_50AC10[1], pVertices2, sizeof(array_50AC10[1])); - array_50AC10[1].flt_20 = 1.0 / v67; - array_50AC10[1].u = 1.0; - array_50AC10[1].v = 1.0; - v68 = v101->vWorldViewPosition.x + 0.0000001000000011686097; - memcpy(&array_50AC10[2], v101, sizeof(array_50AC10[2])); - array_50AC10[2].flt_20 = 1.0 / v68; - array_50AC10[2].u = 1.0; - array_50AC10[2].v = 0.0; - - static stru154 static_sub_0048034E_stru_76D578; - /*static bool __init_flag1 = false; - if (!__init_flag1) - { - __init_flag1 = true; - - stru154::stru154(&static_sub_0048034E_stru_76D578); - }*/ - - v96 = pGame->pLightmapBuilder; - pGame->pLightmapBuilder->StackLights_TerrainFace(v99, &v87, array_50AC10, 3u, 1); - pDecalBuilder->_49BE8A(v40, *(float *)&v99, (int)&v87, array_50AC10, 3u, 1); - v100 = 3; - if ( byte_4D864C && pGame->uFlags & 0x80 ) - { - thisc = pGame->pIndoorCameraD3D; - if ( pGame->pIndoorCameraD3D->_4371C3(array_50AC10, (unsigned int *)&v100, 0) == 1 && !v100 ) - //goto LABEL_126; - { - --pOutdoorCamera->numStru148s; - goto LABEL_162; - } - thisc->ViewTransform(array_50AC10, v100); - thisc->Project(array_50AC10, v100, 0); - } - this_3b = v102->vWorldViewPosition.x < 8.0 - || pVertices2->vWorldViewPosition.x < 8.0 - || v101->vWorldViewPosition.x < 8.0; - v69 = (double)pOutdoorCamera->shading_dist_mist; - v108 = v69 < v102->vWorldViewPosition.x || v69 < pVertices2->vWorldViewPosition.x || v69 < v101->vWorldViewPosition.x; - v70 = 0; - v96->std__vector_000004_size = 0; - if ( stru_F8AD28.uNumLightsApplied > 0 || pDecalBuilder->uNumDecals > 0 ) - { - if ( this_3b ) - v70 = 3; - else - v70 = v108 != 0 ? 5 : 0; - static_sub_0048034E_stru_76D578._49B0C9(v99, v87); - if ( pDecalBuilder->uNumDecals > 0 ) - pDecalBuilder->ApplyDecals(31 - v40->field_58, 4, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70, -1); - } - if ( stru_F8AD28.uNumLightsApplied > 0 ) - v96->ApplyLights(&stru_F8AD28, &static_sub_0048034E_stru_76D578, v100, array_50AC10, 0, v70); - v71 = (RenderVertexSoft *)v59; - v72 = v100; - //v35 = byte_4D864C == 0; - v59->uNumVertices = v100;//??? - if ( !byte_4D864C && pGame->uFlags & 0x80 ) + { +LABEL_154: + v74 = v71->flags; + if ( !(BYTE1(v74) & 1) ) + { + if ( v74 & 2 && v71->uTileBitmapID == pRenderer->field_1036AC_bitmapid ) + { + v80 = false; + v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; + } + else + { + v75 = v71->uTileBitmapID; + v80 = true; + } + //v79 = 0; + //v78 = pBitmaps_LOD->pHardwareTextures[v75]; + v71->pTexture = (Texture *)&pBitmaps_LOD->pHardwareTextures[v75];// Ritor1: It's temporary + //v77 = (int)v71; + //v76 = v71->uNumVertices; + //goto LABEL_161; + pRenderer->DrawTerrainPolygon(v71, pBitmaps_LOD->pHardwareTextures[v75]);//pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80); + goto LABEL_162; + } + v38 = (stru148 *)v71; + goto LABEL_56; + } + v73 = sr_424EE0_MakeFanFromTriangle(v72); + } + v71->uNumVertices = v73; + OutdoorCamera::Project(v73); goto LABEL_154; - if ( this_3b ) - { - v73 = sr_424CD7(v72); - } - else - { - if ( !v108 ) - { -LABEL_154: - v74 = v71[1].vWorldPosition.x; - if ( !(BYTE1(v74) & 1) ) - { - if ( v74 & 2 && LOWORD(v71[1].vWorldViewProjY) == pRenderer->field_1036AC_bitmapid ) - { - v80 = false; - v75 = pRenderer->pHDWaterBitmapIDs[pRenderer->field_1036A8_bitmapid]; - } - else - { - v75 = v71[1].vWorldViewProjY; - v80 = true; - } - //v79 = 0; - v78 = pBitmaps_LOD->pHardwareTextures[v75]; - v77 = (int)v71; - v76 = v71->vWorldViewPosition.z; - //goto LABEL_161; - { - pRenderer->DrawTerrainPolygon(v76, (stru148 *)v71, v78, v79, v80); - goto LABEL_162; - } - } - v38 = (stru148 *)v71; - goto LABEL_56; - } - v73 = sr_424EE0_MakeFanFromTriangle(v72); - } - v71->vWorldViewPosition.z = v73; - OutdoorCamera::Project(v73); - goto LABEL_154; - } -} + } + } // 47F44B: using guessed type int __stdcall WorldPosToGridCellX(int); // 47F458: using guessed type int __stdcall WorldPosToGridCellZ(int); // 4D864C: using guessed type char byte_4D864C; @@ -7126,7 +7327,119 @@ return ::GetActorTintColor(a3, a4, a2, a5, a6); } - +void Render::DrawTerrainPolygon(stru148 *a3, IDirect3DTexture2 *pTexture)//new function +{ + int v5; // ebx@1 + int v6; // edi@1 + int v8; // eax@7 + float v9; // eax@12 + float *v10; // esi@12 + float v11; // ecx@14 + double v12; // st7@14 + double v13; // st7@14 + double v14; // st7@14 + signed int v15; // eax@14 + int v16; // eax@15 + float v17; // ST48_4@15 + char v18; // zf@17 + int v19; // eax@18 + int v20; // eax@18 + int v21; // edx@20 + signed int v22; // ecx@20 + int v23; // eax@20 + const char *v24; // ST4C_4@20 + unsigned int v25; // ST50_4@20 + int v26; // ST54_4@20 + int v27; // eax@20 + _UNKNOWN *v28; // eax@21 + int v29; // ecx@23 + int v30; // eax@23 + int v31; // eax@23 + int v32; // eax@24 + int v33; // eax@25 + int v34; // eax@25 + int v35; // eax@25 + int v36; // eax@25 + signed int v37; // ecx@26 + int v38; // eax@26 + _UNKNOWN *v39; // eax@27 + int v40; // edx@28 + int v41; // eax@29 + int v42; // eax@29 + int v43; // eax@29 + int v44; // eax@29 + unsigned int v46; // eax@29 + int v47; // eax@30 + int v48; // eax@30 + int v49; // eax@30 + double v52; // st6@35 + const char *v55; // [sp+4Ch] [bp-1Ch]@20 + int v57; // [sp+5Ch] [bp-Ch]@3 + signed int v59; // [sp+60h] [bp-8h]@12 + int v61; // [sp+64h] [bp-4h]@4 + int i; + + v6 = (int)this; + v5 = 0; + if (!this->uNumD3DSceneBegins) + return; + + + + + this->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 1); + this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE); + if (this->bUsingSpecular) + { + this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1); + this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2); + this->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1); + } + + pVertices[0].pos.x = array_50AC10[0].vWorldViewProjX; + pVertices[0].pos.y = array_50AC10[0].vWorldViewProjY; + pVertices[0].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[0].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); + pVertices[0].rhw = 1.0 / (array_50AC10[0].vWorldViewPosition.x + 0.0000001000000011686097); + pVertices[0].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[0].vWorldViewPosition.x, 0, 0); + pVertices[0].specular = 0; + pVertices[0].texcoord.x = array_50AC10[0].u; + pVertices[0].texcoord.y = array_50AC10[0].v; + + pVertices[1].pos.x = array_50AC10[3].vWorldViewProjX; + pVertices[1].pos.y = array_50AC10[3].vWorldViewProjY; + pVertices[1].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[3].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); + pVertices[1].rhw = 1.0 / (array_50AC10[3].vWorldViewPosition.x + 0.0000001000000011686097); + pVertices[1].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[3].vWorldViewPosition.x, 0, 0); + pVertices[1].specular = 0; + pVertices[1].texcoord.x = array_50AC10[3].u; + pVertices[1].texcoord.y = array_50AC10[3].v; + + pVertices[2].pos.x = array_50AC10[1].vWorldViewProjX; + pVertices[2].pos.y = array_50AC10[1].vWorldViewProjY; + pVertices[2].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[1].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); + pVertices[2].rhw = 1.0 / (array_50AC10[1].vWorldViewPosition.x + 0.0000001000000011686097); + pVertices[2].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[1].vWorldViewPosition.x, 0, 0); + pVertices[2].specular = 0; + pVertices[2].texcoord.x = array_50AC10[1].u; + pVertices[2].texcoord.y = array_50AC10[1].v; + + memcpy(pVertices + 3, pVertices + 2, sizeof(RenderVertexD3D3)); + memcpy(pVertices + 4, pVertices + 1, sizeof(RenderVertexD3D3)); + + pVertices[5].pos.x = array_50AC10[2].vWorldViewProjX; + pVertices[5].pos.y = array_50AC10[2].vWorldViewProjY; + pVertices[5].pos.z = 1.0 - 1.0 / (1000 * array_50AC10[2].vWorldViewPosition.x / (double)pOutdoorCamera->shading_dist_mist); + pVertices[5].rhw = 1.0 / (array_50AC10[2].vWorldViewPosition.x + 0.0000001000000011686097); + pVertices[5].diffuse = GetActorTintColor(a3->field_58, 0, array_50AC10[2].vWorldViewPosition.x, 0, 0); + pVertices[5].specular = 0; + pVertices[5].texcoord.x = array_50AC10[2].u; + pVertices[5].texcoord.y = array_50AC10[2].v; + + + this->pRenderD3D->pDevice->SetTexture(0, pTexture); + this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, pVertices, 6, D3DDP_DONOTLIGHT); + +} //----- (004A26BC) -------------------------------------------------------- void Render::DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7) { @@ -7276,13 +7589,9 @@ v51 = a7; } } - ErrD3D(pRenderD3D->pDevice->SetTexture(0, a5)); - ErrD3D(pRenderD3D->pDevice->DrawPrimitive( - D3DPT_TRIANGLEFAN, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, - arary_77E5C8, - uNumVertices, - 16)); + this->pRenderD3D->pDevice->SetTexture(0, a5); + this->pRenderD3D->pDevice->DrawPrimitive(D3DPT_TRIANGLEFAN, D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_SPECULAR | D3DFVF_TEX1, + arary_77E5C8, uNumVertices, 16); if ( a6 ) { ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
--- a/Render.h Tue Feb 05 19:08:22 2013 +0600 +++ b/Render.h Tue Feb 05 19:08:52 2013 +0600 @@ -308,6 +308,7 @@ void DrawBillboards_And_MaybeRenderSpecialEffects_And_EndScene(); unsigned int GetActorTintColor(float a2, int a3, int a4, int a5, RenderBillboard *a6); void DrawPolygon(unsigned int uNumVertices, stru148 *a3, ODMFace *a4, IDirect3DTexture2 *pTexture); + void DrawTerrainPolygon(stru148 *a3, IDirect3DTexture2 *pTexture); void DrawTerrainPolygon(unsigned int uNumVertices, stru148 *a4, IDirect3DTexture2 *a5, int a6, int a7); void Render::DrawStrip(unsigned int uNumVertices, struct stru148 *a3, IDirect3DTexture2 *pTexture); void DrawFan(unsigned int uNumVertices, stru148 *a3, IDirect3DTexture2 *a4); @@ -352,6 +353,7 @@ void DrawLayingItems_Shooting_Magic_ODM(); void TransformBillboardsAndSetPalettesODM(); float DrawBezierTerrain(); + void RenderTerrainD3D(); void DrawTerrainD3D(int a1, int edx0, int a3); void DrawTerrainSW(int a1, int a2, int a3); __int16 ExecOutdoorDrawSW();
--- a/SaveLoad.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/SaveLoad.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -247,7 +247,7 @@ int v17; // esi@37 unsigned int v18; // ecx@38 unsigned int v19; // esi@39 - char *v20; // edx@39 + BSPModel *v20; // edx@39 void *v21; // esi@41 void *v22; // esi@41 BSPModel *v23; // eax@42 @@ -265,16 +265,16 @@ //std::string v35; // [sp-18h] [bp-288h]@8 const char *v36; // [sp-10h] [bp-280h]@6 const char *v37; // [sp-Ch] [bp-27Ch]@6 - const char *v38; // [sp-8h] [bp-278h]@8 + unsigned int *v38; // [sp-8h] [bp-278h]@8 CHAR Buffer; // [sp+Ch] [bp-264h]@59 - char Dir; // [sp+8Ch] [bp-1E4h]@51 - char Drive; // [sp+ACh] [bp-1C4h]@51 + char Dir[255]; // [sp+8Ch] [bp-1E4h]@51 + char Drive[255]; // [sp+ACh] [bp-1C4h]@51 SavegameHeader header; // [sp+CCh] [bp-1A4h]@10 //int v43; // [sp+CCh] [bp-1A4h]@10 //char Dest[20]; // [sp+E0h] [bp-190h]@10 //unsigned __int64 pTimePlayed; // [sp+F4h] [bp-17Ch]@10 - char Filename; // [sp+130h] [bp-140h]@51 - char Ext; // [sp+150h] [bp-120h]@51 + char Filename[255]; // [sp+130h] [bp-140h]@51 + char Ext[255]; // [sp+150h] [bp-120h]@51 char v48; // [sp+151h] [bp-11Fh]@51 char Source[32]; // [sp+170h] [bp-100h]@51 char Str[120]; // [sp+190h] [bp-E0h]@8 @@ -419,7 +419,7 @@ } if ( !a2 ) { - __debugbreak(); + //__debugbreak(); sub_42FA22_mess_with_laying_item_list(); v9 = (int)malloc(0xF4240); v71 = (std::string *)v9; @@ -446,7 +446,7 @@ v68 = 0; for (int i = 0; i <= (signed int)pIndoor->uNumFaces; ++i) { - v38 = (char *)v68 + (unsigned int)pIndoor->pFaces + 44; + v38 = &pIndoor->pFaces[i].uAttributes;//(char *)v68 + (unsigned int)pIndoor->pFaces + 44; memcpy(v11, v38, 4); v68 += 48; v11 = (char *)v11 + 4; @@ -489,11 +489,11 @@ if ( (signed int)pOutdoor->uNumBModels > 0 ) { v19 = pOutdoor->uNumBModels; - v20 = (char *)&pOutdoor->pBModels->uNumFaces; + v20 = &pOutdoor->pBModels[0]; do { - v18 += *(int *)v20; - v20 += 188; + v18 += v20->uNumFaces; + ++v20; --v19; pOutdoor->ddm.uNumFacesInBModels = v18; } @@ -512,16 +512,16 @@ { v23 = pOutdoor->pBModels; v24 = 76; - for (int i = 0; i <= (signed int)pOutdoor->uNumBModels ; ++i) + for (int i = 0; i < (signed int)pOutdoor->uNumBModels ; ++i) { - v25 = *(int *)&v23->pModelName[v24] == 0; - v26 = *(int *)&v23->pModelName[v24] < 0; + v25 = v23[i].uNumFaces == 0;//*(int *)&v23->pModelName[v24] == 0; + v26 = v23[i].uNumFaces < 0;//*(int *)&v23->pModelName[v24] < 0; if ( !(v26 | v25) ) { v68 = 0; - for (int j = 0; j <= *(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) + for (int j = 0; j < pOutdoor->pBModels[i].uNumFaces;++j)//*(int *)&pOutdoor->pBModels->pModelName[v24]; ++j) { - v38 = (char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28; + v38 = &(v23[i].pFaces[j].uAttributes); //(char *)v68 + *(int *)&v23->pModelName[v24 + 8] + 28; memcpy(v22, v38, 4); v23 = pOutdoor->pBModels; v68 += 154; @@ -560,7 +560,7 @@ } v32 = v17 + 56; strcpy(Source, pCurrentMapName); - _splitpath(Source, &Drive, &Dir, &Filename, &Ext); + _splitpath(Source, Drive, Dir, Filename, Ext); v48 = 100; Size = v32 - (int)DstBuf; v69 = 999984;
--- a/Vis.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/Vis.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -119,10 +119,10 @@ char Vis::_4C12C3_FindSomeBillboard(RenderVertexSoft *a1, int a2, float a3, float a4) { signed int v5; // esi@1 - char *v6; // edi@2 + RenderBillboardD3D *v6; // edi@2 double v7; // st7@9 int v8; // edx@9 - char *v9; // ecx@10 + RenderVertexSoft *v9; // ecx@10 char result; // al@24 Vis *thisa; // [sp+10h] [bp-8h]@1 float thisb; // [sp+10h] [bp-8h]@9 @@ -134,20 +134,24 @@ v5 = 0; thisa = this; if ( (signed int)pRenderer->uNumBillboardsToDraw <= 0 ) - goto LABEL_28; - v6 = (char *)&pRenderer->pBillboardRenderListD3D[0].uParentBillboardID; + { + return 0; + } + v6 = pRenderer->pBillboardRenderListD3D; do { - if ( IsPointInsideD3DBillboard((RenderBillboardD3D *)(v6 - 152), a3, a4) + if ( IsPointInsideD3DBillboard(v6, a3, a4) && (v13 == -1 - || (unsigned int)pBillboardRenderList[*(int *)v6].sZValue < pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue) ) + || (unsigned int)pBillboardRenderList[v6->uParentBillboardID].sZValue < pBillboardRenderList[pRenderer->pBillboardRenderListD3D[v13].uParentBillboardID].sZValue) ) v13 = v5; ++v5; - v6 += 156; + ++v6; } while ( v5 < (signed int)pRenderer->uNumBillboardsToDraw ); if ( v13 == -1 ) - goto LABEL_28; + { + return 0; + } v7 = 3.4028235e38; v8 = a2; a4a = 3.4028235e38; @@ -155,18 +159,18 @@ thisb = -3.4028235e38; if ( a2 > 0 ) { - v9 = (char *)&a1->vWorldViewProjY; + v9 = a1; do { - if ( *((float *)v9 - 1) < v7 ) - v7 = *((float *)v9 - 1); - if ( *((float *)v9 - 1) > (double)a3a ) - a3a = *((float *)v9 - 1); - if ( *(float *)v9 < (double)a4a ) - a4a = *(float *)v9; - if ( *(float *)v9 > (double)thisb ) - thisb = *(float *)v9; - v9 += 48; + if ( v9->vWorldViewProjX < v7 ) + v7 = v9->vWorldViewProjX; + if ( v9->vWorldViewProjX > (double)a3a ) + a3a = v9->vWorldViewProjX; + if ( v9->vWorldViewProjY < (double)a4a ) + a4a = v9->vWorldViewProjY; + if ( v9->vWorldViewProjY > (double)thisb ) + thisb = v9->vWorldViewProjY; + ++v9; --v8; } while ( v8 ); @@ -175,7 +179,6 @@ || pRenderer->pBillboardRenderListD3D[v13].pQuards[0].pos.y > (double)a4a || pRenderer->pBillboardRenderListD3D[v13].pQuards[3].pos.x < (double)a3a || pRenderer->pBillboardRenderListD3D[v13].pQuards[1].pos.y < (double)thisb ) -LABEL_28: result = 0; else result = 1; @@ -237,14 +240,14 @@ int v6; // ST1C_4@6 Vis_stru1_stru0 *v7; // edi@6 Vis *thisa; // [sp+20h] [bp-Ch]@1 - void **v9; // [sp+24h] [bp-8h]@2 + RenderBillboardD3D *v9; // [sp+24h] [bp-8h]@2 unsigned int uD3DBillboardIdx; // [sp+28h] [bp-4h]@1 uD3DBillboardIdx = 0; thisa = this; if ( (signed int)pRenderer->uNumBillboardsToDraw > 0 ) { - v9 = (void **)&pRenderer->pBillboardRenderListD3D[0].uParentBillboardID; + v9 = pRenderer->pBillboardRenderListD3D;//[0].uParentBillboardID; do { if ( is_part_of_selection((BLVFace *)uD3DBillboardIdx, a2) @@ -252,9 +255,9 @@ { if ( DoesRayIntersectBillboard(fPickDepth, uD3DBillboardIdx) ) { - v6 = pBillboardRenderList[(int)*v9].sZValue; + v6 = pBillboardRenderList[v9->uParentBillboardID].sZValue; v7 = &a4->array_0004[a4->uNumPointers]; - v7->pObjectInfo = *v9; + v7->pObjectInfo = (void *)v9->uParentBillboardID; v7 = (Vis_stru1_stru0 *)((char *)v7 + 4); v7->pObjectInfo = (void *)v6; v7->sZValue = 1; @@ -262,7 +265,7 @@ } } ++uD3DBillboardIdx; - v9 += 39; + ++v9; } while ( (signed int)uD3DBillboardIdx < (signed int)pRenderer->uNumBillboardsToDraw ); } @@ -990,14 +993,18 @@ { v12 = a1a; a3[2 * a1a] = a6->pXInterceptDisplacements[a1a] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[a1a]); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[a1a]); + + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[a1a]].x; *(a5a - 1) = a6->pYInterceptDisplacements[v12] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12] + 4); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12] + 4); + + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[v12]].y; *(__int16 *)((char *)a5a + (int)(char *)a3 - (char *)a4) = a6->pXInterceptDisplacements[v12 + 1] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] - + 12 * a6->pVertexIDs[v12 + 1]); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] +// + 12 * a6->pVertexIDs[v12 + 1]); + + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[v12+1]].x; v13 = a6->pYInterceptDisplacements[v12 + 1] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12 + 1] + 4); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v11] + 12 * a6->pVertexIDs[v12 + 1] + 4); + + pOutdoor->pBModels[v11].pVertices.pVertices[a6->pVertexIDs[v12 + 1]].y; v14 = a5a; ++a1a; a5a += 2; @@ -1020,14 +1027,18 @@ { v16 = a1a; a3[2 * a1a] = a6->pXInterceptDisplacements[a1a] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[a1a]); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[a1a]); + + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[a1a]].x; *(a5b - 1) = a6->pZInterceptDisplacements[v16] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16] + 8); - *(__int16 *)((char *)a5b + (int)a3 - (int)a4) = a6->pXInterceptDisplacements[v16 + 1] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] - + 12 * a6->pVertexIDs[v16 + 1]); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16] + 8); + + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[v16]].y; + *(__int16 *)((char *)a5b + (int)a3 - (int)a4) = a6->pXInterceptDisplacements[v16 + 1] +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] +// + 12 * a6->pVertexIDs[v16 + 1]); + + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[v16+1]].x; v17 = a6->pZInterceptDisplacements[v16 + 1] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16 + 1] + 8); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v15] + 12 * a6->pVertexIDs[v16 + 1] + 8); + + pOutdoor->pBModels[v15].pVertices.pVertices[a6->pVertexIDs[v16+1]].z; v18 = a5b; ++a1a; a5b += 2; @@ -1048,15 +1059,19 @@ { v20 = a1a; a3[2 * a1a] = a6->pYInterceptDisplacements[a1a] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[a1a] + 4); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[a1a] + 4); + + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[a1a]].y; *(a5c - 1) = a6->pZInterceptDisplacements[v20] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20] + 8); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20] + 8); + + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[a1a]].z; *(__int16 *)((char *)a5c + (int)(char *)a3 - (char *)a4) = a6->pYInterceptDisplacements[v20 + 1] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] - + 12 * a6->pVertexIDs[v20 + 1] - + 4); - v21 = a6->pZInterceptDisplacements[v20 + 1] - + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20 + 1] + 8); +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] +// + 12 * a6->pVertexIDs[v20 + 1] +// + 4); + + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[v20+1]].y; + v21 = a6->pZInterceptDisplacements[v20 + 1] +// + *(short *)(*(int *)&pOutdoor->pBModels->pModelName[v19] + 12 * a6->pVertexIDs[v20 + 1] + 8); + + pOutdoor->pBModels[v19].pVertices.pVertices[a6->pVertexIDs[v20+1]].z; v22 = a5c; ++a1a; a5c += 2;
--- a/mm7_1.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_1.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -691,9 +691,9 @@ { while ( 1 ) { - v5 = pStru179->field_0[v21]; - v20 = 8 * pStru179->field_0[v21]; - v6 = (char *)dword_723E80_award_related[v20 / 4]; + v5 = pStru179.field_0[v21]; + v20 = 8 * pStru179.field_0[v21]; + v6 = (char *)pAwards[v20/8-1].pText;//(char *)dword_723E80_award_related[v20 / 4]; if ( v5 != 1 ) break; v17 = pParty->uFine; @@ -701,7 +701,7 @@ sprintf(pTmpBuf, v6, v17); v6 = pTmpBuf; LABEL_43: - v14 = dword_723E84[v20 / 4]; + v14 = pAwards[v20/8-1].uSort;//dword_723E84[v20 / 4]; ++dword_506520; v15 = GenerateColorAsCloseAsPossibleToR8G8B8InTargetFormat( pAwardsTextColors[3 * v14 % 6], @@ -4253,7 +4253,7 @@ int v9; // [sp+9Ch] [bp-10h]@10 unsigned int v10; // [sp+A0h] [bp-Ch]@1 unsigned int v11; // [sp+A4h] [bp-8h]@8 - unsigned int *v12; // [sp+A8h] [bp-4h]@9 + ItemGen *v12; // [sp+A8h] [bp-4h]@9 v1 = 0; v2 = uChestID; @@ -4282,10 +4282,10 @@ v11 = 0; if ( uChestArea > 0 ) { - v12 = &pChests[v3].mm7__vector_pItems[0].uAttributes; + v12 = pChests[v3].mm7__vector_pItems;//&pChests[v3].mm7__vector_pItems[0].uAttributes; do { - v9 = *(v12 - 5); + v9 = v12->uItemID; if ( v9 ) { v6 = 0; @@ -4293,15 +4293,17 @@ { ++v6; if ( v6 >= uChestArea ) - goto LABEL_17; + break; } - Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10); - if ( pChests[v3].uFlags & 4 ) - *v12 |= 1u; - } -LABEL_17: + if(v6<uChestArea) + { + Chest::PlaceItemAt((unsigned __int8)Dst[v6], v11, v10); + if ( pChests[v3].uFlags & 4 ) + v12->uAttributes |= 1u; + } + } ++v11; - v12 += 9; + ++v12; } while ( (signed int)v11 < uChestArea ); }
--- a/mm7_2.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_2.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -2930,10 +2930,10 @@ { unsigned int v1; // esi@8 unsigned int v3; // ecx@10 - char *v4; // esi@15 + Player *v4; // esi@15 int v5; // ebx@16 int v6; // ST38_4@16 - char *v7; // esi@18 + Player *v7; // esi@18 int v8; // ebx@19 int v9; // ST30_4@19 int v10; // ST44_4@19 @@ -3064,10 +3064,10 @@ } if ( a1 == 11 ) { - v7 = (char *)&pParty->pPlayers[0].pConditions[15]; + v7 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pConditions[15]; do { - v8 = *((int *)v7 - 2); + /*v8 = *((int *)v7 - 2); v9 = *((int *)v7 - 1); v10 = *(int *)v7; v11 = *((int *)v7 + 1); @@ -3076,38 +3076,48 @@ v14 = *((int *)v7 + 8); v15 = *((int *)v7 + 9); v16 = *((int *)v7 + 4); - v17 = *((int *)v7 + 5); - memset(v7 - 120, 0, 0xA0u); - *((int *)v7 + 2) = v12; - *((int *)v7 + 3) = v13; - *(int *)v7 = v10; - *((int *)v7 + 1) = v11; - *((int *)v7 - 1) = v9; - *((int *)v7 + 8) = v14; - *((int *)v7 + 9) = v15; - *((int *)v7 + 4) = v16; - *((int *)v7 - 2) = v8; - *((int *)v7 + 5) = v17; - *((int *)v7 + 1585) = ((Player *)(v7 - 120))->GetMaxHealth(); - v7 += 6972; - } - while ( (signed int)v7 < (signed int)&pParty->pHirelings[1].evtb ); + v17 = *((int *)v7 + 5);*/ + v8 = LODWORD(v7->pConditions[14]); + v9 = HIDWORD(v7->pConditions[14]); + v10 = LODWORD(v7->pConditions[15]); + v11 = HIDWORD(v7->pConditions[15]); + v12 = LODWORD(v7->pConditions[16]); + v13 = HIDWORD(v7->pConditions[16]); + v14 = LODWORD(v7->pConditions[19]); + v15 = HIDWORD(v7->pConditions[19]); + v16 = LODWORD(v7->pConditions[17]); + v17 = HIDWORD(v7->pConditions[17]); + memset(v7, 0, 0xA0u); + LODWORD(v7->pConditions[16]) = v12; + HIDWORD(v7->pConditions[16]) = v13; + LODWORD(v7->pConditions[15]) = v10; + HIDWORD(v7->pConditions[15]) = v11; + HIDWORD(v7->pConditions[14]) = v9; + LODWORD(v7->pConditions[19]) = v14; + HIDWORD(v7->pConditions[19]) = v15; + LODWORD(v7->pConditions[17]) = v16; + LODWORD(v7->pConditions[14]) = v8; + HIDWORD(v7->pConditions[17]) = v17; + v7->sHealth = v7->GetMaxHealth(); + ++v7; + } + while ( v7 <= pPlayers[3] ); return 0; } if ( a1 == 12 ) { - v4 = (char *)&pParty->pPlayers[0].pActiveSkills[8]; + v4 = pParty->pPlayers;//(char *)&pParty->pPlayers[0].pActiveSkills[8]; do { - v5 = *((int *)v4 - 32); - v6 = *((int *)v4 - 31); - memset(v4 - 280, 0, 0xA0u); - *(int *)v4 = v5; - *((int *)v4 + 1) = v6; - *((int *)v4 + 1545) = ((Player *)(v4 - 280))->GetMaxHealth(); - v4 += 6972; - } - while ( (signed int)v4 < (signed int)&pParty->field_777C[22] ); + v5 = LODWORD(v4->pConditions[19]);//*((int *)v4 - 32); + v6 = HIDWORD(v4->pConditions[19]);//*((int *)v4 - 31); + memset(v4->pConditions, 0, 0xA0u); + v4->pActiveSkills[8] = v5; + v4->pActiveSkills[10] = v6; + v4->sHealth = v4->GetMaxHealth(); + ++v4; + } + while ( v4 <= pPlayers[3] ); return 0; } if ( a1 == 33 )
--- a/mm7_3.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_3.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -3228,12 +3228,17 @@ { if ( v108 >> 6 < pOutdoor->uNumBModels ) { - v7 = (ODMFace *)&pOutdoor->pBModels[v108 >> 6].pFaces; + v7 = pOutdoor->pBModels[v108 >> 6].pFaces; v6 = v108 & 0x3F; - if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) + /*if ( *(char *)(v7->pFacePlane.vNormal.x + 308 * v6 + 31) & 4 ) { pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel; v103 = *(short *)(v7->pFacePlane.vNormal.x + 308 * v6 + 292); + }*/ + if ( BYTE3(v7[v6].uAttributes) & 4 ) + { + pParty->field_6F4_packedid = 8 * v108 | OBJECT_BModel; + v103 = v7[v6].sCogTriggeredID; } } } @@ -3774,7 +3779,7 @@ pParty->bFlying = 0; v46 = &pOutdoor->pBModels[(signed int)stru_721530.uFaceID >> 9]; v127 = v46; - v47 = &v46->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; + v47 = &v46->pFaces[((signed int)stru_721530.uFaceID >> 3) & 0x3F]; v48 = v47->pBoundingBox.z2 - v47->pBoundingBox.z1; v51 = __OFSUB__(v48, 32); v49 = v48 == 32; @@ -5026,12 +5031,12 @@ //----- (00476750) -------------------------------------------------------- void __cdecl InitializeAutonotes() { - char *v0; // ebp@3 + Autonote *v0; // ebp@3 int v1; // ebx@4 char *v2; // esi@4 char v3; // cl@5 int v4; // eax@5 - int v5; // edi@9 + char *v5; // edi@9 signed int v6; // [sp+0h] [bp-4h]@4 if ( pAutonoteTXT_Raw ) @@ -5039,7 +5044,7 @@ pAutonoteTXT_Raw = 0; pAutonoteTXT_Raw = (char *)pEvents_LOD->LoadRaw("autonote.txt", 0); strtok(pAutonoteTXT_Raw, "\r"); - v0 = (char *)&pAutonoteTxt[0].eType; + v0 = pAutonoteTxt; for (uint i = 0; i < 195; ++i) { v1 = 0; @@ -5054,15 +5059,15 @@ ++v4; v3 = v2[v4]; } - v5 = (int)&v2[v4]; + v5 = &v2[v4]; if ( !v2[v4] ) v6 = 1; - *(char *)v5 = 0; + *v5 = 0; if ( v4 ) { if ( v1 == 1 ) { - *((int *)v0 - 1) = (int)RemoveQuotes(v2); + v0->pText = RemoveQuotes(v2); } else { @@ -5075,23 +5080,23 @@ if ( _strcmpi(v2, "seer") ) { if ( _strcmpi(v2, "obelisk") ) - *(int *)v0 = 5 - (_strcmpi(v2, "teacher") != 0); + v0->eType = (AUTONOTE_TYPE)(5 - (_strcmpi(v2, "teacher") != 0)); else - *(int *)v0 = 2; + v0->eType = (AUTONOTE_TYPE)2; } else { - *(int *)v0 = 3; + v0->eType = (AUTONOTE_TYPE)3; } } else { - *(int *)v0 = 1; + v0->eType = (AUTONOTE_TYPE)1; } } else { - *(int *)v0 = 0; + v0->eType = (AUTONOTE_TYPE)0; } } } @@ -5101,10 +5106,10 @@ v6 = 1; } ++v1; - v2 = (char *)(v5 + 1); + v2 = v5 + 1; } while ( v1 - 1 <= 2 && !v6 ); - v0 += 8; + ++v0; } //while ( (signed int)v0 < (signed int)&pScrolls[1] ); } @@ -6676,10 +6681,10 @@ { IndoorCameraD3D *v0; // eax@3 char result; // al@3 - Vec3_int_ **v2; // ebx@4 - Vec3_int_ *v3; // eax@6 + BSPModel *v2; // ebx@4 + int v3; // eax@6 ODMFace *pFace; // esi@6 - int v5; // ecx@8 + Vec3_int_ *v5; // ecx@8 int v6; // eax@8 stru148 *v7; // ebx@8 LightmapBuilder *v8; // eax@8 @@ -6693,11 +6698,13 @@ unsigned int v16; // edi@22 int v17; // eax@24 int v18; // edi@34 - char *v19; // eax@35 - char *v20; // ecx@35 + RenderVertexSoft *v19; // eax@35 + unsigned short *v20; // ecx@35 + unsigned short *v20b; // ecx@35 + unsigned short *v20c; // ecx@35 Vec3_int_ *v21; // edx@36 int v22; // edx@36 - char *v23; // edi@37 + RenderVertexSoft *v23; // edi@37 int v24; // eax@50 int v25; // ecx@55 int v26; // eax@57 @@ -6716,7 +6723,8 @@ LightmapBuilder *v39; // [sp-8h] [bp-60h]@2 int v40; // [sp-4h] [bp-5Ch]@2 std::string *v41; // [sp+Ch] [bp-4Ch]@2 - Vec3_int_ *v42; // [sp+10h] [bp-48h]@6 + int v41b; + int v42; // [sp+10h] [bp-48h]@6 LightmapBuilder *pLightmapBuilder; // [sp+14h] [bp-44h]@8 float v44; // [sp+18h] [bp-40h]@10 float v45; // [sp+1Ch] [bp-3Ch]@10 @@ -6730,7 +6738,7 @@ int v53; // [sp+3Ch] [bp-1Ch]@8 Vec3_int_ *v54; // [sp+40h] [bp-18h]@6 int a1; // [sp+44h] [bp-14h]@3 - Vec3_int_ **v56; // [sp+48h] [bp-10h]@4 + BSPModel *v56; // [sp+48h] [bp-10h]@4 int uNumVertices; // [sp+4Ch] [bp-Ch]@34 int unused; // [sp+50h] [bp-8h]@3 int a3; // [sp+57h] [bp-1h]@2 @@ -6744,41 +6752,43 @@ a1 = 0; v47 = v0; result = LOBYTE(pOutdoor->pBModels); - v41 = (std::string *)pOutdoor->uNumBModels; + v41b = pOutdoor->uNumBModels; if ( (signed int)pOutdoor->uNumBModels > 0 ) { - v2 = (Vec3_int_ **)&pOutdoor->pBModels->uNumFaces; - v56 = (Vec3_int_ **)&pOutdoor->pBModels->uNumFaces; + v2 = pOutdoor->pBModels; + v56 = pOutdoor->pBModels; while ( 1 ) { if ( IsBModelVisible(a1, &unused) ) { - *(v2 - 3) = (Vec3_int_ *)((unsigned int)*(v2 - 3) | 1); - v3 = *v2; - pFace = (ODMFace *)v2[2]; + v2->field_40 |= 1u; + v3 = v2->uNumFaces; + pFace = v2->pFaces; v54 = 0; v46 = pFace; v42 = v3; - if ( (signed int)v3 > 0 ) + if ( v3 > 0 ) break; } LABEL_86: ++a1; - v2 += 47; + ++v2;// += 47; result = a1; v56 = v2; - if ( a1 >= (signed int)v41 ) + if ( a1 >= v41b ) return result; } while ( 1 ) { if (pFace->Invisible()) goto LABEL_85; - v5 = (int)*(v2 - 1); + //v5 = (int)*(v2 - 1); + v5 = v2->pVertices.pVertices; v6 = pFace->pVertexIDs[0]; v53 = 0; v7 = &array_77EC08[pOutdoorCamera->numStru148s]; - v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8); + //v8 = *(LightmapBuilder **)(v5 + 12 * v6 + 8); + v8 = (LightmapBuilder *)v5[v6].z; *(int *)&v7->flags = 0; pLightmapBuilder = v8; v9 = pFace->uTextureID; @@ -6865,12 +6875,16 @@ uNumVertices = v18; if ( v18 > 0 ) { - v19 = (char *)&array_73D150[0].vWorldPosition.z; - v20 = (char *)pFace->pTextureUIDs; + //v19 = (char *)&array_73D150[0].vWorldPosition.z; + //v20 = (char *)pFace->pTextureUIDs; + v19 = array_73D150; + v20 = pFace->pTextureUIDs; + v20b = pFace->pVertexIDs; + v20c = pFace->pTextureVIDs; v51 = v18; do { - v21 = &(*(v56 - 1))[*((short *)v20 - 20)]; +/* v21 = &(*(v56 - 1))[*((short *)v20 - 20)]; *((float *)v19 - 2) = (double)v21->x; *((float *)v19 - 1) = (double)v21->y; *(float *)v19 = (double)v21->z; @@ -6881,29 +6895,52 @@ v20 += 2; v10 = v51-- == 1; v52 = v22; - *((float *)v19 - 4) = (double)v22 * v44; + *((float *)v19 - 4) = (double)v22 * v44;*/ + + //v21 = (BSPVertexBuffer *)(*((_DWORD *)v56 - 1) + 12 * *(v20 - 20)); + v21 = &v56->pVertices.pVertices[*v20b]; + //*((float *)v19 - 2) = (double)v21->x; + //*((float *)v19 - 1) = (double)v21->y; + v19->vWorldPosition.x = (double)v21->x; + v19->vWorldPosition.y = (double)v21->y; + v19->vWorldPosition.z = (double)v21->z; + ++v19; + v52 = v7->sTextureDeltaU + (signed __int16)*v20; + //*((float *)v19 - 5) = (double)v52 * v45; + (v19-1)->u = (double)v52 * v45; + v22 = v7->sTextureDeltaV + (signed __int16)*v20c; + ++v20; + ++v20b; + ++v20c; + v10 = v51-- == 1; + v52 = v22; + //*((float *)v19 - 4) = (double)v22 * v44; + (v19-1)->v = (double)v22 * v44; } while ( !v10 ); - v23 = (char *)&array_73D150[0].vWorldViewPosition; + //v23 = (char *)&array_73D150[0].vWorldViewPosition; + v23 = array_73D150; v51 = uNumVertices; *(float *)&pLightmapBuilder = (double)(signed int)pLightmapBuilder; do { - if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) ) + //if ( *(float *)&pLightmapBuilder == *((float *)v23 - 1) ) + if ( *(float *)&pLightmapBuilder == v23->vWorldPosition.z ) ++v53; - v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u); - if ( *(float *)v23 < 8.0 || (double)pOutdoorCamera->shading_dist_mist < *(float *)v23 ) - { - if ( *(float *)v23 >= 8.0 ) + //v47->ViewTransform((RenderVertexSoft *)(v23 - 12), 1u); + v47->ViewTransform(v23, 1u); + if ( v23->vWorldViewPosition.x < 8.0 || (double)pOutdoorCamera->shading_dist_mist < v23->vWorldViewPosition.x ) + { + if ( v23->vWorldViewPosition.x >= 8.0 ) v49 = 1; else v50 = 1; } else { - v47->Project((RenderVertexSoft *)(v23 - 12), 1u, 0); - } - v23 += 48; + v47->Project(v23, 1u, 0); + } + ++v23;// += 48; --v51; } while ( v51 ); @@ -7061,9 +7098,9 @@ BSPModel *Render::DrawBuildingsSW() { BSPModel *result; // eax@1 - unsigned int *v1; // ebx@2 + BSPModel *v1; // ebx@2 int v2; // eax@4 - int v3; // edi@4 + ODMFace *v3; // edi@4 int v4; // ecx@6 int v5; // eax@6 int v6; // ecx@6 @@ -7090,7 +7127,7 @@ signed int v27; // ecx@43 double v28; // st6@43 double v29; // st5@43 - int v30; // edx@44 + unsigned short *v30; // edx@44 int v31; // eax@44 double v32; // st4@45 int v33; // ecx@45 @@ -7136,12 +7173,12 @@ int v73; // [sp+8Ch] [bp-34h]@57 int v74; // [sp+90h] [bp-30h]@6 int v75; // [sp+94h] [bp-2Ch]@6 - int v76; // [sp+98h] [bp-28h]@4 + ODMFace *v76; // [sp+98h] [bp-28h]@4 int v77; // [sp+9Ch] [bp-24h]@6 - unsigned int *v78; // [sp+A0h] [bp-20h]@2 + BSPModel *v78; // [sp+A0h] [bp-20h]@2 int v79; // [sp+A4h] [bp-1Ch]@4 int a1; // [sp+A8h] [bp-18h]@1 - int v81; // [sp+ACh] [bp-14h]@7 + unsigned short *v81; // [sp+ACh] [bp-14h]@7 int v82; // [sp+B0h] [bp-10h]@6 int v83; // [sp+B4h] [bp-Ch]@6 signed int v84; // [sp+B8h] [bp-8h]@7 @@ -7149,20 +7186,20 @@ a2 = 0; a1 = 0; - result = pOutdoor->pBModels; + result = (BSPModel *)pOutdoor->pBModels; v66 = pOutdoor->uNumBModels; if ( (signed int)pOutdoor->uNumBModels > 0 ) { - v1 = &pOutdoor->pBModels->uNumFaces; - v78 = &pOutdoor->pBModels->uNumFaces; + v1 = pOutdoor->pBModels; + v78 = pOutdoor->pBModels; while ( 1 ) { if ( IsBModelVisible(a1, &a2) ) { - *(v1 - 3) |= 1u; - v2 = *v1; - v3 = v1[2]; - v79 = 0; + v1->field_40 |= 1u; + v2 = v1->uNumFaces; + v3 = (ODMFace *)v1->pFaces; + v74 = 0; v76 = v3; v68 = v2; if ( v2 > 0 ) @@ -7170,7 +7207,7 @@ } LABEL_73: ++a1; - v1 += 47; + ++v1; result = (BSPModel *)a1; v78 = v1; if ( a1 >= v66 ) @@ -7178,23 +7215,23 @@ } while ( 1 ) { - if ( !(*(char *)(v3 + 29) & 0x20) ) - { - v4 = 3 * *(short *)(v3 + 32); - v5 = (int)(v1 - 2); - v67 = (int)(v1 - 2); - v6 = *(int *)(*(v1 - 1) + 4 * v4 + 8) + 4; + if ( !v3->Invisible() ) + { + v4 = 3 * v3->pVertexIDs[0]; + v5 = (int)((char *)v1 - 8); + v67 = (int)((char *)v1 - 8); + v6 = *(_DWORD *)(*(&v1->uNumConvexFaces - 2) + 4 * v4 + 8) + 4; v82 = 0; v83 = v6; v74 = 0; - v7 = *(char *)(v3 + 302); + v7 = v3->uNumVertices; v75 = 0; v77 = v7; if ( v7 > 0 ) { v8 = (double)v83; v9 = (char *)&array_73D150[0].vWorldViewPosition; - v81 = v3 + 32; + v81 = v3->pVertexIDs; v83 = v7; *(float *)&v84 = v8; while ( 1 ) @@ -7239,9 +7276,9 @@ v82 = -pOutdoor->vSunlight.y; v84 = *(int *)(v3 + 4); v82 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.y) >> 16; - v81 = -pOutdoor->vSunlight.z; + v81 = (unsigned __int16 *)-pOutdoor->vSunlight.z; v84 = *(int *)(v3 + 8); - v81 = (unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16; + v81 = (unsigned __int16 *)((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16); v84 = v83 + v82 + ((unsigned __int64)(v84 * (signed __int64)-pOutdoor->vSunlight.z) >> 16); v13 = (double)v84 * 0.000015258789; if ( v13 < 0.0 ) @@ -7315,7 +7352,7 @@ v29 = 1.0 / (double)v84; if ( v77 > 0 ) { - v30 = v3 + 112; + v30 = v3->pTextureVIDs; v31 = 0; v83 = v77; do @@ -7524,7 +7561,8 @@ v12 = v11 >> 16; if ( v22 <= pOutdoorCamera->shading_dist_mist + 2048 ) { - if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 ) + //if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v10) + 512 ) + if ( abs(v12) > *(int *)((char *)&pOutdoor->pBModels[v14].sBoundingRadius) + 512 ) { result = v12 < 0; LOBYTE(result) = v12 >= 0; @@ -9191,9 +9229,7 @@ 0, 0); ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1)); - pRenderer->DrawTerrainPolygon(uNumVertices, this, - pBitmaps_LOD->pHardwareTextures[uTileBitmapID], - 1, 1); + pRenderer->DrawTerrainPolygon(uNumVertices, this, pBitmaps_LOD->pHardwareTextures[uTileBitmapID], 1, 1); } @@ -15451,7 +15487,7 @@ v5 = abs((signed)pY); v6 = abs((signed)pX); v7 = sub_4621DA(v6, v5, v2); - v8 = pOutdoor->pBModels; + v8 = &pOutdoor->pBModels[0]; if ( v7 < 2 * pOutdoor->pBModels[v4].sBoundingRadius ) { v11 = __OFSUB__(pOutdoor->pBModels[v4].uNumFaces, v2); @@ -15508,7 +15544,7 @@ int v5; // edi@6 int v6; // eax@6 int v7; // eax@6 - BSPModel *v8; // ecx@6 + BSPModel **v8; // ecx@6 unsigned __int8 v9; // zf@7 unsigned __int8 v10; // sf@7 ODMFace *v11; // eax@9 @@ -15547,23 +15583,23 @@ { while ( 1 ) { - pX = *(int *)((char *)&pOutdoor->pBModels->vBoundingCenter.x + v4) - v1; - pY = *(int *)((char *)&pOutdoor->pBModels->vBoundingCenter.y + v4) - LODWORD(v19); + pX = *(int *)((char *)&pOutdoor->pBModels[v4].vBoundingCenter.x) - v1; + pY = *(int *)((char *)&pOutdoor->pBModels[v4].vBoundingCenter.y) - LODWORD(v19); v5 = abs((signed)pY); v6 = abs((signed)pX); v7 = sub_4621DA(v6, v5, 0); - v8 = pOutdoor->pBModels; - if ( v7 < *(int *)((char *)&pOutdoor->pBModels->sBoundingRadius + v4) ) - { - v9 = *(unsigned int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) == 0; - v10 = *(signed int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) < 0; + v8 = &pOutdoor->pBModels; + if ( v7 < *(int *)((char *)&pOutdoor->pBModels[v4].sBoundingRadius) ) + { + v9 = pOutdoor->pBModels[v4].uNumFaces == 0; + v10 = pOutdoor->pBModels[v4].uNumFaces < 0; v21 = 0; if ( !(v10 | v9) ) { v22 = 0; do { - v11 = &(*(ODMFace **)((char *)&v8->pFaces + v4))[v22 / 0x134]; + v11 = &v8[v4]->pFaces[v22 / 0x134]; v12 = v11->sCogTriggeredID; if ( v12 ) { @@ -15579,10 +15615,10 @@ } } ++v21; - v8 = pOutdoor->pBModels; + v8 = &pOutdoor->pBModels; v22 += 308; } - while ( v21 < *(signed int *)((char *)&pOutdoor->pBModels->uNumFaces + v4) ); + while ( v21 < pOutdoor->pBModels[v4].uNumFaces ); } result = v17; if ( v17 ) @@ -16206,7 +16242,7 @@ { v23 = v0->evtf; LABEL_63: - v24 = (&dword_721660)[8 * v23]; + v24 = pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; if ( !v24 ) { v24 = ""; @@ -17769,12 +17805,12 @@ { if ( _5C3420_pDecoration == (LevelDecoration *)1 ) { - ptr_F8B1E8 = (&dword_721664)[8 * v90]; + ptr_F8B1E8 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; goto LABEL_291; } if ( a3 == 1 ) { - v91 = (&dword_721664)[8 * v90]; + v91 = pNPCTopics[v90-1].pText;//(&dword_721664)[8 * v90]; LABEL_248: ShowStatusBarString(v91, 2u); goto LABEL_291; @@ -17793,7 +17829,7 @@ v92 = _evt->v5 + ((_evt->v6 + ((_evt->v7 + ((uint)_evt->v8 << 8)) << 8)) << 8); if ( _5C3420_pDecoration ) { - v93 = (&dword_721664)[8 * v92]; + v93 = (char *)pNPCTopics[v92-1].pText;//(&dword_721664)[8 * v92]; byte_5B0938[0] = 0; ptr_F8B1E8 = v93; } @@ -18328,9 +18364,9 @@ unsigned int v3; // ebx@1 unsigned int v4; // ebp@1 signed int v5; // edi@1 - char *v6; // esi@4 + Actor *v6; // esi@4 size_t v7; // ecx@10 - char *v8; // eax@11 + Actor *v8; // eax@11 unsigned __int16 v9; // dx@14 v4 = uGroupID; @@ -18342,20 +18378,20 @@ { if ( (signed int)uNumActors > Standing ) { - v6 = (char *)&pActors[0].uAttributes; + v6 = pActors;//[0].uAttributes; do { - if ( *((_DWORD *)v6 + 168) == v4 ) - { - *(_DWORD *)v6 |= v3; + if ( v6->uGroup == v4 ) + { + v6->uAttributes |= v3; if ( v3 == 0x10000 ) { - *((_WORD *)v6 + 70) = Disabled; - ((Actor *)(v6 - 36))->UpdateAnimation(); + v6->uAIState = Disabled; + v6->UpdateAnimation(); } } ++v5; - v6 += 836; + ++v6; } while ( v5 < (signed int)uNumActors ); } @@ -18365,23 +18401,23 @@ v7 = uNumActors; if ( (signed int)uNumActors > Standing ) { - v8 = (char *)&pActors[0].uAIState; + v8 = pActors;//[0].uAIState; do { - if ( *((_DWORD *)v8 + 133) == v4 ) + if ( v8->uGroup == v4 ) { if ( v3 == 0x10000 ) { - v9 = *(_WORD *)v8; - if ( *(_WORD *)v8 != Dead ) + v9 = v8->uAIState; + if ( v8->uAIState != Dead ) { if ( v9 != 4 && v9 != 11 ) - *(_WORD *)v8 = Standing; - } - } - *((_DWORD *)v8 - 35) &= ~v3; - } - v8 += 836; + v8->uAIState = Standing; + } + } + LODWORD(v8->uAttributes) &= ~v3; + } + ++v8; --v7; } while ( v7 ); @@ -19867,7 +19903,7 @@ //----- (004016FA) -------------------------------------------------------- int __cdecl BLV_4016FA_AI() { - char *v0; // esi@2 + Actor *v0; // esi@2 int v1; // eax@4 int v2; // ebx@4 unsigned int v3; // ecx@4 @@ -19891,7 +19927,7 @@ bool v21; // eax@33 int v22; // eax@34 signed int v23; // ebx@36 - char *v24; // esi@37 + Actor *v24; // esi@37 signed int v25; // eax@40 int v26; // eax@43 int v27; // ebx@45 @@ -19919,15 +19955,15 @@ v43 = 0; if ( (signed int)uNumActors > 0 ) { - v0 = (char *)&pActors[0].uAttributes; - do - { - v0[1] &= 0xFBu; - if ( ! ((Actor *)(v0 - 36))->CanAct() ) + v0 = pActors;//[0].uAttributes; + do + { + BYTE1(v0->uAttributes) &= 0xFBu; + if ( ! v0->CanAct() ) goto LABEL_60; - v39 = abs(pParty->vPosition.z - *((short *)v0 + 55)); - v38 = abs(pParty->vPosition.y - *((short *)v0 + 54)); - v1 = abs(pParty->vPosition.x - *((short *)v0 + 53)); + v39 = abs(pParty->vPosition.z - v0->vPosition.z); + v38 = abs(pParty->vPosition.y - v0->vPosition.y); + v1 = abs(pParty->vPosition.x - v0->vPosition.x); v2 = v38; v3 = v39; if ( v1 < v38 ) @@ -19949,7 +19985,7 @@ v2 = v6; } v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; - v8 = *((short *)v0 + 50); + v8 = v0->uActorRadius; v9 = v7 - v8; v40 = v7 - v8; if ( v40 < 0 ) @@ -19959,12 +19995,12 @@ } if ( v9 < 10240 ) { - v10 = *(int *)v0 & 0xFEFFFFFF; - *(int *)v0 = v10; - if ( v10 & 0x80000 || ((Actor *)(v0 - 36))->GetActorsRelation(0) ) + v10 = v0->uAttributes & 0xFEFFFFFF; + v0->uAttributes = v10; + if ( v10 & 0x80000 || v0->GetActorsRelation(0) ) { v11 = (pParty->uFlags & 0x10) == 0; - *(int *)v0 = v10 | 0x1000000; + v0->uAttributes = v10 | 0x1000000; if ( v11 && (double)v40 < 307.2 ) pParty->uFlags |= 0x10u; if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) @@ -19977,10 +20013,10 @@ else { LABEL_60: - v0[1] &= 0xBFu; + BYTE1(v0->uAttributes) &= 0xBFu; } ++v43; - v0 += 836; + ++v0; } while ( v43 < (signed int)uNumActors ); } @@ -20036,17 +20072,17 @@ ai_arrays_size = v19; if ( (signed int)uNumActors > 0 ) { - v24 = (char *)&pActors[0].uAttributes; - do - { - if ( ((Actor *)(v24 - 36))->CanAct() && *((short *)v24 + 61) == v37 ) + v24 = pActors;//[0].uAttributes; + do + { + if ( v24->CanAct() && v24->uSectorID == v37 ) { v25 = 0; if ( v19 <= 0 ) { LABEL_43: v26 = ai_arrays_size; - v24[1] |= 0x40u; + BYTE1(v24->uAttributes) |= 0x40u; ++ai_arrays_size; ai_array_4F6638_actor_ids[v26] = v23; } @@ -20061,7 +20097,7 @@ } } ++v23; - v24 += 836; + ++v24; } while ( v23 < (signed int)uNumActors ); } @@ -20122,7 +20158,7 @@ int v2; // ecx@7 int v3; // eax@7 signed int v4; // edi@10 - char *v5; // esi@12 + Actor *v5; // esi@12 signed int v6; // eax@14 __int16 v7; // cx@14 Player **v8; // esi@20 @@ -20233,14 +20269,14 @@ v84 = 0; if ( (signed int)uNumActors > 0 ) { - v5 = (char *)&pActors[0].sCurrentHP; + v5 = pActors;//[0].sCurrentHP; do { - if ( ((Actor *)(v5 - 40))->CanAct() ) - { - v6 = stru_50C198.CalcMagicalDamageToActor((Actor *)(v5 - 40), 5, v4); - v7 = *(short *)v5 - v6; - *(short *)v5 = v7; + if ( v5->CanAct() ) + { + v6 = stru_50C198.CalcMagicalDamageToActor(v5, 5, v4); + v7 = v5->sCurrentHP - v6; + v5->sCurrentHP = v7; if ( v6 ) { if ( v7 >= 0 ) @@ -20250,13 +20286,13 @@ else { Actor::Die(v84); - if ( *((int *)v5 + 19) ) - sub_4269A2_GivePartyExp(pMonsterStats->pInfos[*((short *)v5 + 28)].uExp); + if ( v5->pMonsterInfo.uExp ) + sub_4269A2_GivePartyExp(pMonsterStats->pInfos[v5->pMonsterInfo.uID].uExp); } } } ++v84; - v5 += 836; + ++v5; } while ( (signed int)v84 < (signed int)uNumActors ); }
--- a/mm7_4.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_4.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -1709,13 +1709,18 @@ //----- (00487E3B) -------------------------------------------------------- TileDesc *TileTable::GetTileById(unsigned int uTileID) { - TileDesc *result; // eax@3 + /*TileDesc *result; // eax@3 if ( (uTileID & 0x80000000u) != 0 || (signed int)uTileID > (signed int)(this->uNumTiles - 1) ) result = this->pTiles; else result = &this->pTiles[uTileID]; - return result; + return result;*/ + + if (uTileID < 0 || uTileID > this->uNumTiles - 1) + return this->pTiles; + else + return &this->pTiles[uTileID]; } //----- (00487E58) -------------------------------------------------------- @@ -5042,7 +5047,7 @@ v24 = v23; dword_A74CDC = v23; } - v11 = (char *)dword_723E80_award_related[2 * v55[v24]]; + v11 = (char *)pAwards[v55[v24]-1].pText;//(char *)dword_723E80_award_related[2 * v55[v24]]; } else { @@ -10298,7 +10303,7 @@ { v23 = v58->evtf; LABEL_33: - v15 = (&dword_721660)[8 * v23]; + v15 = (char *)pNPCTopics[v23-1].pTopic;//(&dword_721660)[8 * v23]; if ( !v15 ) { v16->uControlParam = 0; @@ -10318,7 +10323,7 @@ v20 = v19 - 1; if ( !v20 ) { - v15 = (&dword_721660)[8 * v58->evtb]; + v15 = (char *)pNPCTopics[v58->evtb-1].pTopic;//(&dword_721660)[8 * v58->evtb]; if ( !v15 ) { v16->uControlParam = 0;
--- a/mm7_5.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_5.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -12102,7 +12102,7 @@ { unsigned int *v2; // esi@1 signed int v3; // ebx@1 - char *v4; // edi@2 + Actor *v4; // edi@2 int v5; // eax@3 int v7; // [sp+8h] [bp-Ch]@1 int v8; // [sp+Ch] [bp-8h]@1 @@ -12116,21 +12116,21 @@ v9 = 0; if ( (signed int)uNumActors > 0 ) { - v4 = (char *)&pActors[0].pMonsterInfo.uID; + v4 = pActors;//[0].pMonsterInfo.uID; do { - v5 = *((int *)v4 - 15); // actor::attributes + v5 = v4->uAttributes; // actor::attributes if ( (v5 & 0x100000) == v8 ) { - if ( *(short *)v4 - 1 == v7 ) + if ( v4->pMonsterInfo.field_33 == v7 ) { ++*v2; - if ( ((Actor *)(v4 - 96))->IsAlive() == 1 ) + if ( v4->IsAlive() == 1 ) ++v9; } } ++v3; - v4 += 836; + ++v4; } while ( v3 < (signed int)uNumActors ); } @@ -12142,7 +12142,7 @@ { unsigned int *v2; // esi@1 signed int v3; // ebx@1 - char *v4; // edi@2 + Actor *v4; // edi@2 int v5; // eax@3 unsigned int v7; // [sp+8h] [bp-Ch]@1 int v8; // [sp+Ch] [bp-8h]@1 @@ -12156,21 +12156,21 @@ v9 = 0; if ( (signed int)uNumActors > 0 ) { - v4 = (char *)&pActors[0].uGroup; + v4 = pActors;//[0].uGroup; do { - v5 = *((int *)v4 - 168); + v5 = v4->uAttributes; if ( (v5 & 0x100000) == v8 ) { - if ( *(int *)v4 == v7 ) + if ( v4->uGroup == v7 ) { ++*v2; - if ( ((Actor *)(v4 - 708))->IsAlive() == 1 ) + if ( v4->IsAlive() == 1 ) ++v9; } } ++v3; - v4 += 836; + ++v4; } while ( v3 < (signed int)uNumActors ); } @@ -13539,7 +13539,7 @@ pRenderer->DrawTextureTransparent(v1, v12, v14); if ( !byte_5C6D50[dword_506528] ) { - v2 = pStru179->field_0[dword_506528]; + v2 = pStru179.field_0[dword_506528]; a1.uFrameWidth = 460; a1.uFrameX = 8; a1.uFrameY = 8; @@ -13577,7 +13577,7 @@ dword_50651C = 0; } dword_506544 = 0; - v6 = pStru179->field_0[dword_506528]; + v6 = pStru179.field_0[dword_506528]; dword_506548 = 0; dword_506520 = 0; v7 = *(&pStorylineText->field_0 + 3 * v6); @@ -13679,10 +13679,10 @@ dword_506520 = 0; while ( v3 < dword_506524 ) { - v4 = pStru179->field_0[v3]; + v4 = pStru179.field_0[v3]; ++dword_506520; - v5 = (&dword_722F10)[4 * v4]; - a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_722F10)[4 * v4], 0, 0, 0); + v5 = pQuestTable[v4-1];//(&dword_722F10)[4 * v4]; + a1.DrawText(pAutonoteFont, 1, 0, 0, pQuestTable[v4-1], 0, 0, 0);//(&dword_722F10)[4 * v4], 0, 0, 0); v6 = pAutonoteFont->CalcTextHeight(v5, &a1, 1, 0); v7 = a1.uFrameY + v6; if ( (signed int)(a1.uFrameY + v6) > (signed int)a1.uFrameHeight ) @@ -13928,15 +13928,17 @@ v8 = 0; do { - if ( dword_72371C[2 * v8] == dword_506568 ) - { - v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8]; + //if ( dword_72371C[2 * v8] == dword_506568 ) + if ( pAutonoteTxt[v8-1].eType == dword_506568 ) + { + //v32 = (&dword_723718_autonote_related)[8 * (signed __int16)v8]; + v32 = (char *)pAutonoteTxt[v8-1].pText; if ( (short)v8 ) { if ( (unsigned __int16)_449B57_test_bit(pParty->_autonote_bits, v8) && v32 ) { v9 = dword_506520++; - pStru179->field_0[v9] = (signed __int16)v8; + pStru179.field_0[v9] = (signed __int16)v8; } } } @@ -13982,10 +13984,12 @@ dword_506540 = 0; while ( v12 < dword_506524 ) { - v13 = pStru179->field_0[v12]; + v13 = pStru179.field_0[v12]; ++dword_506520; - v14 = (&dword_723718_autonote_related)[8 * v13]; - a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0); + //v14 = (&dword_723718_autonote_related)[8 * v13]; + v14 = pAutonoteTxt[v13-1].pText; + //a1.DrawText(pAutonoteFont, 1, 0, 0, (&dword_723718_autonote_related)[8 * v13], 0, 0, 0); + a1.DrawText(pAutonoteFont, 1, 0, 0, pAutonoteTxt[v13-1].pText, 0, 0, 0); v15 = pAutonoteFont->CalcTextHeight(v14, &a1, 1, 0); v16 = a1.uFrameY + v15; if ( (signed int)(a1.uFrameY + v15) > (signed int)a1.uFrameHeight ) @@ -14224,6 +14228,15 @@ a1.uFrameZ = 467; a1.uFrameW = 467; a1.DrawTitleText(pBook2Font, 0, 0x16u, 0, pGlobalTXT_LocalizationStrings[186], 3u); + if ( pParty->uCurrentHour >= 12 ) + { + if ( pParty->uCurrentHour >= 24 ) + v2=0; + else + v2=1; + } + else + v2=0; v1 = GetDayPart(); sprintf( pTmpBuf, @@ -17627,7 +17640,7 @@ unsigned __int8 v10; // of@7 stru179 *v11; // edi@9 int v12; // edx@11 - int v13; // [sp+Ch] [bp-8h]@2 + char *v13; // [sp+Ch] [bp-8h]@2 signed int v14; // [sp+Ch] [bp-8h]@9 int i; // [sp+10h] [bp-4h]@10 @@ -17643,11 +17656,11 @@ v2 = (unsigned __int8 *)pPlayer->field_152; do { - v13 = dword_723E80_award_related[2 * v1]; + v13 = (char *)pAwards[v1-1].pText;//dword_723E80_award_related[2 * v1]; if ( (unsigned __int16)_449B57_test_bit(v2, v1) && v13 ) { v3 = dword_506520++; - pStru179->field_0[v3] = v1; + pStru179.field_0[v3] = v1; } ++v1; } @@ -17667,21 +17680,22 @@ v9 = dword_506524 + v5++; v10 = v5 > dword_506524;//__OFSUB__(v5, dword_506524); v7 = v5 - dword_506524 < 0; - pStru179->field_0[v9] = v8; + pStru179.field_0[v9] = v8; } while ( v7 ^ v10 ); if ( result > 0 ) { v14 = 1; - v11 = pStru179; + v11 = &pStru179; do { for ( i = v14; i < result; ++i ) { - v12 = pStru179->field_0[i]; - if ( dword_723E84[2 * v12] < dword_723E84[2 * v11->field_0[0]] ) - { - pStru179->field_0[i] = v11->field_0[0]; + v12 = pStru179.field_0[i]; + //if ( dword_723E84[2 * v12] < dword_723E84[2 * v11->field_0[0]] ) + if(pAwards[v12-1].uSort < pAwards[v11->field_0[0]].uSort) + { + pStru179.field_0[i] = v11->field_0[0]; v11->field_0[0] = v12; } }
--- a/mm7_6.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_6.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -1296,13 +1296,13 @@ { unsigned __int64 v1; // qax@1 signed int v2; // ecx@1 - char *v3; // esi@1 + int *v3; // esi@1 bool v4; // edi@6 - char *v5; // edi@10 - char *v6; // esi@10 + int *v5; // edi@10 + Player *v6; // esi@10 int v7; // eax@13 unsigned __int8 v8; // cf@13 - char v10; // [sp+Ch] [bp-14h]@1 + int v10; // [sp+Ch] [bp-14h]@1 int v11; // [sp+1Ch] [bp-4h]@10 v1 = __PAIR__((int)((char *)&pParty + 2620), a1); @@ -1314,40 +1314,40 @@ && !*(int *)HIDWORD(v1) && !*(_QWORD *)(HIDWORD(v1) + 8) && !*(_QWORD *)(HIDWORD(v1) + 16); - *(int *)v3 = v4; + *v3 = v4; HIDWORD(v1) += 6972; v2 += v4; - v3 += 4; + ++v3; } while ( SHIDWORD(v1) < (signed int)&pParty->pHirelings[1].field_24 ); if ( v2 ) { LODWORD(v1) = (signed int)v1 / v2; v5 = &v10; - v6 = (char *)&pParty->pPlayers[0].uExperience; + v6 = pParty->pPlayers;//[0].uExperience; v11 = v1; do { - if ( *(int *)v5 ) + if ( *v5 ) { if ( v11 ) { - LOBYTE(v7) = ((Player *)(v6 - 160))->GetLearningPercent(); + LOBYTE(v7) = v6->GetLearningPercent(); v1 = v11 + v11 * v7 / 100; - v8 = __CFADD__((int)v1, *(int *)v6); - *(int *)v6 += v1; - *((int *)v6 + 1) += HIDWORD(v1) + v8; - if ( *(_QWORD *)v6 > 4000000000i64 ) + v8 = __CFADD__((int)v1, LODWORD(v6->uExperience)); + LODWORD(v6->uExperience) += v1; + HIDWORD(v6->uExperience) += HIDWORD(v1) + v8; + if ( v6->uExperience > 4000000000i64 ) { - *((int *)v6 + 1) = 0; - *(int *)v6 = -294967296; + HIDWORD(v6->uExperience) = 0; + LODWORD(v6->uExperience) = -294967296; } } } - v6 += 6972; - v5 += 4; + ++v6; + ++v5; } - while ( (signed int)v6 < (signed int)&pParty->pPickedItem._bonus_strength ); + while ( v6 <= &pParty->pPlayers[3] ); } return v1; } @@ -7476,7 +7476,7 @@ if ( *(int *)v605 != v1 ) { v606 = HIDWORD(v733)++; - pStru179->field_0[v606] = (int)((char *)&_this->uItemID + 1); + pStru179.field_0[v606] = (int)((char *)&_this->uItemID + 1); } _this = (ItemGen *)((char *)_this + 1); v605 += 76; @@ -8292,7 +8292,7 @@ signed int __cdecl sub_42F4DA() { signed int v0; // edi@1 - char *v1; // esi@4 + Actor *v1; // esi@4 int v2; // ebx@5 int v3; // eax@5 int v4; // ebx@5 @@ -8317,12 +8317,12 @@ } else { - v1 = (char *)&pActors[0].uAIState; + v1 = pActors; while ( 1 ) { - v2 = abs(*((short *)v1 - 17) - pParty->vPosition.x); - v11 = abs(*((short *)v1 - 16) - pParty->vPosition.y); - v12 = abs(*((short *)v1 - 15) - pParty->vPosition.z); + v2 = abs(v1->vInitialPosition.x - pParty->vPosition.x); + v11 = abs(v1->vInitialPosition.y - pParty->vPosition.y); + v12 = abs(v1->vInitialPosition.z - pParty->vPosition.z); v3 = v2; v4 = v11; v5 = v12; @@ -8346,19 +8346,19 @@ } if ( (signed int)(((unsigned int)(11 * v4) >> 5) + (v5 >> 2) + v3) < v0 ) { - v9 = *(short *)v1; - if ( *(short *)v1 != 5 ) + v9 = v1->uAIState; + if ( v1->uAIState != 5 ) { if ( v9 != 4 && v9 != 11 && v9 != 19 && v9 != 17 - && (*(v1 - 138) & 8 || ((Actor *)nullptr)->GetActorsRelation( (Actor *)(v1 - 176))) ) + && (BYTE2(v1->uAttributes) & 8 || ((Actor *)nullptr)->GetActorsRelation( v1)) ) break; } } ++v13; - v1 += 836; + ++v1; if ( v13 >= (signed int)uNumActors ) goto LABEL_20; } @@ -8671,33 +8671,35 @@ } //----- (0042FA22) -------------------------------------------------------- -char *__cdecl sub_42FA22_mess_with_laying_item_list() +LayingItem *__cdecl sub_42FA22_mess_with_laying_item_list() { size_t v0; // edx@1 int v1; // ebp@1 - char *result; // eax@1 - void *v3; // ebx@1 + LayingItem *result; // eax@1 + LayingItem *v3; // ebx@1 v0 = 0; v1 = 0; - result = (char *)&pLayingItems[0].uObjectDescID; + //result = (char *)&pLayingItems[0].uObjectDescID; + result = pLayingItems; v3 = pLayingItems; do { - if ( *(short *)result ) + if ( result->uObjectDescID ) { if ( v1 != v0 ) { - memcpy(v3, result - 2, 0x70u); - *(short *)result = 0; + memcpy(v3, result, 0x70u); + result->uObjectDescID = 0; } ++v0; - v3 = (char *)v3 + 112; + ++v3;// = (char *)v3 + 112; } - result += 112; + ++result;// += 112; ++v1; } - while ( (signed int)result < (signed int)((char *)&pObjectList->uNumObjects + 2) ); + //while ( (signed int)result < (signed int)((char *)&pObjectList->uNumObjects + 2) ); + while( result <= &pLayingItems[999] ); uNumLayingItems = v0; return result; }
--- a/mm7_data.cpp Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_data.cpp Tue Feb 05 19:08:52 2013 +0600 @@ -55,7 +55,7 @@ stru157 a3; // idb #include "stru179.h" -stru179 *pStru179; +stru179 pStru179; #include "stru123.h" stru123 stru_5E4C90;
--- a/mm7_data.h Tue Feb 05 19:08:22 2013 +0600 +++ b/mm7_data.h Tue Feb 05 19:08:52 2013 +0600 @@ -1,7 +1,7 @@ #pragma once #include <string> #include "OSAPI.h" - +#include "LayingItem.h" #include "VectorTypes.h" typedef char _UNKNOWN; @@ -1940,7 +1940,7 @@ signed int __cdecl sub_42F4DA(); bool __fastcall sub_42F7EB_DropItemAt(unsigned int uSpriteID, int x, int y, int z, int a4, int count, int a7, unsigned __int16 attributes, ItemGen *a9); void __fastcall sub_42F960_create_object(int x, int y, int z); // idb -char *__cdecl sub_42FA22_mess_with_laying_item_list(); +LayingItem *__cdecl sub_42FA22_mess_with_laying_item_list(); signed int __fastcall _42FA66_do_explosive_impact(int a1, int a2, int a3, int a4, __int16 a5, signed int a6); bool __fastcall sub_42FB5C(signed int a1); // int __cdecl crt_sub_42FBB7();