Wormholes:
* Enable by default in GNUmakefile * Adjust price to something more plausible * Fix discrepancy in save-files between loading & saving SDL Sound: * Commit in sound patch when no sound-card available (was committed into 1.72 ages ago) git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2124 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
f1014cae40
commit
e0344e1d54
@ -3,7 +3,7 @@ CP = cp
|
||||
BUILD_WITH_DEBUG_FUNCTIONALITY = yes
|
||||
DOCKING_CLEARANCE = yes
|
||||
PROCEDURAL_PLANETS = yes
|
||||
WORMHOLE_SCANNER = no
|
||||
WORMHOLE_SCANNER = yes
|
||||
vpath %.m src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
|
||||
vpath %.h src/SDL:src/Core:src/Core/Entities:src/Core/Materials:src/Core/Scripting:src/Core/OXPVerifier:src/Core/Debug
|
||||
vpath %.c src/SDL:src/Core:src/BSDCompat:src/Core/Debug
|
||||
@ -51,7 +51,6 @@ ifeq ($(WORMHOLE_SCANNER),yes)
|
||||
ADDITIONAL_OBJCFLAGS += -DWORMHOLE_SCANNER
|
||||
endif
|
||||
|
||||
|
||||
OBJC_PROGRAM_NAME = oolite
|
||||
|
||||
oolite_C_FILES = \
|
||||
|
@ -328,10 +328,10 @@
|
||||
</array>
|
||||
<array>
|
||||
<integer>9</integer>
|
||||
<integer>4950</integer>
|
||||
<integer>13950</integer>
|
||||
<string>Wormhole Scanner</string>
|
||||
<string>EQ_WORMHOLE_SCANNER</string>
|
||||
<string>The Mynerium-Krantz Works wormhole scanner integrates into your existing targetting system. It analyzes the residual energy of a wormhole and, in combination with your Galactic Map software, calculates the most likely target system.</string>
|
||||
<string>The Mössbauer-Krantz Works wormhole scanner integrates into your existing targetting system. It analyzes the residual energy of a wormhole and, in combination with your Galactic Map software, calculates the most likely target system.</string>
|
||||
<dict>
|
||||
<key>available_to_all</key>
|
||||
<true/>
|
||||
|
@ -3,7 +3,7 @@
|
||||
WormholeEntity.m
|
||||
|
||||
Oolite
|
||||
Copyright (C) 2004-2008 Giles C Williams and contributors
|
||||
Copyright (C) 2004-2009 Giles C Williams and contributors
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
@ -511,7 +511,7 @@ static void DrawWormholeCorona(GLfloat inner_radius, GLfloat outer_radius, int s
|
||||
[shipArray addObject:myShipDict];
|
||||
*/
|
||||
[shipArray addObject:[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithDouble:[currShipDict doubleForKey:@"time"]], @"arrival_time",
|
||||
[NSNumber numberWithDouble:[currShipDict doubleForKey:@"time"]], @"time_delta",
|
||||
[[currShipDict objectForKey:@"ship"] shipInfoDictionary], @"ship",
|
||||
nil]];
|
||||
}
|
||||
|
@ -61,4 +61,6 @@ SOFTWARE.
|
||||
|
||||
- (NSString *)name;
|
||||
|
||||
+ (BOOL) isSoundOK;
|
||||
|
||||
@end
|
||||
|
@ -89,7 +89,8 @@ static int sEffectiveMasterVolume = MIX_MAX_VOLUME;
|
||||
|
||||
+ (void) setMasterVolume:(float) fraction
|
||||
{
|
||||
if (!sIsSetUp) [self setUp];
|
||||
if (!sIsSetUp && ![self setUp])
|
||||
return;
|
||||
|
||||
fraction = OOClamp_0_1_f(fraction);
|
||||
int volume = (float)MIX_MAX_VOLUME * fraction;
|
||||
@ -108,7 +109,8 @@ static int sEffectiveMasterVolume = MIX_MAX_VOLUME;
|
||||
|
||||
+ (float) masterVolume
|
||||
{
|
||||
if (!sIsSetUp) [self setUp];
|
||||
if (!sIsSetUp && ![self setUp] )
|
||||
return 0;
|
||||
|
||||
return (float)sEffectiveMasterVolume / (float)MIX_MAX_VOLUME;
|
||||
}
|
||||
@ -139,7 +141,14 @@ static int sEffectiveMasterVolume = MIX_MAX_VOLUME;
|
||||
|
||||
+ (void) update
|
||||
{
|
||||
[[OOSoundMixer sharedMixer] update];
|
||||
OOSoundMixer * mixer = [OOSoundMixer sharedMixer];
|
||||
if( sIsSoundOK && mixer)
|
||||
[mixer update];
|
||||
}
|
||||
|
||||
+ (BOOL) isSoundOK
|
||||
{
|
||||
return sIsSoundOK;
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -1,233 +1,236 @@
|
||||
/*
|
||||
|
||||
SDLSound.h
|
||||
|
||||
SDLSound - SDL sound implementation for Oolite.
|
||||
Copyright (C) 2005 David Taylor
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "SDLMusic.h"
|
||||
#import "OOLogging.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.SDLMusic"
|
||||
|
||||
/*
|
||||
* This is used by instances of OOMusic to check if they are currently playing
|
||||
* or not.
|
||||
*
|
||||
* Because SDL_mixer only plays one piece of music at a time (which is
|
||||
* reasonable), the SDL implementation of OOMusic works on the basis that
|
||||
* only one instance of it is "current" at any given time.
|
||||
*
|
||||
* If an instance is not the current instance, the only method that will
|
||||
* work is play. Calling play on an instance that is not the current
|
||||
* instance will make it the current instance, stopping any music that is
|
||||
* already playing.
|
||||
*/
|
||||
OOMusic* current;
|
||||
|
||||
/*
|
||||
* This function is called by SDL_mixer whenever a piece of music finishes
|
||||
* playing.
|
||||
*
|
||||
* This resets the pointer the currently playing OOMusic object to signify
|
||||
* that no music is playing.
|
||||
*/
|
||||
void musicFinished()
|
||||
{
|
||||
current = nil;
|
||||
}
|
||||
|
||||
|
||||
@interface OOMusic (Private)
|
||||
|
||||
- (BOOL) playWithCount:(int)count;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation OOMusic
|
||||
|
||||
/*
|
||||
* Initialise an OOMusic instance from the given file.
|
||||
*
|
||||
* The OOMusic instance is deallocated and nil is returned if the contents
|
||||
* of the file cannot be loaded by SDL_mixer.
|
||||
*/
|
||||
- (id) initWithContentsOfFile:(NSString*) filepath
|
||||
{
|
||||
[super init];
|
||||
|
||||
music = Mix_LoadMUS([filepath cString]);
|
||||
if (!music)
|
||||
{
|
||||
NSLog(@"Mix_LoadMUS(\"%@\"): %s\n", filepath, Mix_GetError());
|
||||
[super dealloc];
|
||||
return nil;
|
||||
}
|
||||
|
||||
name = [[filepath lastPathComponent] copy];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deallocate resources used by this instance of OOMusic.
|
||||
*/
|
||||
- (void) dealloc
|
||||
{
|
||||
if (current == self)
|
||||
Mix_HaltMusic();
|
||||
|
||||
if (music)
|
||||
Mix_FreeMusic(music);
|
||||
|
||||
[name autorelease];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) pause
|
||||
{
|
||||
// Only pause the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
{
|
||||
Mix_PauseMusic();
|
||||
paused=YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isPaused
|
||||
{
|
||||
return paused;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns YES is this instance of OOMusic is currently playing.
|
||||
*/
|
||||
- (BOOL) isPlaying
|
||||
{
|
||||
// If the "current OOMusic instance" pointer points to self, then this
|
||||
// instance is playing.
|
||||
if (current == self)
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) playWithCount:(int)count
|
||||
{
|
||||
int rc;
|
||||
paused=NO;
|
||||
|
||||
// Self is already playing, so do nothing.
|
||||
if (current == self)
|
||||
return YES;
|
||||
|
||||
// Another instance is playing so stop it.
|
||||
if (current != 0)
|
||||
[current stop];
|
||||
|
||||
// There is a potential race condition here because the
|
||||
// SDL_mixer "music stopped" callback sets current to NULL, and this
|
||||
// method sets current to self.
|
||||
//
|
||||
// If the callback is executed from a thread created by SDL_mixer then
|
||||
// that might not happen before the thread executing this code has
|
||||
// already made self current.
|
||||
//
|
||||
// One way of avoiding this is to wait for current to be equal to
|
||||
// NULL. When that happens we know the callback has been called.
|
||||
while (current != 0)
|
||||
;
|
||||
|
||||
rc = Mix_PlayMusic(music, count);
|
||||
if (rc < 0)
|
||||
{
|
||||
NSLog(@"Mix_PlayMusic error: %s", Mix_GetError());
|
||||
return NO;
|
||||
}
|
||||
|
||||
// This is done on every call to play simply because there didn't seem to
|
||||
// be another way to do it without having either a class init method or
|
||||
// doing it outside this class altogether. Both of those solutions seems
|
||||
// messy and this should not have a big performance hit.
|
||||
Mix_HookMusicFinished(musicFinished);
|
||||
current = self;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* Play the music represented by this OOMusic instance. This will replace any
|
||||
* music currently playing.
|
||||
*
|
||||
* If this instance is already playing, there is no effect.
|
||||
*
|
||||
* Returns YES for success, or NO if there was a problem playing the music.
|
||||
/*
|
||||
|
||||
SDLSound.h
|
||||
|
||||
SDLSound - SDL sound implementation for Oolite.
|
||||
Copyright (C) 2005 David Taylor
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
||||
MA 02110-1301, USA.
|
||||
|
||||
*/
|
||||
|
||||
#include "SDLMusic.h"
|
||||
#import "OOLogging.h"
|
||||
#include "OOSDLSound.h"
|
||||
|
||||
#define kOOLogUnconvertedNSLog @"unclassified.SDLMusic"
|
||||
|
||||
/*
|
||||
* This is used by instances of OOMusic to check if they are currently playing
|
||||
* or not.
|
||||
*
|
||||
* Because SDL_mixer only plays one piece of music at a time (which is
|
||||
* reasonable), the SDL implementation of OOMusic works on the basis that
|
||||
* only one instance of it is "current" at any given time.
|
||||
*
|
||||
* If an instance is not the current instance, the only method that will
|
||||
* work is play. Calling play on an instance that is not the current
|
||||
* instance will make it the current instance, stopping any music that is
|
||||
* already playing.
|
||||
*/
|
||||
OOMusic* current;
|
||||
|
||||
/*
|
||||
* This function is called by SDL_mixer whenever a piece of music finishes
|
||||
* playing.
|
||||
*
|
||||
* This resets the pointer the currently playing OOMusic object to signify
|
||||
* that no music is playing.
|
||||
*/
|
||||
void musicFinished()
|
||||
{
|
||||
current = nil;
|
||||
}
|
||||
|
||||
|
||||
@interface OOMusic (Private)
|
||||
|
||||
- (BOOL) playWithCount:(int)count;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation OOMusic
|
||||
|
||||
/*
|
||||
* Initialise an OOMusic instance from the given file.
|
||||
*
|
||||
* The OOMusic instance is deallocated and nil is returned if the contents
|
||||
* of the file cannot be loaded by SDL_mixer.
|
||||
*/
|
||||
- (id) initWithContentsOfFile:(NSString*) filepath
|
||||
{
|
||||
if( ![OOSound isSoundOK] ) return nil;
|
||||
|
||||
[super init];
|
||||
|
||||
music = Mix_LoadMUS([filepath cString]);
|
||||
if (!music)
|
||||
{
|
||||
NSLog(@"Mix_LoadMUS(\"%@\"): %s\n", filepath, Mix_GetError());
|
||||
[super dealloc];
|
||||
return nil;
|
||||
}
|
||||
|
||||
name = [[filepath lastPathComponent] copy];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deallocate resources used by this instance of OOMusic.
|
||||
*/
|
||||
- (void) dealloc
|
||||
{
|
||||
if (current == self)
|
||||
Mix_HaltMusic();
|
||||
|
||||
if (music)
|
||||
Mix_FreeMusic(music);
|
||||
|
||||
[name autorelease];
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) pause
|
||||
{
|
||||
// Only pause the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
{
|
||||
Mix_PauseMusic();
|
||||
paused=YES;
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL) isPaused
|
||||
{
|
||||
return paused;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns YES is this instance of OOMusic is currently playing.
|
||||
*/
|
||||
- (BOOL) isPlaying
|
||||
{
|
||||
// If the "current OOMusic instance" pointer points to self, then this
|
||||
// instance is playing.
|
||||
if (current == self)
|
||||
return YES;
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL) playWithCount:(int)count
|
||||
{
|
||||
int rc;
|
||||
paused=NO;
|
||||
|
||||
// Self is already playing, so do nothing.
|
||||
if (current == self)
|
||||
return YES;
|
||||
|
||||
// Another instance is playing so stop it.
|
||||
if (current != 0)
|
||||
[current stop];
|
||||
|
||||
// There is a potential race condition here because the
|
||||
// SDL_mixer "music stopped" callback sets current to NULL, and this
|
||||
// method sets current to self.
|
||||
//
|
||||
// If the callback is executed from a thread created by SDL_mixer then
|
||||
// that might not happen before the thread executing this code has
|
||||
// already made self current.
|
||||
//
|
||||
// One way of avoiding this is to wait for current to be equal to
|
||||
// NULL. When that happens we know the callback has been called.
|
||||
while (current != 0)
|
||||
;
|
||||
|
||||
rc = Mix_PlayMusic(music, count);
|
||||
if (rc < 0)
|
||||
{
|
||||
NSLog(@"Mix_PlayMusic error: %s", Mix_GetError());
|
||||
return NO;
|
||||
}
|
||||
|
||||
// This is done on every call to play simply because there didn't seem to
|
||||
// be another way to do it without having either a class init method or
|
||||
// doing it outside this class altogether. Both of those solutions seems
|
||||
// messy and this should not have a big performance hit.
|
||||
Mix_HookMusicFinished(musicFinished);
|
||||
current = self;
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
/*
|
||||
* Play the music represented by this OOMusic instance. This will replace any
|
||||
* music currently playing.
|
||||
*
|
||||
* If this instance is already playing, there is no effect.
|
||||
*
|
||||
* Returns YES for success, or NO if there was a problem playing the music.
|
||||
*/
|
||||
- (void) playLooped:(BOOL)loop
|
||||
{
|
||||
[self playWithCount:loop ? -1 : 1];
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop playing this piece of music.
|
||||
*
|
||||
* Returns YES if this music was being played, or NO if this music was not
|
||||
* being played.
|
||||
*/
|
||||
- (void) stop
|
||||
{
|
||||
// Only stop the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
{
|
||||
Mix_HaltMusic();
|
||||
// Flag that there is no tune currently playing
|
||||
current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resume
|
||||
{
|
||||
// Only resume playing the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
{
|
||||
Mix_ResumeMusic();
|
||||
paused=NO;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Go back to the beginning of the music.
|
||||
*/
|
||||
- (void) goToBeginning
|
||||
{
|
||||
// Only rewind the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
Mix_RewindMusic();
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) name
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@end
|
||||
}
|
||||
|
||||
/*
|
||||
* Stop playing this piece of music.
|
||||
*
|
||||
* Returns YES if this music was being played, or NO if this music was not
|
||||
* being played.
|
||||
*/
|
||||
- (void) stop
|
||||
{
|
||||
// Only stop the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
{
|
||||
Mix_HaltMusic();
|
||||
// Flag that there is no tune currently playing
|
||||
current = 0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) resume
|
||||
{
|
||||
// Only resume playing the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
{
|
||||
Mix_ResumeMusic();
|
||||
paused=NO;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Go back to the beginning of the music.
|
||||
*/
|
||||
- (void) goToBeginning
|
||||
{
|
||||
// Only rewind the music if this instance is the one being played.
|
||||
if (current == self)
|
||||
Mix_RewindMusic();
|
||||
}
|
||||
|
||||
|
||||
- (NSString *) name
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
x
Reference in New Issue
Block a user