comparison mm7_4.cpp @ 49:25fabc49627b

Слияние
author Ritor1
date Tue, 23 Oct 2012 17:34:20 +0600
parents 6a62c4005f0e 8a8dd0164b12
children 4211cceb3813 c28452924144
comparison
equal deleted inserted replaced
48:6a62c4005f0e 49:25fabc49627b
3063 // 4ED498: using guessed type char byte_4ED498; 3063 // 4ED498: using guessed type char byte_4ED498;
3064 3064
3065 //----- (00491F87) -------------------------------------------------------- 3065 //----- (00491F87) --------------------------------------------------------
3066 void __cdecl DrawHiredNPCs() 3066 void __cdecl DrawHiredNPCs()
3067 { 3067 {
3068 int v0; // ecx@2
3069 char *v1; // eax@2
3070 int v2; // edx@4
3071 signed int v3; // ebx@6
3072 char *v4; // esi@7
3073 int v5; // ecx@13
3074 int v6; // eax@15 3068 int v6; // eax@15
3075 char v7; // al@17 3069 char v7; // al@17
3076 unsigned int v8; // eax@18 3070 unsigned int v8; // eax@18
3077 int v9; // esi@18 3071 int v9; // esi@18
3078 int v10; // eax@18 3072 int v10; // eax@18
3079 unsigned int v11; // eax@19 3073 unsigned int v11; // eax@19
3080 unsigned int v12; // esi@19 3074 unsigned int v12; // esi@19
3081 unsigned int v13; // eax@23 3075 unsigned int v13; // eax@23
3082 IconFrame *v14; // eax@24 3076 IconFrame *v14; // eax@24
3083 unsigned int v15; // eax@26 3077 unsigned int v15; // eax@26
3084 char pContainer; // [sp+Ch] [bp-30h]@18 3078 char pContainer[20]; // [sp+Ch] [bp-30h]@18
3085 unsigned int v17; // [sp+20h] [bp-1Ch]@19 3079 unsigned int v17; // [sp+20h] [bp-1Ch]@19
3086 signed int uFrameID; // [sp+24h] [bp-18h]@19 3080 signed int uFrameID; // [sp+24h] [bp-18h]@19
3087 int i; // [sp+28h] [bp-14h]@15 3081 int i; // [sp+28h] [bp-14h]@15
3088 unsigned int v20; // [sp+2Ch] [bp-10h]@20 3082 unsigned int v20; // [sp+2Ch] [bp-10h]@20
3089 unsigned int v21; // [sp+30h] [bp-Ch]@19 3083 unsigned int v21; // [sp+30h] [bp-Ch]@19
3092 3086
3093 if ( bNoNPCHiring != 1 ) 3087 if ( bNoNPCHiring != 1 )
3094 { 3088 {
3095 v23 = 0; 3089 v23 = 0;
3096 v22 = 0; 3090 v22 = 0;
3097 v0 = 0; 3091 for (uint i = 0; i < 2; ++i)
3098 v1 = (char *)pParty->pHirelings; 3092 {
3099 do 3093 if (pParty->pHirelings[i].pName)
3100 { 3094 pTmpBuf[v22++] = i;
3101 if ( *(int *)v1 ) 3095 }
3102 { 3096
3103 v2 = v22++; 3097 for (uint i = 0; i < pNPCStats->uNumNewNPCs; ++i)
3104 pTmpBuf[v2] = v0; 3098 {
3105 } 3099 if (pNPCStats->pNewNPCData[i].uFlags & 0x80)
3106 v1 += 76; 3100 {
3107 ++v0; 3101 if (!pParty->pHirelings[0].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[0].pName))
3108 } 3102 {
3109 while ( (signed int)v1 < (signed int)&pParty->pPickedItem ); 3103 if (!pParty->pHirelings[1].pName || strcmp(pNPCStats->pNewNPCData[i].pName, pParty->pHirelings[1].pName))
3110 v3 = 0; 3104 pTmpBuf[v22++] = i + 2;
3111 if ( (signed int)pNPCStats->uNumNewNPCs > 0 ) 3105 }
3112 { 3106 }
3113 v4 = (char *)pNPCStats->pNewNPCData; 3107 }
3114 do 3108
3115 {
3116 if ( v4[8] & 0x80 && (!pParty->pHirelings[0].pName || strcmp(*(const char **)v4, pParty->pHirelings[0].pName)) )
3117 {
3118 if ( !pParty->pHirelings[1].pName || strcmp(*(const char **)v4, pParty->pHirelings[1].pName) )
3119 {
3120 v5 = v22++;
3121 pTmpBuf[v5] = v3 + 2;
3122 }
3123 }
3124 ++v3;
3125 v4 += 76;
3126 }
3127 while ( v3 < (signed int)pNPCStats->uNumNewNPCs );
3128 }
3129 v6 = (unsigned __int8)pParty->field_709; 3109 v6 = (unsigned __int8)pParty->field_709;
3130 for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 ) 3110 for ( i = (unsigned __int8)pParty->field_709; i < v22; v6 = i++ + 1 )
3131 { 3111 {
3132 if ( v23 >= 2u ) 3112 if ( v23 >= 2u )
3133 break; 3113 break;
3134 v7 = pTmpBuf[v6]; 3114 v7 = pTmpBuf[v6];
3135 if ( (unsigned __int8)v7 >= 2u ) 3115 if ( (unsigned __int8)v7 >= 2u )
3136 { 3116 {
3137 sprintfex(&pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID); 3117 sprintf(pContainer, "NPC%03d", pNPCStats->pNPCData[(unsigned __int8)v7 + 499].uPortraitID);
3138 v15 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE); 3118 v15 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
3139 pRenderer->DrawTextureIndexed( 3119 pRenderer->DrawTextureIndexed(
3140 pHiredNPCsIconsOffsetsX[v23], 3120 pHiredNPCsIconsOffsetsX[v23],
3141 pHiredNPCsIconsOffsetsY[v23], 3121 pHiredNPCsIconsOffsetsY[v23],
3142 (Texture *)(v15 != -1 ? 72 * v15 + 7145548 : 0)); 3122 (Texture *)(v15 != -1 ? &pIcons_LOD->pTextures[v15] : 0));
3143 } 3123 }
3144 else 3124 else
3145 { 3125 {
3146 sprintfex(&pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID); 3126 sprintf(pContainer, "NPC%03d", pParty->pHirelings[(unsigned __int8)v7].uPortraitID);
3147 v8 = pIcons_LOD->LoadTexture(&pContainer, TEXTURE_16BIT_PALETTE); 3127 v8 = pIcons_LOD->LoadTexture(pContainer, TEXTURE_16BIT_PALETTE);
3148 v9 = v23; 3128 v9 = v23;
3149 pRenderer->DrawTextureIndexed( 3129 pRenderer->DrawTextureIndexed(
3150 pHiredNPCsIconsOffsetsX[v9], 3130 pHiredNPCsIconsOffsetsX[v9],
3151 pHiredNPCsIconsOffsetsY[v9], 3131 pHiredNPCsIconsOffsetsY[v9],
3152 (Texture *)(v8 != -1 ? (int)&pIcons_LOD->pTextures[v8] : 0)); 3132 (Texture *)(v8 != -1 ? &pIcons_LOD->pTextures[v8] : 0));
3153 v10 = (unsigned __int8)pTmpBuf[i]; 3133 v10 = (unsigned __int8)pTmpBuf[i];
3154 if ( pParty->pHirelings[v10].bDrawSomeAnim == 1 ) 3134 if ( pParty->pHirelings[v10].bDrawSomeAnim == 1 )
3155 { 3135 {
3156 uFrameID = pParty->pHirelings[v10].evtb; 3136 uFrameID = pParty->pHirelings[v10].evtb;
3157 v11 = pHiredNPCsIconsOffsetsX[v9]; 3137 v11 = pHiredNPCsIconsOffsetsX[v9];
3188 3168
3189 3169
3190 //----- (004921C1) -------------------------------------------------------- 3170 //----- (004921C1) --------------------------------------------------------
3191 void GameUI_DrawPortraits(unsigned int _this) 3171 void GameUI_DrawPortraits(unsigned int _this)
3192 { 3172 {
3193 signed int v1; // ebx@2
3194 int v2; // ebp@7
3195 char *v3; // esi@7
3196 Texture *v4; // eax@10 3173 Texture *v4; // eax@10
3197 signed int v5; // edx@13
3198 PlayerFrame *v6; // eax@14
3199 unsigned int v7; // eax@17 3174 unsigned int v7; // eax@17
3200 PlayerFrame *v8; // eax@21 3175 PlayerFrame *v8; // eax@21
3201 unsigned int v9; // eax@27 3176 unsigned int v9; // eax@27
3202 bool v10; // eax@33 3177 bool v10; // eax@33
3203 bool v11; // edi@40 3178 bool v11; // edi@40
3204 bool v12; // edx@43 3179 bool v12; // edx@43
3205 bool v13; // ecx@46 3180 bool v13; // ecx@46
3206 int v14; // esi@54
3207 char *v15; // edi@55
3208 int v16; // eax@57 3181 int v16; // eax@57
3209 __int16 *v17; // esi@59
3210 char *v18; // edi@59
3211 int v19; // eax@62 3182 int v19; // eax@62
3212 Texture *v20; // [sp-4h] [bp-1Ch]@27 3183 Texture *v20; // [sp-4h] [bp-1Ch]@27
3213 signed int v21; // [sp+10h] [bp-8h]@7
3214 unsigned int v22; // [sp+14h] [bp-4h]@1 3184 unsigned int v22; // [sp+14h] [bp-4h]@1
3215 3185
3216 v22 = _this; 3186 v22 = _this;
3217 if ( qword_A750D8 ) 3187 if ( qword_A750D8 )
3218 { 3188 {
3219 qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed; 3189 qword_A750D8 -= (signed int)pMiscTimer->uTimeElapsed;
3220 v1 = 0;
3221 if ( qword_A750D8 <= 0 ) 3190 if ( qword_A750D8 <= 0 )
3222 { 3191 {
3223 if ( pPlayers[word_A750E2]->CanAct() ) 3192 if ( pPlayers[word_A750E2]->CanAct() )
3224 pPlayers[word_A750E2]->PlaySound(word_A750E0, 0); 3193 pPlayers[word_A750E2]->PlaySound(word_A750E0, 0);
3225 qword_A750D8 = 0i64; 3194 qword_A750D8 = 0i64;
3226 } 3195 }
3227 } 3196 }
3228 else 3197
3229 { 3198 for (uint i = 0; i < 4; ++i)
3230 v1 = 0; 3199 {
3231 } 3200 auto pPlayer = pParty->pPlayers + i;
3232 v2 = 0; 3201
3233 v21 = v1; 3202 if (pPlayer->Eradicated())
3234 v3 = (char *)&pParty->pPlayers[0].pConditions[14];
3235 while ( 1 )
3236 {
3237 if ( *((_QWORD *)v3 + 2) )
3238 { 3203 {
3239 v4 = pTexture_PlayerFaceEradicated; 3204 v4 = pTexture_PlayerFaceEradicated;
3240 LABEL_27: 3205 LABEL_27:
3241 v20 = v4; 3206 v20 = v4;
3242 v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[v2]; 3207 v9 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i];
3243 if ( pParty->pPartyBuffs[11].uExpireTime ) 3208 if ( pParty->pPartyBuffs[11].uExpireTime )
3244 pRenderer->_4A6E7E(v9, 0x183u, v20); 3209 pRenderer->_4A6E7E(v9, 0x183u, v20);
3245 else 3210 else
3246 pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, v20); 3211 pRenderer->DrawTextureTransparent(v9 + 1, 0x184u, v20);
3247 v10 = *((int *)v3 + 1541) >= v1 && (*((int *)v3 + 1541) > v1 || *((int *)v3 + 1540) > (unsigned int)v1); 3212 auto _v1 = 0;
3248 if ( *((int *)v3 + 1489) >= v1 && (*((int *)v3 + 1489) > v1 || *((int *)v3 + 1488) > (unsigned int)v1) ) 3213 v10 = pPlayer->pPlayerBuffs[14].uExpireTime > 0;
3249 v1 = 1; 3214 if (pPlayer->pPlayerBuffs[1].uExpireTime > 0)
3250 v11 = *((_QWORD *)v3 + 758) > 0i64; 3215 _v1 = 1;
3251 v12 = *((_QWORD *)v3 + 756) > 0i64; 3216 v11 = pPlayer->pPlayerBuffs[8].uExpireTime > 0;
3252 v13 = *((_QWORD *)v3 + 768) > 0i64; 3217 v12 = pPlayer->pPlayerBuffs[7].uExpireTime > 0;
3253 if ( v13 | v12 | v11 | v1 | v10 ) 3218 v13 = pPlayer->pPlayerBuffs[13].uExpireTime > 0;
3254 sub_441A4E(v2); 3219 if ( v13 | v12 | v11 | _v1 | v10 )
3220 sub_441A4E(i);
3255 goto LABEL_50; 3221 goto LABEL_50;
3256 } 3222 }
3257 if ( *(_QWORD *)v3 ) 3223 if (pPlayer->Dead())
3258 { 3224 {
3259 v4 = pTexture_PlayerFaceDead; 3225 v4 = pTexture_PlayerFaceDead;
3260 goto LABEL_27; 3226 goto LABEL_27;
3261 } 3227 }
3262 v5 = 0; 3228
3263 if ( (signed int)pPlayerFrameTable->uNumFrames <= v1 )
3264 {
3265 LABEL_17:
3266 v7 = 0; 3229 v7 = 0;
3267 } 3230 for (uint j = 0; j < pPlayerFrameTable->uNumFrames; ++j)
3268 else 3231 if (pPlayerFrameTable->pFrames[j].uSequenceID == pPlayer->uExpressionID)
3269 { 3232 {
3270 v6 = pPlayerFrameTable->pFrames; 3233 v7 = j;
3271 while ( v6->uSequenceID != *((short *)v3 + 3350) ) 3234 break;
3272 { 3235 }
3273 ++v5; 3236
3274 ++v6; 3237 if ( v7 == 0 )
3275 if ( v5 >= (signed int)pPlayerFrameTable->uNumFrames )
3276 goto LABEL_17;
3277 }
3278 v7 = v5;
3279 }
3280 if ( v7 == v1 )
3281 v7 = 1; 3238 v7 = 1;
3282 if ( *((short *)v3 + 3350) == 21 ) 3239 if (pPlayer->uExpressionID == 21 )
3283 v8 = pPlayerFrameTable->GetFrameBy_y( 3240 v8 = pPlayerFrameTable->GetFrameBy_y(
3284 (int *)v3 + 1678, 3241 &pPlayer->field_1AA8,
3285 (int *)v3 + 1677, 3242 &pPlayer->field_1AA4,
3286 pMiscTimer->uTimeElapsed); 3243 pMiscTimer->uTimeElapsed);
3287 else 3244 else
3288 v8 = pPlayerFrameTable->GetFrameBy_x(v7, *((short *)v3 + 3351)); 3245 v8 = pPlayerFrameTable->GetFrameBy_x(v7, pPlayer->uExpressionTimePassed);
3289 if ( *((short *)v3 + 3353) != v8->uTextureID - 1 || v22 ) 3246 if (pPlayer->field_1AA2 != v8->uTextureID - 1 || v22 )
3290 { 3247 {
3291 *((short *)v3 + 3353) = v8->uTextureID - 1; 3248 pPlayer->field_1AA2 = v8->uTextureID - 1;
3292 v1 = 0; 3249 v4 = (Texture *)pTextures_PlayerFaces[i][v8->uTextureID];
3293 v4 = (Texture *)A74CEC_player_faces_minus1_indexing[v21 + v8->uTextureID];
3294 goto LABEL_27; 3250 goto LABEL_27;
3295 } 3251 }
3296 LABEL_50: 3252 LABEL_50:
3297 v21 += 56; 3253 ;
3298 v3 += 6972; 3254 }
3299 ++v2; 3255
3300 if ( (signed int)v3 >= (signed int)&pParty->pHirelings[1].field_24 )
3301 break;
3302 v1 = 0;
3303 }
3304 if ( pParty->bTurnBasedModeOn == 1 ) 3256 if ( pParty->bTurnBasedModeOn == 1 )
3305 { 3257 {
3306 if ( pTurnEngine->field_4 != 1 ) 3258 if ( pTurnEngine->field_4 != 1 )
3307 { 3259 {
3308 if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 ) 3260 if ( (pTurnEngine->pQueue[0].uPackedID & 7) == 4 )
3309 { 3261 {
3310 v14 = 0; 3262 //v14 = 0;
3311 if ( pTurnEngine->uActorQueueSize > 0 ) 3263 if ( pTurnEngine->uActorQueueSize > 0 )
3312 { 3264 {
3313 v15 = (char *)pTurnEngine->pQueue; 3265 //v15 = (char *)pTurnEngine->pQueue;
3314 do 3266 for (uint i = 0; i < pTurnEngine->uActorQueueSize; ++i)
3315 { 3267 {
3316 if ( (*v15 & 7) != 4 ) 3268 auto pElem = pTurnEngine->pQueue + i;
3269
3270 if ( (pElem->uPackedID & 7) != 4 )
3317 break; 3271 break;
3318 v16 = dword_5079D0; 3272 v16 = dword_5079D0;
3319 if ( pParty->uFlags & 0x10 ) 3273 if ( pParty->uFlags & 0x10 )
3320 { 3274 {
3321 v16 = dword_5079CC; 3275 v16 = dword_5079CC;
3324 { 3278 {
3325 if ( pParty->uFlags & 0x20 ) 3279 if ( pParty->uFlags & 0x20 )
3326 v16 = dword_5079C8; 3280 v16 = dword_5079C8;
3327 } 3281 }
3328 pRenderer->DrawTextureTransparent( 3282 pRenderer->DrawTextureTransparent(
3329 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[*(int *)v15 >> 3] - 4, 3283 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[pElem->uPackedID >> 3] - 4,
3330 0x181u, 3284 0x181u,
3331 (Texture *)(v16 != -1 ? (int)&pIcons_LOD->pTextures[v16] : 0)); 3285 (Texture *)(v16 != -1 ? &pIcons_LOD->pTextures[v16] : 0));
3332 ++v14;
3333 v15 += 16;
3334 } 3286 }
3335 while ( v14 < pTurnEngine->uActorQueueSize );
3336 } 3287 }
3337 } 3288 }
3338 } 3289 }
3339 } 3290 }
3340 else 3291 else
3341 { 3292 {
3342 v17 = pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing; 3293 for (uint i = 0; i < 4; ++i)
3343 v18 = (char *)pParty->pPlayers; 3294 {
3344 do 3295 auto pPlayer = pParty->pPlayers + i;
3345 { 3296 if (pPlayer->CanAct() && !pPlayer->uTimeToRecovery)
3346 if ( ((Player *)v18)->CanAct() && !*((short *)v18 + 3226) )
3347 { 3297 {
3348 v19 = dword_5079D0; 3298 v19 = dword_5079D0;
3349 if ( pParty->uFlags & 0x10 ) 3299 if ( pParty->uFlags & 0x10 )
3350 { 3300 {
3351 v19 = dword_5079CC; 3301 v19 = dword_5079CC;
3354 { 3304 {
3355 if ( pParty->uFlags & 0x20 ) 3305 if ( pParty->uFlags & 0x20 )
3356 v19 = dword_5079C8; 3306 v19 = dword_5079C8;
3357 } 3307 }
3358 pRenderer->DrawTextureTransparent( 3308 pRenderer->DrawTextureTransparent(
3359 *v17 - 4, 3309 pPlayerPortraitsXCoords_For_PlayerBuffAnimsDrawing[i] - 4,
3360 0x181u, 3310 0x181u,
3361 (Texture *)(v19 != -1 ? (int)&pIcons_LOD->pTextures[v19] : 0)); 3311 (Texture *)(v19 != -1 ? &pIcons_LOD->pTextures[v19] : 0));
3362 } 3312 }
3363 v18 += 6972; 3313 }
3364 ++v17;
3365 }
3366 while ( (signed int)v18 < (signed int)pParty->pHirelings );
3367 } 3314 }
3368 } 3315 }
3369 3316
3370 3317
3371 //----- (0049387A) -------------------------------------------------------- 3318 //----- (0049387A) --------------------------------------------------------
7132 v13 = v12 + 6.7553994e15; 7079 v13 = v12 + 6.7553994e15;
7133 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8); 7080 return LOBYTE(v13) | ((LOBYTE(v11) | (((v6 << 8) | v9) << 8)) << 8);
7134 } 7081 }
7135 7082
7136 7083
7137 //----- (004A1C1E) --------------------------------------------------------
7138 void __cdecl DoRenderBillboards_D3D()
7139 {
7140 signed int v0; // ebp@1
7141 signed int *v1; // esi@2
7142 //IDirect3DDevice3Vtbl *v2; // esi@7
7143 unsigned int v3; // eax@7
7144 unsigned int v4; // [sp+58h] [bp-4h]@2
7145
7146 v0 = -1;
7147 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTextureStageState(0, D3DTSS_ADDRESS, 3u));
7148 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 1u));
7149 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 0));
7150 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 1u));
7151 if ( ((pRenderer->uNumBillboardsToDraw - 1) & 0x80000000u) == 0 )
7152 {
7153 v1 = (signed int *)&pRenderer->pBillboardRenderListD3D[pRenderer->uNumBillboardsToDraw - 1].bOpaque;
7154 v4 = pRenderer->uNumBillboardsToDraw;
7155 do
7156 {
7157 ErrD3D(pRenderer->pRenderD3D->pDevice->SetTexture(
7158 0,
7159 (IDirect3DTexture2 *)*(v1 - 35)));
7160 if ( *v1 != v0 )
7161 {
7162 v0 = *v1;
7163 SetBillboardBlendOptions(*v1);
7164 }
7165 ErrD3D(pRenderer->pRenderD3D->pDevice->DrawPrimitive(
7166 D3DPT_TRIANGLEFAN,
7167 452,
7168 v1 - 33,
7169 *(v1 - 34),
7170 24));
7171 v1 -= 39;
7172 --v4;
7173 }
7174 while ( v4 );
7175 }
7176 if ( pRenderer->turnFogOn )
7177 {
7178 pRenderer->turnFogOn = 0;
7179 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
7180 //v2 = pRenderer->pRenderD3D->pDevice->lpVtbl;
7181 v3 = GetLevelFogColor();
7182 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v3 & 0xFFFFFF));
7183 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
7184 }
7185 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_CULLMODE, 2u));
7186 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE, 1u));
7187 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, 0));
7188 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2u));
7189 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 1u));
7190 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1u));
7191 }
7192
7193 //----- (004A1DA8) --------------------------------------------------------
7194 void __fastcall SetBillboardBlendOptions(signed int a1)
7195 {
7196 //IDirect3DDevice3Vtbl *v1; // edi@9
7197 unsigned int v2; // eax@9
7198 int v3; // [sp+0h] [bp-4h]@0
7199
7200 if ( !a1 )
7201 {
7202 if ( pRenderer->turnFogOn )
7203 {
7204 pRenderer->turnFogOn = 0;
7205 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 1u));
7206 //v1 = pRenderer->pRenderD3D->pDevice->lpVtbl;
7207 v2 = GetLevelFogColor();
7208 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGCOLOR, v2 & 0xFFFFFF));
7209 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGTABLEMODE, 0));
7210 }
7211 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 5));
7212 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 6u));
7213 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 1));
7214 return;
7215 }
7216 if ( a1 > 0 && a1 <= 3 )
7217 {
7218 if ( pRenderer->bUsingSpecular )
7219 {
7220 if ( !pRenderer->turnFogOn )
7221 {
7222 pRenderer->turnFogOn = 1;
7223 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_FOGENABLE, 0));
7224 }
7225 }
7226 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, 2));
7227 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, 2u));
7228 ErrD3D(pRenderer->pRenderD3D->pDevice->SetRenderState(D3DRENDERSTATE_DITHERENABLE, 0));
7229 }
7230 }
7231
7232
7233
7234
7235
7236
7237 7084
7238 //----- (004A46E6) -------------------------------------------------------- 7085 //----- (004A46E6) --------------------------------------------------------
7239 int __fastcall sub_4A46E6(unsigned int x, signed int y, signed int a3, int a4, unsigned int a5) 7086 int __fastcall sr_4A46E6_draw_particle_segment(unsigned int x, signed int y, signed int _z, int a4, unsigned int lightColor)
7240 { 7087 {
7241 int v5; // eax@1 7088 int v5; // eax@1
7242 int z; // eax@1 7089 int z; // eax@1
7243 unsigned int v7; // eax@9 7090 unsigned int v7; // eax@9
7244 unsigned int v8; // ecx@9 7091 unsigned int v8; // ecx@9
7257 int *pTargetZ; // [sp+10h] [bp-4h]@9 7104 int *pTargetZ; // [sp+10h] [bp-4h]@9
7258 unsigned int v22; // [sp+1Ch] [bp+8h]@9 7105 unsigned int v22; // [sp+1Ch] [bp+8h]@9
7259 signed int v23; // [sp+20h] [bp+Ch]@1 7106 signed int v23; // [sp+20h] [bp+Ch]@1
7260 7107
7261 v5 = a4; 7108 v5 = a4;
7262 v23 = a3 >> 16; 7109 v23 = _z >> 16;
7263 z = x + v5; 7110 z = x + v5;
7264 if ( z >= (signed int)pViewport->uViewportX 7111 if ( z >= (signed int)pViewport->uViewportX
7265 && (signed int)x <= (signed int)pViewport->uViewportZ 7112 && (signed int)x <= (signed int)pViewport->uViewportZ
7266 && y >= (signed int)pViewport->uViewportY 7113 && y >= (signed int)pViewport->uViewportY
7267 && y <= (signed int)pViewport->uViewportW ) 7114 && y <= (signed int)pViewport->uViewportW )
7271 if ( z > (signed int)pViewport->uViewportZ ) 7118 if ( z > (signed int)pViewport->uViewportZ )
7272 z = pViewport->uViewportZ; 7119 z = pViewport->uViewportZ;
7273 pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch]; 7120 pTarget = &pRenderer->pTargetSurface[x + y * pRenderer->uTargetSurfacePitch];
7274 v22 = z - x; 7121 v22 = z - x;
7275 pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y]; 7122 pTargetZ = &pRenderer->pActiveZBuffer[x + 640 * y];
7276 v7 = a5 >> 3; 7123 v7 = lightColor >> 3;
7277 v8 = a5 & 0xF0; 7124 v8 = lightColor & 0xF0;
7278 v9 = v7 & 0x1E0000; 7125 v9 = v7 & 0x1E0000;
7279 if ( pRenderer->uTargetGBits == 5 ) 7126 if ( pRenderer->uTargetGBits == 5 )
7280 { 7127 {
7281 v10 = (v8 | (((unsigned __int16)(a5 & 0xF000) | (unsigned int)v9) >> 3)) >> 4; 7128 v10 = (v8 | (((unsigned __int16)(lightColor & 0xF000) | (unsigned int)v9) >> 3)) >> 4;
7282 v11 = (int *)pTarget; 7129 v11 = (int *)pTarget;
7283 v12 = pTargetZ; 7130 v12 = pTargetZ;
7284 v13 = v22; 7131 v13 = v22;
7285 v14 = (v10 << 16) | v10; 7132 v14 = (v10 << 16) | v10;
7286 z = (unsigned __int8)pTarget & 2; 7133 z = (unsigned __int8)pTarget & 2;
7323 *(short *)v11 = z; 7170 *(short *)v11 = z;
7324 } 7171 }
7325 } 7172 }
7326 else 7173 else
7327 { 7174 {
7328 v15 = (v8 | (((unsigned __int16)(a5 & 0xF800) | (unsigned int)v9) >> 2)) >> 4; 7175 v15 = (v8 | (((unsigned __int16)(lightColor & 0xF800) | (unsigned int)v9) >> 2)) >> 4;
7329 v16 = (int *)pTarget; 7176 v16 = (int *)pTarget;
7330 v17 = pTargetZ; 7177 v17 = pTargetZ;
7331 v18 = v22; 7178 v18 = v22;
7332 v19 = (v15 << 16) | v15; 7179 v19 = (v15 << 16) | v15;
7333 z = (unsigned __int8)pTarget & 2; 7180 z = (unsigned __int8)pTarget & 2;
13447 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1; 13294 pMessageQueue_50CBD0->pMessages[pMessageQueue_50CBD0->uNumMessages].param = 1;
13448 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0; 13295 *(&pMessageQueue_50CBD0->uNumMessages + 3 * pMessageQueue_50CBD0->uNumMessages + 3) = 0;
13449 ++pMessageQueue_50CBD0->uNumMessages; 13296 ++pMessageQueue_50CBD0->uNumMessages;
13450 } 13297 }
13451 if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 ) 13298 if ( (uDialogue_SpeakingActorNPC_ID & 0x80000000u) == 0 )
13452 pDialogue_SpeakingActor->uAIState = 11; 13299 pDialogue_SpeakingActor->uAIState = Removed;
13453 if ( uActiveCharacter ) 13300 if ( uActiveCharacter )
13454 pPlayers[uActiveCharacter]->PlaySound(61, 0); 13301 pPlayers[uActiveCharacter]->PlaySound(61, 0);
13455 goto LABEL_87; 13302 goto LABEL_87;
13456 } 13303 }
13457 if ( v3 == 22 ) 13304 if ( v3 == 22 )
15172 } 15019 }
15173 else 15020 else
15174 { 15021 {
15175 v4->uCurrentActionTime = 0; 15022 v4->uCurrentActionTime = 0;
15176 v4->uCurrentActionLength = 0; 15023 v4->uCurrentActionLength = 0;
15177 v4->uAIState = 5; 15024 v4->uAIState = Dead;
15178 v4->UpdateAnimation(); 15025 v4->UpdateAnimation();
15179 } 15026 }
15180 v1 = v18; 15027 v1 = v18;
15181 v2 = 0; 15028 v2 = 0;
15182 } 15029 }
15249 15096
15250 15097
15251 15098
15252 15099
15253 //----- (0043FDED) -------------------------------------------------------- 15100 //----- (0043FDED) --------------------------------------------------------
15254 unsigned int __cdecl PrepareActorRenderList_BLV() 15101 void PrepareActorRenderList_BLV()
15255 { 15102 {
15256 RenderBillboard *v0; // esi@0 15103 RenderBillboard *v0; // esi@0
15257 unsigned int result; // eax@1
15258 char *v2; // edi@2
15259 unsigned __int16 v3; // ax@3 15104 unsigned __int16 v3; // ax@3
15260 unsigned int v4; // eax@5 15105 unsigned int v4; // eax@5
15261 unsigned __int16 v5; // cx@5 15106 unsigned __int16 v5; // cx@5
15262 int v6; // esi@5 15107 int v6; // esi@5
15263 unsigned int v7; // eax@7 15108 unsigned int v7; // eax@7
15264 int v8; // eax@10 15109 int v8; // eax@10
15265 SpriteFrame *v9; // eax@16 15110 SpriteFrame *v9; // eax@16
15266 SpriteFrame *v10; // ebx@18 15111 SpriteFrame *v10; // ebx@18
15267 int *v11; // eax@18 15112 int *v11; // eax@18
15268 int v12; // ecx@28 15113 int v12; // ecx@28
15269 Actor *v13; // ecx@35
15270 IndoorCameraD3D **v14; // eax@36 15114 IndoorCameraD3D **v14; // eax@36
15271 double v15; // st7@36 15115 double v15; // st7@36
15272 float v16; // eax@36 15116 float v16; // eax@36
15273 double v17; // ST30_8@36 15117 double v17; // ST30_8@36
15274 signed __int64 v18; // qtt@36 15118 signed __int64 v18; // qtt@36
15290 int a2; // [sp+24h] [bp-30h]@5 15134 int a2; // [sp+24h] [bp-30h]@5
15291 int a1a; // [sp+28h] [bp-2Ch]@5 15135 int a1a; // [sp+28h] [bp-2Ch]@5
15292 __int16 a5; // [sp+2Ch] [bp-28h]@5 15136 __int16 a5; // [sp+2Ch] [bp-28h]@5
15293 int a5a; // [sp+2Ch] [bp-28h]@36 15137 int a5a; // [sp+2Ch] [bp-28h]@36
15294 int a5b; // [sp+2Ch] [bp-28h]@40 15138 int a5b; // [sp+2Ch] [bp-28h]@40
15295 unsigned int v39; // [sp+30h] [bp-24h]@1
15296 int v40; // [sp+34h] [bp-20h]@2
15297 __int16 v41; // [sp+3Ch] [bp-18h]@18 15139 __int16 v41; // [sp+3Ch] [bp-18h]@18
15298 int a6; // [sp+40h] [bp-14h]@34 15140 int a6; // [sp+40h] [bp-14h]@34
15299 int v43; // [sp+44h] [bp-10h]@34 15141 int v43; // [sp+44h] [bp-10h]@34
15300 int z; // [sp+48h] [bp-Ch]@32 15142 int z; // [sp+48h] [bp-Ch]@32
15301 signed int y; // [sp+4Ch] [bp-8h]@32 15143 signed int y; // [sp+4Ch] [bp-8h]@32
15302 int x; // [sp+50h] [bp-4h]@32 15144 int x; // [sp+50h] [bp-4h]@32
15303 15145
15304 result = 0; 15146 for (uint i = 0; i < uNumActors; ++i)
15305 v39 = 0; 15147 {
15306 if ( (signed int)uNumActors > 0 ) 15148 auto p = pActors + i;
15307 { 15149
15308 v40 = 0; 15150 if (p->uAIState == Removed ||
15309 v2 = (char *)&pActors[0].uAttributes; 15151 p->uAIState == Disabled)
15310 while ( 1 ) 15152 continue;
15311 { 15153
15312 v3 = *((_WORD *)v2 + 70); 15154 a5 = p->uSectorID;
15313 *(_DWORD *)v2 &= 0xFFFFFFF7u; 15155 a2 = p->vPosition.y;
15314 if ( v3 != 11 ) 15156 a1a = p->vPosition.x;
15315 { 15157 a3 = p->vPosition.z;
15316 if ( v3 != 19 )
15317 break;
15318 }
15319 LABEL_48:
15320 ++v39;
15321 v40 += 32;
15322 result = v39;
15323 v2 += 836;
15324 if ( (signed int)v39 >= (signed int)uNumActors )
15325 return result;
15326 }
15327 a5 = *((_WORD *)v2 + 61);
15328 a2 = *((_WORD *)v2 + 54);
15329 a1a = *((_WORD *)v2 + 53);
15330 a3 = *((_WORD *)v2 + 55);
15331 v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y); 15158 v4 = stru_5C6E00->Atan2(a1a - pBLVRenderParams->vPartyPos.x, a2 - pBLVRenderParams->vPartyPos.y);
15332 LOWORD(v0) = *((_WORD *)v2 + 59); 15159 LOWORD(v0) = p->uYawAngle;
15333 v5 = *((_WORD *)v2 + 71); 15160 v5 = p->uCurrentActionAnimation;
15334 v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7; 15161 v6 = ((signed int)((char *)v0 + ((signed int)stru_5C6E00->uIntegerPi >> 3) - v4 + stru_5C6E00->uIntegerPi) >> 8) & 7;
15335 v32 = v6; 15162 v32 = v6;
15336 if ( pParty->bTurnBasedModeOn ) 15163 if ( pParty->bTurnBasedModeOn )
15337 { 15164 {
15338 if ( v5 == 1 ) 15165 if ( v5 == 1 )
15345 { 15172 {
15346 if ( v5 == 1 ) 15173 if ( v5 == 1 )
15347 { 15174 {
15348 v7 = pBLVRenderParams->field_0_timer_; 15175 v7 = pBLVRenderParams->field_0_timer_;
15349 LABEL_10: 15176 LABEL_10:
15350 v8 = v40 + v7; 15177 v8 = i * 32 + v7;
15351 goto LABEL_12; 15178 goto LABEL_12;
15352 } 15179 }
15353 } 15180 }
15354 v8 = *((_DWORD *)v2 + 37); 15181 v8 = p->uCurrentActionTime;
15355 LABEL_12: 15182 LABEL_12:
15356 if ( *((_QWORD *)v2 + 32) > 0i64 || *((_QWORD *)v2 + 34) > 0i64 ) 15183 if (p->pActorBuffs[5].uExpireTime > 0i64 || p->pActorBuffs[6].uExpireTime > 0i64 )
15357 v8 = 0; 15184 v8 = 0;
15358 v31 = *(_WORD *)&v2[2 * (signed __int16)v5 + 152]; 15185 v31 = p->pSpriteIDs[v5];
15359 if ( *((_WORD *)v2 + 70) == 16 ) 15186 if (p->uAIState == 16 )
15360 v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8); 15187 v9 = pSpriteFrameTable->GetFrameBy_x(v31, v8);
15361 else 15188 else
15362 v9 = pSpriteFrameTable->GetFrame(v31, v8); 15189 v9 = pSpriteFrameTable->GetFrame(v31, v8);
15363 v41 = 0; 15190 v41 = 0;
15364 v10 = v9; 15191 v10 = v9;
15386 0xFFu, 15213 0xFFu,
15387 v11); 15214 v11);
15388 } 15215 }
15389 v12 = 0; 15216 v12 = 0;
15390 if ( pStru170->field_53730 <= 0 ) 15217 if ( pStru170->field_53730 <= 0 )
15391 goto LABEL_48; 15218 continue;
15392 while ( pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != *((_WORD *)v2 + 61) ) 15219 while (pStru170->pSectorIDs_toDrawDecorationsFrom[v12] != p->uSectorID)
15393 { 15220 {
15394 ++v12; 15221 ++v12;
15395 if ( v12 >= pStru170->field_53730 ) 15222 if ( v12 >= pStru170->field_53730 )
15396 goto LABEL_48; 15223 continue;
15397 } 15224 }
15398 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1) 15225 if ( !pGame->pIndoorCameraD3D->ApplyViewTransform_TrueIfStillVisible(a1a, a2, a3, &x, &y, &z, 1)
15399 || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) ) 15226 || (v0 = (RenderBillboard *)abs(x), (signed int)v0 < abs(y)) )
15400 goto LABEL_48; 15227 continue;
15401 pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6); 15228 pGame->pIndoorCameraD3D->Project(x, y, z, &v43, &a6);
15402 result = uNumBillboardsToDraw; 15229
15403 v0 = &pBillboardRenderList[uNumBillboardsToDraw]; 15230 v0 = &pBillboardRenderList[uNumBillboardsToDraw];
15404 if ( (signed int)uNumBillboardsToDraw >= 500 ) 15231 if (uNumBillboardsToDraw >= 500)
15405 return result; 15232 break;
15406 ++uNumBillboardsToDraw; 15233 ++uNumBillboardsToDraw;
15407 ++uNumSpritesDrawnThisFrame; 15234 ++uNumSpritesDrawnThisFrame;
15408 v13 = (Actor *)(v2 - 36); 15235 p->uAttributes |= 8u;
15409 *(_DWORD *)v2 |= 8u;
15410 v29 = pRenderer->pRenderD3D == 0; 15236 v29 = pRenderer->pRenderD3D == 0;
15411 v0->uHwSpriteID = v10->pHwSpriteIDs[v32]; 15237 v0->uHwSpriteID = v10->pHwSpriteIDs[v32];
15412 v0->uPalette = v10->uPaletteIndex; 15238 v0->uPalette = v10->uPaletteIndex;
15413 v0->uIndoorSectorID = a5; 15239 v0->uIndoorSectorID = a5;
15414 if ( v29 ) 15240 if ( v29 )
15432 v19 = v18 / x; 15258 v19 = v18 / x;
15433 v0->field_0 = (unsigned __int64)(v10->scale * v18 / x) >> 16; 15259 v0->field_0 = (unsigned __int64)(v10->scale * v18 / x) >> 16;
15434 a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16; 15260 a5a = (unsigned __int64)(v10->scale * (signed __int64)v19) >> 16;
15435 } 15261 }
15436 v0->field_4 = a5a; 15262 v0->field_4 = a5a;
15437 if ( (signed __int64)v13->pActorBuffs[3].uExpireTime <= 0 ) 15263 if ( (signed __int64)p->pActorBuffs[3].uExpireTime <= 0 )
15438 { 15264 {
15439 if ( (signed __int64)v13->pActorBuffs[10].uExpireTime > 0 ) 15265 if ( (signed __int64)p->pActorBuffs[10].uExpireTime > 0 )
15440 { 15266 {
15441 a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F((Actor *)(v2 - 36)) * (signed __int64)v0->field_4) >> 16; 15267 a5b = (unsigned __int64)(pGame->pStru6Instance->_4A806F(p) * (signed __int64)v0->field_4) >> 16;
15442 goto LABEL_43; 15268 goto LABEL_43;
15443 } 15269 }
15444 } 15270 }
15445 else 15271 else
15446 { 15272 {
15447 v22 = v13->pActorBuffs[3].uPower; 15273 v22 = p->pActorBuffs[3].uPower;
15448 if ( v22 ) 15274 if ( v22 )
15449 { 15275 {
15450 v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16; 15276 v23 = (unsigned __int64)(65536 / (unsigned __int16)v22 * (signed __int64)v0->field_0) >> 16;
15451 v24 = *((_WORD *)v2 + 116); 15277 v24 = p->pActorBuffs[3].uPower;
15452 v0->field_0 = v23; 15278 v0->field_0 = v23;
15453 a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16; 15279 a5b = (unsigned __int64)(65536 / v24 * (signed __int64)v0->field_4) >> 16;
15454 LABEL_43: 15280 LABEL_43:
15455 v0->field_4 = a5b; 15281 v0->field_4 = a5b;
15456 goto LABEL_44; 15282 goto LABEL_44;
15457 } 15283 }
15458 } 15284 }
15459 LABEL_44: 15285 LABEL_44:
15460 HIWORD(v25) = HIWORD(x); 15286 HIWORD(v25) = HIWORD(x);
15461 v0->field_20 = a1a; 15287 v0->some_x = a1a;
15462 v0->field_22 = a2; 15288 v0->some_y = a2;
15463 v0->field_24 = a3; 15289 v0->some_z = a3;
15464 v0->field_26 = v43; 15290 v0->uScreenSpaceX = v43;
15465 v0->field_28 = a6; 15291 v0->uScreenSpaceY = a6;
15466 LOWORD(v25) = 0; 15292 LOWORD(v25) = 0;
15467 LOBYTE(v26) = v41; 15293 LOBYTE(v26) = v41;
15468 v0->sZValue = v25 + (8 * v39 | 3); 15294 v0->sZValue = v25 + (8 * i | 3);
15469 v27 = pMonsterList->pMonsters; 15295 v27 = pMonsterList->pMonsters;
15470 v28 = *((_WORD *)v2 + 30); 15296 v28 = p->pMonsterInfo.uID;
15471 v29 = *((_DWORD *)v2 + 65) == 0; 15297 v29 = HIDWORD(p->pActorBuffs[5].uExpireTime) == 0;
15472 v30 = *((_DWORD *)v2 + 65) < 0; 15298 v30 = HIDWORD(p->pActorBuffs[5].uExpireTime) < 0;
15473 v0->field_1E = v41; 15299 v0->field_1E = v41;
15474 v0->pSpriteFrame = v10; 15300 v0->pSpriteFrame = v10;
15475 v0->field_2C_prolly_tint = *((_DWORD *)&v27[v28] - 36); 15301 v0->uTintColor = *((_DWORD *)&v27[v28] - 36);
15476 if ( !v30 && (!(v30 | v29) || *((_DWORD *)v2 + 64)) ) 15302 if ( !v30 && (!(v30 | v29) || LODWORD(p->pActorBuffs[5].uExpireTime)) )
15477 { 15303 {
15478 HIBYTE(v26) = HIBYTE(v41) | 1; 15304 HIBYTE(v26) = HIBYTE(v41) | 1;
15479 v0->field_1E = v26; 15305 v0->field_1E = v26;
15480 } 15306 }
15481 goto LABEL_48; 15307 }
15482 }
15483 return result;
15484 } 15308 }
15485 15309
15486 15310
15487 15311
15488 15312