From 35d09e3f7546490635933caebb329af9d8202d1f Mon Sep 17 00:00:00 2001 From: Jens Ayton Date: Thu, 21 Aug 2008 20:48:24 +0000 Subject: [PATCH] Updated remaining old-style sound code. Afterburner loop fixed to use a single sound file instead of two identical ones. git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1736 127b21dd-08f5-0310-b4b7-95ae10353056 --- Oolite.xcodeproj/project.pbxproj | 4 - Resources/Config/customsounds.plist | 14 +- src/Core/Entities/PlayerEntity.h | 9 -- src/Core/Entities/PlayerEntity.m | 73 ++-------- src/Core/Entities/PlayerEntityControls.m | 34 ++--- src/Core/Entities/PlayerEntitySound.h | 18 +++ src/Core/Entities/PlayerEntitySound.m | 162 +++++++++++++++++++---- src/Core/Entities/ShipEntity.m | 11 +- src/Core/OOCacheManager.m | 2 +- src/Core/OOQuaternion.m | 6 +- src/Core/Scripting/OOJSVector.m | 20 +-- src/Core/Universe.h | 1 - 12 files changed, 208 insertions(+), 146 deletions(-) diff --git a/Oolite.xcodeproj/project.pbxproj b/Oolite.xcodeproj/project.pbxproj index 7ceced0f..76bd20ee 100644 --- a/Oolite.xcodeproj/project.pbxproj +++ b/Oolite.xcodeproj/project.pbxproj @@ -225,7 +225,6 @@ 1A2319760B9D02F900EF0852 /* BlueDanube.ogg in Copy Music */ = {isa = PBXBuildFile; fileRef = 1A2319740B9D02F900EF0852 /* BlueDanube.ogg */; }; 1A2319770B9D02F900EF0852 /* OoliteTheme.ogg in Copy Music */ = {isa = PBXBuildFile; fileRef = 1A2319750B9D02F900EF0852 /* OoliteTheme.ogg */; }; 1A2319A60B9D031D00EF0852 /* afterburner1.ogg in Copy Sounds */ = {isa = PBXBuildFile; fileRef = 1A2319920B9D031D00EF0852 /* afterburner1.ogg */; }; - 1A2319A70B9D031D00EF0852 /* afterburner2.ogg in Copy Sounds */ = {isa = PBXBuildFile; fileRef = 1A2319930B9D031D00EF0852 /* afterburner2.ogg */; }; 1A2319A80B9D031D00EF0852 /* beep.ogg in Copy Sounds */ = {isa = PBXBuildFile; fileRef = 1A2319940B9D031D00EF0852 /* beep.ogg */; }; 1A2319A90B9D031D00EF0852 /* bigbang.ogg in Copy Sounds */ = {isa = PBXBuildFile; fileRef = 1A2319950B9D031D00EF0852 /* bigbang.ogg */; }; 1A2319AA0B9D031D00EF0852 /* boop.ogg in Copy Sounds */ = {isa = PBXBuildFile; fileRef = 1A2319960B9D031D00EF0852 /* boop.ogg */; }; @@ -942,7 +941,6 @@ dstSubfolderSpec = 7; files = ( 1A2319A60B9D031D00EF0852 /* afterburner1.ogg in Copy Sounds */, - 1A2319A70B9D031D00EF0852 /* afterburner2.ogg in Copy Sounds */, 1A2319A80B9D031D00EF0852 /* beep.ogg in Copy Sounds */, 1A2319A90B9D031D00EF0852 /* bigbang.ogg in Copy Sounds */, 1A2319AA0B9D031D00EF0852 /* boop.ogg in Copy Sounds */, @@ -1233,7 +1231,6 @@ 1A2319740B9D02F900EF0852 /* BlueDanube.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = BlueDanube.ogg; sourceTree = ""; }; 1A2319750B9D02F900EF0852 /* OoliteTheme.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = OoliteTheme.ogg; sourceTree = ""; }; 1A2319920B9D031D00EF0852 /* afterburner1.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = afterburner1.ogg; sourceTree = ""; }; - 1A2319930B9D031D00EF0852 /* afterburner2.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = afterburner2.ogg; sourceTree = ""; }; 1A2319940B9D031D00EF0852 /* beep.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = beep.ogg; sourceTree = ""; }; 1A2319950B9D031D00EF0852 /* bigbang.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = bigbang.ogg; sourceTree = ""; }; 1A2319960B9D031D00EF0852 /* boop.ogg */ = {isa = PBXFileReference; lastKnownFileType = file; path = boop.ogg; sourceTree = ""; }; @@ -1992,7 +1989,6 @@ isa = PBXGroup; children = ( 1A2319920B9D031D00EF0852 /* afterburner1.ogg */, - 1A2319930B9D031D00EF0852 /* afterburner2.ogg */, 1A2319940B9D031D00EF0852 /* beep.ogg */, 1A2319950B9D031D00EF0852 /* bigbang.ogg */, 1A2319960B9D031D00EF0852 /* boop.ogg */, diff --git a/Resources/Config/customsounds.plist b/Resources/Config/customsounds.plist index 87d9401a..ec8611b5 100644 --- a/Resources/Config/customsounds.plist +++ b/Resources/Config/customsounds.plist @@ -4,9 +4,10 @@ */ // Interface sounds - "[@beep]" = "beep.ogg"; // positive beep - "[@boop]" = "boop.ogg"; // negative beep - "[@click]" = "guiclick.ogg"; + "[@beep]" = "beep.ogg"; // positive beep + "[@boop]" = "boop.ogg"; // negative beep + "[@click]" = "guiclick.ogg"; + "[@witchabort]" = "witchabort.ogg"; "[@switch-on]" = "[@beep]"; "[@switch-off]" = "[@boop]"; @@ -14,6 +15,7 @@ "[ident-off]" = "[@switch-off]"; // Turned off ident "[ident-locked-on]" = "[@beep]"; // Ident targeted ship "[missile-locked-on]" = "[@beep]"; + "[missile-launched]" = "missile.ogg"; "[missile-armed]" = "[@beep]"; "[mine-armed]" = "[@beep]"; "[missile-safe]" = "[@boop]"; @@ -47,6 +49,7 @@ "[dismissed-report-screen]" = "[@click]"; "[dismissed-mission-screen]" = "[@click]"; // No way to differentiate between mission options "[changed-option]" = "[@click]"; // Player made a change on options screen + "[scoop]" = "scoop.ogg"; // Hyperspace "[hyperspace-countdown-begun]" = "[@beep]"; @@ -54,7 +57,9 @@ "[hyperspace-countdown-aborted]" = "[@boop]"; "[witch-no-target]" = "[@boop]"; "[witch-no-fuel]" = "[@boop]"; - "[witch-blocked-by-@]" = "[@boop]"; + "[witch-blocked-by-@]" = "[@witchabort]"; + "[witch-too-far]" = "[@witchabort]"; + "[witch-no-fuel]" = "[@witchabort]"; // Damage "[player-hit-by-weapon]" = "hit.ogg"; // Hit by weapon @@ -94,7 +99,6 @@ "[aegis-station]" = ""; "[escape-pod-scooped]" = ""; "[mine-launched]" = ""; - "[missile-launched]" = ""; "[weapon-overheat]" = ""; "[wormhole-created]" = ""; */ diff --git a/src/Core/Entities/PlayerEntity.h b/src/Core/Entities/PlayerEntity.h index 068c4fc2..f4b863db 100644 --- a/src/Core/Entities/PlayerEntity.h +++ b/src/Core/Entities/PlayerEntity.h @@ -275,12 +275,6 @@ typedef enum double ecm_start_time; - OOSound *missileSound; - OOSound *afterburner1Sound; - OOSound *afterburner2Sound; - OOSound *witchAbortSound; - OOSound *fuelScoopSound; - OOSoundReferencePoint *refPoint; OOGUIScreenID gui_screen; @@ -612,9 +606,6 @@ waitingForStickCallback: 1; - (BOOL) isSpeechOn; - (void) addEquipmentFromCollection:(id)equipment; // equipment may be an array, a set, a dictionary whose values are all YES, or a string. - -- (void) loopAfterburnerSound; -- (void) stopAfterburnerSound; - (void) getFined; diff --git a/src/Core/Entities/PlayerEntity.m b/src/Core/Entities/PlayerEntity.m index 7e16b264..b5912ce7 100644 --- a/src/Core/Entities/PlayerEntity.m +++ b/src/Core/Entities/PlayerEntity.m @@ -1168,7 +1168,6 @@ static PlayerEntity *sSharedPlayer = nil; } -double scoopSoundPlayTime = 0.0; - (void) update:(OOTimeDelta)delta_t { [self updateMovementFlags]; @@ -1525,12 +1524,7 @@ double scoopSoundPlayTime = 0.0; { if (scoopsActive) { - scoopSoundPlayTime -= delta_t; - if (scoopSoundPlayTime < 0.0) - { - [fuelScoopSound play]; - scoopSoundPlayTime = 0.5; - } + [self updateFuelScoopSoundWithInterval:delta_t]; scoopsActive = NO; } } @@ -1713,8 +1707,7 @@ double scoopSoundPlayTime = 0.0; { [UNIVERSE clearPreviousMessage]; [UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"witch-blocked-by-@"), [blocker name]] forCount: 4.5]; - if (![UNIVERSE playCustomSound:@"[witch-blocked-by-@]"]) - [witchAbortSound play]; + [self playWitchjumpBlocked]; status = STATUS_IN_FLIGHT; [self doScriptEvent:@"playerJumpFailed" withArgument:@"blocked"]; go = NO; @@ -1729,8 +1722,7 @@ double scoopSoundPlayTime = 0.0; { [UNIVERSE clearPreviousMessage]; [UNIVERSE addMessage:DESC(@"witch-too-far") forCount: 4.5]; - if (![UNIVERSE playCustomSound:@"[witch-too-far]"]) - [witchAbortSound play]; + [self playWitchjumpDistanceTooGreat]; status = STATUS_IN_FLIGHT; [self doScriptEvent:@"playerJumpFailed" withArgument:@"too far"]; go = NO; @@ -1745,8 +1737,7 @@ double scoopSoundPlayTime = 0.0; { [UNIVERSE clearPreviousMessage]; [UNIVERSE addMessage:DESC(@"witch-no-fuel") forCount: 4.5]; - if (![UNIVERSE playCustomSound:@"[witch-no-fuel]"]) - [witchAbortSound play]; + [self playWitchjumpInsufficientFuel]; status = STATUS_IN_FLIGHT; [self doScriptEvent:@"playerJumpFailed" withArgument:@"insufficient fuel"]; go = NO; @@ -2636,12 +2627,12 @@ double scoopSoundPlayTime = 0.0; { if ([ms isEqual:@"AEGIS_CLOSE_TO_MAIN_PLANET"]&&(compassMode == COMPASS_MODE_PLANET)) { - [UNIVERSE playCustomSound:@"[aegis-planet]"]; + [self playAegisCloseToPlanet]; [self setCompassMode:COMPASS_MODE_STATION]; } if ([ms isEqual:@"AEGIS_IN_DOCKING_RANGE"]&&(compassMode == COMPASS_MODE_PLANET)) { - [UNIVERSE playCustomSound:@"[aegis-station]"]; + [self playAegisCloseToStation]; [self setCompassMode:COMPASS_MODE_STATION]; } if ([ms isEqual:@"AEGIS_NONE"]&&(compassMode == COMPASS_MODE_STATION)) @@ -2684,7 +2675,7 @@ double scoopSoundPlayTime = 0.0; BOOL launchedOK = [self launchMine:missile]; if (launchedOK) { - [UNIVERSE playCustomSound:@"[mine-launched]"]; + [self playMineLaunched]; [missile release]; // release } missile_entity[activeMissile] = nil; @@ -2751,8 +2742,8 @@ double scoopSoundPlayTime = 0.0; [target setPrimaryAggressor:self]; [target doScriptEvent:@"shipAttackedWithMissile" withArgument:missile andArgument:self]; [target reactToAIMessage:@"INCOMING_MISSILE"]; - - [UNIVERSE playCustomSound:@"[missile-launched]"]; + + [self playMissileLaunched]; return YES; } @@ -2829,7 +2820,7 @@ double scoopSoundPlayTime = 0.0; } } [UNIVERSE addMessage:DESC(@"energy-bomb-activated") forCount:4.5]; - [UNIVERSE playCustomSound:@"[energy-bomb-fired]"]; + [self playEnergyBombFired]; return YES; } @@ -2842,7 +2833,7 @@ double scoopSoundPlayTime = 0.0; if (weapon_temp / PLAYER_MAX_WEAPON_TEMP >= 0.85) { - [UNIVERSE playCustomSound:@"[weapon-overheat]"]; + [self playWeaponOverheated]; [UNIVERSE addMessage:DESC(@"weapon-overheat") forCount:3.0]; return NO; } @@ -3441,7 +3432,7 @@ double scoopSoundPlayTime = 0.0; [self becomeLargeExplosion:4.0]; [self moveForward:100.0]; - [UNIVERSE playCustomSound:@"[game-over]"]; + [self playGameOver]; flightSpeed = 160.0f; status = STATUS_DEAD; @@ -5766,7 +5757,7 @@ static int last_outfitting_index; eqEnum = [[NSArray arrayWithObject:equipment] objectEnumerator]; } // Now remove items that should not be in the equipment list. - while (eqDesc = [eqEnum nextObject]) + while ((eqDesc = [eqEnum nextObject])) { if (![self equipmentValidToAdd:eqDesc]) { @@ -5794,44 +5785,6 @@ static int last_outfitting_index; } -// time delay method for playing afterburner sounds -// this overlaps two sounds each 2 seconds long, but with a .5s -// crossfade -OOSound* burnersound; -- (void) loopAfterburnerSound -{ - SEL _loopAfterburnerSoundSelector = @selector(loopAfterburnerSound); - - if (!afterburner_engaged) // end the loop cycle - { - afterburnerSoundLooping = NO; - return; - } - - afterburnerSoundLooping = YES; - - if (burnersound == afterburner1Sound) - burnersound = afterburner2Sound; - else - burnersound = afterburner1Sound; - - [burnersound play]; - - [self performSelector:_loopAfterburnerSoundSelector - withObject:NULL - afterDelay:1.25]; // and swap sounds in 1.25s time -} - - -- (void) stopAfterburnerSound -{ -#if 0 - // FIXME: should use an OOSoundSource. - [burnersound stop]; -#endif -} - - - (BOOL) hasHostileTarget { ShipEntity *playersTarget = [self primaryTarget]; diff --git a/src/Core/Entities/PlayerEntityControls.m b/src/Core/Entities/PlayerEntityControls.m index 45f78e38..344faefb 100644 --- a/src/Core/Entities/PlayerEntityControls.m +++ b/src/Core/Entities/PlayerEntityControls.m @@ -482,12 +482,11 @@ static NSTimeInterval time_last_frame; [self hasFuelInjection] && !hyperspeed_engaged) { - if ((fuel > 0)&&(!afterburner_engaged)) + if (fuel > 0 && !afterburner_engaged) { [UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[fuel-inject-on]") forCount:1.5]; afterburner_engaged = YES; - if (!afterburnerSoundLooping) - [self loopAfterburnerSound]; + [self startAfterburnerSound]; } else { @@ -601,16 +600,11 @@ static NSTimeInterval time_last_frame; // launch here if (!fire_missile_pressed) { - BOOL missile_noise = [missile_entity[activeMissile] isMissile]; - if ([self fireMissile]) - { - if (missile_noise) [missileSound play]; - } + [self fireMissile]; + fire_missile_pressed = YES; } - fire_missile_pressed = YES; } - else - fire_missile_pressed = NO; + else fire_missile_pressed = NO; // shoot 'y' // next missile if ([gameView isDown:key_next_missile] || joyButtonState[BUTTON_CYCLEMISSILE]) @@ -622,8 +616,7 @@ static NSTimeInterval time_last_frame; } next_missile_pressed = YES; } - else - next_missile_pressed = NO; + else next_missile_pressed = NO; // '+' // next target if ([gameView isDown:key_next_target]) @@ -634,8 +627,7 @@ static NSTimeInterval time_last_frame; } next_target_pressed = YES; } - else - next_target_pressed = NO; + else next_target_pressed = NO; // '-' // previous target if ([gameView isDown:key_previous_target]) @@ -646,8 +638,7 @@ static NSTimeInterval time_last_frame; } previous_target_pressed = YES; } - else - previous_target_pressed = NO; + else previous_target_pressed = NO; // shoot 'r' // switch on ident system if ([gameView isDown:key_ident_system] || joyButtonState[BUTTON_ID]) @@ -663,8 +654,7 @@ static NSTimeInterval time_last_frame; } ident_pressed = YES; } - else - ident_pressed = NO; + else ident_pressed = NO; // shoot 't' // switch on missile targetting if (([gameView isDown:key_target_missile] || joyButtonState[BUTTON_ARMMISSILE])&&(missile_entity[activeMissile])) @@ -703,8 +693,7 @@ static NSTimeInterval time_last_frame; } target_missile_pressed = YES; } - else - target_missile_pressed = NO; + else target_missile_pressed = NO; // shoot 'u' // disarm missile targetting if ([gameView isDown:key_untarget_missile] || joyButtonState[BUTTON_UNARM]) @@ -732,8 +721,7 @@ static NSTimeInterval time_last_frame; } safety_pressed = YES; } - else - safety_pressed = NO; + else safety_pressed = NO; // shoot 'e' // ECM if (([gameView isDown:key_ecm] || joyButtonState[BUTTON_ECM]) && [self hasECM]) diff --git a/src/Core/Entities/PlayerEntitySound.h b/src/Core/Entities/PlayerEntitySound.h index 489ca169..50ef8207 100644 --- a/src/Core/Entities/PlayerEntitySound.h +++ b/src/Core/Entities/PlayerEntitySound.h @@ -64,6 +64,11 @@ MA 02110-1301, USA. - (void) playDismissedMissionScreen; - (void) playChangedOption; +- (void) updateFuelScoopSoundWithInterval:(OOTimeDelta)delta_t; + +- (void) startAfterburnerSound; +- (void) stopAfterburnerSound; + // Buy/sell get their own source. - (void) playBuyCommodity; - (void) playBuyShip; @@ -103,6 +108,9 @@ MA 02110-1301, USA. - (void) playDockingDenied; - (void) playWitchjumpFailure; - (void) playWitchjumpMisjump; +- (void) playWitchjumpBlocked; +- (void) playWitchjumpDistanceTooGreat; +- (void) playWitchjumpInsufficientFuel; - (void) playFuelLeak; // Damage sounds @@ -112,5 +120,15 @@ MA 02110-1301, USA. // Weapon sounds - (void) playLaserHit:(BOOL)hit; +- (void) playWeaponOverheated; +- (void) playMissileLaunched; +- (void) playMineLaunched; +- (void) playEnergyBombFired; + +// Miscellaneous sounds +- (void) playEscapePodScooped; +- (void) playAegisCloseToPlanet; +- (void) playAegisCloseToStation; +- (void) playGameOver; @end diff --git a/src/Core/Entities/PlayerEntitySound.m b/src/Core/Entities/PlayerEntitySound.m index 8a3a8ccb..5c6d30e1 100644 --- a/src/Core/Entities/PlayerEntitySound.m +++ b/src/Core/Entities/PlayerEntitySound.m @@ -32,20 +32,23 @@ MA 02110-1301, USA. // Sizes of sound source pools enum { - kWarningPoolSize = 2, - kWeaponPoolSize = 2, - kDamagePoolSize = 4 + kWarningPoolSize = 6, + kWeaponPoolSize = 3, + kDamagePoolSize = 4, + kMiscPoolSize = 2 }; static OOSoundSourcePool *sWarningSoundPool; static OOSoundSourcePool *sWeaponSoundPool; static OOSoundSourcePool *sDamageSoundPool; +static OOSoundSourcePool *sMiscSoundPool; static OOSoundSource *sHyperspaceSoundSource; static OOSoundSource *sInterfaceBeepSource; static OOSoundSource *sEcmSource; static OOSoundSource *sBreakPatternSource; static OOSoundSource *sBuySellSource; +static OOSoundSource *sAfterburnerSources[2]; @implementation PlayerEntity (Sound) @@ -54,15 +57,6 @@ static OOSoundSource *sBuySellSource; { [self destroySound]; - missileSound = [[ResourceManager ooSoundNamed:@"missile.ogg" inFolder:@"Sounds"] retain]; - - afterburner1Sound = [[ResourceManager ooSoundNamed:@"afterburner1.ogg" inFolder:@"Sounds"] retain]; - afterburner2Sound = [[ResourceManager ooSoundNamed:@"afterburner2.ogg" inFolder:@"Sounds"] retain]; - - witchAbortSound = [[ResourceManager ooSoundNamed:@"witchabort.ogg" inFolder:@"Sounds"] retain]; - - fuelScoopSound = [[ResourceManager ooSoundNamed:@"scoop.ogg" inFolder:@"Sounds"] retain]; - refPoint = [[OOSoundReferencePoint alloc] init]; sInterfaceBeepSource = [[OOSoundSource alloc] init]; @@ -71,28 +65,22 @@ static OOSoundSource *sBuySellSource; sHyperspaceSoundSource = [[OOSoundSource alloc] init]; sBuySellSource = [[OOSoundSource alloc] init]; - sWarningSoundPool = [[OOSoundSourcePool alloc] initWithCount:kWarningPoolSize minRepeatTime:0]; - sWeaponSoundPool = [[OOSoundSourcePool alloc] initWithCount:kWeaponPoolSize minRepeatTime:0]; + sWarningSoundPool = [[OOSoundSourcePool alloc] initWithCount:kWarningPoolSize minRepeatTime:0.0]; + sWeaponSoundPool = [[OOSoundSourcePool alloc] initWithCount:kWeaponPoolSize minRepeatTime:0.0]; sDamageSoundPool = [[OOSoundSourcePool alloc] initWithCount:kDamagePoolSize minRepeatTime:0.1]; // Repeat time limit is to avoid playing a scrape sound every frame on glancing scrapes. This does limit the number of laser hits that can be played in a furrball, though; maybe lasers and scrapes should use different pools. + sMiscSoundPool = [[OOSoundSourcePool alloc] initWithCount:kMiscPoolSize minRepeatTime:0.0]; + + // Two sources with the same sound are used to simulate looping. + sAfterburnerSources[0] = [[OOSoundSource alloc] init]; + sAfterburnerSources[1] = [[OOSoundSource alloc] init]; + OOSound *afterburnerSound = [ResourceManager ooSoundNamed:@"afterburner1.ogg" inFolder:@"Sounds"]; + [sAfterburnerSources[0] setSound:afterburnerSound]; + [sAfterburnerSources[1] setSound:afterburnerSound]; } - (void) destroySound { - [missileSound release]; - missileSound = nil; - - [afterburner1Sound release]; - afterburner1Sound = nil; - [afterburner2Sound release]; - afterburner2Sound = nil; - - [witchAbortSound release]; - witchAbortSound = nil; - - [fuelScoopSound release]; - fuelScoopSound = nil; - [refPoint release]; refPoint = nil; @@ -332,6 +320,58 @@ static OOSoundSource *sBuySellSource; } +- (void) updateFuelScoopSoundWithInterval:(OOTimeDelta)delta_t +{ + static double scoopSoundPlayTime = 0.0; + scoopSoundPlayTime -= delta_t; + if (scoopSoundPlayTime < 0.0) + { + [self playInterfaceBeep:@"[scoop]"]; + scoopSoundPlayTime = 0.5; + } +} + + +// time delay method for playing afterburner sounds +// this overlaps two sounds each 2 seconds long, but with a .5s +// crossfade +- (void) updateAfterburnerSound +{ + static uint8_t which = 0; + + if (!afterburner_engaged) // end the loop cycle + { + afterburnerSoundLooping = NO; + } + + if (afterburnerSoundLooping) + { + [sAfterburnerSources[which] play]; + which = !which; + + [self performSelector:@selector(updateAfterburnerSound) + withObject:NULL + afterDelay:1.25]; // and swap sounds in 1.25s time + } +} + + +- (void) startAfterburnerSound +{ + if (!afterburnerSoundLooping) + { + afterburnerSoundLooping = YES; + [self updateAfterburnerSound]; + } +} + + +- (void) stopAfterburnerSound +{ + afterburnerSoundLooping = NO; +} + + - (void) playCloakingDeviceInsufficientEnergy { [self playInterfaceBeep:@"[cloaking-device-insufficent-energy]"]; @@ -464,6 +504,24 @@ static OOSoundSource *sBuySellSource; } +- (void) playWitchjumpBlocked +{ + [sWarningSoundPool playSoundWithKey:@"[witch-blocked-by-@]" priority:1.3]; +} + + +- (void) playWitchjumpDistanceTooGreat +{ + [sWarningSoundPool playSoundWithKey:@"[witch-too-far]" priority:1.3]; +} + + +- (void) playWitchjumpInsufficientFuel +{ + [sWarningSoundPool playSoundWithKey:@"[witch-no-fuel]" priority:1.3]; +} + + - (void) playFuelLeak { [sWarningSoundPool playSoundWithKey:@"[fuel-leak]" priority:0.5]; @@ -500,4 +558,52 @@ static OOSoundSource *sBuySellSource; } } + +- (void) playWeaponOverheated +{ + [sWeaponSoundPool playSoundWithKey:@"[weapon-overheat]"]; +} + + +- (void) playMissileLaunched +{ + [sWeaponSoundPool playSoundWithKey:@"[missile-launched]"]; +} + + +- (void) playMineLaunched +{ + [sWeaponSoundPool playSoundWithKey:@"[mine-launched]"]; +} + + +- (void) playEnergyBombFired +{ + [sWeaponSoundPool playSoundWithKey:@"[energy-bomb-fired]" priority:2.0]; +} + + +- (void) playEscapePodScooped +{ + [sMiscSoundPool playSoundWithKey:@"[escape-pod-scooped]"]; +} + + +- (void) playAegisCloseToPlanet +{ + [sMiscSoundPool playSoundWithKey:@"[aegis-planet]"]; +} + + +- (void) playAegisCloseToStation +{ + [sMiscSoundPool playSoundWithKey:@"[aegis-station]"]; +} + + +- (void) playGameOver +{ + [sMiscSoundPool playSoundWithKey:@"[game-over]"]; +} + @end diff --git a/src/Core/Entities/ShipEntity.m b/src/Core/Entities/ShipEntity.m index 6ebadf5c..f287d3a7 100644 --- a/src/Core/Entities/ShipEntity.m +++ b/src/Core/Entities/ShipEntity.m @@ -55,6 +55,7 @@ MA 02110-1301, USA. #import "PlanetEntity.h" #import "PlayerEntity.h" #import "PlayerEntityLegacyScriptEngine.h" +#import "PlayerEntitySound.h" #import "WormholeEntity.h" #import "GuiDisplayGen.h" #import "HeadUpDisplay.h" @@ -6802,6 +6803,12 @@ BOOL class_masslocks(int some_class) } +- (void) suppressTargetLost +{ + +} + + - (void) scoopUp:(ShipEntity *)other { if (other == nil) return; @@ -6898,7 +6905,7 @@ BOOL class_masslocks(int some_class) { [UNIVERSE addMessage: DESC(@"scoop-got-slave") forCount: 4.5]; } - [UNIVERSE playCustomSound:@"[escape-pod-scooped]"]; + [(PlayerEntity *)self playEscapePodScooped]; } } else @@ -6913,7 +6920,7 @@ BOOL class_masslocks(int some_class) if ([cargo count] == max_cargo) [shipAI message:@"HOLD_FULL"]; } [[other collisionArray] removeObject:self]; // so it can't be scooped twice! - if (isPlayer) [(PlayerEntity*)self suppressTargetLost]; + [self suppressTargetLost]; [UNIVERSE removeEntity:other]; } diff --git a/src/Core/OOCacheManager.m b/src/Core/OOCacheManager.m index 8e4d459b..a25e9231 100644 --- a/src/Core/OOCacheManager.m +++ b/src/Core/OOCacheManager.m @@ -64,7 +64,7 @@ static NSString * const kCacheKeyCaches = @"caches"; enum { kEndianTagValue = 0x0123456789ABCDEFULL, - kFormatVersionValue = 20 + kFormatVersionValue = 21 }; diff --git a/src/Core/OOQuaternion.m b/src/Core/OOQuaternion.m index d9de8824..3bd23978 100644 --- a/src/Core/OOQuaternion.m +++ b/src/Core/OOQuaternion.m @@ -332,9 +332,9 @@ NSString *QuaternionDescription(Quaternion quaternion) y = fabsf(quaternion.y); z = fabsf(quaternion.z); - xs = (x == quaternion.x) ? '+' : '-'; - ys = (y == quaternion.y) ? '+' : '-'; - zs = (z == quaternion.z) ? '+' : '-'; + xs = (quaternion.x > 0) ? '+' : '-'; + ys = (quaternion.y > 0) ? '+' : '-'; + zs = (quaternion.z > 0) ? '+' : '-'; return [NSString stringWithFormat:@"(%g %c %gi %c %gj %c %gk)", quaternion.w, xs, x, ys, y, zs, z]; } diff --git a/src/Core/Scripting/OOJSVector.m b/src/Core/Scripting/OOJSVector.m index 59ad0185..993a81fe 100644 --- a/src/Core/Scripting/OOJSVector.m +++ b/src/Core/Scripting/OOJSVector.m @@ -468,7 +468,7 @@ static JSBool VectorToString(JSContext *context, JSObject *this, uintN argc, jsv } -// add(v : vectorExpression) : Vector +// add(v : vectorExpression) : Vector3D static JSBool VectorAdd(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, thatv, result; @@ -482,7 +482,7 @@ static JSBool VectorAdd(JSContext *context, JSObject *this, uintN argc, jsval *a } -// subtract(v : vectorExpression) : Vector +// subtract(v : vectorExpression) : Vector3D static JSBool VectorSubtract(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, thatv, result; @@ -496,7 +496,7 @@ static JSBool VectorSubtract(JSContext *context, JSObject *this, uintN argc, jsv } -// distanceTo(v : vectorExpression) : Vector +// distanceTo(v : vectorExpression) : Vector3D static JSBool VectorDistanceTo(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, thatv; @@ -511,7 +511,7 @@ static JSBool VectorDistanceTo(JSContext *context, JSObject *this, uintN argc, j } -// squaredDistanceTo(v : vectorExpression) : Vector +// squaredDistanceTo(v : vectorExpression) : Vector3D static JSBool VectorSquaredDistanceTo(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, thatv; @@ -526,7 +526,7 @@ static JSBool VectorSquaredDistanceTo(JSContext *context, JSObject *this, uintN } -// multiply(n : Number) : Vector +// multiply(n : Number) : Vector3D static JSBool VectorMultiply(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, result; @@ -571,7 +571,7 @@ static JSBool VectorAngleTo(JSContext *context, JSObject *this, uintN argc, jsva } -// cross(v : vectorExpression) : Vector +// cross(v : vectorExpression) : Vector3D static JSBool VectorCross(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, thatv, result; @@ -585,7 +585,7 @@ static JSBool VectorCross(JSContext *context, JSObject *this, uintN argc, jsval } -// tripleProduct(v : vectorExpression) : Number +// tripleProduct(v : vectorExpression, u : vectorExpression) : Number static JSBool VectorTripleProduct(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, thatv, theotherv; @@ -604,7 +604,7 @@ static JSBool VectorTripleProduct(JSContext *context, JSObject *this, uintN argc } -// direction() : Vector +// direction() : Vector3D static JSBool VectorDirection(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, result; @@ -673,7 +673,7 @@ static JSBool VectorRotationTo(JSContext *context, JSObject *this, uintN argc, j } -// rotateBy(q : quaternionExpression) : Vector +// rotateBy(q : quaternionExpression) : Vector3D static JSBool VectorRotateBy(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector thisv, result; @@ -717,7 +717,7 @@ static JSBool VectorToArray(JSContext *context, JSObject *this, uintN argc, jsva } -// interpolate(v : Vector, u : Vector, alpha : Number) : Vector +// interpolate(v : Vector3D, u : Vector3D, alpha : Number) : Vector3D static JSBool VectorStaticInterpolate(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) { Vector av, bv; diff --git a/src/Core/Universe.h b/src/Core/Universe.h index ccf9726c..9c6c29db 100644 --- a/src/Core/Universe.h +++ b/src/Core/Universe.h @@ -420,7 +420,6 @@ enum - (void) setViewDirection:(OOViewID) vd; - (OOViewID) viewDirection; -- (BOOL) playCustomSound:(NSString*)key; // DEPRECATED -- use +[OOSound soundWithCustomSoundKey:] and OOSoundSource. - (NSString *) soundNameForCustomSoundKey:(NSString *)key; - (void) clearPreviousMessage;