# HG changeset patch # User Ritor1 # Date 1362579366 -21600 # Node ID 7bae884b7cd0649b27d4812a3bbaf1828fe4bdcb # Parent c615ff03b1446f13a9601d97cb6ad729ec6a1468# Parent b5240254cbbd152e4464bf16392464a4bfa8b1c5 Слияние diff -r c615ff03b144 -r 7bae884b7cd0 AudioPlayer.cpp --- a/AudioPlayer.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/AudioPlayer.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -90,7 +90,7 @@ if ( pSoundList->pSounds[v2].eType != SOUND_DESC_SYSTEM || (sprintf(pSoundName, "%s", pSounds[v2].pSoundName), pSoundList->pSounds[v2].pSoundData[0] = ::LoadSound(pSoundName, (SoundData *)0xFFFFFFFF, pSounds[v2].uSoundID), !pAudioPlayer->b3DSoundInitialized) - || (pSoundDesc = &pSoundList->pSounds[v2], !(pSoundDesc->uFlags & 2)) + || (pSoundDesc = &pSoundList->pSounds[v2], !(pSoundDesc->uFlags & SOUND_DESC_SWAP)) || !pSoundDesc->pSoundData[0] ) // goto LABEL_17; pSoundData = pSoundDesc->pSoundData[0]; @@ -163,8 +163,8 @@ if (!pSound) return 0; - if (pSound->uFlags & 2 && pSound->p3DSound || - ~pSound->uFlags & 2 && pSound->pSoundData[0]) + if (pSound->uFlags & SOUND_DESC_SWAP && pSound->p3DSound || + ~pSound->uFlags & SOUND_DESC_SWAP && pSound->pSoundData[0]) return uSoundIdx; if (!pSound->pSoundData[0]) @@ -174,12 +174,12 @@ return 0; if (a3) - pSound->uFlags |= 1u; + pSound->uFlags |= SOUND_DESC_SYSTEM; if (!pAudioPlayer->b3DSoundInitialized) return uSoundIdx; - if (~pSound->uFlags & 2 || !pSound->pSoundData[0]) + if (~pSound->uFlags & SOUND_DESC_SWAP || !pSound->pSoundData[0]) return uSoundIdx; @@ -368,7 +368,7 @@ ReleaseSoundData(v7); v2->pSounds[v3].pSoundData[0] = 0; } - v2->pSounds[v3].uFlags &= 0xFFFFFFFEu; + v2->pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; } ++i; } @@ -387,19 +387,19 @@ v5 = &this->pSounds[uSoundID]; if ( v5->eType != SOUND_DESC_SYSTEM ) { - if ( v5->uFlags & 2 && v5->p3DSound && a3 ) + if ( v5->uFlags & SOUND_DESC_SWAP && v5->p3DSound && a3 ) { if ( LOBYTE(v5->bDecompressed) ) AIL_mem_free_lock(v5->p3DSound); pSounds[v3].p3DSound = 0; - pSounds[v3].uFlags &= 0xFFFFFFFEu; + pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; } v6 = pSounds[v3].pSoundData[0]; if ( v6 ) { ReleaseSoundData(v6); pSounds[v3].pSoundData[0] = 0; - pSounds[v3].uFlags &= 0xFFFFFFFEu; + pSounds[v3].uFlags &= ~SOUND_DESC_SYSTEM; } } } @@ -521,7 +521,7 @@ if ( v19.field_0 >= 4 && !_strcmpi(v19.pProperties[3], "3D") ) { v15 = (int)&v2->pSounds[v2->uNumSounds].uFlags; - *(int *)v15 |= 2u; + *(int *)v15 |= SOUND_DESC_SWAP; } ++v2->uNumSounds; } @@ -1743,7 +1743,7 @@ auto decor_desc = &pDecorationList->pDecorations[decor->uDecorationDescID]; //v48 = &pDecorationList->pDecorations[decor->uDecorationDescID]; //v49 = v48->uFlags; - uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & 0x40) >> 6; + uNumRepeats = (~(unsigned __int8)decor_desc->uFlags & DECORATION_SLOW_LOOP) >> 6; if (decor_desc->SoundOnDawn() || decor_desc->SoundOnDusk()) { @@ -2231,7 +2231,7 @@ v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; if ( v4->eType == SOUND_DESC_SWAP) { - if ( v4->pSoundData[0] && !(v4->uFlags & 1) ) + if ( v4->pSoundData[0] && !(v4->uFlags & SOUND_DESC_SYSTEM) ) { v5 = this->uMixerChannels == 0; v6 = this->uMixerChannels < 0; @@ -2371,7 +2371,7 @@ v4 = &pSoundList->pSounds[a2->field_8]; if ( v4->eType == SOUND_DESC_SWAP) { - if ( v4->p3DSound && !(v4->uFlags & 1) ) + if ( v4->p3DSound && !(v4->uFlags & SOUND_DESC_SYSTEM) ) { v5 = this->uNum3DSamples == 0; v6 = this->uNum3DSamples < 0; diff -r c615ff03b144 -r 7bae884b7cd0 Chest.cpp --- a/Chest.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/Chest.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -613,7 +613,7 @@ if(test_positionpFacePlane.dist; } - if (stru_F8AD28.uNumLightsApplied > 0 && !pFace->uAttributes) - //!(pFace->uAttributes & 0x400000)) + if (stru_F8AD28.uNumLightsApplied > 0 && !(pFace->uAttributes & 0x400000)) pGame->pLightmapBuilder->ApplyLights(&stru_F8AD28, &stru_F7B60C, uNumVerticesa, array_507D30, pVertices, 0); if (pDecalBuilder->uNumDecals > 0) @@ -557,17 +556,20 @@ v23 = pFace->uBitmapID; goto LABEL_42; } - else if (pFace->uAttributes)//(pFace->uAttributes & 0x4000) + else if (pFace->uAttributes & 0x4000) { v23 = pTextureFrameTable->GetFrameTexture(pFace->uBitmapID, pBLVRenderParams->field_0_timer_); LABEL_42: v27 = pBitmaps_LOD->pHardwareTextures[v23]; - if (pFace->uAttributes & 0x400000) + if (pFace->uAttributes & FACE_DO_NOT_LIGHT) _479A53_draw_some_blv_poly(uNumVerticesa, uFaceID); else pRenderer->DrawIndoorPolygon(uNumVerticesa, pFace, v27, v28, 8 * uFaceID | 6, v17, 0); return; } + //v17 = 0xFFFFFFFF; + v23 = pFace->uBitmapID; + goto LABEL_42; } } } diff -r c615ff03b144 -r 7bae884b7cd0 Indoor.h --- a/Indoor.h Wed Mar 06 20:15:47 2013 +0600 +++ b/Indoor.h Wed Mar 06 20:16:06 2013 +0600 @@ -257,6 +257,7 @@ #define FACE_TEXTURE_FRAME 0x00004000 // Texture ID is a frameset from TextureFrameTable, otherwise BitmapID #define FACE_OUTLINED 0x00010000 // outline face edges #define FACE_TEXTURE_FLOW 0x00040000 // The texture moves slowly. For horizontal facets only. +#define FACE_DO_NOT_LIGHT 0x00400000 #define FACE_CLICKABLE 0x02000000 // Event can be triggered by clicking on the facet. #define FACE_PRESSURE_PLATE 0x04000000 // Event can be triggered by stepping on the facet. #define FACE_ETHEREAL 0x20000000 // Untouchable. You can pass through it. diff -r c615ff03b144 -r 7bae884b7cd0 LightmapBuilder.cpp --- a/LightmapBuilder.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/LightmapBuilder.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -1621,7 +1621,7 @@ { //v30 = 0.0; //v4 = pRenderer->pRenderD3D->pDevice; - ErrD3D(v4->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); + ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u)); //v6 = (char *)stru_69BD44.c_str(); //if ( !stru_69BD44.c_str() ) // v6 = (char *)&dword_4D86F0; diff -r c615ff03b144 -r 7bae884b7cd0 Party.cpp --- a/Party.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/Party.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -198,38 +198,31 @@ //----- (00492AD5) -------------------------------------------------------- -__int16 Party::SetFood(unsigned int uNumFood) +void Party::SetFood(unsigned int uNumFood) { - __int16 result; // ax@1 - pUIAnim_Food->uAnimTime = 0; pParty->uNumFoodRations = uNumFood; - result = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - return result; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; } //----- (00492B03) -------------------------------------------------------- void Party::TakeFood(unsigned int uNumFood) { - if ( ((pParty->uNumFoodRations - uNumFood) & 0x80000000u) == 0 ) - pParty->uNumFoodRations -= uNumFood; + if (pParty->uNumFoodRations <= uNumFood) + pParty->uNumFoodRations = 0; else - pParty->uNumFoodRations = 0; + pParty->uNumFoodRations -= uNumFood; + pUIAnim_Food->uAnimTime = 0; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; } //----- (00492B42) -------------------------------------------------------- -__int16 Party::GiveFood(unsigned int _this) +void Party::GiveFood(unsigned int _this) { - __int16 result; // ax@1 - pParty->uNumFoodRations += _this; pUIAnim_Food->uAnimTime = 0; - result = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Food->uIconID].uAnimLength; - return result; + pUIAnim_Food->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Food->uIconID].uAnimLength; } //----- (00492B70) -------------------------------------------------------- @@ -237,7 +230,7 @@ { pParty->uNumGold = uNumGold; pUIAnim_Gold->uAnimTime = 0; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); } @@ -249,7 +242,7 @@ else pParty->uNumGold = 0; pUIAnim_Gold->uAnimTime = 0; - pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[(signed __int16)pUIAnim_Gold->uIconID].uAnimLength; + pUIAnim_Gold->uAnimLength = 8 * pIconsFrameTable->pIcons[pUIAnim_Gold->uIconID].uAnimLength; pAudioPlayer->PlaySound(SOUND_GoldReceived, 0, 0, -1, 0, 0, 0, 0); } diff -r c615ff03b144 -r 7bae884b7cd0 Party.h --- a/Party.h Wed Mar 06 20:15:47 2013 +0600 +++ b/Party.h Wed Mar 06 20:16:06 2013 +0600 @@ -180,9 +180,9 @@ static void SetGold(unsigned int uNumGold); static void TakeGold(unsigned int uNumGold); - static __int16 SetFood(unsigned int uNumFood); + static void SetFood(unsigned int uNumFood); static void TakeFood(unsigned int uNumFood); - static __int16 GiveFood(unsigned int _this); + static void GiveFood(unsigned int _this); inline bool WizardEyeActive() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uExpireTime > 0;} inline int WizardEyeSkillLevel() {return pPartyBuffs[PARTY_BUFF_WIZARD_EYE].uSkill;} diff -r c615ff03b144 -r 7bae884b7cd0 Render.cpp --- a/Render.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/Render.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -7800,14 +7800,14 @@ double v17; // st6@10 //char v18; // zf@10 Texture *v19; // edx@10 - Texture *v23; // edx@16 - char *v24; // ecx@16 - char *v25; // eax@16 - double v26; // st6@17 - int v27; // esi@17 - double v28; // st6@17 - unsigned int v33; // ecx@18 - char *v34; // eax@19 + //Texture *v23; // edx@16 + //char *v24; // ecx@16 + //char *v25; // eax@16 + //double v26; // st6@17 + //int v27; // esi@17 + //double v28; // st6@17 + //unsigned int v33; // ecx@18 + //char *v34; // eax@19 //Texture *v45; // edx@23 //char *v46; // ecx@23 //char *v47; // eax@23 @@ -7908,36 +7908,47 @@ } else { - __debugbreak(); - if ( (signed int)uNumVertices > 0 ) - { - v23 = pTex; - v24 = (char *)&array_507D30[0].vWorldViewPosition; - v25 = (char *)&d3d_vertex_buffer[0].pos.y; - pTex = (Texture *)uNumVertices; - uint v18; - do - { - v26 = *(float *)v24 * 0.061758894; - v27 = *((int *)v24 + 3); - *((int *)v25 + 4) = 0; - *((int *)v25 - 1) = v27; - *(int *)v25 = *((int *)v24 + 4); - *((int *)v25 + 3) = uColor; - v25 += 32; - *((float *)v25 - 7) = 1.0 - 1.0 / v26; - v28 = 1.0 / *(float *)v24; - v24 += 48; - v18 = pTex == (Texture *)1; - pTex = (Texture *)((char *)pTex - 1); - *((float *)v25 - 6) = v28; + for (uint i = 0; i < uNumVertices; ++i) + { + d3d_vertex_buffer[i].pos.x = array_507D30[i].vWorldViewProjX; + d3d_vertex_buffer[i].pos.y = array_507D30[i].vWorldViewProjY; + d3d_vertex_buffer[i].pos.z = 1.0 - 1.0 / (array_507D30[i].vWorldViewPosition.x * 0.061758894); + d3d_vertex_buffer[i].rhw = 1.0 / array_507D30[i].vWorldViewPosition.x; + d3d_vertex_buffer[i].diffuse = uColor; + d3d_vertex_buffer[i].specular = 0; + d3d_vertex_buffer[i].texcoord.x = array_507D30[i].u / (double)pTex->uTextureWidth; + d3d_vertex_buffer[i].texcoord.y = array_507D30[i].v / (double)pTex->uTextureHeight; + } + //__debugbreak(); + //if ( (signed int)uNumVertices > 0 ) + //{ + //v23 = pTex; + //v24 = (char *)&array_507D30[0].vWorldViewPosition; + //v25 = (char *)&d3d_vertex_buffer[0].pos.y; + //pTex = (Texture *)uNumVertices; + //uint v18; + //do + //{ + //v26 = *(float *)v24 * 0.061758894; + //v27 = *((int *)v24 + 3); + //*((int *)v25 + 4) = 0; + //*((int *)v25 - 1) = v27; + //*(int *)v25 = *((int *)v24 + 4); + //*((int *)v25 + 3) = uColor; + //v25 += 32; + //*((float *)v25 - 7) = 1.0 - 1.0 / v26; + //v28 = 1.0 / *(float *)v24; + //v24 += 48; + //v18 = pTex == (Texture *)1; + //pTex = (Texture *)((char *)pTex - 1); + //*((float *)v25 - 6) = v28; //a3 = (BLVFace *)v23->uTextureWidth; - *((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; + //*((float *)v25 - 3) = *((float *)v24 - 6) / (double)(signed int)v23->uTextureWidth; //a3 = (BLVFace *)v23->uTextureHeight; - *((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; - } - while ( !v18 ); - } + //*((float *)v25 - 2) = *((float *)v24 - 5) / (double)(signed int)v23->uTextureHeight; + //} + //while ( !v18 ); + //} ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, false)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); ErrD3D(pRenderD3D->pDevice->SetTexture(0, nullptr)); @@ -7946,9 +7957,13 @@ d3d_vertex_buffer, uNumVertices, 28)); - ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1)); + + ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, D3DCULL_NONE)); pGame->pLightmapBuilder->_45D74F_MessWithLight(-1, 0); - v33 = uNumVertices; + + for (uint i = 0; i < uNumVertices; ++i) + d3d_vertex_buffer[i].diffuse = uCorrectedColor; + /*v33 = uNumVertices; if ( (signed int)uNumVertices > 0 ) { v34 = (char *)&d3d_vertex_buffer[0].diffuse; @@ -7959,7 +7974,7 @@ --v33; } while ( v33 ); - } + }*/ ErrD3D(pRenderD3D->pDevice->SetTexture(0, pHwTex)); ErrD3D(pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, D3DTADDRESS_WRAP)); ErrD3D(pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, TRUE)); diff -r c615ff03b144 -r 7bae884b7cd0 mm7_1.cpp --- a/mm7_1.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/mm7_1.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -3192,132 +3192,139 @@ v74 = 0; v69 = 0; v66 = pGlobalTXT_LocalizationStrings[630]; - goto LABEL_123; + a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); } - a4 = 0; - v51 = &v121->pActorBuffs[1]; - v222 = 0; - v120 = &v121->pActorBuffs[1]; - do + else { - if ( (signed __int64)v51->uExpireTime > 0 ) - { - switch ( (int)v51 ) - { - case 0u: - v124 = 60; - a4 = pGlobalTXT_LocalizationStrings[591]; - break; - case 1u: - v124 = 82; - a4 = pGlobalTXT_LocalizationStrings[649]; - break; - case 2u: - v124 = 92; - a4 = pGlobalTXT_LocalizationStrings[592]; - break; - case 3u: - v124 = 63; - a4 = pGlobalTXT_LocalizationStrings[4]; - break; - case 4u: - v52 = pGlobalTXT_LocalizationStrings[220]; - goto LABEL_100; - case 5u: - v52 = pGlobalTXT_LocalizationStrings[162]; -LABEL_100: - a4 = v52; - v124 = 81; - break; - case 6u: - v53 = pGlobalTXT_LocalizationStrings[593]; - v124 = 35; - goto LABEL_103; - case 8u: - v53 = pGlobalTXT_LocalizationStrings[608]; - v124 = 62; -LABEL_103: - a4 = v53; - break; - case 7u: - case 9u: - a4 = 0; - v124 = 0; - goto LABEL_119; - case 0xAu: - v124 = 47; - a4 = pGlobalTXT_LocalizationStrings[221]; - break; - case 0xBu: - v124 = 66; - a4 = pGlobalTXT_LocalizationStrings[607]; - break; - case 0xCu: - v124 = 85; - a4 = pGlobalTXT_LocalizationStrings[610]; - break; - case 0xDu: - v124 = 86; - a4 = pGlobalTXT_LocalizationStrings[609]; - break; - case 0xEu: - v124 = 17; - a4 = pGlobalTXT_LocalizationStrings[279]; - break; - case 0xFu: - v124 = 38; - a4 = pGlobalTXT_LocalizationStrings[442]; - break; - case 0x10u: - v124 = 46; - a4 = pGlobalTXT_LocalizationStrings[443]; - break; - case 0x11u: - v124 = 51; - a4 = pGlobalTXT_LocalizationStrings[440]; - break; - case 0x12u: - v124 = 5; - a4 = pGlobalTXT_LocalizationStrings[441]; - break; - case 0x13u: - v124 = 95; - a4 = pGlobalTXT_LocalizationStrings[229]; - break; - case 0x14u: - v124 = 73; - a4 = pGlobalTXT_LocalizationStrings[228]; - break; - default: - a4 = 0; - break; - } - if ( a4 ) - { - v54 = a4; - v55 = GetSpellColor(v124); - a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0); - v50 = v50 + BYTE5(a2->pConditions[0]) - 3; - v51 = v120; - } - } -LABEL_119: - ++v51; - v222 = (IDirectDrawSurface *)((char *)v222 + 1); - v120 = v51; - - __debugbreak(); // fix condition - } - //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 ); - while (true); - if ( !a4 ) - { - v78 = 0; - v74 = 0; - v69 = 0; - v66 = pGlobalTXT_LocalizationStrings[153]; -LABEL_123: - a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); + a4 = 0; + v51 = &v121->pActorBuffs[1]; + v222 = 0; + v120 = &v121->pActorBuffs[1]; + do + { + if ( (signed __int64)v51->uExpireTime > 0 ) + { + switch ( (int)v51 ) + { + case 0u: + v124 = 60; + a4 = pGlobalTXT_LocalizationStrings[591]; + break; + case 1u: + v124 = 82; + a4 = pGlobalTXT_LocalizationStrings[649]; + break; + case 2u: + v124 = 92; + a4 = pGlobalTXT_LocalizationStrings[592]; + break; + case 3u: + v124 = 63; + a4 = pGlobalTXT_LocalizationStrings[4]; + break; + case 4u: + v52 = pGlobalTXT_LocalizationStrings[220]; + a4 = v52; + v124 = 81; + break; + case 5u: + v52 = pGlobalTXT_LocalizationStrings[162]; + a4 = v52; + v124 = 81; + break; + case 6u: + v53 = pGlobalTXT_LocalizationStrings[593]; + v124 = 35; + a4 = v53; + break; + case 8u: + v53 = pGlobalTXT_LocalizationStrings[608]; + v124 = 62; + a4 = v53; + break; + case 7u: + case 9u: + a4 = 0; + v124 = 0; + ++v51; + v222 = (IDirectDrawSurface *)((char *)v222 + 1); + v120 = v51; + __debugbreak(); // fix condition + continue; + case 0xAu: + v124 = 47; + a4 = pGlobalTXT_LocalizationStrings[221]; + break; + case 0xBu: + v124 = 66; + a4 = pGlobalTXT_LocalizationStrings[607]; + break; + case 0xCu: + v124 = 85; + a4 = pGlobalTXT_LocalizationStrings[610]; + break; + case 0xDu: + v124 = 86; + a4 = pGlobalTXT_LocalizationStrings[609]; + break; + case 0xEu: + v124 = 17; + a4 = pGlobalTXT_LocalizationStrings[279]; + break; + case 0xFu: + v124 = 38; + a4 = pGlobalTXT_LocalizationStrings[442]; + break; + case 0x10u: + v124 = 46; + a4 = pGlobalTXT_LocalizationStrings[443]; + break; + case 0x11u: + v124 = 51; + a4 = pGlobalTXT_LocalizationStrings[440]; + break; + case 0x12u: + v124 = 5; + a4 = pGlobalTXT_LocalizationStrings[441]; + break; + case 0x13u: + v124 = 95; + a4 = pGlobalTXT_LocalizationStrings[229]; + break; + case 0x14u: + v124 = 73; + a4 = pGlobalTXT_LocalizationStrings[228]; + break; + default: + a4 = 0; + break; + } + if ( a4 ) + { + v54 = a4; + v55 = GetSpellColor(v124); + a1->DrawText((GUIFont *)a2, 28, v50, v55, v54, 0, 0, 0); + v50 = v50 + BYTE5(a2->pConditions[0]) - 3; + v51 = v120; + } + } + + ++v51; + v222 = (IDirectDrawSurface *)((char *)v222 + 1); + v120 = v51; + + __debugbreak(); // fix condition + } + //while ( (signed int)((char *)&v222->lpVtbl + 1) < 22 ); + while (true); + if ( !a4 ) + { + v78 = 0; + v74 = 0; + v69 = 0; + v66 = pGlobalTXT_LocalizationStrings[153]; + a1->DrawText((GUIFont *)a2, 28, v50, a5, v66, v69, v74, v78); + } } v56 = pFontSmallnum; a4 = (char *)v106.uViewportY; @@ -3384,42 +3391,47 @@ v76 = 0; v71 = pGlobalTXT_LocalizationStrings[628]; v68 = "%s\f%05u\t080%s\n"; - goto LABEL_144; - } - v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628]; - v59 = v121; - v114 = v121->pMonsterInfo.uSpell1ID; - if ( v114 && v121->pMonsterInfo.uSpell2ID ) - v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629]; - if ( v114 ) - { - sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); - v58 = LOBYTE(v56->uFontHeight); - a4 = &a4[v58 - 3]; - v59 = v121; - } - v60 = v59->pMonsterInfo.uSpell2ID; - if ( v60 ) - { - sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName); - a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); - v58 = LOBYTE(v56->uFontHeight); - a4 = &a4[v58 - 3]; - v59 = v121; - } - if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID ) - { - v80 = pGlobalTXT_LocalizationStrings[153]; - v76 = 0; - v71 = pGlobalTXT_LocalizationStrings[628]; - v68 = "%s\f%05u\t060%s\n"; -LABEL_144: sprintf(pTmpBuf, v68, v71, v76, v80); a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); v58 = LOBYTE(v56->uFontHeight); a4 = &a4[v58 - 3]; } + else + { + v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[628]; + v59 = v121; + v114 = v121->pMonsterInfo.uSpell1ID; + if ( v114 && v121->pMonsterInfo.uSpell2ID ) + v120 = (SpellBuff *)pGlobalTXT_LocalizationStrings[629]; + if ( v114 ) + { + sprintf(pTmpBuf, "%s\f%05u\t060%s\n", v120, 0, pSpellStats->pInfos[v114].pShortName); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = &a4[v58 - 3]; + v59 = v121; + } + v60 = v59->pMonsterInfo.uSpell2ID; + if ( v60 ) + { + sprintf(pTmpBuf, "\f%05u\t060%s\n", 0, pSpellStats->pInfos[v60].pShortName); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = &a4[v58 - 3]; + v59 = v121; + } + if ( !v59->pMonsterInfo.uSpell1ID && !v59->pMonsterInfo.uSpell2ID ) + { + v80 = pGlobalTXT_LocalizationStrings[153]; + v76 = 0; + v71 = pGlobalTXT_LocalizationStrings[628]; + v68 = "%s\f%05u\t060%s\n"; + sprintf(pTmpBuf, v68, v71, v76, v80); + a1->DrawText(v56, 150, (int)a4, a5, pTmpBuf, 0, 0, 0); + v58 = LOBYTE(v56->uFontHeight); + a4 = &a4[v58 - 3]; + } + } a4 = &a4[v58 - 3]; a1->DrawText(v56, 150, (int)a4, a5, pGlobalTXT_LocalizationStrings[626], 0, 0, 0); a4 = &a4[LOBYTE(v56->uFontHeight) - 3]; @@ -4322,9 +4334,131 @@ return; } v1 = uNumVisibleWindows; - if ( uNumVisibleWindows <= 0 ) + if ( uNumVisibleWindows > 0 ) { -LABEL_38: + while ( 1 ) // some other fullscreen ui + { + pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1]; + if ( (signed int)pX >= (signed int)pWindow->uFrameX + && (signed int)pX <= (signed int)pWindow->uFrameZ + && (signed int)pY >= (signed int)pWindow->uFrameY + && (signed int)pY <= (signed int)pWindow->uFrameW ) + { + for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext ) + { + if ( !pButton ) + break; + if ( pButton->uButtonType == 1 ) + { + if ( (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + { + //LABEL_24: + pMessageType1 = (UIMessageType)pButton->field_1C; + if ( pMessageType1 ) + { + v12 = pButton->uControlParam; + pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + //LABEL_27: + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + } + //LABEL_28: + v13 = pButton->pButtonName; + //_set_status_and_ret: + sub_41C0B8_set_status_string(v13); + //LABEL_131: + uLastPointedObjectID = 1; + return; + } + } + else + { + if ( pButton->uButtonType == 2 ) + { + v45 = pX - pButton->uX; + v45 = pY - pButton->uY; + if ( (double)(signed int)pButton->uWidth != 0.0 ) + { + if ( (double)(signed int)pButton->uHeight != 0.0 ) + { + //UNDEF(v8); + //if ( v9 | v10 ) + //goto LABEL_24; + //{ + pMessageType1 = (UIMessageType)pButton->field_1C; + if ( pMessageType1 ) + { + v12 = pButton->uControlParam; + pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0); + /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) + { + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1; + pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; + *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; + ++pMessageQueue_50CBD0->uNumMessages; + }*/ + } + v13 = pButton->pButtonName; + sub_41C0B8_set_status_string(v13); + uLastPointedObjectID = 1; + return; + //} + } + } + } + else // click on skill + { + if ( pButton->uButtonType == 3 + && (signed int)pX >= (signed int)pButton->uX + && (signed int)pX <= (signed int)pButton->uZ + && (signed int)pY >= (signed int)pButton->uY + && (signed int)pY <= (signed int)pButton->uW ) + { + //LABEL_19: + pPlayer = pPlayers[uActiveCharacter]; + v5 = LOBYTE(pPlayer->pActiveSkills[pButton->uControlParam]); + v6 = pPlayer->uSkillPoints; + v7 = (v5 & 0x3F) + 1; + if ( v6 < v7 ) + { + v41 = v7 - v6; + v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" + } + else + { + v41 = v7; + v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" + } + sprintf(Str1, v39, v41); + v13 = Str1; + //goto _set_status_and_ret; + sub_41C0B8_set_status_string(v13); + uLastPointedObjectID = 1; + return; + } + } + } + } + } + if ( pWindow->uFrameHeight == 480 ) + break; + --v1; + if ( v1 <= 0 ) + { + break; + } + } + } + if ( uNumVisibleWindows <= 0 || (uNumVisibleWindows > 0 && pWindow->uFrameHeight != 480 && v1 <= 0)) + { if ( pCurrentScreen == SCREEN_CHEST ) { sub_42038D(); @@ -4537,126 +4671,6 @@ uLastPointedObjectID = pMouse->uPointingObjectID; return; } - while ( 1 ) // some other fullscreen ui - { - pWindow = &pWindowList[pVisibleWindowsIdxs[v1] - 1]; - if ( (signed int)pX >= (signed int)pWindow->uFrameX - && (signed int)pX <= (signed int)pWindow->uFrameZ - && (signed int)pY >= (signed int)pWindow->uFrameY - && (signed int)pY <= (signed int)pWindow->uFrameW ) - { - for ( pButton = pWindow->pControlsHead; ; pButton = pButton->pNext ) - { - if ( !pButton ) - break; - if ( pButton->uButtonType == 1 ) - { - if ( (signed int)pX >= (signed int)pButton->uX - && (signed int)pX <= (signed int)pButton->uZ - && (signed int)pY >= (signed int)pButton->uY - && (signed int)pY <= (signed int)pButton->uW ) - { -//LABEL_24: - pMessageType1 = (UIMessageType)pButton->field_1C; - if ( pMessageType1 ) - { - v12 = pButton->uControlParam; - pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; -//LABEL_27: - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - } -//LABEL_28: - v13 = pButton->pButtonName; -//_set_status_and_ret: - sub_41C0B8_set_status_string(v13); -//LABEL_131: - uLastPointedObjectID = 1; - return; - } - } - else - { - if ( pButton->uButtonType == 2 ) - { - v45 = pX - pButton->uX; - v45 = pY - pButton->uY; - if ( (double)(signed int)pButton->uWidth != 0.0 ) - { - if ( (double)(signed int)pButton->uHeight != 0.0 ) - { - //UNDEF(v8); - //if ( v9 | v10 ) - //goto LABEL_24; - //{ - pMessageType1 = (UIMessageType)pButton->field_1C; - if ( pMessageType1 ) - { - v12 = pButton->uControlParam; - pMessageQueue_50CBD0->AddMessage(pMessageType1, v12, 0); - /*if ( (signed int)pMessageQueue_50CBD0->uNumMessages < 40 ) - { - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].eType = pMessageType1; - pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = v12; - *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; - ++pMessageQueue_50CBD0->uNumMessages; - }*/ - } - v13 = pButton->pButtonName; - sub_41C0B8_set_status_string(v13); - uLastPointedObjectID = 1; - return; - //} - } - } - } - else // click on skill - { - if ( pButton->uButtonType == 3 - && (signed int)pX >= (signed int)pButton->uX - && (signed int)pX <= (signed int)pButton->uZ - && (signed int)pY >= (signed int)pButton->uY - && (signed int)pY <= (signed int)pButton->uW ) - { -//LABEL_19: - pPlayer = pPlayers[uActiveCharacter]; - v5 = LOBYTE(pPlayer->pActiveSkills[pButton->uControlParam]); - v6 = pPlayer->uSkillPoints; - v7 = (v5 & 0x3F) + 1; - if ( v6 < v7 ) - { - v41 = v7 - v6; - v39 = pGlobalTXT_LocalizationStrings[469];// "You need %d more Skill Points to advance here" - } - else - { - v41 = v7; - v39 = pGlobalTXT_LocalizationStrings[468];// "Clicking here will spend %d Skill Points" - } - sprintf(Str1, v39, v41); - v13 = Str1; - //goto _set_status_and_ret; - sub_41C0B8_set_status_string(v13); - uLastPointedObjectID = 1; - return; - } - } - } - } - } - if ( pWindow->uFrameHeight == 480 ) - break; - --v1; - if ( v1 <= 0 ) - { - goto LABEL_38; - } - } } @@ -4878,14 +4892,13 @@ if (!player->CanAct()) { - if ( pPlayers[uActiveCharacter]->CanAct()) - goto LABEL_9; player = pPlayers[uActiveCharacter]; } - player->PlaySound(SPEECH_NoRoom, 0); + if(player->CanAct() || !pPlayers[uActiveCharacter]->CanAct()) + player->PlaySound(SPEECH_NoRoom, 0); } -LABEL_9: +//LABEL_9: if (pCurrentScreen == SCREEN_GAME) { viewparams->bRedrawGameUI = true; @@ -5045,7 +5058,8 @@ memcpy(&pParty->pPickedItem, &v0->pInventoryItems[v8-1], sizeof(pParty->pPickedItem)); v0->RemoveItemAtInventoryIndex(a4); v9 = pParty->pPickedItem.uItemID; - goto LABEL_24; + pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); + return; } v13 = v8; if ( v8 ) @@ -5066,7 +5080,6 @@ } v9 = this_.uItemID; memcpy(&pParty->pPickedItem, &this_, sizeof(pParty->pPickedItem)); -LABEL_24: pMouse->SetCursorBitmap(pItemsTable->pItems[v9].pIconName); return; } @@ -5152,7 +5165,10 @@ SpriteObject::OnInteraction(a2.y); return; } - goto LABEL_13; + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; } if ( (v0 & 7) != OBJECT_Actor) { @@ -5160,7 +5176,12 @@ { v13 = &pLevelDecorations[(signed int)(unsigned __int16)v0 >> 3]; if ( (signed int)(((unsigned int)v0 >> 16) - pDecorationList->pDecorations[v13->uDecorationDescID].uRadius) >= 512 ) - goto LABEL_13; + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } v14 = v13->field_16_event_id; if ( !v14 ) { @@ -5178,7 +5199,12 @@ else { if ( (v0 & 7) != OBJECT_BModel || (unsigned int)v0 >= 0x2000000 ) - goto LABEL_13; + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } v2 = (signed int)(unsigned __int16)v0 >> 3; if ( uCurrentlyLoadedLevelType == LEVEL_Indoor) { @@ -5186,61 +5212,61 @@ if ( !(v3->uAttributes & 0x2000000) ) { LABEL_11: - v4 = pParty->pPickedItem.uItemID; - if ( pParty->pPickedItem.uItemID ) - { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + { + ShowNothingHereStatus(); + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + } LABEL_14: - v5 = pItemsTable->pItems[v4].uSpriteID; - v6 = 0; - a1.uType = v5; - if ( (signed int)pObjectList->uNumObjects <= 0 ) - { -LABEL_18: - LOWORD(v6) = 0; - } - else - { - v7 = (char *)&pObjectList->pObjects->uObjectID; - while ( v5 != *(short *)v7 ) - { - ++v6; - v7 += 56; - if ( v6 >= (signed int)pObjectList->uNumObjects ) - goto LABEL_18; - } - } - a1.uObjectDescID = v6; - a1.vPosition.y = pParty->vPosition.y; - a1.field_58_pid = OBJECT_Player; - a1.vPosition.x = pParty->vPosition.x; - a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; - a1.uSoundID = 0; - a1.uFacing = 0; - a1.uAttributes = 8; - a1.uSectorID = pIndoor->GetSector( - pParty->vPosition.x, - pParty->vPosition.y, - pParty->sEyelevel + pParty->vPosition.z); - a1.uSpriteFrameID = 0; - memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); - v8 = (int *)pMouse->GetCursorPos(&v25); - v9 = UnprojectX(*v8); - a1.Create(pParty->sRotationY + v9, 184, 200, 0); - v10 = pIcons_LOD->LoadTexture( - pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, - TEXTURE_16BIT_PALETTE); - if (v10 != -1) - pIcons_LOD->pTextures[v10].Release(); - pMouse->RemoveHoldingItem(); - pIcons_LOD->_40F9C5(); - return; - } - ShowNothingHereStatus(); -LABEL_13: - v4 = pParty->pPickedItem.uItemID; - if ( !pParty->pPickedItem.uItemID ) - return; - goto LABEL_14; + v5 = pItemsTable->pItems[v4].uSpriteID; + v6 = 0; + a1.uType = v5; + if ( (signed int)pObjectList->uNumObjects <= 0 ) + { + LOWORD(v6) = 0; + } + else + { + v7 = (char *)&pObjectList->pObjects->uObjectID; + while ( v5 != *(short *)v7 ) + { + ++v6; + v7 += 56; + if ( v6 >= (signed int)pObjectList->uNumObjects ) + { + LOWORD(v6) = 0; + break; + } + } + } + a1.uObjectDescID = v6; + a1.vPosition.y = pParty->vPosition.y; + a1.field_58_pid = OBJECT_Player; + a1.vPosition.x = pParty->vPosition.x; + a1.vPosition.z = pParty->sEyelevel + pParty->vPosition.z; + a1.uSoundID = 0; + a1.uFacing = 0; + a1.uAttributes = 8; + a1.uSectorID = pIndoor->GetSector( + pParty->vPosition.x, + pParty->vPosition.y, + pParty->sEyelevel + pParty->vPosition.z); + a1.uSpriteFrameID = 0; + memcpy(&a1.stru_24, &pParty->pPickedItem, 0x24u); + v8 = (int *)pMouse->GetCursorPos(&v25); + v9 = UnprojectX(*v8); + a1.Create(pParty->sRotationY + v9, 184, 200, 0); + v10 = pIcons_LOD->LoadTexture( + pItemsTable->pItems[pParty->pPickedItem.uItemID].pIconName, + TEXTURE_16BIT_PALETTE); + if (v10 != -1) + pIcons_LOD->pTextures[v10].Release(); + pMouse->RemoveHoldingItem(); + pIcons_LOD->_40F9C5(); + return; } v11 = pIndoor->pFaceExtras[v3->uFaceExtraID].uEventID; } @@ -5265,14 +5291,22 @@ stru_50C198.LootActor(&pActors[v16]); return; } - goto LABEL_13; + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; } if ( GetAsyncKeyState(VK_SHIFT) >= 0 ) { if ( !v17->GetActorsRelation(0) && !(BYTE2(v17->uAttributes) & 8) ) { if ( (unsigned int)v0 >= 0x2000000 ) - goto LABEL_13; + { + v4 = pParty->pPickedItem.uItemID; + if ( !pParty->pPickedItem.uItemID ) + return; + goto LABEL_14; + } if ( !v17->CanAct() ) return; v18 = a2.y; diff -r c615ff03b144 -r 7bae884b7cd0 mm7_2.cpp --- a/mm7_2.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/mm7_2.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -3247,7 +3247,8 @@ v22 = 0; v21 = (SoundID)11090; } - goto LABEL_40; + pAudioPlayer->PlaySound(v21, v22, v23, v24, v25, v27, v29, v31); + return 0; } if ( a1 == 10 ) { @@ -3828,37 +3829,31 @@ { //v3 = p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C]; v3 = p2DEvents[window_SpeakInHouse->par1C - 1].uType; - if ( v3 < 5 ) - goto LABEL_12; - if ( v3 <= 13 ) - { - v0 = rand() % word_4F0F30[(signed int)v1] - //+ 11 * p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C] - + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType - + 345; - } - else - { - if ( v3 == 14 ) - { - v4 = rand() % 4; - } - else - { - if ( v3 == 15 ) - { - v4 = rand() % 3 + 4; - } - else - { - if ( v3 != 16 ) - goto LABEL_12; - v4 = rand() % 2 + 7; - } - } - v0 = rand() % word_4F0F30[(signed int)v1] + 11 * v4 + 400; - } -LABEL_12: + if ( v3 >= 5 ) + { + if ( v3 <= 13 ) + { + v0 = rand() % word_4F0F30[(signed int)v1] + //+ 11 * p2DEvents_minus1___00[26 * (unsigned int)ptr_507BC0->ptr_1C] + + 11 * p2DEvents[(unsigned int)window_SpeakInHouse->ptr_1C - 1].uType + + 345; + } + else + { + if ( v3 == 14 ) + { + v4 = rand() % 4; + } + else if ( v3 == 15 ) + { + v4 = rand() % 3 + 4; + } + else if ( v3 == 16 ) + v4 = rand() % 2 + 7; + if( v3 <= 16 ) + v0 = rand() % word_4F0F30[(signed int)v1] + 11 * v4 + 400; + } + } if ( v0 == 487 ) { if ( !(unsigned __int16)_449B57_test_bit(pParty->_quest_bits, 239) ) @@ -3958,58 +3953,72 @@ pRenderer->ClearZBuffer(0, 479); //v3 = dword_F8B198; if ( dword_F8B19C != 1 ) - goto LABEL_13; - if ( in_current_building_type == BildingType_Training ) - { - if ( uMessageParam == 17 ) - { - v4 = 0; - v5 = 0; - //v6 = pPlayers[uActiveCharacter]; - //v7 = pPlayers[uActiveCharacter]->uLevel; - if ( pPlayers[uActiveCharacter]->uLevel > 0 ) - { - do - v4 += v5++ + 1; - while ( v5 < pPlayers[uActiveCharacter]->uLevel ); - } - if ( pPlayers[uActiveCharacter]->uLevel < (unsigned __int16)word_4F0866[(unsigned int)window_SpeakInHouse->ptr_1C] - && (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * v4 ) - return; - } - goto LABEL_9; - } - v8 = window_SpeakInHouse; - if ( (in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) - && (v1 = 0, *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + uMessageParam)] + pParty->uDaysPlayed % 7)) - || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) - { -LABEL_9: - pDialogueWindow->Release(); - pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, v1, v1); - pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, v1, 0x71u, v1, v1, pGlobalTXT_LocalizationStrings[74],// "End Conversation" - (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), v1); - pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1); -LABEL_10: - //v3 = dword_F8B198; - v8 = window_SpeakInHouse; - goto LABEL_11; - } - if ( uActiveCharacter != v1 ) - { - if ( !pPlayers[uActiveCharacter]->_4B6FF9() ) - return; - goto LABEL_10; - } -LABEL_11: - dword_F8B19C = uMessageParam; - if ( in_current_building_type < BildingType_19 ) - { - v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); - //v3 = dword_F8B198; - ShopTexture = &pIcons_LOD->pTextures[v9]; -LABEL_13: - v8 = window_SpeakInHouse; + { + v8 = window_SpeakInHouse; + } + else + { + if ( in_current_building_type == BildingType_Training ) + { + if ( uMessageParam == 17 ) + { + v4 = 0; + v5 = 0; + //v6 = pPlayers[uActiveCharacter]; + //v7 = pPlayers[uActiveCharacter]->uLevel; + if ( pPlayers[uActiveCharacter]->uLevel > 0 ) + { + do + v4 += v5++ + 1; + while ( v5 < pPlayers[uActiveCharacter]->uLevel ); + } + if ( pPlayers[uActiveCharacter]->uLevel < (unsigned __int16)word_4F0866[(unsigned int)window_SpeakInHouse->ptr_1C] + && (signed __int64)pPlayers[uActiveCharacter]->uExperience < 1000 * v4 ) + return; + } + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, v1, v1); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, v1, 0x71u, v1, v1, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), v1); + pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1); +// LABEL_10: + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + } + else + { + v8 = window_SpeakInHouse; + if ( (in_current_building_type == BildingType_Stables || in_current_building_type == BildingType_Boats) + && (v1 = 0, *(&byte_4F09B1[32 * (unsigned __int8)*(&byte_4F0CCF[4 * (unsigned int)window_SpeakInHouse->ptr_1C] + uMessageParam)] + pParty->uDaysPlayed % 7)) + || in_current_building_type != BildingType_Temple || uMessageParam != BildingType_MindGuild ) + { + //LABEL_9: + pDialogueWindow->Release(); + pDialogueWindow = GUIWindow::Create(0, 0, 640, 0x159u, WINDOW_MainMenu, v1, v1); + pBtn_ExitCancel = pDialogueWindow->CreateButton(526, 445, 75, 33, 1, v1, 0x71u, v1, v1, pGlobalTXT_LocalizationStrings[74],// "End Conversation" + (Texture *)(uTextureID_BUTTDESC2 != -1 ? (int)&pIcons_LOD->pTextures[uTextureID_BUTTDESC2] : 0), v1); + pDialogueWindow->CreateButton(8u, 8u, 0x1C2u, 0x140u, 1, v1, 0x51u, v1, v1, "", (Texture *)v1); + // LABEL_10: + //v3 = dword_F8B198; + v8 = window_SpeakInHouse; + } + else if ( uActiveCharacter != v1 ) + { + if ( !pPlayers[uActiveCharacter]->_4B6FF9() ) + return; + v8 = window_SpeakInHouse; + } + } + //LABEL_11: + dword_F8B19C = uMessageParam; + if ( in_current_building_type < BildingType_19 ) + { + v9 = pIcons_LOD->LoadTexture(off_4F03B8[in_current_building_type], TEXTURE_16BIT_PALETTE); + //v3 = dword_F8B198; + ShopTexture = &pIcons_LOD->pTextures[v9]; + //LABEL_13: + v8 = window_SpeakInHouse; + } } if ( in_current_building_type > BildingType_Tavern ) { @@ -4263,12 +4272,10 @@ v1 = 0; dword_F8B1A4 = pNPCTopics[352].pText; } - goto LABEL_196; - } - if ( uMessageParam == 100 ) + } + else if ( uMessageParam == 100 ) { pKeyActionMap->EnterText(1, 10, v8); - goto LABEL_196; } } } @@ -4527,7 +4534,7 @@ if ( v0 == -1 ) { _4B4224_UpdateNPCTopics((int)((char *)pDialogueNPCCount - 1)); -LABEL_33: +//LABEL_33: pVideoPlayer->_4BF5B2(); return 1; } @@ -4544,7 +4551,7 @@ if ( v0 != 102 && v0 != 103 && v0 != 104 ) { pVideoPlayer->_4BF5B2(); -LABEL_28: +//LABEL_28: dword_F8B19C = 1; sub_4B3B42(in_current_building_type); return 1; @@ -4558,7 +4565,9 @@ } pVideoPlayer->_4BF5B2(); UI_CreateEndConversationButton(); - goto LABEL_28; + dword_F8B19C = 1; + sub_4B3B42(in_current_building_type); + return 1; } pDialogueNPCCount = 0; pDialogueWindow->Release(); @@ -4583,7 +4592,8 @@ } while ( (signed int)v2 < uNumDialogueNPCPortraits ); } - goto LABEL_33; + pVideoPlayer->_4BF5B2(); + return 1; } } return 0; @@ -4682,7 +4692,10 @@ v0 = pPlayers[uActiveCharacter]; v77 = pPlayers[uActiveCharacter]; if ( pCurrentScreen == SCREEN_E ) - goto LABEL_73; + { + sub_421EA6_OnInventoryLeftClick(); + return; + } if ( !sub_4B1784_check_if_player_concious__draw_warning_else_mess_with_dlg_win() ) { v56 = 0; @@ -4692,7 +4705,8 @@ v48 = -1; v47 = 0; v46 = 0; - goto LABEL_87; + pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56); + return; } if ( dword_F8B19C > 18 ) { @@ -4719,14 +4733,17 @@ v55 = 4; else v55 = 2; - goto LABEL_84; + HousePlaySomeSound((unsigned int)v13, v55); + return; } Party::TakeGold(v44); v53 = 0; dword_F8B1E4 = 1; *pSkill = 1; v51 = 78; - goto LABEL_80; + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } } return; @@ -4738,7 +4755,7 @@ goto LABEL_49; } pWindowList_at_506F50_minus1_indexing_buttons____and_an_int_[0] = 103; -LABEL_73: +//LABEL_73: sub_421EA6_OnInventoryLeftClick(); return; } @@ -4760,11 +4777,12 @@ if ( pParty->uNumGold < v23 ) { v24 = 2; -LABEL_62: +//LABEL_62: HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v24); v9 = pGlobalTXT_LocalizationStrings[155]; v54 = 2; - goto LABEL_71; + ShowStatusBarString(v9, v54); + return; } v25 = v0->AddItem(0xFFFFFFFFu, v20->uItemID); if ( v25 ) @@ -4772,13 +4790,23 @@ v26 = 1; v20->SetIdentified(); memcpy(&v0->pInventoryItems[v25-1], v20, 0x24u); - goto LABEL_42; + dword_F8B1E4 = v26; + Party::TakeGold(v80); + viewparams->bRedrawGameUI = v26; + _this->Reset(); + pRenderer->ClearZBuffer(0, 479); + v27 = v77; + v53 = 0; + v51 = SPEECH_75; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } v0->PlaySound(SPEECH_NoRoom, 0); v54 = 5; -LABEL_70: +//LABEL_70: v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" - goto LABEL_71; + ShowStatusBarString(v9, v54); + return; } if ( dword_F8B19C == 2 ) { @@ -4832,7 +4860,13 @@ if ( uNumSeconds != 2 ) { if ( uNumSeconds != 1 ) - goto LABEL_62; + { + HousePlaySomeSound((unsigned int)window_SpeakInHouse->ptr_1C, v24); + v9 = pGlobalTXT_LocalizationStrings[155]; + v54 = 2; + ShowStatusBarString(v9, v54); + return; + } } } v39 = v0->AddItem(0xFFFFFFFFu, v32->uItemID); @@ -4851,27 +4885,36 @@ { *(char *)(v40 + 517) |= 1u; sub_4B1447_party_fine((int)window_SpeakInHouse->ptr_1C, v41, a6); - goto LABEL_43; - } - } - } -LABEL_42: + viewparams->bRedrawGameUI = v26; + _this->Reset(); + pRenderer->ClearZBuffer(0, 479); + v27 = v77; + v53 = 0; + v51 = SPEECH_75; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } + } + } +//LABEL_42: dword_F8B1E4 = v26; Party::TakeGold(v80); -LABEL_43: +//LABEL_43: viewparams->bRedrawGameUI = v26; _this->Reset(); pRenderer->ClearZBuffer(0, 479); v27 = v77; v53 = 0; v51 = SPEECH_75; -LABEL_81: +//LABEL_81: v27->PlaySound((PlayerSpeech)v51, v53); return; } v0->PlaySound(SPEECH_NoRoom, 0); v54 = 2; - goto LABEL_70; + v9 = pGlobalTXT_LocalizationStrings[563]; // "Pack is Full!" + ShowStatusBarString(v9, v54); + return; } if ( dword_F8B19C == 3 ) { @@ -4890,8 +4933,10 @@ pRenderer->ClearZBuffer(0, 479); v53 = 0; v51 = 77; - goto LABEL_80; - } + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } v0->PlaySound(SPEECH_79, 0); v56 = 0; v52 = 0; @@ -4900,7 +4945,7 @@ v48 = -1; v47 = 0; v46 = 0; -LABEL_87: +//LABEL_87: pAudioPlayer->PlaySound(SOUND_27, v46, v47, v48, v49, v50, v52, v56); return; } @@ -4930,19 +4975,29 @@ *(int *)(v12 + 20) |= 1u; v0->PlaySound(SPEECH_73, 0); v9 = pGlobalTXT_LocalizationStrings[569]; - goto LABEL_25; + v54 = 2; + ShowStatusBarString(v9, v54); + return; } - goto LABEL_26; + v13 = _this; + v55 = 2; + HousePlaySomeSound((unsigned int)v13, v55); + return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); v53 = 0; - goto LABEL_28; + v51 = 79; + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } v53 = 0; -LABEL_30: +//LABEL_30: v51 = 76; - goto LABEL_80; - } + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } } } } @@ -4983,30 +5038,34 @@ *(int *)(v3 + 20) = v8 | 1; v0->PlaySound(SPEECH_74, 0); v9 = pGlobalTXT_LocalizationStrings[570]; -LABEL_25: +//LABEL_25: v54 = 2; -LABEL_71: +//LABEL_71: ShowStatusBarString(v9, v54); return; } -LABEL_26: +//LABEL_26: v13 = _this; v55 = 2; -LABEL_84: +//LABEL_84: HousePlaySomeSound((unsigned int)v13, v55); return; } pAudioPlayer->PlaySound(SOUND_27, 0, 0, -1, 0, 0, 0, 0); v53 = 0; -LABEL_28: +//LABEL_28: v51 = 79; -LABEL_80: +//LABEL_80: v27 = v0; - goto LABEL_81; + v27->PlaySound((PlayerSpeech)v51, v53); + return; } v53 = 0; - goto LABEL_30; - } + v51 = 76; + v27 = v0; + v27->PlaySound((PlayerSpeech)v51, v53); + return; + } } } } @@ -5130,15 +5189,26 @@ *v2 = v5; if ( !v5 ) { -LABEL_23: +//LABEL_23: *v2 = 0; break; } if ( v5 == ',' ) { if ( v3 ) - goto LABEL_18; - *v2 = 0; + { + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 0; + } + else + { + *v2 = 0; + v4 = 1; + } } else { @@ -5161,35 +5231,50 @@ ++stru_F8B5E8.field_0; } } - goto LABEL_21; - } -LABEL_18: - if ( v4 ) - { - stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; - ++stru_F8B5E8.field_0; - } - v4 = 0; - goto LABEL_21; - } - if ( v3 ) - goto LABEL_18; - *v2 = 0; - if ( v4 ) - { - stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; - ++stru_F8B5E8.field_0; - } - } - v4 = 1; -LABEL_21: + } + else + { +//LABEL_18: + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 0; + } + } + else + { + if ( v3 ) + { + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 0; + } + else + { + *v2 = 0; + if ( v4 ) + { + stru_F8B5E8.pProperties[stru_F8B5E8.field_0] = v2; + ++stru_F8B5E8.field_0; + } + v4 = 1; + } + } + } +//LABEL_21: if ( stru_F8B5E8.field_0 < 30 ) { ++v2; if ( (unsigned int)v2 < (unsigned int)&unk_F8B5E0 ) continue; } - goto LABEL_23; + *v2 = 0; + break; } } result = a2; @@ -11616,8 +11701,6 @@ pIcons_LOD->_4114F2(); } - - //----- (004637EB) -------------------------------------------------------- int __stdcall aWinProc(HWND hWnd, UINT Msg, WPARAM wParam, unsigned int lParam) { @@ -13166,7 +13249,7 @@ if ( ReadWindowsRegistryInt("Bloodsplats", 1) ) pGame->uFlags2 |= GAME_FLAGS_2_DRAW_BLOODSPLATS; else - pGame->uFlags2 &= ~GAME_FLAGS_2_DRAW_BLOODSPLATS; + pGame->uFlags2 &= GAME_FLAGS_2_DRAW_BLOODSPLATS; uTurnSpeed = ReadWindowsRegistryInt("TurnDelta", 0); dword_6BE384_2dacceloff = ReadWindowsRegistryInt("2dacceloff", 0); diff -r c615ff03b144 -r 7bae884b7cd0 mm7_5.cpp --- a/mm7_5.cpp Wed Mar 06 20:15:47 2013 +0600 +++ b/mm7_5.cpp Wed Mar 06 20:16:06 2013 +0600 @@ -15978,6 +15978,8 @@ v9 = pX + pSRZBufferLineOffsets[pY]; if ( pRenderer->pActiveZBuffer[v9] & 0xFFFF ) { + + __debugbreak(); // invalid indexing will result in invalid object ptr v8 = (ItemGen *)(&pOtherOverlayList->pOverlays[49].field_4 + 2662 * (unsigned int)pChestWindow->ptr_1C + 18* *((short *)&pChests[0].igChestItems[139].uExpireTime + (pRenderer->pActiveZBuffer[v9] & 0xFFFF) + 2662 * (unsigned int)pChestWindow->ptr_1C + 3)); GameUI_DrawItemInfo(v8); @@ -16025,10 +16027,6 @@ pAudioPlayer->StopChannels(-1, -1); v3 = (void *)1; } - else - { - sub_416B01(v3); - } } else {