Mercurial > mm7
changeset 390:35a62d1948d4
More sound fixes
author | Nomad |
---|---|
date | Sat, 23 Feb 2013 08:27:32 +0200 |
parents | e32950ebabb9 |
children | 86637e3f59a9 74205b91647b |
files | AudioPlayer.cpp Indoor.cpp Party.h mm7_3.cpp mm7_5.cpp mm7_data.cpp mm7_data.h |
diffstat | 7 files changed, 111 insertions(+), 99 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Sat Feb 23 04:02:05 2013 +0200 +++ b/AudioPlayer.cpp Sat Feb 23 08:27:32 2013 +0200 @@ -976,7 +976,6 @@ auto channel = &pMixerChannels[v62]; AIL_init_sample(channel->hSample); AIL_set_sample_file(channel->hSample, (char *)pSoundList->pSounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); - int s = AIL_sample_status(channel->hSample); if (uVolume) sample_volume = uVolume; AIL_set_sample_volume(channel->hSample, sample_volume); @@ -1620,13 +1619,19 @@ { auto channel = pMixerChannels + i; - AIL_end_sample(channel->hSample); - _4ABE55(channel); + if (AIL_sample_status(channel->hSample) == AIL::Sample::Done) + { + AIL_end_sample(channel->hSample); + _4ABE55(channel); + } } for (uint i = 0; i < uMixerChannels; ++i) { auto channel = pMixerChannels + i; + if (channel->source_pid <= 0) + continue; + int source_type = channel->source_pid & 7, source_id = channel->source_pid >> 3; int source_x, @@ -2220,8 +2225,9 @@ v2 = 0; //v3 = this; - if ( pSoundList->pSounds ) - { + if (!pSoundList->pSounds) + return; + v4 = &pSoundList->pSounds[pChannel->uSourceTrackIdx]; if ( v4->eType == SOUND_DESC_SWAP) { @@ -2270,7 +2276,6 @@ } } } - } }
--- a/Indoor.cpp Sat Feb 23 04:02:05 2013 +0200 +++ b/Indoor.cpp Sat Feb 23 08:27:32 2013 +0200 @@ -4148,7 +4148,7 @@ { do { - v54 = ai_array_4F7DB0_actor_ids[v25]; + v54 = ai_near_actors_ids[v25]; if ( v54 != v63 ) { v26 = v54;
--- a/Party.h Sat Feb 23 04:02:05 2013 +0200 +++ b/Party.h Sat Feb 23 08:27:32 2013 +0200 @@ -16,7 +16,9 @@ /* 355 */ enum PARTY_FLAGS_1: __int32 { - PARTY_FLAGS_1_LANDING = 0x100, + PARTY_FLAGS_1_ALERT_RED = 0x0010, + PARTY_FLAGS_1_ALERT_YELLOW = 0x0020, + PARTY_FLAGS_1_LANDING = 0x0100, }; enum PARTY_FLAGS_2: __int32 { @@ -186,6 +188,11 @@ inline bool FeatherFallActive() {return pPartyBuffs[PARTY_BUFF_FEATHER_FALL].uExpireTime > 0;} inline bool Invisible() {return pPartyBuffs[PARTY_BUFF_INVISIBILITY].uExpireTime > 0;} + inline bool GetRedAlert() {return uFlags & PARTY_FLAGS_1_ALERT_RED;} + inline void SetRedAlert() {uFlags |= PARTY_FLAGS_1_ALERT_RED;} + inline bool GetYellowAlert() {return uFlags & PARTY_FLAGS_1_ALERT_YELLOW;} + inline void SetYellowAlert() {uFlags |= PARTY_FLAGS_1_ALERT_YELLOW;} + int field_0; unsigned int uPartyHeight;
--- 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;
--- a/mm7_5.cpp Sat Feb 23 04:02:05 2013 +0200 +++ b/mm7_5.cpp Sat Feb 23 08:27:32 2013 +0200 @@ -9587,7 +9587,7 @@ v8 = v1->pQueue; do { - if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_array_4F7DB0_actor_ids[v20] == v8->uPackedID >> 3 ) + if ( (v8->uPackedID & 7) == OBJECT_Actor && ai_near_actors_ids[v20] == v8->uPackedID >> 3 ) break; ++v18; ++v8; @@ -9597,7 +9597,7 @@ } if ( v18 == v1->uActorQueueSize ) { - v9 = ai_array_4F7DB0_actor_ids[v20]; + v9 = ai_near_actors_ids[v20]; *(int *)v7 = 1; *((int *)v7 + 2) = v2; *((int *)v7 - 1) = 8 * v9 | 3;
--- a/mm7_data.cpp Sat Feb 23 04:02:05 2013 +0200 +++ b/mm7_data.cpp Sat Feb 23 08:27:32 2013 +0200 @@ -1668,8 +1668,8 @@ int ai_array_4F6638_actor_ids[500]; int dword_4F6E08[500]; int ai_arrays_size; // weak -int ai_array_4F75E0[500]; -unsigned int ai_array_4F7DB0_actor_ids[500]; +int ai_near_actors_distances[500]; +unsigned int ai_near_actors_ids[500]; int dword_4F8580[182]; // weak int dword_4FA9B0[777]; // weak int dword_4FA9B4[777]; // weak
--- a/mm7_data.h Sat Feb 23 04:02:05 2013 +0200 +++ b/mm7_data.h Sat Feb 23 08:27:32 2013 +0200 @@ -1072,8 +1072,8 @@ extern int ai_array_4F6638_actor_ids[500]; extern int dword_4F6E08[500]; extern int ai_arrays_size; // weak -extern int ai_array_4F75E0[500]; -extern unsigned int ai_array_4F7DB0_actor_ids[500]; +extern int ai_near_actors_distances[500]; +extern unsigned int ai_near_actors_ids[500]; extern int dword_4F8580[]; // weak extern int dword_4FA9B0[]; // weak extern int dword_4FA9B4[]; // weak