Tested under a stricter compiler and fixed some warnings. Removed -[OOSound stop] under OS X, OOSound's an OOMusic's pause/resume and related methods, which have done nothing under OS X since pre-1.65; all call sites have been #if 0-ed out, and need to be replaced with use of OOSoundSource. -[OOSound stop] is still there in the SDL implementation, but is for the use of OOBasicSoundSource only. May have broken build for SDL by fiddling with prototypes. Removed all uses of deprecated-in-OS-X methods -[NSString cString] and -[NSString lossyCString].

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1464 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2008-03-07 20:09:56 +00:00
parent b17ba19a77
commit fe418babea
26 changed files with 137 additions and 107 deletions

View File

@ -57,7 +57,7 @@ SOFTWARE.
OOSound *sound;
}
- (BOOL)playLooped;
- (BOOL)stop;
- (void)playLooped;
- (void)stop;
@end

View File

@ -88,7 +88,7 @@ static OOSoundSource *sMusicSource = nil;
}
- (BOOL)doPlayWithLoop:(BOOL)inLoop
- (void)doPlayWithLoop:(BOOL)inLoop
{
if (sPlayingMusic != self)
{
@ -103,13 +103,12 @@ static OOSoundSource *sMusicSource = nil;
sPlayingMusic = self;
}
return YES;
}
- (BOOL)play
- (void)play
{
return [self doPlayWithLoop:NO];
[self doPlayWithLoop:NO];
}
@ -119,20 +118,6 @@ static OOSoundSource *sMusicSource = nil;
}
- (BOOL)pause
{
OOLog(kOOLogDeprecatedMethodOOCASound, @"%s called but ignored - please report.", __FUNCTION__);
return NO;
}
- (BOOL)resume
{
OOLog(kOOLogDeprecatedMethodOOCASound, @"%s called but ignored - please report.", __FUNCTION__);
return NO;
}
- (BOOL)isPaused
{
return NO;
@ -147,20 +132,19 @@ static OOSoundSource *sMusicSource = nil;
#pragma mark OOMusic
- (BOOL)playLooped
- (void)playLooped
{
return [self doPlayWithLoop:YES];
[self doPlayWithLoop:YES];
}
- (BOOL)stop
- (void)stop
{
if (sPlayingMusic == self)
{
sPlayingMusic = nil;
[sMusicSource stop];
}
return YES;
}
@end

View File

@ -64,8 +64,7 @@ SOFTWARE.
- (id) initWithContentsOfFile:(NSString *)path;
- (BOOL) play;
- (BOOL) stop; // Deprecated; does nothing. If needed, use OOCASoundSource.
- (void) play;
- (BOOL) isPlaying;
- (uint32_t)playingCount;

View File

@ -288,28 +288,26 @@ static size_t sMaxBufferedSoundSize = 1 << 20; // 1 MB
}
- (BOOL) play
- (void) play
{
return NO;
}
- (BOOL)stop
- (void)stop
{
return YES;
}
- (BOOL)pause
#if OBSOLETE
- (void)pause
{
return NO;
}
- (BOOL)resume
- (void)resume
{
return NO;
}
#endif
- (BOOL)prepareToPlayWithContext:(OOCASoundRenderContext *)outContext looped:(BOOL)inLoop

View File

@ -2973,8 +2973,11 @@ double scoopSoundPlayTime = 0.0;
if (damageSound)
{
#if 0
// FIXME: should use an OOSoundSource.
if ([damageSound isPlaying]) [damageSound stop];
[damageSound play];
#endif
}
// firing on an innocent ship is an offence
@ -3016,7 +3019,10 @@ double scoopSoundPlayTime = 0.0;
energy -= amount;
if (scrapeDamageSound)
{
#if 0
// FIXME: should use an OOSoundSource.
if ([scrapeDamageSound isPlaying]) [scrapeDamageSound stop];
#endif
[scrapeDamageSound play];
}
ship_temperature += amount;
@ -3054,7 +3060,10 @@ double scoopSoundPlayTime = 0.0;
if (scrapeDamageSound)
{
#if 0
// FIXME: should use an OOSoundSource.
if ([scrapeDamageSound isPlaying]) [scrapeDamageSound stop];
#endif
[scrapeDamageSound play];
}
if (d_forward >= 0)
@ -5819,7 +5828,10 @@ OOSound* burnersound;
- (void) stopAfterburnerSound
{
#if 0
// FIXME: should use an OOSoundSource.
[burnersound stop];
#endif
}

View File

@ -597,8 +597,11 @@ static NSTimeInterval time_last_frame;
{
if (weaponHitSound)
{
#if 0
// FIXME: should use an OOSoundSource.
if ([weaponHitSound isPlaying])
[weaponHitSound stop];
#endif
[weaponHitSound play];
}
}
@ -606,7 +609,10 @@ static NSTimeInterval time_last_frame;
{
if (weaponSound)
{
#if 0
// FIXME: should use an OOSoundSource.
if ([weaponSound isPlaying]) [weaponSound stop];
#endif
[weaponSound play];
}
}
@ -987,10 +993,13 @@ static NSTimeInterval time_last_frame;
if (status == STATUS_WITCHSPACE_COUNTDOWN)
{
// abort!
#if 0
// FIXME: should use an OOSoundSource.
if (galactic_witchjump)
[UNIVERSE stopCustomSound:@"[galactic-hyperspace-countdown-begun]"];
else
[UNIVERSE stopCustomSound:@"[hyperspace-countdown-begun]"];
#endif
jumpOK = NO;
galactic_witchjump = NO;
status = STATUS_IN_FLIGHT;
@ -1032,10 +1041,13 @@ static NSTimeInterval time_last_frame;
if (status == STATUS_WITCHSPACE_COUNTDOWN)
{
// abort!
#if 0
// FIXME: should use an OOSoundSource.
if (galactic_witchjump)
[UNIVERSE stopCustomSound:@"[galactic-hyperspace-countdown-begun]"];
else
[UNIVERSE stopCustomSound:@"[hyperspace-countdown-begun]"];
#endif
jumpOK = NO;
galactic_witchjump = NO;
status = STATUS_IN_FLIGHT;

View File

@ -76,7 +76,9 @@ typedef enum
} OOComparisonType;
#if SUPPORT_TRACE_MESSAGES
static NSString *ComparisonTypeToString(OOComparisonType type) CONST_FUNC;
#endif
static NSString * const kOOLogScriptAddShipsFailed = @"script.addShips.failed";
@ -2654,6 +2656,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
@end
#if SUPPORT_TRACE_MESSAGES
static NSString *ComparisonTypeToString(OOComparisonType type)
{
switch (type)
@ -2668,3 +2671,4 @@ static NSString *ComparisonTypeToString(OOComparisonType type)
}
return @"<error: invalid comparison type>";
}
#endif

View File

@ -201,7 +201,10 @@ MA 02110-1301, USA.
- (void)playAlertConditionRed
{
#if 0
// FIXME: should use an OOSoundSource.
if ([warningSound isPlaying]) [warningSound stop];
#endif
[warningSound play];
}

View File

@ -54,6 +54,7 @@ MA 02110-1301, USA.
#import "PlayerEntityLegacyScriptEngine.h"
#import "WormholeEntity.h"
#import "GuiDisplayGen.h"
#import "HeadUpDisplay.h"
#import "OODebugGLDrawing.h"
@ -738,7 +739,7 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
beaconCode = [bcode copy];
if (beaconCode != nil)
{
beaconChar = [bcode lossyCString][0];
beaconChar = [bcode cStringUsingOoliteEncodingAndRemapping][0];
}
else
{
@ -3217,7 +3218,7 @@ static GLfloat mascem_color2[4] = { 0.4, 0.1, 0.4, 1.0}; // purple
}
- (void) setStatus:(int) stat
- (void) setStatus:(OOEntityStatus) stat
{
status = stat;
if ((status == STATUS_LAUNCHING)&&(UNIVERSE))

View File

@ -330,7 +330,6 @@ OOINLINE BOOL RowInRange(OOGUIRow row, NSRange range)
- (void) click
{
if ([guiclick isPlaying]) [guiclick stop];
[guiclick play];
}

View File

@ -271,3 +271,14 @@ void drawScannerGrid(double x, double y, double z, NSSize siz, int v_dir, GLfloa
- (GLfloat) line_width;
@end
@interface NSString (OODisplayEncoding)
// Return a C string in the 8-bit encoding used for display.
- (const char *) cStringUsingOoliteEncoding;
// Return a C string in the 8-bit encoding used for display, with substitutions performed.
- (const char *) cStringUsingOoliteEncodingAndRemapping;
@end

View File

@ -2241,6 +2241,28 @@ static void DrawSpecialOval(GLfloat x, GLfloat y, GLfloat z, NSSize siz, GLfloat
@end
@implementation NSString (OODisplayEncoding)
- (const char *) cStringUsingOoliteEncoding
{
if (sEncodingCoverter == nil) InitTextEngine();
// Note: the data will be autoreleased, so the bytes behave as though they're autoreleased too.
return [[self dataUsingEncoding:[sEncodingCoverter encoding] allowLossyConversion:YES] bytes];
}
- (const char *) cStringUsingOoliteEncodingAndRemapping
{
if (sEncodingCoverter == nil) InitTextEngine();
// Note: the data will be autoreleased, so the bytes behave as though they're autoreleased too.
return [[sEncodingCoverter convertString:self] bytes];
}
@end
static void GetRGBAArrayFromInfo(NSDictionary *info, GLfloat ioColor[4])
{
id colorDesc = nil;

View File

@ -199,7 +199,7 @@ static NSString *GetGLSLInfoLog(GLhandleARB shaderObject);
vertexShader = glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB);
if (vertexShader != NULL_SHADER)
{
sourceString = [vertexSource lossyCString];
sourceString = [vertexSource UTF8String];
glShaderSourceARB(vertexShader, 1, &sourceString, NULL);
glCompileShaderARB(vertexShader);
@ -219,7 +219,7 @@ static NSString *GetGLSLInfoLog(GLhandleARB shaderObject);
fragmentShader = glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
if (fragmentShader != NULL_SHADER)
{
sourceString = [fragmentSource lossyCString];
sourceString = [fragmentSource UTF8String];
glShaderSourceARB(fragmentShader, 1, &sourceString, NULL);
glCompileShaderARB(fragmentShader);

View File

@ -205,7 +205,7 @@ OOINLINE BOOL ValidBindingType(OOShaderUniformType type)
if (OK)
{
location = glGetUniformLocationARB([shaderProgram program], [uniformName lossyCString]);
location = glGetUniformLocationARB([shaderProgram program], [uniformName UTF8String]);
if (location == -1)
{
OK = NO;
@ -424,7 +424,7 @@ OOINLINE BOOL ValidBindingType(OOShaderUniformType type)
if (OK)
{
location = glGetUniformLocationARB([shaderProgram program], [uniformName lossyCString]);
location = glGetUniformLocationARB([shaderProgram program], [uniformName UTF8String]);
if (location == -1) OK = NO;
}

View File

@ -69,6 +69,8 @@ SOFTWARE.
- (NSData *) convertString:(NSString *)string;
- (NSStringEncoding) encoding;
@end
#endif //OOENCODINGCONVERTER_EXCLUDE

View File

@ -170,6 +170,12 @@ static unsigned sCacheMisses = 0;
return data;
}
- (NSStringEncoding) encoding
{
return _encoding;
}
@end

View File

@ -28,6 +28,7 @@ MA 02110-1301, USA.
#if OO_PPC
#ifndef __llvm__
/* OOInvSqrtf()
Based on G3-otimized fsqrtf() by Conn Clark. The only difference is that
it does not store and multiply by the original value to go from reciprocal
@ -121,4 +122,15 @@ not_a_number:
blr /* return */
}
#else
#import <math.h>
// LLVM-GCC doesn't support asm at the moment.
float OOInvSqrtf(float x)
{
return 1.0 / sqrtf(x);
}
#endif
#endif

View File

@ -24,8 +24,7 @@ MA 02110-1301, USA.
#import "OOScript.h"
#import "OOWeakReference.h"
#import <jsapi.h>
#import "OOJavaScriptEngine.h"
@interface OOJSScript: OOScript <OOWeakReferenceSupport>

View File

@ -290,7 +290,7 @@ static JSFunctionSpec sScriptMethods[] =
jsval value;
JSFunction *function = NULL;
OK = JS_GetProperty(context, object, [eventName cString], &value);
OK = JS_GetProperty(context, object, [eventName UTF8String], &value);
#if SUPPORT_CHANGED_HANDLERS
if (!OK || value == JSVAL_VOID)
@ -317,7 +317,7 @@ static JSFunctionSpec sScriptMethods[] =
{
for (oldNameEnum = [oldNames objectEnumerator]; (oldName = [oldNameEnum nextObject]) && value == JSVAL_VOID && OK; )
{
OK = JS_GetProperty(context, object, [oldName cString], &value);
OK = JS_GetProperty(context, object, [oldName UTF8String], &value);
if (OK && value != JSVAL_VOID)
{

View File

@ -27,6 +27,24 @@ MA 02110-1301, USA.
#import "Universe.h"
#import "PlayerEntity.h"
#import "PlayerEntityLegacyScriptEngine.h"
#if 0 && OOLITE_MAC_OS_X
// Spoof libjs types defined in jsotypes.h due to a conflict with Security.framework
#define PROTYPES_H
#define uint JSUint
#define uintn JSUintn
typedef int8_t int8;
typedef uint8_t uint8;
typedef int16_t int16;
typedef uint16_t uint16;
typedef int32_t int32;
typedef uint32_t uint32;
typedef int64_t int64;
typedef uint64_t uint64;
// float32 is in jscompat.h
typedef Float64 float64;
#endif
#import <jsapi.h>
#define OOJSENGINE_MONITOR_SUPPORT (!defined(NDEBUG))

View File

@ -410,8 +410,6 @@ enum
- (OOViewID) viewDirection;
- (BOOL) playCustomSound:(NSString*)key;
- (BOOL) stopCustomSound:(NSString*)key;
- (BOOL) isPlayingCustomSound:(NSString*)key;
- (void) clearPreviousMessage;
- (void) setMessageGuiBackgroundColor:(OOColor *) some_color;

View File

@ -1903,7 +1903,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
Vector p_pos = the_planet->position;
Vector s_pos = the_sun->position;
const char* c_sys = [l_sys lossyCString];
const char* c_sys = [l_sys UTF8String];
Vector p0 = make_vector(1,0,0);
Vector p1 = make_vector(0,1,0);
Vector p2 = make_vector(0,0,1);
@ -2004,7 +2004,7 @@ GLfloat docked_light_specular[4] = { (GLfloat) 1.0, (GLfloat) 1.0, (GLfloat) 0.5
Vector p_pos = the_planet->position;
Vector s_pos = the_sun->position;
const char* c_sys = [l_sys lossyCString];
const char* c_sys = [l_sys UTF8String];
Vector p0 = make_vector(1,0,0);
Vector p1 = make_vector(0,1,0);
Vector p2 = make_vector(0,0,1);
@ -4939,38 +4939,6 @@ OOINLINE BOOL EntityInRange(Vector p1, Entity *e2, float range)
}
- (BOOL) stopCustomSound:(NSString*)key
{
NSString *fileName = nil;
fileName = [customsounds stringForKey:key];
if (fileName != nil)
{
OOSound* sound = [ResourceManager ooSoundNamed:fileName inFolder:@"Sounds"];
if (sound)
{
return [sound stop];
}
}
return NO;
}
- (BOOL) isPlayingCustomSound:(NSString*)key
{
NSString *fileName = nil;
fileName = [customsounds stringForKey:key];
if (fileName != nil)
{
OOSound* sound = [ResourceManager ooSoundNamed:fileName inFolder:@"Sounds"];
if (sound)
return [sound isPlaying];
}
return NO;
}
- (void) clearPreviousMessage
{
if (currentMessage) [currentMessage release];

View File

@ -47,8 +47,8 @@ MA 02110-1301, USA.
// Start playing this instance of OOMusic, stopping any other instance
// currently playing.
- (BOOL) play;
- (BOOL) playLooped;
- (void) play;
- (void) playLooped;
// Stop the music if this instance is currently playing.
- (void) stop;

View File

@ -182,7 +182,7 @@ void musicFinished()
*
* Returns YES for success, or NO if there was a problem playing the music.
*/
- (BOOL) play
- (void) play
{
return [self playWithCount:1];
}
@ -195,7 +195,7 @@ void musicFinished()
*
* Returns YES for success, or NO if there was a problem playing the music.
*/
- (BOOL) playLooped
- (void) playLooped
{
return [self playWithCount:-1];
}

View File

@ -47,11 +47,9 @@ MA 02110-1301, USA.
+ (void) setMasterVolume: (float) fraction;
- (id) initWithContentsOfFile:(NSString*) filepath;
- (BOOL) pause;
- (BOOL) isPlaying;
- (BOOL) play;
- (BOOL) stop;
- (BOOL) resume;
- (void) play;
- (void) stop;
- (NSString *) name;

View File

@ -75,14 +75,6 @@ static BOOL isSetUp=NO;
setFloat: masterVol forKey: KEY_VOLUME_CONTROL];
}
- (BOOL) pause
{
if (sample && currentChannel > -1)
Mix_Pause(currentChannel);
return YES;
}
- (BOOL) isPlaying
{
int i;
@ -95,7 +87,7 @@ static BOOL isSetUp=NO;
return NO;
}
- (BOOL) play
- (void) play
{
if(!isSetUp) [OOSound setUp];
int chansScanned=1;
@ -126,7 +118,7 @@ static BOOL isSetUp=NO;
return YES;
}
- (BOOL) stop
- (void) stop
{
if (sample && currentChannel > -1)
{
@ -137,14 +129,6 @@ static BOOL isSetUp=NO;
return YES;
}
- (BOOL) resume
{
if (sample && currentChannel > -1)
Mix_Resume(currentChannel);
return YES;
}
- (id) initWithContentsOfFile:(NSString*)filepath
{
[super init];