# HG changeset patch # User Ritor1 # Date 1361858514 -21600 # Node ID 89f6107c3362ad0393c18b4a87f52a77b29bd273 # Parent d4ea2d382004c6e59c52d2ac567524916f8bc052# Parent 77430756f06aef455254f0178cbe6aeb4391cfe1 Слияние diff -r d4ea2d382004 -r 89f6107c3362 GUIWindow.cpp --- a/GUIWindow.cpp Tue Feb 26 12:00:57 2013 +0600 +++ b/GUIWindow.cpp Tue Feb 26 12:01:54 2013 +0600 @@ -1070,7 +1070,7 @@ v18.uFrameZ += 8; if ( !pDialogueNPCCount ) { - if ( dword_F8B198 == 31 ) + if ( in_current_bilding_type == 31 ) { sub_4B4F4F(); goto LABEL_58; @@ -1151,9 +1151,9 @@ //p2DEvents_minus1__10[13 * (unsigned int)ptr_507BC0->ptr_1C]); p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].pProprieterTitle); v18.DrawTitleText(pFontCreate, 0x1E3u, 0x71u, v19, pTmpBuf, 3u); - if ( dword_F8B198 <= 18 ) + if ( in_current_bilding_type <= 18 ) { - switch ( dword_F8B198 ) + switch ( in_current_bilding_type ) { case 18: sub_4B6478(); @@ -1171,15 +1171,15 @@ AlchemistDialog(); break; default: - if ( dword_F8B198 > 4 ) + if ( in_current_bilding_type > 4 ) { - if ( dword_F8B198 <= 16 ) + if ( in_current_bilding_type <= 16 ) { GuildDialog(); } else { - if ( dword_F8B198 == 17 ) + if ( in_current_bilding_type == 17 ) sub_4B7911(); } } @@ -1187,7 +1187,7 @@ } goto LABEL_58; } - switch ( dword_F8B198 ) + switch ( in_current_bilding_type ) { case 21: TavernDialog(); @@ -1199,17 +1199,17 @@ TampleDialog(); break; default: - if ( dword_F8B198 <= 26 ) + if ( in_current_bilding_type <= 26 ) break; - if ( dword_F8B198 <= 28 ) + if ( in_current_bilding_type <= 28 ) { TravelByTransport(); } else { - if ( dword_F8B198 != 30 ) + if ( in_current_bilding_type != 30 ) { - if ( dword_F8B198 != 31 ) + if ( in_current_bilding_type != 31 ) break; sub_4B4F4F(); goto LABEL_58; diff -r d4ea2d382004 -r 89f6107c3362 Indoor.cpp --- a/Indoor.cpp Tue Feb 26 12:00:57 2013 +0600 +++ b/Indoor.cpp Tue Feb 26 12:01:54 2013 +0600 @@ -3482,40 +3482,40 @@ //----- (0046F228) -------------------------------------------------------- void __cdecl BLV_UpdateDoors() { - int v0; // ebx@1 - int v1; // edi@1 - BLVDoor *v2; // esi@3 - unsigned __int16 v3; // ax@3 - unsigned int v4; // ecx@5 - int v5; // eax@8 - int v6; // ecx@8 - int v7; // eax@12 - int v8; // eax@16 - unsigned __int8 v9; // zf@18 - char v10; // sf@18 - unsigned __int8 v11; // of@18 - int v12; // edi@19 - int v13; // ecx@19 - __int16 v14; // ax@19 + //int v0; // ebx@1 + //int v1; // edi@1 + //BLVDoor *v2; // esi@3 + //unsigned __int16 v3; // ax@3 + //unsigned int v4; // ecx@5 + //int v5; // eax@8 + //int v6; // ecx@8 + //int v7; // eax@12 + //int v8; // eax@16 + //unsigned __int8 v9; // zf@18 + //char v10; // sf@18 + //unsigned __int8 v11; // of@18 + //int v12; // edi@19 + //int v13; // ecx@19 + //__int16 v14; // ax@19 BLVFace *v15; // ebx@24 - unsigned __int16 *v16; // ecx@24 + //unsigned __int16 *v16; // ecx@24 Vec3_short_ *v17; // esi@24 int v18; // eax@24 int v19; // edx@24 signed int v20; // eax@24 - Vec3_short_ *v21; // ecx@24 - double v22; // st7@24 - double v23; // st6@24 + //Vec3_short_ *v21; // ecx@24 + //double v22; // st7@24 + //double v23; // st6@24 int v24; // esi@25 int v25; // eax@25 - BLVDoor *v26; // edi@25 + //BLVDoor *v26; // edi@25 signed __int64 v27; // qtt@27 BLVFaceExtra *v28; // esi@32 int v29; // ecx@34 int v30; // edx@34 unsigned __int64 v31; // qax@34 int v32; // eax@34 - unsigned __int16 *v33; // eax@35 + //unsigned __int16 *v33; // eax@35 Vec3_short_ *v34; // eax@35 int v35; // ecx@35 int v36; // edx@35 @@ -3523,291 +3523,298 @@ signed int v38; // edx@35 int v39; // eax@35 int v40; // edx@35 - unsigned __int8 v41; // cf@35 - unsigned __int16 *v42; // edi@36 + //unsigned __int8 v41; // cf@35 + //unsigned __int16 *v42; // edi@36 Vec3_short_ *v43; // edi@36 - int v44; // ecx@36 - int v45; // edi@36 - int v46; // ecx@36 - __int16 *v47; // edx@44 - int v48; // ecx@44 + //int v44; // ecx@36 + //int v45; // edi@36 + //int v46; // ecx@36 + //__int16 *v47; // edx@44 + //int v48; // ecx@44 unsigned int v49; // ecx@46 unsigned __int16 v50; // ax@48 unsigned int v51; // eax@51 unsigned __int16 v52; // ax@54 int v53; // ecx@57 - int v54; // edx@57 + //int v54; // edx@57 unsigned __int64 v55; // qax@57 int v56; // ecx@58 int v57; // eax@58 - int v58; // eax@59 - SoundID v59; // [sp-24h] [bp-88h]@12 - signed int v60; // [sp-20h] [bp-84h]@12 - unsigned int v61; // [sp-1Ch] [bp-80h]@12 - signed int v62; // [sp-18h] [bp-7Ch]@12 - signed int v63; // [sp-14h] [bp-78h]@12 - int v64; // [sp-10h] [bp-74h]@12 - unsigned int v65; // [sp-Ch] [bp-70h]@12 - int v66; // [sp-8h] [bp-6Ch]@12 - int v67; // [sp+8h] [bp-5Ch]@31 - int v68; // [sp+Ch] [bp-58h]@34 - int v69; // [sp+10h] [bp-54h]@34 - int v70; // [sp+14h] [bp-50h]@31 - int v71; // [sp+18h] [bp-4Ch]@34 - int v72; // [sp+1Ch] [bp-48h]@34 + //int v58; // eax@59 + //SoundID v59; // [sp-24h] [bp-88h]@12 + //signed int v60; // [sp-20h] [bp-84h]@12 + //unsigned int v61; // [sp-1Ch] [bp-80h]@12 + //signed int v62; // [sp-18h] [bp-7Ch]@12 + //signed int v63; // [sp-14h] [bp-78h]@12 + //int v64; // [sp-10h] [bp-74h]@12 + //unsigned int v65; // [sp-Ch] [bp-70h]@12 + //int v66; // [sp-8h] [bp-6Ch]@12 + Vec3_int_ v67; + //int v67; // [sp+8h] [bp-5Ch]@31 + //int v68; // [sp+Ch] [bp-58h]@34 + //int v69; // [sp+10h] [bp-54h]@34 + Vec3_int_ v70; + //int v70; // [sp+14h] [bp-50h]@31 + //int v71; // [sp+18h] [bp-4Ch]@34 + //int v72; // [sp+1Ch] [bp-48h]@34 int v73; // [sp+20h] [bp-44h]@24 - __int16 v74; // [sp+24h] [bp-40h]@24 + //__int16 v74; // [sp+24h] [bp-40h]@24 int v75; // [sp+28h] [bp-3Ch]@36 int v76; // [sp+2Ch] [bp-38h]@36 int v77; // [sp+30h] [bp-34h]@36 - int v78; // [sp+34h] [bp-30h]@36 - int v79; // [sp+38h] [bp-2Ch]@19 - unsigned int v80; // [sp+3Ch] [bp-28h]@2 - int v81; // [sp+40h] [bp-24h]@1 + //int v78; // [sp+34h] [bp-30h]@36 + //int v79; // [sp+38h] [bp-2Ch]@19 + //unsigned int v80; // [sp+3Ch] [bp-28h]@2 + //int v81; // [sp+40h] [bp-24h]@1 int v82; // [sp+44h] [bp-20h]@35 int v83; // [sp+48h] [bp-1Ch]@34 int v84; // [sp+4Ch] [bp-18h]@34 int v85; // [sp+50h] [bp-14h]@19 SoundID eDoorSoundID; // [sp+54h] [bp-10h]@1 - BLVDoor *v87; // [sp+58h] [bp-Ch]@3 + //BLVDoor *v87; // [sp+58h] [bp-Ch]@3 int v88; // [sp+5Ch] [bp-8h]@18 int v89; // [sp+60h] [bp-4h]@6 - v0 = 0; - v1 = 0; + //v0 = 0; + //v1 = 0; eDoorSoundID = (SoundID)pDoorSoundIDsByLocationID[dword_6BE13C_uCurrentlyLoadedLocationID]; - v81 = 0; - if ( pIndoor->uNumDoors > 0 ) + //v81 = 0; + //if ( pIndoor->uNumDoors > 0 ) + for (uint i = 0; i < pIndoor->uNumDoors; ++i) { - v80 = 0; - do - { - v2 = &pIndoor->pDoors[v80 / 0x50]; - v87 = &pIndoor->pDoors[v80 / 0x50]; - v3 = pIndoor->pDoors[v80 / 0x50].uState; - if ( v3 == (short)v0 || v3 == 2 ) + auto door = pIndoor->pDoors + i; + //v80 = 0; + //do + //{ + //v2 = &pIndoor->pDoors[v80 / 0x50]; + //v87 = &pIndoor->pDoors[v80 / 0x50]; + //v3 = door->uState; + if (door->uState == BLVDoor::Closed || door->uState == BLVDoor::Open) { - v2->uAttributes &= 0xFFFFFFFDu; + door->uAttributes &= 0xFFFFFFFDu; goto LABEL_62; } - v2->uTimeSinceTriggered += pEventTimer->uTimeElapsed; - v4 = v2->uTimeSinceTriggered; - if ( v2->uState == 1 ) + door->uTimeSinceTriggered += pEventTimer->uTimeElapsed; + //v4 = door->uTimeSinceTriggered; + if (door->uState == BLVDoor::Opening) { - v89 = (signed int)(v4 * v2->uCloseSpeed) / 128; - if ( v89 >= v2->uMoveLength ) + v89 = (signed int)(door->uTimeSinceTriggered * door->uCloseSpeed) / 128; + if ( v89 >= door->uMoveLength ) { - v89 = v2->uMoveLength; - v2->uState = BLVDoor::Open; + v89 = door->uMoveLength; + door->uState = BLVDoor::Open; LABEL_10: - if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 ) + if ( !(door->uAttributes & 6) && door->uNumVertices != 0) { - v66 = v0; - v65 = v0; - v64 = v0; - v7 = 8 * v1; - v63 = v0; - v62 = -1; - LOBYTE(v7) = 8 * v1 | 1; - v61 = v0; - v60 = v7; - v59 = (SoundID)((int)eDoorSoundID + 1); -LABEL_17: - pAudioPlayer->PlaySound(v59, v60, v61, v62, v63, v64, v65, v66); - goto LABEL_18; + //v66 = 0; + //v65 = 0; + //v64 = 0; + //v7 = 8 * i | OBJECT_BLVDoor; + //v63 = 0; + //v62 = -1; + //LOBYTE(v7) = 8 * i | OBJECT_BLVDoor; + //v61 = 0; + //v60 = 8 * i | OBJECT_BLVDoor; + //v59 = (SoundID)((int)eDoorSoundID + 1); +//LABEL_17: + pAudioPlayer->PlaySound((SoundID)((int)eDoorSoundID + 1), 8 * i | OBJECT_BLVDoor, 0, -1, 0, 0, 0, 0); + //goto LABEL_18; } goto LABEL_18; } } else { - v5 = (signed int)(v4 * v2->uOpenSpeed) / 128; - v6 = v2->uMoveLength; - if ( v5 >= v6 ) + auto v5 = (signed int)(door->uTimeSinceTriggered * door->uOpenSpeed) / 128; + //v6 = door->uMoveLength; + if ( v5 >= door->uMoveLength) { - v89 = v0; - v2->uState = (BLVDoor::State)v0; + v89 = 0; + door->uState = BLVDoor::Closed; goto LABEL_10; } - v89 = v6 - v5; + v89 = door->uMoveLength - v5; } - if ( !(v2->uAttributes & 6) && v2->uNumVertices != (short)v0 ) + if ( !(door->uAttributes & 6) && door->uNumVertices) { - v66 = v0; - v65 = v0; - v64 = v0; - v8 = 8 * v1; - v63 = v0; - v62 = -1; - LOBYTE(v8) = 8 * v1 | 1; - v61 = 1; - v60 = v8; - v59 = eDoorSoundID; - goto LABEL_17; + //v66 = 0; + //v65 = 0; + //v64 = 0; + //v8 = 8 * i | OBJECT_BLVDoor; + //v63 = 0; + //v62 = -1; + //LOBYTE(v8) = 8 * v1 | 1; + //v61 = 1; + //v60 = 8 * i | OBJECT_BLVDoor; + //v59 = eDoorSoundID; + pAudioPlayer->PlaySound(eDoorSoundID, 8 * i | OBJECT_BLVDoor, 1, -1, 0, 0, 0, 0); + //goto LABEL_18; } LABEL_18: - v11 = __OFSUB__(v2->uNumVertices, (short)v0); - v9 = v2->uNumVertices == (short)v0; - v10 = (signed __int16)(v2->uNumVertices - v0) < 0; - v88 = v0; - if ( !((unsigned __int8)(v10 ^ v11) | v9) ) + //v11 = __OFSUB__(v2->uNumVertices, 0); + //v9 = v2->uNumVertices == 0; + //v10 = (signed __int16)(v2->uNumVertices - 0) < 0; + //v88 = 0; + //if (door->uNumVertices > 0) + for (uint j = 0; j < door->uNumVertices; ++j) { - do - { - v12 = v88; - v13 = v2->pVertexIDs[v88]; - v85 = v89; - v79 = v2->vDirection.x; - v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; - v13 *= 6; - *(__int16 *)((char *)&pIndoor->pVertices->x + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pXOffsets[v88]; - v85 = v89; - v79 = v2->vDirection.y; - v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; - *(__int16 *)((char *)&pIndoor->pVertices->y + v13) = ((unsigned int)(v79 * v89) >> 16) + v2->pYOffsets[v12]; - v85 = v89; - v79 = v2->vDirection.z; - v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; - v14 = ((unsigned int)(v79 * v89) >> 16) + v2->pZOffsets[v12]; - ++v88; - *(__int16 *)((char *)&pIndoor->pVertices->z + v13) = v14; - } - while ( v88 < v2->uNumVertices ); - v1 = v81; + //do + //{ + //v12 = v88; + //v13 = door->pVertexIDs[v88]; + //v85 = v89; + //v79 = door->vDirection.x; + //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; + //v13 *= 6; + pIndoor->pVertices[door->pVertexIDs[j]].x = ((unsigned int)(door->vDirection.x * v89) >> 16) + door->pXOffsets[j]; + //v85 = v89; + //v79 = door->vDirection.y; + //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; + pIndoor->pVertices[door->pVertexIDs[j]].y = ((unsigned int)(door->vDirection.y * v89) >> 16) + door->pYOffsets[j]; + //v85 = v89; + //v79 = door->vDirection.z; + //v85 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; + //v14 = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; + pIndoor->pVertices[door->pVertexIDs[j]].z = ((unsigned int)(door->vDirection.z * v89) >> 16) + door->pZOffsets[j]; + //++v88; + //} + //while ( v88 < door->uNumVertices ); + //v1 = v81; } - v11 = __OFSUB__(v2->uNumFaces, (short)v0); - v9 = v2->uNumFaces == (short)v0; - v10 = (signed __int16)(v2->uNumFaces - v0) < 0; - v88 = v0; - if ( !((unsigned __int8)(v10 ^ v11) | v9) ) + //v11 = __OFSUB__(v2->uNumFaces, 0); + //v9 = v2->uNumFaces == 0; + //v10 = (signed __int16)(v2->uNumFaces - 0) < 0; + v88 = 0; + if (door->uNumFaces > 0) { while ( 1 ) { - v15 = &pIndoor->pFaces[v2->pFaceIDs[v88]]; - v16 = v15->pVertexIDs; - v17 = &pIndoor->pVertices[*v16]; + v15 = &pIndoor->pFaces[door->pFaceIDs[v88]]; + //v16 = v15->pVertexIDs; + v17 = &pIndoor->pVertices[v15->pVertexIDs[0]]; v18 = v15->pFacePlane_old.vNormal.y; v73 = *(int *)&v17->x; - v74 = v17->z; + //v74 = v17->z; v19 = v15->pFacePlane_old.vNormal.z; - v20 = -(v19 * v74 + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18); + v20 = -(v19 * (int)v17->z + (signed __int16)v73 * v15->pFacePlane_old.vNormal.x + SHIWORD(v73) * v18); v15->pFacePlane_old.dist = v20; - v21 = &pIndoor->pVertices[*v16]; - v79 = v21->x; - v22 = (double)v79; - v23 = (double)v21->y; - v79 = v21->z; - v15->pFacePlane.dist = -((double)v79 * v15->pFacePlane.vNormal.z - + v23 * v15->pFacePlane.vNormal.y - + v22 * v15->pFacePlane.vNormal.x); + //v21 = &pIndoor->pVertices[v15->pVertexIDs[0]]; + //v79 = v21->x; + //v22 = (double)v21->x; + //v23 = (double)v21->y; + //v79 = v21->z; + v15->pFacePlane.dist = -((double)v17->z * v15->pFacePlane.vNormal.z + + (double)v17->y * v15->pFacePlane.vNormal.y + + (double)v17->x * v15->pFacePlane.vNormal.x); if ( v19 ) { v24 = abs(v20 >> 15); v25 = abs(v15->pFacePlane_old.vNormal.z); - v26 = v87; + //v26 = v87; if ( v24 > v25 ) Abortf( "Door Error\ndoor id: %i\nfacet no: %i\n\nOverflow dividing facet->d [%i] by facet->nz [%i]", - v87->uDoorID, - v87->pFaceIDs[v88], + door->uDoorID, + door->pFaceIDs[v88], v15->pFacePlane_old.dist, v15->pFacePlane_old.vNormal.z); - v79 = v15->pFacePlane_old.vNormal.z; - v85 = v15->pFacePlane_old.dist; - LODWORD(v27) = v85 << 16; - HIDWORD(v27) = v85 >> 16; - v85 = v27 / v79; - v15->zCalc3 = -(v27 / v79); + //v79 = v15->pFacePlane_old.vNormal.z; + //v85 = v15->pFacePlane_old.dist; + LODWORD(v27) = v15->pFacePlane_old.dist << 16; + HIDWORD(v27) = v15->pFacePlane_old.dist >> 16; + //v85 = v27 / v15->pFacePlane_old.vNormal.z; + v15->zCalc3 = -v27 / v15->pFacePlane_old.vNormal.z; } - else + /*else { v26 = v87; - } + }*/ if ( BYTE2(v15->uAttributes) & 4 || pRenderer->pRenderD3D ) - v15->_get_normals((Vec3_int_ *)&v70, (Vec3_int_ *)&v67); + v15->_get_normals(&v70, &v67); v28 = &pIndoor->pFaceExtras[v15->uFaceExtraID]; if ( !pRenderer->pRenderD3D ) { if ( !(BYTE2(v15->uAttributes) & 4) ) goto LABEL_59; - v79 = v26->vDirection.x; - v83 = (unsigned __int64)(v79 * (signed __int64)v70) >> 16; - v85 = v71; - v79 = v26->vDirection.y; - v85 = (unsigned __int64)(v79 * (signed __int64)v71) >> 16; - v84 = v72; - v79 = v26->vDirection.z; - v84 = (unsigned __int64)(v79 * (signed __int64)v72) >> 16; - v79 = v83 + v85 + ((unsigned __int64)(v79 * (signed __int64)v72) >> 16); + //v79 = door->vDirection.x; + v83 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; + //v85 = v71; + //v79 = door->vDirection.y; + v85 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; + //v84 = v72; + //v79 = door->vDirection.z; + v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; + //v79 = v83 + v85 + v84; v29 = v89; - v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; - v28->sTextureDeltaU = -((unsigned int)(v79 * v89) >> 16); - v79 = v26->vDirection.x; - v85 = (unsigned __int64)(v79 * (signed __int64)v67) >> 16; - v83 = v68; - v79 = v26->vDirection.y; - v83 = (unsigned __int64)(v79 * (signed __int64)v68) >> 16; - v84 = v69; - v79 = v26->vDirection.z; - v84 = (unsigned __int64)(v79 * (signed __int64)v69) >> 16; - v30 = v83 + ((unsigned __int64)(v79 * (signed __int64)v69) >> 16); - v79 = v85 + v30; - v31 = (v85 + v30) * (signed __int64)v29; - v83 = v31 >> 16; + //v83 = (unsigned __int64)(v79 * (signed __int64)v89) >> 16; + v28->sTextureDeltaU = -((v83 + v85 + v84) * (signed __int64)v89) >> 16; + //v79 = door->vDirection.x; + v85 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; + //v83 = v68; + //v79 = door->vDirection.y; + v83 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; + //v84 = v69; + //v79 = door->vDirection.z; + v84 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; + //v30 = v83 + v84; + //v79 = v85 + v30; + v31 = (v85 + v83 + v84) * (signed __int64)v29; + //v83 = v31 >> 16; v32 = v31 >> 16; goto LABEL_58; } v28->sTextureDeltaU = 0; v28->sTextureDeltaV = 0; - v33 = v15->pVertexIDs; - v85 = 1; - v34 = &pIndoor->pVertices[*v33]; + //v33 = v15->pVertexIDs; + //v85 = 1; + v34 = &pIndoor->pVertices[v15->pVertexIDs[0]]; v35 = v34->z; v36 = v34->y; v82 = v34->x; - v79 = v36; - v37 = v70 * v82 + v71 * v36 + v72 * v35; - v38 = v67 * v82 + v68 * v36 + v35 * v69; + //v79 = v36; + v37 = v70.x * v82 + v70.y * v36 + v70.z * v35; + v38 = v67.x * v82 + v67.y * v36 + v67.z * v35; v39 = v37 >> 16; *v15->pVertexUIDs = v39; v40 = v38 >> 16; *v15->pVertexVIDs = v40; - v41 = v15->uNumVertices < 1u; - v9 = v15->uNumVertices == 1; - v83 = v40; + //v41 = v15->uNumVertices < 1u; + //v9 = v15->uNumVertices == 1; + //v83 = v40; v84 = v39; v82 = v40; - if ( !(v41 | v9) ) + //if (v15->uNumVertices > 1) + for (uint j = 1; j < v15->uNumVertices; ++j) { - do - { - v42 = v15->pVertexIDs; - v75 = 2 * v85; - v43 = &pIndoor->pVertices[v42[v85]]; - v79 = v43->z; - v44 = v43->y; - v45 = v43->x; - v78 = v44; - v76 = (v72 * v79 + v70 * v45 + v71 * v44) >> 16; - v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16; - v77 = v46; + //do + //{ + //v42 = v15->pVertexIDs; + //v75 = 2 * v85; + v43 = &pIndoor->pVertices[v15->pVertexIDs[j]]; + //v79 = v43->z; + //v44 = v43->y; + //v45 = v43->x; + //v78 = v43->y; + v76 = ((__int64)v70.z * v43->z + (__int64)v70.x * v43->x + (__int64)v70.y * v43->y) >> 16; + //v46 = (v67 * v45 + v68 * v44 + v79 * v69) >> 16; + v77 = ((__int64)v67.x * v43->x + (__int64)v67.y * v43->y + (__int64)v43->z * v67.z) >> 16; if ( v76 < v39 ) v39 = v76; - if ( v46 < v40 ) - v83 = v46; + if ( v77 < v40 ) + v40 = v77; if ( v76 > v84 ) v84 = v76; - if ( v46 > v82 ) - v82 = v46; - v47 = v15->pVertexUIDs; - v48 = v75; - ++v85; - *(unsigned __int16 *)((char *)v47 + v75) = v76; - *(unsigned __int16 *)((char *)v15->pVertexVIDs + v48) = v77; - v40 = v83; - } - while ( v85 < v15->uNumVertices ); - v26 = v87; + if ( v77 > v82 ) + v82 = v77; + //v40 = v83; + //v47 = v15->pVertexUIDs; + //v48 = v75; + //++v85; + v15->pVertexUIDs[j] = v76; + v15->pVertexVIDs[j] = v77; + //} + //while ( v85 < v15->uNumVertices ); + //v26 = v87; } v49 = v15->uAttributes; if ( BYTE1(v49) & 0x10 ) @@ -3836,61 +3843,61 @@ } if ( BYTE2(v15->uAttributes) & 4 ) { - v75 = v26->vDirection.x; - v84 = (unsigned __int64)(v75 * (signed __int64)v70) >> 16; - v82 = v71; - v75 = v26->vDirection.y; - v82 = (unsigned __int64)(v75 * (signed __int64)v71) >> 16; - v83 = v72; - v75 = v26->vDirection.z; - v83 = (unsigned __int64)(v75 * (signed __int64)v72) >> 16; - v75 = v84 + v82 + ((unsigned __int64)(v75 * (signed __int64)v72) >> 16); + //v75 = door->vDirection.x; + v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v70.x) >> 16; + //v82 = v71; + //v75 = door->vDirection.y; + v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v70.y) >> 16; + //v83 = v72; + //v75 = door->vDirection.z; + v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v70.z) >> 16; + v75 = v84 + v82 + v83; v53 = v89; v82 = (unsigned __int64)(v75 * (signed __int64)v89) >> 16; - v28->sTextureDeltaU = -((unsigned int)(v75 * v89) >> 16); - v75 = v26->vDirection.x; - v84 = (unsigned __int64)(v75 * (signed __int64)v67) >> 16; - v82 = v68; - v75 = v26->vDirection.y; - v82 = (unsigned __int64)(v75 * (signed __int64)v68) >> 16; - v83 = v69; - v75 = v26->vDirection.z; - v83 = (unsigned __int64)(v75 * (signed __int64)v69) >> 16; - v54 = v82 + ((unsigned __int64)(v75 * (signed __int64)v69) >> 16); - v75 = v84 + v54; - v55 = (v84 + v54) * (signed __int64)v53; - v82 = v55 >> 16; + v28->sTextureDeltaU = -v82; + //v75 = door->vDirection.x; + v84 = (unsigned __int64)(door->vDirection.x * (signed __int64)v67.x) >> 16; + //v82 = v68; + //v75 = door->vDirection.y; + v82 = (unsigned __int64)(door->vDirection.y * (signed __int64)v67.y) >> 16; + //v83 = v69; + //v75 = door->vDirection.z; + v83 = (unsigned __int64)(door->vDirection.z * (signed __int64)v67.z) >> 16; + //v54 = v82 + v83; + v75 = v84 + v82 + v83; + v55 = v75 * (signed __int64)v53; + //v82 = v55 >> 16; v32 = v55 >> 16; LABEL_58: v56 = v88; v57 = -v32; v28->sTextureDeltaV = v57; - v28->sTextureDeltaU += v26->pDeltaUs[v56]; - v28->sTextureDeltaV = v57 + v26->pDeltaVs[v56]; + v28->sTextureDeltaU += door->pDeltaUs[v56]; + v28->sTextureDeltaV = v57 + door->pDeltaVs[v56]; } LABEL_59: - v58 = v26->uNumFaces; + //v58 = door->uNumFaces; ++v88; - if ( v88 >= v58 ) + if ( v88 >= door->uNumFaces) { - v1 = v81; - v0 = 0; + //v1 = v81; + //v0 = 0; goto LABEL_62; } - v2 = v87; + //v2 = v87; } - LOWORD(v39) = v84 - + ((signed __int16)v39 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v39].uTextureWidth : 24); + LOWORD(v39) = v84 + ((signed __int16)v39 != -1 ? pBitmaps_LOD->pTextures[(signed __int16)v39].uTextureWidth : 24); LABEL_50: v28->sTextureDeltaU -= v39; goto LABEL_51; } LABEL_62: - v80 += 80; - ++v1; - v81 = v1; - } - while ( v1 < pIndoor->uNumDoors ); + ; + //v80 += 80; + //++v1; + //v81 = v1; + //} + //while ( v1 < pIndoor->uNumDoors ); } } // 6BE13C: using guessed type int dword_6BE13C_uCurrentlyLoadedLocationID; diff -r d4ea2d382004 -r 89f6107c3362 Items.cpp --- a/Items.cpp Tue Feb 26 12:00:57 2013 +0600 +++ b/Items.cpp Tue Feb 26 12:01:54 2013 +0600 @@ -130,6 +130,7 @@ unsigned __int16 shopMagicSpc_treasure_lvl[14] = {0, 2, 2, 3, 3, 5, 5, 4, 3, 3, 3, 3, 3, 3}; unsigned __int16 shopAlchSpc_treasure_lvl[13] = {0, 2, 2, 3, 3, 4, 4, 5, 5, 3, 2, 2, 2}; +int sub_4BE571(int a1, int *a2, int a3, int a4); ItemGen *ptr_50C9A4; @@ -2243,383 +2244,166 @@ // 4505CC: using guessed type int var_A0[32]; //----- (004B3703) -------------------------------------------------------- - int sub_4B3703( int _this ) +void FillAviableSkillsToTeach( int _this ) + { + char *v30; // ecx@65 + unsigned int v29; // edx@56 + int v15; // ecx@19 + int v33; // [sp-4h] [bp-2Ch]@23 + int v34; // [sp-4h] [bp-2Ch]@43 + int v21; // ecx@34 + int v35[5]; // [sp+Ch] [bp-1Ch]@8 + int v37=0; // [sp+24h] [bp-4h]@1* + int i=0; + + dword_F8B1DC = 0; + + switch (_this) { - signed int v1; // edi@1 - int v2; // eax@1 - int v3; // ecx@1 - signed int v4; // ebx@1 - int v5; // ecx@2 - int v6; // ecx@3 - int v7; // ecx@4 - int v8; // ecx@5 - int v9; // ecx@6 - signed int v10; // ebx@13 - signed int v11; // edi@14 - signed int v12; // esi@15 - unsigned int v13; // ecx@16 - int v14; // ecx@16 - int v15; // ecx@17 - int v16; // ecx@19 - int v17; // ecx@20 - int v18; // ecx@21 - signed int v19; // esi@32 - char *v20; // ecx@33 - int v21; // ecx@34 - int v22; // ecx@36 - int v23; // ecx@37 - int v24; // ecx@38 - int v25; // ecx@39 - int v26; // ecx@40 - int v27; // ecx@41 - int *v28; // esi@54 - unsigned int v29; // edx@56 - char *v30; // ecx@65 - int v31; // ecx@106 - int result; // eax@107 - int v33; // [sp-4h] [bp-2Ch]@23 - int v34; // [sp-4h] [bp-2Ch]@43 - int v35[5]; // [sp+Ch] [bp-1Ch]@8 - int a2; // [sp+20h] [bp-8h]@1 - int v37; // [sp+24h] [bp-4h]@1 + case 1: //shop weapon + for (int i=0; i<2; ++i) + { + for (int j=0; j<4; ++j) + { + if ( i ) + v21 = shopWeap_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j]; + else + v21 = shopWeap_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C].item_class[j]; - //need fixing - __debugbreak(); - v1 = 0; - v2 = 0; - v3 = _this - 1; - a2 = 0; - v37 = 0; - dword_F8B1DC = 0; - v4 = 2; - if ( !v3 ) - { - while ( 1 ) - { - v19 = 1; - do + switch (v21) { - v20 = (char *)window_SpeakInHouse->ptr_1C + 4 * (unsigned int)window_SpeakInHouse->ptr_1C + v19; - /*if ( v1 ) - v21 = word_4F063E[(signed int)v20]; - else - v21 = word_4F0404[(signed int)v20 - 4];//word_4F03FE[(signed int)v20];*/ - v22 = v21 - 23; - if ( v22 ) - { - v23 = v22 - 1; - if ( v23 ) - { - v24 = v23 - 1; - if ( v24 ) - { - v25 = v24 - 1; - if ( v25 ) - { - v26 = v25 - 1; - if ( v26 ) - { - v27 = v26 - 1; - if ( v27 ) - { - if ( v27 != v4 ) - goto LABEL_51; - v34 = 36; - } - else - { - v34 = 42; - } - } - else - { - v34 = 41; - } - } - else - { - v34 = 40; - } - } - else - { - v34 = 39; - } - } - else - { - v34 = 38; - } - } - else - { - v34 = 37; - } - v37 = sub_4BE571(v34, v35, v37, 5); - v2 = dword_F8B1DC; - v4 = 2; -LABEL_51: - ++v19; - } - while ( v19 <= 4 ); - ++v1; - if ( v1 >= v4 ) - goto LABEL_53; + case 23: v34 = 37; break; + case 24: v34 = 38; break; + case 25: v34 = 39; break; + case 26: v34 = 40; break; + case 27: v34 = 41; break; + case 28: v34 = 42; break; + case 30: v34 = 36; break; + default: + continue; + } + v37 = sub_4BE571(v34, v35, v37, 5); } } - v5 = (int)(v3 - 1); - if ( !v5 ) + break; + case 2: //shop armor + + for (int i=0; i<2; ++i) { - v10 = 0; - while ( 1 ) + for (int j=0; j<2; ++j) { - v11 = 0; - do + for (int k=0; k<4; ++k) { - v12 = 1; - do + if ( i ) + v15 = shopArmr_variation_spc[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k]; + else + v15 = shopArmr_variation_ord[(unsigned int)window_SpeakInHouse->ptr_1C-15+j].item_class[k]; + switch (v15) { - v13 = v11 + 2 * (unsigned int)window_SpeakInHouse->ptr_1C - 30; - v14 = v12 + 4 * v13 + v13; - /* if ( v10 ) - v15 = word_4F06D8[v14]; - else - v15 = word_4F0498[v14];*/ - v16 = v15 - 31; - if ( v16 ) - { - v17 = v16 - 1; - if ( v17 ) - { - v18 = v17 - 1; - if ( v18 ) - { - if ( v18 != 1 ) - goto LABEL_28; - v33 = 44; - } - else - { - v33 = 47; - } - } - else - { - v33 = 46; - } - } - else - { - v33 = 45; - } - v37 = sub_4BE571(v33, v35, v37, 5); - v2 = dword_F8B1DC; -LABEL_28: - ++v12; + case 31: v33 = 45; break; + case 32: v33 = 46; break; + case 33: v33 = 47; break; + case 34: v33 = 44; break; + default: + continue; } - while ( v12 <= 4 ); - ++v11; + v37 = sub_4BE571(v33, v35, v37, 5); } - while ( v11 < 2 ); - ++v10; - if ( v10 >= 2 ) - goto LABEL_53; } } - v6 = v5 - 1; - if ( v6 ) - { - v7 = v6 - 1; - if ( v7 ) - { - v8 = v7 - 17; - if ( v8 ) - { - v9 = v8 - 2; - if ( v9 ) - { - if ( v9 == 7 ) - { - v37 = 2; - v35[0] = 69; - v35[1] = 60; - } - } - else - { - v37 = 3; - v35[0] = 67; - v35[1] = 66; - v35[2] = 58; - } - } - else - { - v37 = 3; - v35[0] = 70; - v35[1] = 65; - v35[2] = 62; - } - } - else - { - v37 = 2; - v35[0] = 71; - v35[1] = 68; - } - } - else - { - v37 = 2; - v35[0] = 57; - v35[1] = 59; - } -LABEL_53: - if ( v37 > 0 ) + break; + case 3: //shop magic + v37 = 2; + v35[0] = 57; + v35[1] = 59; + break; + case 4: //shop alchemist + v37 = 2; + v35[0] = 71; + v35[1] = 68; + break; + case 21: //tavern + v37 = 3; + v35[0] = 70; + v35[1] = 65; + v35[2] = 62; + break; + case 23: //temple + v37 = 3; + v35[0] = 67; + v35[1] = 66; + v35[2] = 58; + break; + case 30: ///trainig + v37 = 2; + v35[0] = 69; + v35[1] = 60; + break; + } + for(i=0;i= v37 ) - goto LABEL_107; - v2 = dword_F8B1DC; - } - if ( *v28 == 47 ) - { - v30 = pSkillNames[11]; - goto LABEL_106; - } - if ( (signed int)v29 > 40 ) - { - if ( v29 == 41 ) - { - v30 = pSkillNames[5]; - goto LABEL_106; - } - if ( v29 == 42 ) - { - v30 = pSkillNames[6]; - goto LABEL_106; - } - if ( v29 == 44 ) - { - v30 = pSkillNames[8]; - goto LABEL_106; - } - if ( v29 == 45 ) - { - v30 = pSkillNames[9]; - goto LABEL_106; - } - if ( v29 == 46 ) - { - v30 = pSkillNames[10]; - goto LABEL_106; - } - } - else - { - if ( v29 == 40 ) - { - v30 = pSkillNames[4]; - goto LABEL_106; - } - if ( v29 == 5 ) - { - v30 = pSkillNames[23]; - goto LABEL_106; - } - if ( v29 == 36 ) - { - v30 = pSkillNames[0]; - goto LABEL_106; - } - if ( v29 == 37 ) - { - v30 = pSkillNames[1]; - goto LABEL_106; - } - if ( v29 == 38 ) - { - v30 = pSkillNames[2]; - goto LABEL_106; - } - if ( v29 == 39 ) - { - v30 = pSkillNames[3]; - goto LABEL_106; - } - } -LABEL_100: + case 40 :v30 = pSkillNames[4]; break; + case 5 : v30 = pSkillNames[23]; break; + case 36 :v30 = pSkillNames[0]; break; + case 37 :v30 = pSkillNames[1]; break; + case 38 :v30 = pSkillNames[2]; break; + case 39 :v30 = pSkillNames[3]; break; + case 41 :v30 = pSkillNames[5]; break; + case 42 :v30 = pSkillNames[6]; break; + case 44 :v30 = pSkillNames[8]; break; + case 45 :v30 = pSkillNames[9]; break; + case 46 :v30 = pSkillNames[10]; break; + case 47 :v30 = pSkillNames[11]; break; + case 66 :v30 = pSkillNames[30]; break; + case 57 :v30 = pSkillNames[21]; break; + case 58 :v30 = pSkillNames[22]; break; + case 60 :v30 = pSkillNames[24]; break; + case 62 :v30 = pSkillNames[26]; break; + case 65 :v30 = pSkillNames[29]; break; + case 67:v30 = pSkillNames[31]; break; + case 68:v30 = pSkillNames[32]; break; + case 69:v30 = pSkillNames[33]; break; + case 70:v30 = pSkillNames[34]; break; + case 71:v30 = pSkillNames[35]; break; + default: v30 = pGlobalTXT_LocalizationStrings[127]; //"No Text!" - goto LABEL_106; } -LABEL_107: - pDialogueWindow->_41D08F(a2, 1, 0, 2); - result = pDialogueWindow->pNumPresenceButton; - dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; + pShopOptions[dword_F8B1DC] = v30; + ++dword_F8B1DC; + CreateButtonInColumn(i+1, v29); + } + pDialogueWindow->_41D08F(i, 1, 0, 2); + dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; + } + + //----- (004BE571) -------------------------------------------------------- +int sub_4BE571(int a1, int *a2, int a3, int a4) + { + int result; // eax@1 + int i; // esi@3 + + result = a3; + if ( a3 < a4 ) + { + for ( i = 0; i < a3; ++i ) + { + if ( a1 == a2[i] ) + break; + } + if ( i == a3 ) + { + a2[a3] = a1; + result = a3 + 1; + } return result; } + else + { + return a4; + } + } + + diff -r d4ea2d382004 -r 89f6107c3362 Overlays.cpp --- a/Overlays.cpp Tue Feb 26 12:00:57 2013 +0600 +++ b/Overlays.cpp Tue Feb 26 12:01:54 2013 +0600 @@ -152,12 +152,8 @@ //----- (00458D97) -------------------------------------------------------- void OverlayList::InitializeSprites() { - OverlayList *v1; // esi@1 - signed int i; // edi@1 - - v1 = this; - for ( i = 0; i < (signed int)v1->uNumOverlays; ++i ) - pSpriteFrameTable->InitializeSprite(v1->pOverlays[i].uSpriteFramesetID); + for (uint i = 0; i < uNumOverlays; ++i) + pSpriteFrameTable->InitializeSprite(pOverlays[i].uSpriteFramesetID); } //----- (00458DBC) -------------------------------------------------------- diff -r d4ea2d382004 -r 89f6107c3362 mm7_2.cpp --- a/mm7_2.cpp Tue Feb 26 12:00:57 2013 +0600 +++ b/mm7_2.cpp Tue Feb 26 12:01:54 2013 +0600 @@ -2781,9 +2781,9 @@ v75 = (int)window_SpeakInHouse->ptr_1C; v76 = 9 * (v74 - 1 + 12 * v75); if ( dword_F8B19C == 2 ) - v77 = (ItemGen *)&pParty->StandartItemsInShops[v76]; + v77 = (ItemGen *)&pParty->StandartItemsInShops[(int)75][v74-1]; else - v77 = &pParty->SpecialItemsInShops[(int)75][v74-1];//(ItemGen *)&pParty->field_C59C[v76 + 724]; + v77 = &pParty->SpecialItemsInShops[(int)v75][v74-1];//(ItemGen *)&pParty->field_C59C[v76 + 724]; if ( v69 == (short)v11 || Str == v11 ) { v124 = (__int64 *)v11; @@ -3757,7 +3757,7 @@ //v3 = dword_F8B198; if ( dword_F8B19C != 1 ) goto LABEL_13; - if ( dword_F8B198 == 30 ) + if ( in_current_bilding_type == 30 ) { if ( uMessageParam == 17 ) { @@ -3778,9 +3778,9 @@ goto LABEL_9; } v8 = window_SpeakInHouse; - if ( (dword_F8B198 == 27 || dword_F8B198 == 28) + if ( (in_current_bilding_type == 27 || in_current_bilding_type == 28) && (v1 = 0, *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + uMessageParam)] + pParty->uDaysPlayed % 7)) - || dword_F8B198 != 23 || uMessageParam != 10 ) + || in_current_bilding_type != 23 || uMessageParam != 10 ) { LABEL_9: pDialogueWindow->Release(); @@ -3801,34 +3801,34 @@ } LABEL_11: dword_F8B19C = uMessageParam; - if ( dword_F8B198 < 19 ) - { - v9 = pIcons_LOD->LoadTexture(off_4F03B8[dword_F8B198], TEXTURE_16BIT_PALETTE); + if ( in_current_bilding_type < 19 ) + { + v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_bilding_type], TEXTURE_16BIT_PALETTE); //v3 = dword_F8B198; dword_F8B164 = &pIcons_LOD->pTextures[v9]; LABEL_13: v8 = window_SpeakInHouse; } - if ( dword_F8B198 > 21 ) - { - if ( dword_F8B198 == 22 ) + if ( in_current_bilding_type > 21 ) + { + if ( in_current_bilding_type == 22 ) { if ( dword_F8B19C >= 7 && dword_F8B19C <= 8 ) pKeyActionMap->EnterText(1, 10, v8); return; } - if ( dword_F8B198 != 23 && dword_F8B198 != 30 ) + if ( in_current_bilding_type != 23 && in_current_bilding_type != 30 ) return; } else { - if ( dword_F8B198 != 21 ) - { - if ( dword_F8B198 <= (signed int)v1 ) + if ( in_current_bilding_type != 21 ) + { + if ( in_current_bilding_type <= (signed int)v1 ) return; - if ( dword_F8B198 > 4 ) - { - if ( dword_F8B198 <= 16 ) + if ( in_current_bilding_type > 4 ) + { + if ( in_current_bilding_type <= 16 ) { if ( (signed __int64)__PAIR__( *(int *)&stru_AA1058[3].pSounds[8 * (unsigned int)v8->ptr_1C + 44472], @@ -3864,7 +3864,7 @@ } return; } - if ( dword_F8B198 != 17 ) + if ( in_current_bilding_type != 17 ) return; if ( uMessageParam == 99 ) { @@ -4080,12 +4080,12 @@ case 96: pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3703(dword_F8B198); + FillAviableSkillsToTeach(in_current_bilding_type); break; case 101: pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3A72(dword_F8B198); + sub_4B3A72(in_current_bilding_type); break; case 102: dword_F8B19C = 102; @@ -4150,7 +4150,7 @@ if ( pParty->uNumGold < v37 ) { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u); - if ( dword_F8B198 == 30 || dword_F8B198 == 21 ) + if ( in_current_bilding_type == 30 || in_current_bilding_type == 21 ) v39 = 4; else v39 = 2; @@ -4172,7 +4172,7 @@ { pDialogueWindow->eWindowType = WINDOW_MainMenu; UI_CreateEndConversationButton(); - sub_4B3AD4(dword_F8B198); + sub_4B3AD4(in_current_bilding_type); } } } @@ -4222,7 +4222,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( dword_F8B198 == 1 ) + if ( in_current_bilding_type == 1 ) { v47 = v8->ptr_1C; v48 = 0; @@ -4267,7 +4267,7 @@ //while ( v43 < (unsigned __int8)_4F063C_smthn_by_2da_uType[p2DEvents_minus1___00[26 * (unsigned int)v8->ptr_1C]] ); while ( v43 < (unsigned __int8)uItemsAmountPerShopType[p2DEvents[(unsigned int)v8->ptr_1C - 1].uType] ); } - if ( dword_F8B198 == 1 ) + if ( in_current_bilding_type == 1 ) { v52 = v8->ptr_1C; v53 = 0; @@ -4336,7 +4336,7 @@ { UI_CreateEndConversationButton(); dword_F8B19C = 94; - sub_4B3AD4(dword_F8B198); + sub_4B3AD4(in_current_bilding_type); } else { @@ -4345,13 +4345,13 @@ pVideoPlayer->_4BF5B2(); LABEL_28: dword_F8B19C = 1; - sub_4B3B42(dword_F8B198); + sub_4B3B42(in_current_bilding_type); return 1; } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); dword_F8B19C = 101; - sub_4B3A72(dword_F8B198); + sub_4B3A72(in_current_bilding_type); } return 1; } @@ -4514,7 +4514,7 @@ { ShowStatusBarString(pGlobalTXT_LocalizationStrings[155], 2u);// "You don't have enough gold" v13 = window_SpeakInHouse->ptr_1C; - if ( dword_F8B198 == 30 ) + if ( in_current_bilding_type == 30 ) v55 = 4; else v55 = 2; @@ -4997,33 +4997,6 @@ } // F8B5E8: using guessed type FrameTableTxtLine stru_F8B5E8; -//----- (004BE571) -------------------------------------------------------- -int __fastcall sub_4BE571(int a1, int *a2, int a3, int a4) -{ - int result; // eax@1 - int i; // esi@3 - - result = a3; - if ( a3 < a4 ) - { - for ( i = 0; i < a3; ++i ) - { - if ( a1 == a2[i] ) - break; - } - if ( i == a3 ) - { - a2[a3] = a1; - result = a3 + 1; - } - } - else - { - result = a4; - } - return result; -} - //----- (004BF91E) -------------------------------------------------------- @@ -7871,9 +7844,9 @@ //----- (0044FFD8) -------------------------------------------------------- int MapInfo::SpawnRandomTreasure(SpawnPointMM7 *a2) { - MapInfo *v2; // ebx@1 - SpawnPointMM7 *v3; // esi@1 - int v4; // eax@1 + //MapInfo *v2; // ebx@1 + //SpawnPointMM7 *v3; // esi@1 + //int v4; // eax@1 int v5; // edx@1 int v6; // eax@1 int v7; // ecx@1 @@ -7896,69 +7869,66 @@ unsigned __int16 v24; // dx@29 char *v25; // ecx@30 unsigned __int16 v26; // ax@33 - int v27; // ecx@35 - int v28; // eax@35 - int v29; // esi@35 - __int16 v30; // ax@35 + //int v27; // ecx@35 + //int v28; // eax@35 + //int v29; // esi@35 + //__int16 v30; // ax@35 LayingItem a1a; // [sp+Ch] [bp-7Ch]@1 - int v32; // [sp+7Ch] [bp-Ch]@1 - int v33; // [sp+80h] [bp-8h]@1 + //int v32; // [sp+7Ch] [bp-Ch]@1 + //int v33; // [sp+80h] [bp-8h]@1 int v34; // [sp+84h] [bp-4h]@1 - __debugbreak(); - - auto a1 = this; - - v2 = a1; - v3 = a2; - v4 = rand(); + //auto a1 = this; + //v2 = a1; + //v3 = a2; + //v4 = rand(); v34 = 0; - v5 = v4 % 100; + v5 = rand() % 100; // v6 = 2 * (v2->Treasure_prob + 7 * v3->uIndex) - 14; - v7 = (unsigned __int8)byte_4E8168[v3->uIndex-1][2*v2->Treasure_prob]; - v8 = (unsigned __int8)byte_4E8168[v3->uIndex-1][2*v2->Treasure_prob+1]; - v32 = v5; - v33 = v7; + v7 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob]; + v8 = (unsigned __int8)byte_4E8168[a2->uIndex - 1][2 * Treasure_prob + 1]; + //v32 = v5; + //v33 = v7; v9 = rand(); - v10 = v8 - v33 + 1; + v10 = v8 - v7 + 1; v12 = v9; result = v9 / v10; - v13 = v33 + (unsigned __int64)(v12 % v10); + v13 = v7 + (unsigned __int64)(v12 % v10); if ( v13 < 7 ) { - if ( v32 < 20 ) + if ( v5 < 20 ) return result; - if ( v32 >= 60 ) - { - v19 = v3->vPosition.z; - v20 = v3->vPosition.y; - v21 = v3->vPosition.x; + if ( v5 >= 60 ) + { + v19 = a2->vPosition.z; + v20 = a2->vPosition.y; + v21 = a2->vPosition.x; v22 = rand(); return sub_450521_ProllyDropItemAt(v13, v22 % 27 + 20, v21, v20, v19, 0); } - if ( v3->uIndex == 1 ) + if ( a2->uIndex == 1 ) { v14 = rand() % 51 + 50; } else { - if ( v3->uIndex != 2 ) - { - if ( v3->uIndex == 3 ) + if ( a2->uIndex != 2 ) + { + if ( a2->uIndex == 3 ) { v14 = rand() % 301 + 200; } else { - if ( v3->uIndex != 4 ) - { - if ( v3->uIndex == 5 ) + if ( a2->uIndex != 4 ) + { + if ( a2->uIndex == 5 ) { v14 = rand() % 1001 + 1000; } else { - if ( v3->uIndex != 6 ) + if ( a2->uIndex != 6 ) { LABEL_20: v15 = 0; @@ -8028,24 +7998,21 @@ } a1a.uObjectDescID = v26; a1a.stru_24.Reset(); + LABEL_35: - v27 = v3->vPosition.y; - v28 = v3->vPosition.x; - v29 = v3->vPosition.z; - a1a.vPosition.y = v27; + a1a.vPosition.y = a2->vPosition.y; a1a.uAttributes = 0; a1a.uSoundID = 0; a1a.uFacing = 0; - a1a.vPosition.z = v29; - a1a.vPosition.x = v28; + a1a.vPosition.z = a2->vPosition.z; + a1a.vPosition.x = a2->vPosition.x; a1a.field_50 = 0; a1a.field_4C = 0; a1a.field_48 = 0; - v30 = pIndoor->GetSector(v28, v27, v29); a1a.field_5C = 0; a1a.field_58_pid = 0; a1a.uSpriteFrameID = 0; - a1a.uSectorID = v30; + a1a.uSectorID = pIndoor->GetSector(a2->vPosition.x, a2->vPosition.y, a2->vPosition.z);; return a1a.Create(0, 0, 0, 0); } @@ -13368,7 +13335,7 @@ } } else - Log::Warning(L"MM init: failed"); + Log::Warning(L"MM init: failed"); pGame->Deinitialize(); } diff -r d4ea2d382004 -r 89f6107c3362 mm7_4.cpp --- a/mm7_4.cpp Tue Feb 26 12:00:57 2013 +0600 +++ b/mm7_4.cpp Tue Feb 26 12:01:54 2013 +0600 @@ -9069,20 +9069,20 @@ ItemGen *v7; // ecx@13 signed int v8; // esi@17 unsigned int v9; // eax@19 - char v10; // [sp+8h] [bp-44h]@12 - char v11; // [sp+10h] [bp-3Ch]@12 - char v12; // [sp+18h] [bp-34h]@18 - char v13; // [sp+20h] [bp-2Ch]@17 - char v14; // [sp+28h] [bp-24h]@17 - char v15; // [sp+30h] [bp-1Ch]@17 - char v16; // [sp+38h] [bp-14h]@5 + POINT v10; // [sp+8h] [bp-44h]@12 + POINT v11; // [sp+10h] [bp-3Ch]@12 + POINT v12; // [sp+18h] [bp-34h]@18 + POINT v13; // [sp+20h] [bp-2Ch]@17 + POINT v14; // [sp+28h] [bp-24h]@17 + POINT v15; // [sp+30h] [bp-1Ch]@17 + POINT v16; // [sp+38h] [bp-14h]@5 POINT a2; // [sp+40h] [bp-Ch]@5 int v18; // [sp+48h] [bp-4h]@5 //v0 = pPlayers[uActiveCharacter]; - if ( dword_F8B198 <= 0 ) + if ( in_current_bilding_type <= 0 ) return; - if ( dword_F8B198 <= 4 ) + if ( in_current_bilding_type <= 4 ) { if ( dword_F8B19C != 2 ) { @@ -9090,10 +9090,10 @@ return; if ( dword_F8B19C <= 5 || dword_F8B19C == 94 ) { - v8 = pMouse->GetCursorPos((POINT *)&v15)->x - 14; - v18 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos((POINT *)&v14)->y - 17) >> 5); - if ( pMouse->GetCursorPos((POINT *)&v13)->x <= 13 - || pMouse->GetCursorPos((POINT *)&v12)->x >= 462 + v8 = pMouse->GetCursorPos(&v15)->x - 14; + v18 = (v8 >> 5) + 14 * ((pMouse->GetCursorPos(&v14)->y - 17) >> 5); + if ( pMouse->GetCursorPos(&v13)->x <= 13 + || pMouse->GetCursorPos(&v12)->x >= 462 || (v9 = pPlayers[uActiveCharacter]->GetItemIDAtInventoryIndex(&v18)) == 0 ) return; v7 = (ItemGen *)&pPlayers[uActiveCharacter]->pInventoryItems[v9-1]; @@ -9104,8 +9104,8 @@ if ( dword_F8B19C != 95 ) return; } - v4 = pMouse->GetCursorPos((POINT *)&v11); - v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v10)->y]] & 0xFFFF; + v4 = pMouse->GetCursorPos(&v11); + v5 = pRenderer->pActiveZBuffer[v4->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v10)->y]] & 0xFFFF; v18 = v5; if ( !v5 ) return; @@ -9116,10 +9116,10 @@ v7 =&pParty->SpecialItemsInShops[(unsigned int)window_SpeakInHouse->ptr_1C][v5]; goto LABEL_15; } - if ( dword_F8B198 <= 16 && dword_F8B19C == 18 ) + if ( in_current_bilding_type <= 16 && dword_F8B19C == 18 ) { v1 = pMouse->GetCursorPos(&a2); - v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos((POINT *)&v16)->y]; + v2 = v1->x + pSRZBufferLineOffsets[pMouse->GetCursorPos(&v16)->y]; v3 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; v18 = pRenderer->pActiveZBuffer[v2] & 0xFFFF; if ( v18 ) @@ -9180,19 +9180,19 @@ int v6; // esi@20 int v7[4]; // [sp+Ch] [bp-10h]@12 - if ( dword_F8B198 > 0 ) + if ( in_current_bilding_type > 0 ) { v0 = 3; - if ( dword_F8B198 > 3 ) - { - if ( dword_F8B198 == 22 ) + if ( in_current_bilding_type > 3 ) + { + if ( in_current_bilding_type == 22 ) { if ( !dword_F8B1E4 ) return; } else { - if ( dword_F8B198 != 23 ) + if ( in_current_bilding_type != 23 ) return; } v1 = (unsigned int)window_SpeakInHouse->ptr_1C; @@ -10349,94 +10349,61 @@ //----- (004B36CC) -------------------------------------------------------- -GUIButton *__fastcall sub_4B36CC(int a1, unsigned int a2) -{ - return pDialogueWindow->CreateButton( - 0x1E0u, - 30 * a1 + 146, - 0x8Cu, - 0x1Eu, - 1, - 0, - 0x195u, - a2, - 0, - "", - 0); +void CreateButtonInColumn( int column_pos, unsigned int control_id ) + { + pDialogueWindow->CreateButton( 480, 30 * column_pos + 146, 140, 30, 1, 0, 0x195u, control_id, 0, "", 0); } //----- (004B3A72) -------------------------------------------------------- -int __thiscall sub_4B3A72(int a1) -{ - int v1; // esi@1 - int result; // eax@4 - - v1 = 0; +void sub_4B3A72( int a1 ) + { + int num_buttons; // esi@1 + + num_buttons = 0; if ( a1 == 21 ) { - sub_4B36CC(0, 0x66u); - v1 = 2; - sub_4B36CC(1, 0x67u); - if ( pParty->HasItem(0x28Bu) ) - { - v1 = 3; - sub_4B36CC(2, 0x68u); - } - } - pDialogueWindow->_41D08F(v1, 1, 0, 2); - result = pDialogueWindow->pNumPresenceButton; + CreateButtonInColumn(0, 0x66u); + num_buttons = 2; + CreateButtonInColumn(1, 0x67u); + if ( pParty->HasItem(651) ) //Arcomage Deck + { + num_buttons = 3; + CreateButtonInColumn(2, 0x68u); + } + } + pDialogueWindow->_41D08F(num_buttons, 1, 0, 2); dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; - return result; } // F8B1E0: using guessed type int dword_F8B1E0; //----- (004B3AD4) -------------------------------------------------------- -int __fastcall sub_4B3AD4(signed int a1) -{ - int result; // eax@7 - int v2; // [sp-10h] [bp-10h]@4 - int v3; // [sp-Ch] [bp-Ch]@4 - int v4; // [sp-8h] [bp-8h]@4 - int v5; // [sp-4h] [bp-4h]@4 - +void sub_4B3AD4( signed int a1 ) + { if ( a1 > 0 ) { if ( a1 <= 3 ) { - sub_4B36CC(0, 3u); - sub_4B36CC(1, 4u); - sub_4B36CC(2, 5u); - v5 = 2; - v4 = 0; - v3 = 1; - v2 = 3; - goto LABEL_6; + CreateButtonInColumn(0, 3u); + CreateButtonInColumn(1, 4u); + CreateButtonInColumn(2, 5u); + pDialogueWindow->_41D08F(3, 1, 0, 2); } if ( a1 == 4 ) { - sub_4B36CC(0, 3u); - sub_4B36CC(1, 4u); - v5 = 2; - v4 = 0; - v3 = 1; - v2 = 2; -LABEL_6: - pDialogueWindow->_41D08F(v2, v3, v4, v5); - goto LABEL_7; - } - } -LABEL_7: - result = pDialogueWindow->pNumPresenceButton; + CreateButtonInColumn(0, 3u); + CreateButtonInColumn(1, 4u); + pDialogueWindow->_41D08F(2, 1, 0, 2); + } + } dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; - return result; } // F8B1E0: using guessed type int dword_F8B1E0; //----- (004B3B42) -------------------------------------------------------- -int __fastcall sub_4B3B42(signed int a1) -{ +void sub_4B3B42( signed int a1 ) + { int v1; // ecx@18 int v2; // ecx@19 int v3; // ecx@20 @@ -10461,11 +10428,11 @@ { if ( a1 == 23 ) { - sub_4B36CC(0, 0xAu); - sub_4B36CC(1, 0xBu); + CreateButtonInColumn(0, 0xAu); + CreateButtonInColumn(1, 0xBu); v14 = 96; LABEL_41: - sub_4B36CC(2, v14); + CreateButtonInColumn(2, v14); v17 = 2; v11 = 0; v10 = 1; @@ -10478,31 +10445,31 @@ { if ( a1 != 30 ) goto LABEL_43; - sub_4B36CC(0, 0x11u); + CreateButtonInColumn(0, 0x11u); v16 = 96; goto LABEL_37; } - sub_4B36CC(0, 0x69u); - sub_4B36CC(1, 0x6Au); - sub_4B36CC(2, 0x6Bu); + CreateButtonInColumn(0, 0x69u); + CreateButtonInColumn(1, 0x6Au); + CreateButtonInColumn(2, 0x6Bu); v12 = 108; } else { if ( a1 == 22 ) { - sub_4B36CC(0, 7u); + CreateButtonInColumn(0, 7u); v16 = 8; goto LABEL_37; } v1 = a1 - 14; if ( !v1 ) { - sub_4B36CC(0, 0x12u); - sub_4B36CC(1, 0x30u); - sub_4B36CC(2, 0x31u); - sub_4B36CC(3, 0x32u); - sub_4B36CC(4, 0x33u); + CreateButtonInColumn(0, 0x12u); + CreateButtonInColumn(1, 0x30u); + CreateButtonInColumn(2, 0x31u); + CreateButtonInColumn(3, 0x32u); + CreateButtonInColumn(4, 0x33u); v17 = 2; v11 = 0; v10 = 1; @@ -10517,10 +10484,10 @@ { if ( v3 != 4 ) goto LABEL_43; - sub_4B36CC(0, 0xFu); - sub_4B36CC(1, 0x10u); + CreateButtonInColumn(0, 0xFu); + CreateButtonInColumn(1, 0x10u); v4 = 3; - sub_4B36CC(2, 0x60u); + CreateButtonInColumn(2, 0x60u); v5 = (signed int)window_SpeakInHouse->ptr_1C; if ( v5 < 108 || v5 > 120 ) goto LABEL_28; @@ -10531,7 +10498,7 @@ else { v4 = 1; - sub_4B36CC(0, 0x63u); + CreateButtonInColumn(0, 0x63u); if ( !pParty->uFine ) { LABEL_28: @@ -10547,16 +10514,16 @@ v7 = 1; v6 = 100; } - sub_4B36CC(v7, v6); + CreateButtonInColumn(v7, v6); goto LABEL_28; } - sub_4B36CC(0, 0x12u); - sub_4B36CC(1, 0x34u); - sub_4B36CC(2, 0x35u); + CreateButtonInColumn(0, 0x12u); + CreateButtonInColumn(1, 0x34u); + CreateButtonInColumn(2, 0x35u); v12 = 54; } LABEL_39: - sub_4B36CC(3, v12); + CreateButtonInColumn(3, v12); v17 = 2; v11 = 0; v10 = 1; @@ -10565,10 +10532,10 @@ } if ( a1 == 13 ) { - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v16 = 56; LABEL_37: - sub_4B36CC(1, v16); + CreateButtonInColumn(1, v16); v17 = 2; v11 = 0; v10 = 1; @@ -10581,56 +10548,54 @@ case 2: case 3: case 4: - sub_4B36CC(0, 2u); - sub_4B36CC(1, 0x5Fu); - sub_4B36CC(2, 0x5Eu); + CreateButtonInColumn(0, 2u); + CreateButtonInColumn(1, 0x5Fu); + CreateButtonInColumn(2, 0x5Eu); v12 = 96; goto LABEL_39; case 5: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v13 = 48; goto LABEL_9; case 6: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v13 = 49; goto LABEL_9; case 7: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v13 = 50; goto LABEL_9; case 8: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v13 = 51; LABEL_9: - sub_4B36CC(1, v13); + CreateButtonInColumn(1, v13); v14 = 72; goto LABEL_41; case 9: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v15 = 52; goto LABEL_13; case 10: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v15 = 53; goto LABEL_13; case 11: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v15 = 54; LABEL_13: - sub_4B36CC(1, v15); + CreateButtonInColumn(1, v15); v14 = 61; goto LABEL_41; case 12: - sub_4B36CC(0, 0x12u); + CreateButtonInColumn(0, 0x12u); v16 = 55; goto LABEL_37; default: break; } LABEL_43: - result = pDialogueWindow->pNumPresenceButton; dword_F8B1E0 = pDialogueWindow->pNumPresenceButton; - return result; } // F8B1E0: using guessed type int dword_F8B1E0; @@ -10815,7 +10780,7 @@ pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, 0, 0x51u, 0, 0, "", 0); if ( pDialogueNPCCount == 1 && dword_591080 ) { - sub_4B3B42(dword_F8B198); + sub_4B3B42(in_current_bilding_type); } else { @@ -14472,8 +14437,8 @@ pAudioPlayer->StopChannels(-1, -1); //uCurrentHouse_Animation = p2DEvents_minus1___02[v2]; uCurrentHouse_Animation = p2DEvents[uHouseID - 1].uAnimationID; - dword_F8B198 = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C); - if ( dword_F8B198 == 20 && pParty->uFine ) // going 2 jail + in_current_bilding_type = LOBYTE(pAnimatedRooms[uCurrentHouse_Animation].field_C); + if ( in_current_bilding_type == 20 && pParty->uFine ) // going 2 jail { uCurrentHouse_Animation = (signed __int16)p2DEvents[186].uAnimationID; //v25 = HOUSE_187; @@ -14482,7 +14447,7 @@ LODWORD(pParty->uTimePlayed) += 0x7620000u; v14 = LOBYTE(pAnimatedRooms[(signed __int16)p2DEvents[HOUSE_186].uAnimationID].field_C); pParty->uTimePlayed = __PAIR__(HIDWORD(pParty->uTimePlayed), v12) + 0x7620000; - dword_F8B198 = v14; + in_current_bilding_type = v14; //v13 = pParty->pPlayers;//[0].uNumDivineInterventionCastsThisDay; //do ++pParty->uNumPrisonTerms; diff -r d4ea2d382004 -r 89f6107c3362 mm7_data.cpp --- a/mm7_data.cpp Tue Feb 26 12:00:57 2013 +0600 +++ b/mm7_data.cpp Tue Feb 26 12:01:54 2013 +0600 @@ -1610,7 +1610,7 @@ int dword_4EFA84; // weak void *off_4EFDB0; // weak int dword_4F031C[777]; // weak -const char *off_4F03B8[] = +const char *off_4F03B8[19] = { "", "WEPNTABL", "ARMORY", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", "MAGSHELF", @@ -2341,7 +2341,7 @@ __int16 word_F8B158[777]; // weak struct Texture *dword_F8B164; // idb struct Texture *ItemsInShopTexture[12]; -int dword_F8B198; // weak +int in_current_bilding_type; // weak int dword_F8B19C; // weak __int16 word_F8B1A0; // weak const char *dword_F8B1A4; // idb diff -r d4ea2d382004 -r 89f6107c3362 mm7_data.h --- a/mm7_data.h Tue Feb 26 12:00:57 2013 +0600 +++ b/mm7_data.h Tue Feb 26 12:01:54 2013 +0600 @@ -1686,7 +1686,7 @@ extern __int16 word_F8B158[]; // weak extern struct Texture *dword_F8B164; // idb extern struct Texture *ItemsInShopTexture[12]; -extern int dword_F8B198; // weak +extern int in_current_bilding_type; // weak extern int dword_F8B19C; // weak extern __int16 word_F8B1A0; // weak extern const char *dword_F8B1A4; // idb @@ -2307,11 +2307,11 @@ char *__thiscall _4B254D_SkillMasteryTeacher(int _this); const char *__fastcall ContractSelectText(int pEventNumber); char __cdecl SimpleHouseAndBoatsDialog(); -struct GUIButton *__fastcall sub_4B36CC(int a1, unsigned int a2); -int sub_4B3703(int _this); -int __thiscall sub_4B3A72(int a1); // idb -int __fastcall sub_4B3AD4(signed int a1); -int __fastcall sub_4B3B42(signed int a1); +void CreateButtonInColumn(int a1, unsigned int a2); +void FillAviableSkillsToTeach(int _this); +void sub_4B3A72(int a1); // idb +void sub_4B3AD4(signed int a1); +void sub_4B3B42(signed int a1); void __cdecl sub_4B3E1E(); void __fastcall DrawJoinGuildWindow(int pEventNumber); void __fastcall sub_4B3FE5(int a4); @@ -2347,7 +2347,7 @@ void __cdecl sub_4BDB56_buy_skill____(); struct FrameTableTxtLine *__thiscall texture_frame_table_txt_parser(const char *_this, FrameTableTxtLine *a2); struct FrameTableTxtLine *__thiscall frame_table_txt_parser(const char *pString, FrameTableTxtLine *a2); -int __fastcall sub_4BE571(int a1, int *a2, int a3, int a4); + void __cdecl ShowIntroVideo_and_LoadingScreen(); unsigned int __thiscall GameOverMenu(void *ecx0); bool __thiscall BinkLockBuffer(struct _BINKBUF *_this);