Mercurial > mm7
changeset 2106:b52c09e01e7e
PlaySound() blv_door and other sounds
author | Ritor1 |
---|---|
date | Fri, 20 Dec 2013 00:37:39 +0600 |
parents | 7ee21636d67a |
children | 16f5a7ca289a 18b0ff5e1bf1 |
files | AudioPlayer.cpp Spells.cpp |
diffstat | 2 files changed, 104 insertions(+), 208 deletions(-) [+] |
line wrap: on
line diff
--- a/AudioPlayer.cpp Thu Dec 19 00:55:16 2013 +0600 +++ b/AudioPlayer.cpp Fri Dec 20 00:37:39 2013 +0600 @@ -559,9 +559,6 @@ //----- (004AA306) -------------------------------------------------------- void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int PartyX, signed int PartyY, int a7, unsigned int uVolume, int sPlaybackRate) { - //AudioPlayer *pAudioPlayer1; // esi@1 - //signed int pNum; // edx@5 - //int *pSoundID; // ecx@6 int v12; // edi@13 signed int v13; // ecx@17 signed int v14; // eax@20 @@ -587,9 +584,7 @@ int v34; // eax@70 char v35; // zf@70 signed int v36; // ebx@74 - //AudioPlayer *pAudioPlayer2; // edi@79 AudioPlayer_3DSample *pAudioPlayer_3DSample3; // esi@79 - //unsigned int v39; // ebx@80 int v40; // eax@81 char *v41; // edi@82 int v42; // esi@82 @@ -605,47 +600,16 @@ int v52; // eax@104 float v53; // ST0C_4@106 float v54; // ST04_4@106 - //AudioPlayer *pAudioPlayer3; // edx@106 SoundDesc *pSoundDesc; // edx@107 SpriteObject *pLayingItem3; // eax@114 - //int v58; // edx@115 - //int v59; // ecx@115 - //Actor *pActor2; // eax@118 - //MixerChannel *pMixerChannel; // esi@126 signed int v62; // esi@133 - //AudioPlayer *pAudioPlayer4; // ebx@133 - //MixerChannel *pMixerChannel2; // edi@134 - //int v65; // ebx@141 - //AudioPlayer *pAudioPlayer5; // ecx@142 - //MixerChannel *pMixerChannel3; // edi@142 int v68; // eax@143 - //MixerChannel *pMixerChannel4; // edi@149 - //int v70; // ecx@152 - //SoundDesc *pSoundDesc2; // eax@153 - //int v72; // edi@156 - //MixerChannel *pMixerChannel5; // esi@157 - //unsigned int pVolume; // eax@157 - //int pPartyX; // ebx@159 - //int v76; // ebx@160 - //SpriteObject *pLayingItem4; // edi@164 - //unsigned int pPosY; // edx@166 - //unsigned int pPosX; // ecx@166 - //int v80; // eax@167 - //Actor *pActor3; // edi@168 - //BLVDoor *pBLVDoor2; // edi@173 - //int v83; // eax@183 - //int v84; // eax@183 - //_SAMPLE *v85; // ST18_4@186 unsigned int v86; // [sp+14h] [bp-60h]@84 - //int v87; // [sp+14h] [bp-60h]@115 RenderVertexSoft pRenderVertexSoft; // [sp+24h] [bp-50h]@1 - //unsigned int v89; // [sp+54h] [bp-20h]@12 int v90; // [sp+58h] [bp-1Ch]@68 float v91; // [sp+5Ch] [bp-18h]@68 - //unsigned int v92; // [sp+60h] [bp-14h]@10 float v93; // [sp+64h] [bp-10h]@1 signed int varC; // [sp+68h] [bp-Ch]@68 - //AudioPlayer *pAudioPlayer; // [sp+6Ch] [bp-8h]@1 int v96; // [sp+70h] [bp-4h]@19 signed int uNumRepeatsb; // [sp+84h] [bp+10h]@93 float uNumRepeatsa; // [sp+84h] [bp+10h]@104 @@ -655,22 +619,11 @@ int v102; // [sp+90h] [bp+1Ch]@60 int v103; // [sp+90h] [bp+1Ch]@68 - if (!bPlayerReady) - return; - if (!uSoundVolumeMultiplier) - return; - if (!hDigDriver) - return; - if (eSoundID == SOUND_Invalid) + if ( !bPlayerReady || !uSoundVolumeMultiplier || !hDigDriver || eSoundID == SOUND_Invalid ) return; - //pAudioPlayer = this; - //v35 = this->bPlayerReady == 0; - //pAudioPlayer = this; - //LODWORD(v93) = 10000; int sample_volume = 10000; - int sound_id = 0; for (uint i = 0; i < pSoundList->sNumSounds; ++i) if (pSoundList->pSounds[i].uSoundID == eSoundID) @@ -685,39 +638,72 @@ return; } assert(sound_id < pSoundList->sNumSounds); - SoundDesc* sound_desc = &pSoundList->pSounds[sound_id]; - if ( !a7 ) - { - //pSoundDesc = pSoundList->pSounds; - //pSoundDesc2 = &pSoundList->pSounds[sound_id]; - if ( !sound_desc->pSoundData[0] ) - { - if ( sound_desc->eType == SOUND_DESC_SWAP ) - pSoundList->LoadSound(eSoundID, 0); - } - } - //v72 = 4 * (a7 + 30 * sound_id) + 44; - if ( !pSoundList->pSounds[sound_id].pSoundData[a7] ) - return; + if ( !a7 ) + { + if ( !pSoundList->pSounds[sound_id].pSoundData[0] ) + { + if ( pSoundList->pSounds[sound_id].eType == SOUND_DESC_SWAP ) + pSoundList->LoadSound(eSoundID, 0); + } + } + if ( !pSoundList->pSounds[sound_id].pSoundData[a7] ) + return; int start_channel = 0, end_channel = 0; -v62 = start_channel; + v62 = start_channel; - if (!b3DSoundInitialized || sound_desc->Is3D()) + if (!b3DSoundInitialized || pSoundList->pSounds[sound_id].Is3D()) { if (a3 == 0) // generic sound like from UI { - for (int i = 10; i <= 12; ++i) + start_channel = 10; + end_channel = 12; + for (uint i = start_channel; i <= end_channel; ++i) { - if (AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Done) + if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) { - AIL_end_sample(pMixerChannels[i].hSample); - if ( pMixerChannels[i].uSourceTrackIdx ) - FreeChannel(&pMixerChannels[i]); - break; + if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) + return; // already playing the same sound from the same source - return + AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch + FreeChannel(&pMixerChannels[i]); } } + for ( uint j = start_channel; j <= end_channel; j++ ) + { + if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) + { + AIL_init_sample(pMixerChannels[j].hSample); + AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); + if ( sample_volume == 10000 ) + sample_volume = uMasterVolume; + if (uVolume) + sample_volume = uVolume; + int object_type = PID_TYPE(a3), + object_id = PID_ID(a3); + /*if (PartyX != -1) + { + if (!PartyX) + PartyX = pParty->vPosition.x; + if (!PartyY) + PartyY = pParty->vPosition.y; + AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(PartyX, PartyY)); + AIL_set_sample_volume(pMixerChannels[v62].hSample, GetSoundStrengthByDistanceFromParty(PartyX, PartyY, pParty->vPosition.z)); + } */ + if (uNumRepeats) + AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); + pMixerChannels[j].uSourceTrackIdx = sound_id; + pMixerChannels[j].source_pid = a3; + pMixerChannels[j].uSourceTrackID = eSoundID; + int rval = AIL_start_sample(pMixerChannels[j].hSample); + if ( sPlaybackRate ) + AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); + if (object_type == OBJECT_Player) + AIL_sample_ms_position(pMixerChannels[j].hSample, &sLastTrackLengthMS, 0); + return; + } + } + return; } else if (a3 == -1) // exclusive sounds - can override { @@ -728,20 +714,49 @@ FreeChannel(&pMixerChannels[13]); } } + else if (a3 < 0) // exclusive sounds - no override (close chest) + { + start_channel = 14; + end_channel = 14; + for (uint i = start_channel; i <= end_channel; ++i) + { + if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) + { + if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) + return; // already playing the same sound from the same source - return + AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch + FreeChannel(&pMixerChannels[i]); + } + } + for ( uint j = start_channel; j <= end_channel; j++ ) + { + if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) + { + AIL_init_sample(pMixerChannels[j].hSample); + AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); + if ( sample_volume == 10000 ) + sample_volume = uMasterVolume; + if (uVolume) + sample_volume = uVolume; + int object_type = PID_TYPE(a3), + object_id = PID_ID(a3); + if (uNumRepeats) + AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); + pMixerChannels[j].uSourceTrackIdx = sound_id; + pMixerChannels[j].source_pid = a3; + pMixerChannels[j].uSourceTrackID = eSoundID; + int rval = AIL_start_sample(pMixerChannels[j].hSample);//no sound chest close + if ( sPlaybackRate ) + AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); + if (object_type == OBJECT_Player) + AIL_sample_ms_position(pMixerChannels[j].hSample, &sLastTrackLengthMS, 0); + return; + } + } + return; + } else { - if (a3 < 0) // exclusive sounds - no override - { - if ( pMixerChannels[14].source_pid == a3 && AIL_sample_status(pMixerChannels[14].hSample) == AIL::Sample::Playing ) - { - if ( pMixerChannels[14].uSourceTrackIdx == sound_id ) - return; // already playing the same sound from the same source - return - AIL_end_sample(pMixerChannels[14].hSample); // requested new sound from the same source - end & switch - FreeChannel(&pMixerChannels[14]); - } - } - else - { int object_type = PID_TYPE(a3), object_id = PID_ID(a3); switch (object_type) @@ -774,12 +789,12 @@ if (uVolume) sample_volume = uVolume; AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume); - if (!GetSoundStrengthByDistanceFromParty(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0], pIndoor->pDoors[object_id].pZOffsets[0])) + /*if (!GetSoundStrengthByDistanceFromParty(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0], pIndoor->pDoors[object_id].pZOffsets[0])) { AIL_end_sample(pMixerChannels[j].hSample); FreeChannel(&pMixerChannels[j]); return; - } + } */ AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0])); if (uNumRepeats) AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); @@ -1017,27 +1032,11 @@ assert(false); } } - } - /*if ( start_channel <= end_channel) - { - pMixerChannel2 = &pAudioPlayer->pMixerChannels[start_channel]; - while ( AIL_sample_status(pMixerChannel2->hSample) != AIL::Sample::Done) - { - ++v62; - ++pMixerChannel2; - if ( v62 > end_channel ) - goto LABEL_140; - } - AIL_end_sample(pMixerChannel2->hSample); - if ( pMixerChannel2->uSourceTrackIdx ) - _4ABE55(pMixerChannel2); - } -LABEL_140:*/ + __debugbreak();//Ritor1 if (start_channel > end_channel) // no free channel - occupy the quitest one { start_channel = -1; - int min_volume = sample_volume; for (uint i = start_channel; i <= end_channel; ++i) { @@ -1048,32 +1047,12 @@ start_channel = i; } } - /*v65 = start_channel; - v91 = v93; - if (start_channel <= end_channel) - { - //pAudioPlayer5 = pAudioPlayer; - pMixerChannel3 = &pAudioPlayer->pMixerChannels[start_channel]; - do - { - v68 = AIL_sample_volume(pMixerChannel3->hSample); - if ( v68 < SLODWORD(v91) ) - { - LODWORD(v91) = v68; - v62 = v65; - } - ++v65; - ++pMixerChannel3; - } - while ( v65 <= end_channel );*/ - if (v62 == -1) // no free channels at all - only channel 13 allows override (a3 == -1) { if (start_channel != 13) return; v62 = 13; } - AIL_end_sample(pMixerChannels[v62].hSample); FreeChannel(&pMixerChannels[v62]); } @@ -1084,21 +1063,6 @@ if ( sample_volume == 10000 ) sample_volume = uMasterVolume; - //v70 = 0; - if ( !a7 ) - { - //pSoundDesc = pSoundList->pSounds; - //pSoundDesc2 = &pSoundList->pSounds[sound_id]; - if ( !sound_desc->pSoundData[0] ) - { - if ( sound_desc->eType == SOUND_DESC_SWAP ) - pSoundList->LoadSound(eSoundID, 0); - } - } - //v72 = 4 * (a7 + 30 * sound_id) + 44; - if ( !pSoundList->pSounds[sound_id].pSoundData[a7] ) - return; - AIL_init_sample(pMixerChannels[v62].hSample); AIL_set_sample_file(pMixerChannels[v62].hSample, (char *)pSoundList->pSounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); if (uVolume) @@ -1116,64 +1080,6 @@ AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(PartyX, PartyY)); AIL_set_sample_volume(pMixerChannels[v62].hSample, GetSoundStrengthByDistanceFromParty(PartyX, PartyY, pParty->vPosition.z)); } - /*else if (object_type == OBJECT_BLVDoor) - { - assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); - assert(object_id < pIndoor->uNumDoors); - if ( !pIndoor->pDoors[object_id].uDoorID ) - return; - - if (!GetSoundStrengthByDistanceFromParty(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0], pIndoor->pDoors[object_id].pZOffsets[0])) - { - AIL_end_sample(pMixerChannels[v62].hSample); - FreeChannel(&pMixerChannels[v62]); - return; - } - AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0])); - } - else if (object_type == OBJECT_Item) - { - assert(object_id < uNumSpriteObjects); - if (!GetSoundStrengthByDistanceFromParty(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y, pSpriteObjects[object_id].vPosition.z) ) - return; - AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y)); - } - else if (object_type == OBJECT_Actor) - { - assert(object_id < uNumActors); - if (!GetSoundStrengthByDistanceFromParty(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y, pActors[object_id].vPosition.z)) - return; - AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y)); - if (uNumRepeats) - AIL_set_sample_loop_count(pMixerChannels[v62].hSample, uNumRepeats - 1); - pMixerChannels[v62].uSourceTrackIdx = sound_id; - pMixerChannels[v62].source_pid = a3; - pMixerChannels[v62].uSourceTrackID = eSoundID; - int rval = AIL_start_sample(pMixerChannels[v62].hSample); - if ( sPlaybackRate ) - AIL_set_sample_playback_rate(pMixerChannels[v62].hSample, sPlaybackRate); - if (object_type == OBJECT_Player) - AIL_sample_ms_position(pMixerChannels[v62].hSample, &sLastTrackLengthMS, 0); - return; - } - else if (object_type == OBJECT_Decoration) - { - assert(object_id < uNumLevelDecorations); - if (!GetSoundStrengthByDistanceFromParty(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y, pLevelDecorations[object_id].vPosition.z)) - return; - AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y)); - if (uNumRepeats) - AIL_set_sample_loop_count(pMixerChannels[v62].hSample, uNumRepeats - 1); - pMixerChannels[v62].uSourceTrackIdx = sound_id; - pMixerChannels[v62].source_pid = a3; - pMixerChannels[v62].uSourceTrackID = eSoundID; - int rval = AIL_start_sample(pMixerChannels[v62].hSample); - if ( sPlaybackRate ) - AIL_set_sample_playback_rate(pMixerChannels[v62].hSample, sPlaybackRate); - if (object_type == OBJECT_Player) - AIL_sample_ms_position(pMixerChannels[v62].hSample, &sLastTrackLengthMS, 0); - return; - } */ if (uNumRepeats) AIL_set_sample_loop_count(pMixerChannels[v62].hSample, uNumRepeats - 1);
--- a/Spells.cpp Thu Dec 19 00:55:16 2013 +0600 +++ b/Spells.cpp Fri Dec 20 00:37:39 2013 +0600 @@ -960,21 +960,11 @@ if ( v15 > 0 ) { if ( v15 <= 2 ) - { v9 = 60 * (uSkill + 60); - } - else - { - if ( v15 == 3 ) - { - v9 = 180 * (uSkill + 20); - } - else - { - if ( v15 == 4 ) - v9 = 240 * (uSkill + 15); - } - } + else if ( v15 == 3 ) + v9 = 180 * (uSkill + 20); + else if ( v15 == 4 ) + v9 = 240 * (uSkill + 15); } //levela = 1; //v32 = pParty->pPlayers;//[0].pConditions[1];