comparison AudioPlayer.cpp @ 2396:6997e2ad913b

_46BFFA_check_object_intercept refactor
author zipi
date Sun, 06 Jul 2014 16:27:17 +0100
parents bddcaf5d5db2
children e7a551f458e1
comparison
equal deleted inserted replaced
2395:eba7123e4a2d 2396:6997e2ad913b
484 } 484 }
485 } 485 }
486 } 486 }
487 487
488 //----- (004AA306) -------------------------------------------------------- 488 //----- (004AA306) --------------------------------------------------------
489 void AudioPlayer::PlaySound(SoundID eSoundID, signed int a3, unsigned int uNumRepeats, signed int source_x, signed int source_y, int a7, float uVolume, int sPlaybackRate) 489 void AudioPlayer::PlaySound(SoundID eSoundID, signed int pid, unsigned int uNumRepeats, signed int source_x, signed int source_y, int sound_data_id, float uVolume, int sPlaybackRate)
490 { 490 {
491 int v12; // edi@13 491 int v12; // edi@13
492 signed int v13; // ecx@17 492 signed int v13; // ecx@17
493 signed int v14; // eax@20 493 signed int v14; // eax@20
494 int v15; // eax@24 494 int v15; // eax@24
565 { 565 {
566 Log::Warning(L"SoundID = %u not found", eSoundID); 566 Log::Warning(L"SoundID = %u not found", eSoundID);
567 return; 567 return;
568 } 568 }
569 assert(sound_id < pSoundList->sNumSounds); 569 assert(sound_id < pSoundList->sNumSounds);
570 if ( !a7 ) 570 if ( !sound_data_id )
571 { 571 {
572 if ( !pSoundList->pSL_Sounds[sound_id].pSoundData[0] ) 572 if ( !pSoundList->pSL_Sounds[sound_id].pSoundData[0] )
573 { 573 {
574 if ( pSoundList->pSL_Sounds[sound_id].eType == SOUND_DESC_SWAP ) 574 if ( pSoundList->pSL_Sounds[sound_id].eType == SOUND_DESC_SWAP )
575 pSoundList->LoadSound(eSoundID, 0); 575 pSoundList->LoadSound(eSoundID, 0);
576 } 576 }
577 } 577 }
578 if ( !pSoundList->pSL_Sounds[sound_id].pSoundData[a7] ) 578 if ( !pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] )
579 return; 579 return;
580 580
581 int start_channel = 0, 581 int start_channel = 0,
582 end_channel = 0; 582 end_channel = 0;
583 v62 = start_channel; 583 v62 = start_channel;
584 584
585 if (!b3DSoundInitialized || pSoundList->pSL_Sounds[sound_id].Is3D()) 585 if (!b3DSoundInitialized || pSoundList->pSL_Sounds[sound_id].Is3D())
586 { 586 {
587 if (a3 == 0) // generic sound like from UI 587 if (pid == 0) // generic sound like from UI
588 { 588 {
589 start_channel = 10; 589 start_channel = 10;
590 end_channel = 12; 590 end_channel = 12;
591 for (uint i = start_channel; i <= end_channel; ++i) 591 for (uint i = start_channel; i <= end_channel; ++i)
592 { 592 {
593 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) 593 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )
594 { 594 {
595 if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) 595 if ( pMixerChannels[i].uSourceTrackIdx == sound_id )
596 return; // already playing the same sound from the same source - return 596 return; // already playing the same sound from the same source - return
597 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 597 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
598 FreeChannel(&pMixerChannels[i]); 598 FreeChannel(&pMixerChannels[i]);
601 for ( uint j = start_channel; j <= end_channel; j++ ) 601 for ( uint j = start_channel; j <= end_channel; j++ )
602 { 602 {
603 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 603 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
604 { 604 {
605 AIL_init_sample(pMixerChannels[j].hSample); 605 AIL_init_sample(pMixerChannels[j].hSample);
606 char *p = (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7]; 606 char *p = (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id];
607 if (a7 == 0) p = p + 4;//for RIFF 607 if (sound_data_id == 0) p = p + 4;//for RIFF
608 if ( eSoundID == 75 )// Ritor1: include +7 for pSounds[20] 608 if ( eSoundID == 75 )// Ritor1: include +7 for pSounds[20]
609 p = p + 7; 609 p = p + 7;
610 AIL_set_sample_file(pMixerChannels[j].hSample, p, -1); 610 AIL_set_sample_file(pMixerChannels[j].hSample, p, -1);
611 if ( sample_volume == 10000 ) 611 if ( sample_volume == 10000 )
612 sample_volume = uMasterVolume; 612 sample_volume = uMasterVolume;
613 if (uVolume) 613 if (uVolume)
614 sample_volume = uVolume; 614 sample_volume = uVolume;
615 int object_type = PID_TYPE(a3), 615 int object_type = PID_TYPE(pid),
616 object_id = PID_ID(a3); 616 object_id = PID_ID(pid);
617 if (source_x != -1)//срабатывает например у форта в Хермондейле звук выстрелов пушек 617 if (source_x != -1)//срабатывает например у форта в Хермондейле звук выстрелов пушек
618 { 618 {
619 //if (!source_x) 619 //if (!source_x)
620 //source_x = pParty->vPosition.x; 620 //source_x = pParty->vPosition.x;
621 //if (!source_y) 621 //if (!source_y)
628 } 628 }
629 } 629 }
630 if (uNumRepeats) 630 if (uNumRepeats)
631 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 631 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
632 pMixerChannels[j].uSourceTrackIdx = sound_id; 632 pMixerChannels[j].uSourceTrackIdx = sound_id;
633 pMixerChannels[j].source_pid = a3; 633 pMixerChannels[j].source_pid = pid;
634 pMixerChannels[j].uSourceTrackID = eSoundID; 634 pMixerChannels[j].uSourceTrackID = eSoundID;
635 int rval = AIL_start_sample(pMixerChannels[j].hSample); 635 int rval = AIL_start_sample(pMixerChannels[j].hSample);
636 if ( sPlaybackRate ) 636 if ( sPlaybackRate )
637 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 637 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
638 if (object_type == OBJECT_Player) 638 if (object_type == OBJECT_Player)
640 return; 640 return;
641 } 641 }
642 } 642 }
643 return; 643 return;
644 } 644 }
645 else if (a3 == -1) // exclusive sounds - can override 645 else if (pid == -1) // exclusive sounds - can override
646 { 646 {
647 /*if ( AIL_sample_status(pMixerChannels[13].hSample) == AIL::Sample::Done ) 647 /*if ( AIL_sample_status(pMixerChannels[13].hSample) == AIL::Sample::Done )
648 { 648 {
649 AIL_end_sample(pMixerChannels[13].hSample); 649 AIL_end_sample(pMixerChannels[13].hSample);
650 if ( pMixerChannels[13].uSourceTrackIdx ) 650 if ( pMixerChannels[13].uSourceTrackIdx )
651 FreeChannel(&pMixerChannels[13]); 651 FreeChannel(&pMixerChannels[13]);
652 }*/ 652 }*/
653 AIL_init_sample(pMixerChannels[13].hSample); 653 AIL_init_sample(pMixerChannels[13].hSample);
654 char *p = (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7]; 654 char *p = (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id];
655 if (a7 == 0) 655 if (sound_data_id == 0)
656 p = p + 4;//for RIFF 656 p = p + 4;//for RIFF
657 if ( eSoundID == 75 )// Ritor1: include +7 for pSounds[20] 657 if ( eSoundID == 75 )// Ritor1: include +7 for pSounds[20]
658 p = p + 7; 658 p = p + 7;
659 AIL_set_sample_file(pMixerChannels[13].hSample, p, -1); 659 AIL_set_sample_file(pMixerChannels[13].hSample, p, -1);
660 if ( sample_volume == 10000 ) 660 if ( sample_volume == 10000 )
661 sample_volume = uMasterVolume; 661 sample_volume = uMasterVolume;
662 if (uVolume) 662 if (uVolume)
663 sample_volume = uVolume; 663 sample_volume = uVolume;
664 AIL_set_sample_volume(pMixerChannels[13].hSample, sample_volume); 664 AIL_set_sample_volume(pMixerChannels[13].hSample, sample_volume);
665 int object_type = PID_TYPE(a3), 665 int object_type = PID_TYPE(pid),
666 object_id = PID_ID(a3); 666 object_id = PID_ID(pid);
667 if (uNumRepeats) 667 if (uNumRepeats)
668 AIL_set_sample_loop_count(pMixerChannels[13].hSample, uNumRepeats - 1); 668 AIL_set_sample_loop_count(pMixerChannels[13].hSample, uNumRepeats - 1);
669 pMixerChannels[13].uSourceTrackIdx = sound_id; 669 pMixerChannels[13].uSourceTrackIdx = sound_id;
670 pMixerChannels[13].source_pid = a3; 670 pMixerChannels[13].source_pid = pid;
671 pMixerChannels[13].uSourceTrackID = eSoundID; 671 pMixerChannels[13].uSourceTrackID = eSoundID;
672 int rval = AIL_start_sample(pMixerChannels[13].hSample);//no sound chest close 672 int rval = AIL_start_sample(pMixerChannels[13].hSample);//no sound chest close
673 if ( sPlaybackRate ) 673 if ( sPlaybackRate )
674 AIL_set_sample_playback_rate(pMixerChannels[13].hSample, sPlaybackRate); 674 AIL_set_sample_playback_rate(pMixerChannels[13].hSample, sPlaybackRate);
675 if (object_type == OBJECT_Player) 675 if (object_type == OBJECT_Player)
676 AIL_sample_ms_position(pMixerChannels[13].hSample, &sLastTrackLengthMS, 0); 676 AIL_sample_ms_position(pMixerChannels[13].hSample, &sLastTrackLengthMS, 0);
677 return; 677 return;
678 } 678 }
679 else if (a3 < 0) // exclusive sounds - no override (close chest) 679 else if (pid < 0) // exclusive sounds - no override (close chest)
680 { 680 {
681 start_channel = 14; 681 start_channel = 14;
682 end_channel = 14; 682 end_channel = 14;
683 for (uint i = start_channel; i <= end_channel; ++i) 683 for (uint i = start_channel; i <= end_channel; ++i)
684 { 684 {
685 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) 685 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )
686 { 686 {
687 if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) 687 if ( pMixerChannels[i].uSourceTrackIdx == sound_id )
688 return; // already playing the same sound from the same source - return 688 return; // already playing the same sound from the same source - return
689 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 689 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
690 FreeChannel(&pMixerChannels[i]); 690 FreeChannel(&pMixerChannels[i]);
693 for ( uint j = start_channel; j <= end_channel; j++ ) 693 for ( uint j = start_channel; j <= end_channel; j++ )
694 { 694 {
695 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 695 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
696 { 696 {
697 AIL_init_sample(pMixerChannels[j].hSample); 697 AIL_init_sample(pMixerChannels[j].hSample);
698 char *p = (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7]; 698 char *p = (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id];
699 if (a7 == 0) p = p + 4;//for RIFF 699 if (sound_data_id == 0) p = p + 4;//for RIFF
700 if ( eSoundID == 75 )// Ritor1: include +7 for pSounds[20] 700 if ( eSoundID == 75 )// Ritor1: include +7 for pSounds[20]
701 p = p + 7; 701 p = p + 7;
702 AIL_set_sample_file(pMixerChannels[j].hSample, p, -1); 702 AIL_set_sample_file(pMixerChannels[j].hSample, p, -1);
703 if ( sample_volume == 10000 ) 703 if ( sample_volume == 10000 )
704 sample_volume = uMasterVolume; 704 sample_volume = uMasterVolume;
705 if (uVolume) 705 if (uVolume)
706 sample_volume = uVolume; 706 sample_volume = uVolume;
707 int object_type = PID_TYPE(a3), 707 int object_type = PID_TYPE(pid),
708 object_id = PID_ID(a3); 708 object_id = PID_ID(pid);
709 if (uNumRepeats) 709 if (uNumRepeats)
710 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 710 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
711 pMixerChannels[j].uSourceTrackIdx = sound_id; 711 pMixerChannels[j].uSourceTrackIdx = sound_id;
712 pMixerChannels[j].source_pid = a3; 712 pMixerChannels[j].source_pid = pid;
713 pMixerChannels[j].uSourceTrackID = eSoundID; 713 pMixerChannels[j].uSourceTrackID = eSoundID;
714 int rval = AIL_start_sample(pMixerChannels[j].hSample);//no sound chest close 714 int rval = AIL_start_sample(pMixerChannels[j].hSample);//no sound chest close
715 if ( sPlaybackRate ) 715 if ( sPlaybackRate )
716 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 716 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
717 if (object_type == OBJECT_Player) 717 if (object_type == OBJECT_Player)
721 } 721 }
722 return; 722 return;
723 } 723 }
724 else 724 else
725 { 725 {
726 int object_type = PID_TYPE(a3), 726 int object_type = PID_TYPE(pid),
727 object_id = PID_ID(a3); 727 object_id = PID_ID(pid);
728 switch (object_type) 728 switch (object_type)
729 { 729 {
730 case OBJECT_BLVDoor: 730 case OBJECT_BLVDoor:
731 { 731 {
732 assert(uCurrentlyLoadedLevelType == LEVEL_Indoor); 732 assert(uCurrentlyLoadedLevelType == LEVEL_Indoor);
736 736
737 start_channel = 10; 737 start_channel = 10;
738 end_channel = 12; 738 end_channel = 12;
739 for (uint i = start_channel; i <= end_channel; ++i) 739 for (uint i = start_channel; i <= end_channel; ++i)
740 { 740 {
741 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) 741 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )
742 { 742 {
743 if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) 743 if ( pMixerChannels[i].uSourceTrackIdx == sound_id )
744 return; // already playing the same sound from the same source - return 744 return; // already playing the same sound from the same source - return
745 AIL_end_sample( pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 745 AIL_end_sample( pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
746 FreeChannel(&pMixerChannels[i]); 746 FreeChannel(&pMixerChannels[i]);
749 for ( uint j = start_channel; j <= end_channel; j++ ) 749 for ( uint j = start_channel; j <= end_channel; j++ )
750 { 750 {
751 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 751 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
752 { 752 {
753 AIL_init_sample(pMixerChannels[j].hSample); 753 AIL_init_sample(pMixerChannels[j].hSample);
754 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); 754 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] + 4 * (sound_data_id == 0), -1);
755 if (uVolume) 755 if (uVolume)
756 sample_volume = uVolume; 756 sample_volume = uVolume;
757 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume); 757 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume);
758 /*if (!GetSoundStrengthByDistanceFromParty(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0], pIndoor->pDoors[object_id].pZOffsets[0])) 758 /*if (!GetSoundStrengthByDistanceFromParty(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0], pIndoor->pDoors[object_id].pZOffsets[0]))
759 { 759 {
763 } */ 763 } */
764 AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0])); 764 AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(pIndoor->pDoors[object_id].pXOffsets[0], pIndoor->pDoors[object_id].pYOffsets[0]));
765 if (uNumRepeats) 765 if (uNumRepeats)
766 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 766 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
767 pMixerChannels[j].uSourceTrackIdx = sound_id; 767 pMixerChannels[j].uSourceTrackIdx = sound_id;
768 pMixerChannels[j].source_pid = a3; 768 pMixerChannels[j].source_pid = pid;
769 pMixerChannels[j].uSourceTrackID = eSoundID; 769 pMixerChannels[j].uSourceTrackID = eSoundID;
770 int rval = AIL_start_sample(pMixerChannels[j].hSample); 770 int rval = AIL_start_sample(pMixerChannels[j].hSample);
771 if ( sPlaybackRate ) 771 if ( sPlaybackRate )
772 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 772 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
773 if (object_type == OBJECT_Player) 773 if (object_type == OBJECT_Player)
782 { 782 {
783 start_channel = 10; 783 start_channel = 10;
784 end_channel = 12; 784 end_channel = 12;
785 for (uint i = start_channel; i <= end_channel; ++i) 785 for (uint i = start_channel; i <= end_channel; ++i)
786 { 786 {
787 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) 787 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )
788 { 788 {
789 if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) 789 if ( pMixerChannels[i].uSourceTrackIdx == sound_id )
790 return; // already playing the same sound from the same source - return 790 return; // already playing the same sound from the same source - return
791 AIL_end_sample( pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 791 AIL_end_sample( pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
792 FreeChannel(&pMixerChannels[i]); 792 FreeChannel(&pMixerChannels[i]);
795 for ( uint j = start_channel; j <= end_channel; j++ ) 795 for ( uint j = start_channel; j <= end_channel; j++ )
796 { 796 {
797 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 797 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
798 { 798 {
799 AIL_init_sample(pMixerChannels[j].hSample); 799 AIL_init_sample(pMixerChannels[j].hSample);
800 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); 800 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] + 4 * (sound_data_id == 0), -1);
801 if (uVolume) 801 if (uVolume)
802 sample_volume = uVolume; 802 sample_volume = uVolume;
803 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume); 803 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume);
804 if (uNumRepeats) 804 if (uNumRepeats)
805 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 805 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
806 pMixerChannels[j].uSourceTrackIdx = sound_id; 806 pMixerChannels[j].uSourceTrackIdx = sound_id;
807 pMixerChannels[j].source_pid = a3; 807 pMixerChannels[j].source_pid = pid;
808 pMixerChannels[j].uSourceTrackID = eSoundID; 808 pMixerChannels[j].uSourceTrackID = eSoundID;
809 int rval = AIL_start_sample(pMixerChannels[j].hSample); 809 int rval = AIL_start_sample(pMixerChannels[j].hSample);
810 if ( sPlaybackRate ) 810 if ( sPlaybackRate )
811 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 811 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
812 if (object_type == OBJECT_Player) 812 if (object_type == OBJECT_Player)
825 sample_volume = GetSoundStrengthByDistanceFromParty(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y, pActors[object_id].vPosition.z); 825 sample_volume = GetSoundStrengthByDistanceFromParty(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y, pActors[object_id].vPosition.z);
826 if (!sample_volume) 826 if (!sample_volume)
827 return; 827 return;
828 for (uint i = start_channel; i <= end_channel; ++i) 828 for (uint i = start_channel; i <= end_channel; ++i)
829 { 829 {
830 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) 830 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )
831 { 831 {
832 if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) 832 if ( pMixerChannels[i].uSourceTrackIdx == sound_id )
833 return; // already playing the same sound from the same source - return 833 return; // already playing the same sound from the same source - return
834 AIL_end_sample( pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 834 AIL_end_sample( pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
835 FreeChannel(&pMixerChannels[i]); 835 FreeChannel(&pMixerChannels[i]);
838 for ( uint j = start_channel; j <= end_channel; j++ ) 838 for ( uint j = start_channel; j <= end_channel; j++ )
839 { 839 {
840 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 840 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
841 { 841 {
842 AIL_init_sample(pMixerChannels[j].hSample); 842 AIL_init_sample(pMixerChannels[j].hSample);
843 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); 843 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] + 4 * (sound_data_id == 0), -1);
844 if (uVolume) 844 if (uVolume)
845 sample_volume = uVolume; 845 sample_volume = uVolume;
846 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume); 846 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume);
847 if (!GetSoundStrengthByDistanceFromParty(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y, pActors[object_id].vPosition.z)) 847 if (!GetSoundStrengthByDistanceFromParty(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y, pActors[object_id].vPosition.z))
848 return; 848 return;
849 AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y)); 849 AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(pActors[object_id].vPosition.x, pActors[object_id].vPosition.y));
850 if (uNumRepeats) 850 if (uNumRepeats)
851 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 851 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
852 pMixerChannels[j].uSourceTrackIdx = sound_id; 852 pMixerChannels[j].uSourceTrackIdx = sound_id;
853 pMixerChannels[j].source_pid = a3; 853 pMixerChannels[j].source_pid = pid;
854 pMixerChannels[j].uSourceTrackID = eSoundID; 854 pMixerChannels[j].uSourceTrackID = eSoundID;
855 int rval = AIL_start_sample(pMixerChannels[j].hSample); 855 int rval = AIL_start_sample(pMixerChannels[j].hSample);
856 if ( sPlaybackRate ) 856 if ( sPlaybackRate )
857 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 857 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
858 if (object_type == OBJECT_Player) 858 if (object_type == OBJECT_Player)
871 sample_volume = GetSoundStrengthByDistanceFromParty(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y, pLevelDecorations[object_id].vPosition.z); 871 sample_volume = GetSoundStrengthByDistanceFromParty(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y, pLevelDecorations[object_id].vPosition.z);
872 if (!sample_volume) 872 if (!sample_volume)
873 return; 873 return;
874 for (uint i = start_channel; i <= end_channel; ++i) 874 for (uint i = start_channel; i <= end_channel; ++i)
875 { 875 {
876 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )//звук фонтана и шагов не проходят проверку на повтор 876 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )//звук фонтана и шагов не проходят проверку на повтор
877 { 877 {
878 if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) 878 if ( pMixerChannels[i].uSourceTrackIdx == sound_id )
879 return; // already playing the same sound from the same source - return 879 return; // already playing the same sound from the same source - return
880 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 880 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
881 FreeChannel(&pMixerChannels[i]); 881 FreeChannel(&pMixerChannels[i]);
884 for ( uint j = start_channel; j <= end_channel; j++ ) 884 for ( uint j = start_channel; j <= end_channel; j++ )
885 { 885 {
886 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 886 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
887 { 887 {
888 AIL_init_sample(pMixerChannels[j].hSample); 888 AIL_init_sample(pMixerChannels[j].hSample);
889 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); 889 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] + 4 * (sound_data_id == 0), -1);
890 if (uVolume) 890 if (uVolume)
891 sample_volume = uVolume; 891 sample_volume = uVolume;
892 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume); 892 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume);
893 if (!GetSoundStrengthByDistanceFromParty(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y, pLevelDecorations[object_id].vPosition.z)) 893 if (!GetSoundStrengthByDistanceFromParty(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y, pLevelDecorations[object_id].vPosition.z))
894 return; 894 return;
895 AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y)); 895 AIL_set_sample_pan(pMixerChannels[j].hSample, sub_4AB66C(pLevelDecorations[object_id].vPosition.x, pLevelDecorations[object_id].vPosition.y));
896 if (uNumRepeats) 896 if (uNumRepeats)
897 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 897 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
898 pMixerChannels[j].uSourceTrackIdx = sound_id; 898 pMixerChannels[j].uSourceTrackIdx = sound_id;
899 pMixerChannels[j].source_pid = a3; 899 pMixerChannels[j].source_pid = pid;
900 pMixerChannels[j].uSourceTrackID = eSoundID; 900 pMixerChannels[j].uSourceTrackID = eSoundID;
901 int rval = AIL_start_sample(pMixerChannels[j].hSample); 901 int rval = AIL_start_sample(pMixerChannels[j].hSample);
902 if ( sPlaybackRate ) 902 if ( sPlaybackRate )
903 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 903 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
904 if (object_type == OBJECT_Player) 904 if (object_type == OBJECT_Player)
917 sample_volume = GetSoundStrengthByDistanceFromParty(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y, pSpriteObjects[object_id].vPosition.z); 917 sample_volume = GetSoundStrengthByDistanceFromParty(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y, pSpriteObjects[object_id].vPosition.z);
918 if (!sample_volume) 918 if (!sample_volume)
919 return; 919 return;
920 for (uint i = start_channel; i <= end_channel; ++i) 920 for (uint i = start_channel; i <= end_channel; ++i)
921 { 921 {
922 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) 922 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )
923 { 923 {
924 if (pMixerChannels[i].uSourceTrackIdx == sound_id) 924 if (pMixerChannels[i].uSourceTrackIdx == sound_id)
925 return; // already playing the same sound from the same source - return 925 return; // already playing the same sound from the same source - return
926 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 926 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
927 FreeChannel(&pMixerChannels[i]); 927 FreeChannel(&pMixerChannels[i]);
930 for ( uint j = start_channel; j <= end_channel; j++ ) 930 for ( uint j = start_channel; j <= end_channel; j++ )
931 { 931 {
932 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 932 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
933 { 933 {
934 AIL_init_sample(pMixerChannels[j].hSample); 934 AIL_init_sample(pMixerChannels[j].hSample);
935 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); 935 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] + 4 * (sound_data_id == 0), -1);
936 if (uVolume) 936 if (uVolume)
937 sample_volume = uVolume; 937 sample_volume = uVolume;
938 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume); 938 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume);
939 if (!GetSoundStrengthByDistanceFromParty(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y, pSpriteObjects[object_id].vPosition.z) ) 939 if (!GetSoundStrengthByDistanceFromParty(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y, pSpriteObjects[object_id].vPosition.z) )
940 return; 940 return;
941 AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y)); 941 AIL_set_sample_pan(pMixerChannels[v62].hSample, sub_4AB66C(pSpriteObjects[object_id].vPosition.x, pSpriteObjects[object_id].vPosition.y));
942 if (uNumRepeats) 942 if (uNumRepeats)
943 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 943 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
944 pMixerChannels[j].uSourceTrackIdx = sound_id; 944 pMixerChannels[j].uSourceTrackIdx = sound_id;
945 pMixerChannels[j].source_pid = a3; 945 pMixerChannels[j].source_pid = pid;
946 pMixerChannels[j].uSourceTrackID = eSoundID; 946 pMixerChannels[j].uSourceTrackID = eSoundID;
947 int rval = AIL_start_sample(pMixerChannels[j].hSample); 947 int rval = AIL_start_sample(pMixerChannels[j].hSample);
948 if ( sPlaybackRate ) 948 if ( sPlaybackRate )
949 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 949 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
950 if (object_type == OBJECT_Player) 950 if (object_type == OBJECT_Player)
959 { 959 {
960 start_channel = 8; 960 start_channel = 8;
961 end_channel = 9; 961 end_channel = 9;
962 for (uint i = start_channel; i <= end_channel; ++i) 962 for (uint i = start_channel; i <= end_channel; ++i)
963 { 963 {
964 if ( pMixerChannels[i].source_pid == a3 && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing ) 964 if ( pMixerChannels[i].source_pid == pid && AIL_sample_status(pMixerChannels[i].hSample) == AIL::Sample::Playing )
965 { 965 {
966 if ( pMixerChannels[i].uSourceTrackIdx == sound_id ) 966 if ( pMixerChannels[i].uSourceTrackIdx == sound_id )
967 return; // already playing the same sound from the same source - return 967 return; // already playing the same sound from the same source - return
968 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch 968 AIL_end_sample(pMixerChannels[i].hSample); // requested new sound from the same source - end & switch
969 FreeChannel(&pMixerChannels[i]); 969 FreeChannel(&pMixerChannels[i]);
972 for ( uint j = start_channel; j <= end_channel; j++ ) 972 for ( uint j = start_channel; j <= end_channel; j++ )
973 { 973 {
974 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done ) 974 if ( AIL_sample_status(pMixerChannels[j].hSample) == AIL::Sample::Done )
975 { 975 {
976 AIL_init_sample(pMixerChannels[j].hSample); 976 AIL_init_sample(pMixerChannels[j].hSample);
977 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); 977 AIL_set_sample_file(pMixerChannels[j].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] + 4 * (sound_data_id == 0), -1);
978 if (uVolume) 978 if (uVolume)
979 sample_volume = uVolume; 979 sample_volume = uVolume;
980 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume); 980 AIL_set_sample_volume(pMixerChannels[j].hSample, sample_volume);
981 if (uNumRepeats) 981 if (uNumRepeats)
982 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1); 982 AIL_set_sample_loop_count(pMixerChannels[j].hSample, uNumRepeats - 1);
983 pMixerChannels[j].uSourceTrackIdx = sound_id; 983 pMixerChannels[j].uSourceTrackIdx = sound_id;
984 pMixerChannels[j].source_pid = a3; 984 pMixerChannels[j].source_pid = pid;
985 pMixerChannels[j].uSourceTrackID = eSoundID; 985 pMixerChannels[j].uSourceTrackID = eSoundID;
986 int rval = AIL_start_sample(pMixerChannels[j].hSample); 986 int rval = AIL_start_sample(pMixerChannels[j].hSample);
987 if ( sPlaybackRate ) 987 if ( sPlaybackRate )
988 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate); 988 AIL_set_sample_playback_rate(pMixerChannels[j].hSample, sPlaybackRate);
989 if (object_type == OBJECT_Player) 989 if (object_type == OBJECT_Player)
1028 1028
1029 if ( sample_volume == 10000 ) 1029 if ( sample_volume == 10000 )
1030 sample_volume = uMasterVolume; 1030 sample_volume = uMasterVolume;
1031 1031
1032 AIL_init_sample(pMixerChannels[v62].hSample); 1032 AIL_init_sample(pMixerChannels[v62].hSample);
1033 AIL_set_sample_file(pMixerChannels[v62].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[a7] + 4 * (a7 == 0), -1); 1033 AIL_set_sample_file(pMixerChannels[v62].hSample, (char *)pSoundList->pSL_Sounds[sound_id].pSoundData[sound_data_id] + 4 * (sound_data_id == 0), -1);
1034 if (uVolume) 1034 if (uVolume)
1035 sample_volume = uVolume; 1035 sample_volume = uVolume;
1036 AIL_set_sample_volume(pMixerChannels[v62].hSample, sample_volume); 1036 AIL_set_sample_volume(pMixerChannels[v62].hSample, sample_volume);
1037 1037
1038 int object_type = PID_TYPE(a3), 1038 int object_type = PID_TYPE(pid),
1039 object_id = PID_ID(a3); 1039 object_id = PID_ID(pid);
1040 if (source_x != -1) 1040 if (source_x != -1)
1041 { 1041 {
1042 if (!source_x) 1042 if (!source_x)
1043 source_x = pParty->vPosition.x; 1043 source_x = pParty->vPosition.x;
1044 if (!source_y) 1044 if (!source_y)
1048 } 1048 }
1049 1049
1050 if (uNumRepeats) 1050 if (uNumRepeats)
1051 AIL_set_sample_loop_count(pMixerChannels[v62].hSample, uNumRepeats - 1); 1051 AIL_set_sample_loop_count(pMixerChannels[v62].hSample, uNumRepeats - 1);
1052 pMixerChannels[v62].uSourceTrackIdx = sound_id; 1052 pMixerChannels[v62].uSourceTrackIdx = sound_id;
1053 pMixerChannels[v62].source_pid = a3; 1053 pMixerChannels[v62].source_pid = pid;
1054 pMixerChannels[v62].uSourceTrackID = eSoundID; 1054 pMixerChannels[v62].uSourceTrackID = eSoundID;
1055 int rval = AIL_start_sample(pMixerChannels[v62].hSample); 1055 int rval = AIL_start_sample(pMixerChannels[v62].hSample);
1056 if ( sPlaybackRate ) 1056 if ( sPlaybackRate )
1057 AIL_set_sample_playback_rate(pMixerChannels[v62].hSample, sPlaybackRate); 1057 AIL_set_sample_playback_rate(pMixerChannels[v62].hSample, sPlaybackRate);
1058 if (object_type == OBJECT_Player) 1058 if (object_type == OBJECT_Player)
1061 } 1061 }
1062 else 1062 else
1063 { 1063 {
1064 __debugbreak(); // 3d sound stuff, refactor 1064 __debugbreak(); // 3d sound stuff, refactor
1065 v12 = 13; 1065 v12 = 13;
1066 if ( a3 < 0 ) 1066 if ( pid < 0 )
1067 { 1067 {
1068 v15 = pAudioPlayer->uNum3DSamples; 1068 v15 = pAudioPlayer->uNum3DSamples;
1069 if ( a3 == -1 ) 1069 if ( pid == -1 )
1070 { 1070 {
1071 if ( v15 < 16 ) 1071 if ( v15 < 16 )
1072 v12 = v15 - 1; 1072 v12 = v15 - 1;
1073 v96 = v12; 1073 v96 = v12;
1074 //goto LABEL_46; 1074 //goto LABEL_46;
1085 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; 1085 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
1086 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y; 1086 pRenderVertexSoft.vWorldPosition.y = (double)pParty->vPosition.y;
1087 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; 1087 v21 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
1088 goto LABEL_47; 1088 goto LABEL_47;
1089 } 1089 }
1090 if ( PID_TYPE(a3) == 2 ) 1090 if ( PID_TYPE(pid) == 2 )
1091 { 1091 {
1092 v22 = pAudioPlayer->uNum3DSamples; 1092 v22 = pAudioPlayer->uNum3DSamples;
1093 if ( v22 < 16 ) 1093 if ( v22 < 16 )
1094 { 1094 {
1095 v12 = 5 * v22 / 16; 1095 v12 = 5 * v22 / 16;
1098 else 1098 else
1099 { 1099 {
1100 v96 = 7; 1100 v96 = 7;
1101 v12 = 5; 1101 v12 = 5;
1102 } 1102 }
1103 pLayingItem = &pSpriteObjects[PID_ID(a3)]; 1103 pLayingItem = &pSpriteObjects[PID_ID(pid)];
1104 } 1104 }
1105 else 1105 else
1106 { 1106 {
1107 if ( PID_TYPE(a3) == 3 ) 1107 if ( PID_TYPE(pid) == 3 )
1108 { 1108 {
1109 v18 = pAudioPlayer->uNum3DSamples; 1109 v18 = pAudioPlayer->uNum3DSamples;
1110 v12 = 0; 1110 v12 = 0;
1111 if ( v18 < 16 ) 1111 if ( v18 < 16 )
1112 v96 = 3 * v18 / 16; 1112 v96 = 3 * v18 / 16;
1113 else 1113 else
1114 v96 = 3; 1114 v96 = 3;
1115 pActor1 = &pActors[PID_ID(a3)]; 1115 pActor1 = &pActors[PID_ID(pid)];
1116 v20 = pActor1->vPosition.y; 1116 v20 = pActor1->vPosition.y;
1117 pRenderVertexSoft.vWorldPosition.x = (double)pActor1->vPosition.x; 1117 pRenderVertexSoft.vWorldPosition.x = (double)pActor1->vPosition.x;
1118 v100 = pActor1->vPosition.z; 1118 v100 = pActor1->vPosition.z;
1119 pRenderVertexSoft.vWorldPosition.y = (double)v20; 1119 pRenderVertexSoft.vWorldPosition.y = (double)v20;
1120 v21 = (double)v100; 1120 v21 = (double)v100;
1121 goto LABEL_47; 1121 goto LABEL_47;
1122 } 1122 }
1123 if ( PID_TYPE(a3) != 5 ) 1123 if ( PID_TYPE(pid) != 5 )
1124 { 1124 {
1125 v13 = pAudioPlayer->uNum3DSamples; 1125 v13 = pAudioPlayer->uNum3DSamples;
1126 if ( PID_TYPE(a3) == 6 ) 1126 if ( PID_TYPE(pid) == 6 )
1127 { 1127 {
1128 if ( v13 >= 16 ) 1128 if ( v13 >= 16 )
1129 { 1129 {
1130 v96 = 9; 1130 v96 = 9;
1131 v12 = 8; 1131 v12 = 8;
1171 else 1171 else
1172 { 1172 {
1173 v12 = 4; 1173 v12 = 4;
1174 v96 = 4; 1174 v96 = 4;
1175 } 1175 }
1176 pLayingItem = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; 1176 pLayingItem = (SpriteObject *)&pLevelDecorations[PID_ID(pid)];
1177 } 1177 }
1178 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x; 1178 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem->vPosition.x;
1179 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y; 1179 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem->vPosition.y;
1180 v21 = (double)pLayingItem->vPosition.z; 1180 v21 = (double)pLayingItem->vPosition.z;
1181 LABEL_47: 1181 LABEL_47:
1182 pRenderVertexSoft.vWorldPosition.z = v21; 1182 pRenderVertexSoft.vWorldPosition.z = v21;
1183 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 1183 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
1184 sub_4AAEA6_transform(&pRenderVertexSoft); 1184 sub_4AAEA6_transform(&pRenderVertexSoft);
1185 else 1185 else
1186 pGame->pIndoorCameraD3D->ViewTransform(&pRenderVertexSoft, 1); 1186 pGame->pIndoorCameraD3D->ViewTransform(&pRenderVertexSoft, 1);
1187 if ( a3 ) 1187 if ( pid )
1188 { 1188 {
1189 if ( a3 != -1 ) 1189 if ( pid != -1 )
1190 { 1190 {
1191 v101 = 0; 1191 v101 = 0;
1192 if ( pAudioPlayer->uNum3DSamples > 0 ) 1192 if ( pAudioPlayer->uNum3DSamples > 0 )
1193 { 1193 {
1194 pAudioPlayer_3DSample = pAudioPlayer->p3DSamples; 1194 pAudioPlayer_3DSample = pAudioPlayer->p3DSamples;
1195 do 1195 do
1196 { 1196 {
1197 if ( AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 1197 if ( AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4
1198 && pAudioPlayer_3DSample->field_4 == a3 && AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 ) 1198 && pAudioPlayer_3DSample->field_4 == pid && AIL_3D_sample_status(pAudioPlayer_3DSample->hSample) == 4 )
1199 { 1199 {
1200 if ( pAudioPlayer_3DSample->field_8 == sound_id ) 1200 if ( pAudioPlayer_3DSample->field_8 == sound_id )
1201 return; 1201 return;
1202 AIL_end_3D_sample(pAudioPlayer_3DSample->hSample); 1202 AIL_end_3D_sample(pAudioPlayer_3DSample->hSample);
1203 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample); 1203 pAudioPlayer->_4ABF23(pAudioPlayer_3DSample);
1293 else 1293 else
1294 v86 = 1; 1294 v86 = 1;
1295 AIL_set_3D_sample_loop_count(*(int *)v42, v86); 1295 AIL_set_3D_sample_loop_count(*(int *)v42, v86);
1296 if ( source_x == -1 ) 1296 if ( source_x == -1 )
1297 { 1297 {
1298 if ( PID_TYPE(a3) == 1 ) 1298 if ( PID_TYPE(pid) == 1 )
1299 { 1299 {
1300 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor ) 1300 if ( uCurrentlyLoadedLevelType == LEVEL_Indoor )
1301 { 1301 {
1302 //goto LABEL_103; 1302 //goto LABEL_103;
1303 pBLVDoor = &pIndoor->pDoors[PID_ID(a3)]; 1303 pBLVDoor = &pIndoor->pDoors[PID_ID(pid)];
1304 if ( !pBLVDoor->uDoorID ) 1304 if ( !pBLVDoor->uDoorID )
1305 return; 1305 return;
1306 pRenderVertexSoft.vWorldPosition.x = (double)*pBLVDoor->pXOffsets; 1306 pRenderVertexSoft.vWorldPosition.x = (double)*pBLVDoor->pXOffsets;
1307 pRenderVertexSoft.vWorldPosition.y = (double)*pBLVDoor->pYOffsets; 1307 pRenderVertexSoft.vWorldPosition.y = (double)*pBLVDoor->pYOffsets;
1308 v47 = (double)*pBLVDoor->pZOffsets; 1308 v47 = (double)*pBLVDoor->pZOffsets;
1332 AIL_set_3D_position((void *)*(int *)v42, LODWORD(v99), 0.0, LODWORD(uNumRepeatsa)); 1332 AIL_set_3D_position((void *)*(int *)v42, LODWORD(v99), 0.0, LODWORD(uNumRepeatsa));
1333 v53 = -uNumRepeatsa; 1333 v53 = -uNumRepeatsa;
1334 v54 = -v99; 1334 v54 = -v99;
1335 AIL_set_3D_orientation((void *)*(int *)v42, LODWORD(v54), 0.0, LODWORD(v53), 0.0, 1.0, 0.0); 1335 AIL_set_3D_orientation((void *)*(int *)v42, LODWORD(v54), 0.0, LODWORD(v53), 0.0, 1.0, 0.0);
1336 //pAudioPlayer3 = pAudioPlayer; 1336 //pAudioPlayer3 = pAudioPlayer;
1337 *((int *)v41 + 6) = a3; 1337 *((int *)v41 + 6) = pid;
1338 *((int *)v41 + 7) = sound_id; 1338 *((int *)v41 + 7) = sound_id;
1339 *(&pAudioPlayer->bEAXSupported + 4 * (v102 + 2)) = eSoundID; 1339 *(&pAudioPlayer->bEAXSupported + 4 * (v102 + 2)) = eSoundID;
1340 } 1340 }
1341 else 1341 else
1342 { 1342 {
1343 AIL_end_3D_sample(*(int **)v42); 1343 AIL_end_3D_sample(*(int **)v42);
1344 pAudioPlayer->_4ABF23((AudioPlayer_3DSample *)(v41 + 20)); 1344 pAudioPlayer->_4ABF23((AudioPlayer_3DSample *)(v41 + 20));
1345 } 1345 }
1346 return; 1346 return;
1347 } 1347 }
1348 if ( PID_TYPE(a3) == 2 ) 1348 if ( PID_TYPE(pid) == 2 )
1349 { 1349 {
1350 pLayingItem2 = &pSpriteObjects[PID_ID(a3)]; 1350 pLayingItem2 = &pSpriteObjects[PID_ID(pid)];
1351 } 1351 }
1352 else 1352 else
1353 { 1353 {
1354 if ( PID_TYPE(a3) == 3 ) 1354 if ( PID_TYPE(pid) == 3 )
1355 { 1355 {
1356 pActor = &pActors[PID_ID(a3)]; 1356 pActor = &pActors[PID_ID(pid)];
1357 v46 = pActor->vPosition.y; 1357 v46 = pActor->vPosition.y;
1358 pRenderVertexSoft.vWorldPosition.x = (double)pActor->vPosition.x; 1358 pRenderVertexSoft.vWorldPosition.x = (double)pActor->vPosition.x;
1359 uNumRepeatsb = pActor->vPosition.z; 1359 uNumRepeatsb = pActor->vPosition.z;
1360 pRenderVertexSoft.vWorldPosition.y = (double)v46; 1360 pRenderVertexSoft.vWorldPosition.y = (double)v46;
1361 v47 = (double)uNumRepeatsb; 1361 v47 = (double)uNumRepeatsb;
1362 goto LABEL_101; 1362 goto LABEL_101;
1363 } 1363 }
1364 if ( PID_TYPE(a3) != 5 ) 1364 if ( PID_TYPE(pid) != 5 )
1365 { 1365 {
1366 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x; 1366 pRenderVertexSoft.vWorldPosition.x = (double)pParty->vPosition.x;
1367 v43 = (double)pParty->vPosition.y; 1367 v43 = (double)pParty->vPosition.y;
1368 pRenderVertexSoft.vWorldPosition.y = v43; 1368 pRenderVertexSoft.vWorldPosition.y = v43;
1369 v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z; 1369 v47 = (double)pParty->sEyelevel + (double)pParty->vPosition.z;
1370 goto LABEL_101; 1370 goto LABEL_101;
1371 } 1371 }
1372 pLayingItem2 = (SpriteObject *)&pLevelDecorations[PID_ID(a3)]; 1372 pLayingItem2 = (SpriteObject *)&pLevelDecorations[PID_ID(pid)];
1373 } 1373 }
1374 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x; 1374 pRenderVertexSoft.vWorldPosition.x = (double)pLayingItem2->vPosition.x;
1375 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y; 1375 pRenderVertexSoft.vWorldPosition.y = (double)pLayingItem2->vPosition.y;
1376 v47 = (double)pLayingItem2->vPosition.z; 1376 v47 = (double)pLayingItem2->vPosition.z;
1377 goto LABEL_101; 1377 goto LABEL_101;