Mercurial > mm7
diff mm7_3.cpp @ 79:6ad816231528
structure fixes, death crash fix
author | zipi |
---|---|
date | Sat, 02 Feb 2013 16:52:36 +0000 |
parents | 6ef241d53522 |
children | 377535d6e366 |
line wrap: on
line diff
--- a/mm7_3.cpp Tue Jan 29 07:51:31 2013 +0600 +++ b/mm7_3.cpp Sat Feb 02 16:52:36 2013 +0000 @@ -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; @@ -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; @@ -15451,7 +15489,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 +15546,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 +15585,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 +15617,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 )