Mercurial > might-and-magic-trilogy
diff mm7_4.cpp @ 47:8a8dd0164b12
BLV render
cd check fix
author | Nomad |
---|---|
date | Tue, 23 Oct 2012 13:51:21 +0200 |
parents | 79a30ee1ecdb |
children | 25fabc49627b fde5c5acb66e |
line wrap: on
line diff
--- a/mm7_4.cpp Mon Oct 22 20:54:14 2012 +0200 +++ b/mm7_4.cpp Tue Oct 23 13:51:21 2012 +0200 @@ -3065,12 +3065,6 @@ //----- (00491F87) -------------------------------------------------------- void __cdecl DrawHiredNPCs() { - int v0; // ecx@2 - char *v1; // eax@2 - int v2; // edx@4 - signed int v3; // ebx@6 - char *v4; // esi@7 - int v5; // ecx@13 int v6; // eax@15 char v7; // al@17 unsigned int v8; // eax@18 @@ -3081,7 +3075,7 @@ unsigned int v13; // eax@23 IconFrame *v14; // eax@24 unsigned int v15; // eax@26 - char pContainer; // [sp+Ch] [bp-30h]@18 + char pContainer[20]; // [sp+Ch] [bp-30h]@18 unsigned int v17; // [sp+20h] [bp-1Ch]@19 signed int uFrameID; // [sp+24h] [bp-18h]@19 int i; // [sp+28h] [bp-14h]@15 @@ -3094,38 +3088,24 @@ { v23 = 0; v22 = 0; - v0 = 0; - v1 = (char *)pParty->pHirelings; - do - { - if ( *(int *)v1 ) - { - v2 = v22++; - pTmpBuf[v2] = v0; - } - v1 += 76; - ++v0; - } - while ( (signed int)v1 < (signed int)&pParty->pPickedItem ); - v3 = 0; - if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) - { - v4 = (char *)pNPCStats->pNewNPCData; - do - { - if ( v4[8] & 0x80 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v4, pParty->pHirelings[0].pName)) ) - { - if ( !pParty->pHirelings[1].pName || strcmp(*(const char **)v4, pParty->pHirelings[1].pName) ) - { - v5 = v22++; - pTmpBuf[v5] = v3 + 2; - } - } - ++v3; - v4 += 76; - } - while ( v3 < (signed int)pNPCStats->uNumNewNPCs ); - } + for (uint i = 0; i < 2; ++i) + { + if (pParty->pHirelings[i].pName) + pTmpBuf[v22++] = i; + } + + for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i) + { + if (pNPCStats->pNewNPCData[i].uFlags & 0x80) + { + if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName)) + { + if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName)) + pTmpBuf[v22++] = i + 2; + } + } + } + v6 = (unsigned __int8)pParty->field_709; for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 ) { @@ -3134,22 +3114,22 @@ v7 = pTmpBuf[v6]; if ( (unsigned __int8)v7 >= 2u ) { - sprintfex(&pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID); - v15 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE); + sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID); + v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); pRenderer->DrawTextureIndexed( pHiredNPCsIconsOffsetsX[v23], pHiredNPCsIconsOffsetsY[v23], - (Texture *)(v15 != -1 ? 72 * v15 + 7145548 : 0)); + (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0)); } else { - sprintfex(&pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID); - v8 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE); + sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID); + v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE); v9 = v23; pRenderer->DrawTextureIndexed( pHiredNPCsIconsOffsetsX[v9], pHiredNPCsIconsOffsetsY[v9], - (Texture *)(v8 != -1 ? (int)&pIcons_LOD->pTextures[v8] : 0)); + (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0)); v10 = (unsigned __int8)pTmpBuf[i]; if ( pParty->pHirelings[v10].bDrawSomeAnim == 1 ) { @@ -3190,12 +3170,7 @@ //----- (004921C1) -------------------------------------------------------- void GameUI_DrawPortraits(unsigned int _this) { - signed int v1; // ebx@2 - int v2; // ebp@7 - char *v3; // esi@7 Texture *v4; // eax@10 - signed int v5; // edx@13 - PlayerFrame *v6; // eax@14 unsigned int v7; // eax@17 PlayerFrame *v8; // eax@21 unsigned int v9; // eax@27 @@ -3203,21 +3178,15 @@ bool v11; // edi@40 bool v12; // edx@43 bool v13; // ecx@46 - int v14; // esi@54 - char *v15; // edi@55 int v16; // eax@57 - __int16 *v17; // esi@59 - char *v18; // edi@59 int v19; // eax@62 Texture *v20; // [sp-4h] [bp-1Ch]@27 - signed int v21; // [sp+10h] [bp-8h]@7 unsigned int v22; // [sp+14h] [bp-4h]@1 v22 = _this; if ( qword_A750D8 ) { qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed; - v1 = 0; if ( qword_A750D8 <= 0 ) { if ( pPlayers[word_A750E2]->CanAct() ) @@ -3225,95 +3194,80 @@ qword_A750D8 = 0i64; } } - else - { - v1 = 0; - } - v2 = 0; - v21 = v1; - v3 = (char *)&pParty->pPlayers[0].pConditions[14]; - while ( 1 ) - { - if ( *((_QWORD *)v3 + 2) ) + + for (uint i = 0; i < 4; ++i) + { + auto pPlayer = pParty->pPlayers + i; + + if (pPlayer->Eradicated()) { v4 = pTexture_PlayerFaceEradicated; LABEL_27: v20 = v4; - v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[v2]; + v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i]; if ( pParty->pPartyBuffs[11].uExpireTime ) pRenderer->_4A6E7E(v9, 0x183u, v20); else pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, v20); - v10 = *((int *)v3 + 1541) >= v1 && (*((int *)v3 + 1541) > v1 || *((int *)v3 + 1540) > (unsigned int)v1); - if ( *((int *)v3 + 1489) >= v1 && (*((int *)v3 + 1489) > v1 || *((int *)v3 + 1488) > (unsigned int)v1) ) - v1 = 1; - v11 = *((_QWORD *)v3 + 758) > 0i64; - v12 = *((_QWORD *)v3 + 756) > 0i64; - v13 = *((_QWORD *)v3 + 768) > 0i64; - if ( v13 | v12 | v11 | v1 | v10 ) - sub_441A4E(v2); + auto _v1 = 0; + v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0; + if (pPlayer->pPlayerBuffs[1].uExpireTime > 0) + _v1 = 1; + v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0; + v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0; + v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0; + if ( v13 | v12 | v11 | _v1 | v10 ) + sub_441A4E(i); goto LABEL_50; } - if ( *(_QWORD *)v3 ) + if (pPlayer->Dead()) { v4 = pTexture_PlayerFaceDead; goto LABEL_27; } - v5 = 0; - if ( (signed int)pPlayerFrameTable->uNumFrames <= v1 ) - { -LABEL_17: + v7 = 0; - } - else - { - v6 = pPlayerFrameTable->pFrames; - while ( v6->uSequenceID != *((short *)v3 + 3350) ) - { - ++v5; - ++v6; - if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames ) - goto LABEL_17; - } - v7 = v5; - } - if ( v7 == v1 ) + for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j) + if (pPlayerFrameTable->pFrames[j].uSequenceID == pPlayer->uExpressionID) + { + v7 = j; + break; + } + + if ( v7 == 0 ) v7 = 1; - if ( *((short *)v3 + 3350) == 21 ) + if (pPlayer->uExpressionID == 21 ) v8 = pPlayerFrameTable->GetFrameBy_y( - (int *)v3 + 1678, - (int *)v3 + 1677, + &pPlayer->field_1AA8, + &pPlayer->field_1AA4, pMiscTimer->uTimeElapsed); else - v8 = pPlayerFrameTable->GetFrameBy_x(v7, *((short *)v3 + 3351)); - if ( *((short *)v3 + 3353) != v8->uTextureID - 1 || v22 ) - { - *((short *)v3 + 3353) = v8->uTextureID - 1; - v1 = 0; - v4 = (Texture *)A74CEC_player_faces_minus1_indexing[v21 + v8->uTextureID]; + v8 = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed); + if (pPlayer->field_1AA2 != v8->uTextureID - 1 || v22 ) + { + pPlayer->field_1AA2 = v8->uTextureID - 1; + v4 = (Texture *)pTextures_PlayerFaces[i][v8->uTextureID]; goto LABEL_27; } LABEL_50: - v21 += 56; - v3 += 6972; - ++v2; - if ( (signed int)v3 >= (signed int)&pParty->pHirelings[1].field_24 ) - break; - v1 = 0; - } + ; + } + if ( pParty->bTurnBasedModeOn == 1 ) { if ( pTurnEngine->field_4 != 1 ) { if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 ) { - v14 = 0; + //v14 = 0; if ( pTurnEngine->uActorQueueSize > 0 ) { - v15 = (char *)pTurnEngine->pQueue; - do - { - if ( (*v15 & 7) != 4 ) + //v15 = (char *)pTurnEngine->pQueue; + for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i) + { + auto pElem = pTurnEngine->pQueue + i; + + if ( (pElem->uPackedID & 7) != 4 ) break; v16 = dword_5079D0; if ( pParty->uFlags & 0x10 ) @@ -3326,24 +3280,20 @@ v16 = dword_5079C8; } pRenderer->DrawTextureTransparent( - pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[*(int *)v15 >> 3] - 4, + pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4, 0x181u, - (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0)); - ++v14; - v15 += 16; - } - while ( v14 < pTurnEngine->uActorQueueSize ); - } - } - } - } - else - { - v17 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing; - v18 = (char *)pParty->pPlayers; - do - { - if ( ((Player *)v18)->CanAct() && !*((short *)v18 + 3226) ) + (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0)); + } + } + } + } + } + else + { + for (uint i = 0; i < 4; ++i) + { + auto pPlayer = pParty->pPlayers + i; + if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery) { v19 = dword_5079D0; if ( pParty->uFlags & 0x10 ) @@ -3356,14 +3306,11 @@ v19 = dword_5079C8; } pRenderer->DrawTextureTransparent( - *v17 - 4, + pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4, 0x181u, - (Texture *)(v19 != -1 ? (int)&pIcons_LOD->pTextures[v19] : 0)); - } - v18 += 6972; - ++v17; - } - while ( (signed int)v18 < (signed int)pParty->pHirelings ); + (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0)); + } + } } }