Mercurial > mm7
diff mm7_3.cpp @ 390:35a62d1948d4
More sound fixes
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 08:27:32 +0200 |
parents | 243418228760 |
children | 86637e3f59a9 |
line wrap: on
line diff
--- a/mm7_3.cpp Sat Feb 23 04:02:05 2013 +0200 +++ b/mm7_3.cpp Sat Feb 23 08:27:32 2013 +0200 @@ -1165,7 +1165,7 @@ v31 = 0; for ( i = 0; v31 < ai_arrays_size; ++v31 ) { - v33 = ai_array_4F7DB0_actor_ids[v31]; + v33 = ai_near_actors_ids[v31]; if ( v33 != v75 && _46DF1A_collide_against_actor(v33, 40) ) ++i; } @@ -17280,7 +17280,7 @@ //----- (004014E6) -------------------------------------------------------- int __cdecl ODM_4014E6_AI() { - Actor *v0; // esi@2 + //Actor *v0; // esi@2 int v1; // eax@4 int v2; // ebx@4 unsigned int v3; // ecx@4 @@ -17288,11 +17288,11 @@ int v5; // edx@7 unsigned int v6; // edx@9 unsigned int v7; // ST20_4@10 - int v8; // eax@10 + //int v8; // eax@10 int v9; // edi@10 int v10; // ebx@14 - char v11; // zf@16 - int v12; // eax@22 + //char v11; // zf@16 + //int v12; // eax@22 int result; // eax@24 int v14; // edx@25 int v15; // ecx@25 @@ -17303,27 +17303,33 @@ char *v20; // ecx@34 int v21; // [sp+Ch] [bp-14h]@4 int v22; // [sp+10h] [bp-10h]@4 - int v23; // [sp+14h] [bp-Ch]@10 + //int v23; // [sp+14h] [bp-Ch]@10 int v24; // [sp+14h] [bp-Ch]@29 - signed int v25; // [sp+18h] [bp-8h]@1 + //signed int v25; // [sp+18h] [bp-8h]@1 signed int v26; // [sp+18h] [bp-8h]@25 int v27; // [sp+1Ch] [bp-4h]@1 pParty->uFlags &= 0xFFFFFFCFu; v27 = 0; - v25 = 0; - if ( (signed int)uNumActors > 0 ) - { - v0 = pActors;//[0].uAttributes; - do - { + + //v25 = 0; + for (uint i = 0; i < uNumActors; ++i) + { + auto actor = pActors + i; + //v0 = pActors;//[0].uAttributes; + //do + //{ //*(char *)(v0 + 1) &= 0xFBu; - BYTE1(v0->uAttributes) &= 0xFBu; - if ( ! v0->CanAct() ) - goto LABEL_37; - v22 = abs(pParty->vPosition.z - v0->vPosition.z); - v21 = abs(pParty->vPosition.y - v0->vPosition.y); - v1 = abs(pParty->vPosition.x - v0->vPosition.x); + actor->uAttributes &= 0xFFFFFBFF; + if (!actor->CanAct()) + { + actor->uAttributes &= 0xFFFFBFFF; + continue; + } + + v22 = abs(pParty->vPosition.z - actor->vPosition.z); + v21 = abs(pParty->vPosition.y - actor->vPosition.y); + v1 = abs(pParty->vPosition.x - actor->vPosition.x); v2 = v21; v3 = v22; if ( v1 < v21 ) @@ -17345,42 +17351,36 @@ v2 = v6; } v7 = ((unsigned int)(11 * v2) >> 5) + (v3 >> 2) + v1; - v8 = v0->uActorRadius; - v9 = v7 - v8; - v23 = v7 - v8; - if ( v23 < 0 ) + //v8 = actor->uActorRadius; + v9 = v7 - actor->uActorRadius; + //v23 = v7 - v8; + if ( v9 < 0 ) { v9 = 0; - v23 = 0; - } - if ( v9 < 5632 ) - { - v10 = v0->uAttributes & 0xFEFFFFFF; - v0->uAttributes = v10; - if ( v10 & 0x80000 || v0->GetActorsRelation(0) ) - { - v11 = (pParty->uFlags & 0x10) == 0; - v0->uAttributes = v10 | 0x1000000; - if ( v11 && (double)v23 < 307.2 ) - pParty->uFlags |= 0x10u; - if ( !(pParty->uFlags & 0x20) && v9 < 5120 ) - pParty->uFlags |= 0x20u; - } - BYTE1(v0->uAttributes) |= 0x40u; - v12 = v27++; - ai_array_4F75E0[v12] = v9; - ai_array_4F7DB0_actor_ids[v12] = v25; - } - else - { -LABEL_37: - BYTE1(v0->uAttributes) &= 0xBFu; - } - ++v25; - ++v0; - } - while ( v25 < (signed int)uNumActors ); - } + //v23 = 0; + } + + if (v9 < 5632) + { + v10 = actor->uAttributes & 0xFEFFFFFF; + actor->uAttributes = v10; + if ( v10 & 0x80000 || actor->GetActorsRelation(0) ) + { + //v11 = (pParty->uFlags & 0x10) == 0; + actor->uAttributes = v10 | 0x1000000; + if (v9 < 5120 ) + pParty->SetYellowAlert(); + if (v9 < 307) + pParty->SetRedAlert(); + } + actor->uAttributes |= 0x00004000; + ai_near_actors_distances[v27] = v9; + ai_near_actors_ids[v27++] = i; + } + else + actor->uAttributes &= 0xFFFFBFFF; + } + result = v27; if ( v27 > 0 ) { @@ -17394,16 +17394,16 @@ v24 = v15; if ( v15 >= result ) break; - v16 = ai_array_4F75E0[v14]; - if ( v16 > ai_array_4F75E0[v15] ) - { - v17 = &ai_array_4F7DB0_actor_ids[v15]; - v18 = ai_array_4F7DB0_actor_ids[v14]; - ai_array_4F7DB0_actor_ids[v14] = *v17; + v16 = ai_near_actors_distances[v14]; + if ( v16 > ai_near_actors_distances[v15] ) + { + v17 = &ai_near_actors_ids[v15]; + v18 = ai_near_actors_ids[v14]; + ai_near_actors_ids[v14] = *v17; *v17 = v18; v15 = v24; - ai_array_4F75E0[v14] = ai_array_4F75E0[v24]; - ai_array_4F75E0[v24] = v16; + ai_near_actors_distances[v14] = ai_near_actors_distances[v24]; + ai_near_actors_distances[v24] = v16; } result = v27; ++v15; @@ -17422,7 +17422,7 @@ } for ( i = 0; i < result; ++i ) { - v20 = (char *)&pActors[ai_array_4F7DB0_actor_ids[i]].uAttributes; + v20 = (char *)&pActors[ai_near_actors_ids[i]].uAttributes; v20[1] |= 4u; } return result; @@ -17536,8 +17536,8 @@ pParty->uFlags |= 0x20u; } v12 = v45++; - ai_array_4F75E0[v12] = v9; - ai_array_4F7DB0_actor_ids[v12] = v43; + ai_near_actors_distances[v12] = v9; + ai_near_actors_ids[v12] = v43; } else { @@ -17561,16 +17561,16 @@ v41 = v14; if ( v14 >= v45 ) break; - v15 = ai_array_4F75E0[v13]; - if ( v15 > ai_array_4F75E0[v14] ) - { - v16 = &ai_array_4F7DB0_actor_ids[v14]; - v17 = ai_array_4F7DB0_actor_ids[v13]; - ai_array_4F7DB0_actor_ids[v13] = *v16; + v15 = ai_near_actors_distances[v13]; + if ( v15 > ai_near_actors_distances[v14] ) + { + v16 = &ai_near_actors_ids[v14]; + v17 = ai_near_actors_ids[v13]; + ai_near_actors_ids[v13] = *v16; *v16 = v17; v14 = v41; - ai_array_4F75E0[v13] = ai_array_4F75E0[v41]; - ai_array_4F75E0[v41] = v15; + ai_near_actors_distances[v13] = ai_near_actors_distances[v41]; + ai_near_actors_distances[v41] = v15; } ++v14; } @@ -17584,14 +17584,14 @@ v19 = 0; for ( i = 0; v18 < v45; i = v18 ) { - v20 = &pActors[ai_array_4F7DB0_actor_ids[v18]]; + v20 = &pActors[ai_near_actors_ids[v18]]; if ( v20->uAttributes & 0x8000 - || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_array_4F7DB0_actor_ids[v18] | 3, 4u), v18 = i, v21) ) - { - v22 = ai_array_4F7DB0_actor_ids[v18]; + || (v21 = sub_4070EF_prolly_collide_objects(8 * ai_near_actors_ids[v18] | 3, 4u), v18 = i, v21) ) + { + v22 = ai_near_actors_ids[v18]; v20->uAttributes |= 0x8000u; ai_array_4F6638_actor_ids[v19] = v22; - ai_array_4F5E68[v19++] = ai_array_4F75E0[v18]; + ai_array_4F5E68[v19++] = ai_near_actors_distances[v18]; if ( v19 >= 30 ) break; } @@ -17633,7 +17633,7 @@ v27 = ai_arrays_size; for ( j = 0; j < v45; ++j ) { - v29 = ai_array_4F7DB0_actor_ids[j]; + v29 = ai_near_actors_ids[j]; if ( pActors[v29].uAttributes & 0xC000 && pActors[v29].CanAct() ) { v30 = 0; @@ -17641,13 +17641,13 @@ { LABEL_51: v31 = ai_arrays_size; - v32 = ai_array_4F7DB0_actor_ids[j]; + v32 = ai_near_actors_ids[j]; ++ai_arrays_size; ai_array_4F6638_actor_ids[v31] = v32; } else { - while ( ai_array_4F6638_actor_ids[v30] != ai_array_4F7DB0_actor_ids[j] ) + while ( ai_array_4F6638_actor_ids[v30] != ai_near_actors_ids[j] ) { ++v30; if ( v30 >= v27 ) @@ -17662,14 +17662,14 @@ v33 = 30; ai_arrays_size = 30; } - memcpy(ai_array_4F7DB0_actor_ids, ai_array_4F6638_actor_ids, 4 * v33); - memcpy(ai_array_4F75E0, ai_array_4F5E68, 4 * ai_arrays_size); + memcpy(ai_near_actors_ids, ai_array_4F6638_actor_ids, 4 * v33); + memcpy(ai_near_actors_distances, ai_array_4F5E68, 4 * ai_arrays_size); v34 = (unsigned int)ai_arrays_size; if ( ai_arrays_size > 0 ) { do { - v35 = (char *)&pActors[ai_array_4F7DB0_actor_ids[HIDWORD(v34)]].uAttributes; + v35 = (char *)&pActors[ai_near_actors_ids[HIDWORD(v34)]].uAttributes; v35[1] |= 4u; ++HIDWORD(v34); } @@ -17935,7 +17935,7 @@ { while ( 1 ) { - uActorID = ai_array_4F7DB0_actor_ids[v78]; + uActorID = ai_near_actors_ids[v78]; v20 = &dword_4F6E08[uActorID]; v21 = &pActors[uActorID]; Actor::_401221(uActorID, &dword_4F6E08[uActorID], 1u); @@ -18682,7 +18682,7 @@ v40b = v35; if ( v40b < v40b + ai_arrays_size ) { - v34 = (int *)ai_array_4F7DB0_actor_ids; + v34 = (int *)ai_near_actors_ids; do { v37 = *v34;