Skip to content

Commit

Permalink
- fix: refactored thargoids were using various 'EQ_MISSILES' instead …
Browse files Browse the repository at this point in the history
…of thargons - now they use thargons again! - 'thargon' is now a thargoid-only piece of equipment. Equipment name kept the same as pre-exisiting thargon role for backward compatibility.

- fix: no more occasional 'ident system locked onto(null)' on game restart.
- code cleanup: replaced all (deprecated) cStrings inside the GNUStep code with UTF8String.


git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2835 127b21dd-08f5-0310-b4b7-95ae10353056
  • Loading branch information
Kaks committed Dec 3, 2009
1 parent 44e20b8 commit 8731d87
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 19 deletions.
6 changes: 6 additions & 0 deletions Resources/Config/equipment.plist
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,12 @@
}
),
/* next items are new items, don't place new items before this mark */
/* Thargoid equipment, incompatible with non-thargoid ships. */
(
95, 1000, "Thargon",
"thargon",
"Alien drone ship."
),
( /* Passenger Compartment, like missiles this can be bought multiple times */
5, 8250, "Passenger Berth - takes up 5t of cargo space",
"EQ_PASSENGER_BERTH",
Expand Down
3 changes: 3 additions & 0 deletions src/Core/Entities/PlayerEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,9 @@ - (BOOL) setUpShipFromDictionary:(NSDictionary *)shipDict
{
missile_entity[i] = [UNIVERSE newShipWithRole:@"EQ_MISSILE"]; // retain count = 1
}

primaryTarget = NO_TARGET;
[self safeAllMissiles];
[self setActiveMissile:0];

// set view offsets
Expand Down
36 changes: 24 additions & 12 deletions src/Core/Entities/ShipEntity.m
Original file line number Diff line number Diff line change
Expand Up @@ -349,14 +349,6 @@ - (BOOL) setUpShipFromDictionary:(NSDictionary *) shipDict

scannerRange = [shipDict oo_floatForKey:@"scanner_range" defaultValue:(float)SCANNER_MAX_RANGE];

missileRole = [shipDict oo_stringForKey:@"missile_role"];
unsigned i;
for (i = 0; i < missiles; i++)
{
missile_list[i] = [self newMissile];
if (missile_list[i] == nil) i--;
}

fuel = [shipDict oo_unsignedShortForKey:@"fuel"]; // Does it make sense that this defaults to 0? Should it not be 70? -- Ahruman
fuel_accumulator = 1.0;

Expand Down Expand Up @@ -422,7 +414,16 @@ - (BOOL) setUpShipFromDictionary:(NSDictionary *) shipDict
{
scanClass = StringToScanClass([shipDict oo_stringForKey:@"scanClass" defaultValue:@"CLASS_NOT_SET"]);
}


// Populate the missiles here. Must come after scanClass.
missileRole = [shipDict oo_stringForKey:@"missile_role"];
unsigned i;
for (i = 0; i < missiles; i++)
{
missile_list[i] = [self newMissile];
if (missile_list[i] == nil) i--;
}

// accuracy. Must come after scanClass, because we are using scanClass to determine if this is a missile.
accuracy = [shipDict oo_floatForKey:@"accuracy" defaultValue:-100.0f]; // Out-of-range default
if (accuracy >= -5.0f && accuracy <= 10.0f)
Expand Down Expand Up @@ -1981,7 +1982,7 @@ - (BOOL) canAddEquipment:(NSString *)equipmentKey
equipmentKey = [equipmentKey substringToIndex:[equipmentKey length] - [@"_DAMAGED" length]];
}

if ([equipmentKey hasSuffix:@"MISSILE"]||[equipmentKey hasSuffix:@"MINE"])
if ([equipmentKey hasSuffix:@"MISSILE"]||[equipmentKey hasSuffix:@"MINE"]||([self isThargoid] && [equipmentKey isEqualToString:@"thargon"]))
{
if (missiles >= max_missiles) return NO;
}
Expand Down Expand Up @@ -2133,7 +2134,7 @@ - (BOOL) addEquipmentItem:(NSString *)equipmentKey withValidation:(BOOL)validate

// special cases

if ([equipmentKey hasSuffix:@"MISSILE"]||[equipmentKey hasSuffix:@"MINE"])
if ([equipmentKey hasSuffix:@"MISSILE"]||[equipmentKey hasSuffix:@"MINE"]||([self isThargoid] && [equipmentKey isEqualToString:@"thargon"]))
{
if (missiles >= max_missiles) return NO;

Expand All @@ -2143,6 +2144,9 @@ - (BOOL) addEquipmentItem:(NSString *)equipmentKey withValidation:(BOOL)validate
return YES;
}

// don't add any thargons to non-thargoid ships.
if([equipmentKey isEqualToString:@"thargon"]) return NO;

// we can theoretically add a damaged weapon, but not a working one.
if([equipmentKey hasPrefix:@"EQ_WEAPON"] && ![equipmentKey hasSuffix:@"_DAMAGED"])
{
Expand Down Expand Up @@ -2200,7 +2204,7 @@ - (void) removeEquipmentItem:(NSString *)equipmentKey
OOEquipmentType *eqType = [OOEquipmentType equipmentTypeWithIdentifier:equipmentTypeCheckKey];
if (eqType == nil) return;

if ([eqType isMissileOrMine])
if ([eqType isMissileOrMine] || ([self isThargoid] && [equipmentTypeCheckKey isEqualToString:@"thargon"]))
{
[self removeExternalStore:eqType];
}
Expand Down Expand Up @@ -2250,6 +2254,14 @@ - (OOEquipmentType *) newMissile
id value;
double chance = randf();

if ([self isThargoid])
{
if (missileRole != nil) missile = [UNIVERSE newShipWithRole:missileRole]; // retained
else missile = [UNIVERSE newShipWithRole:@"thargon"]; // retained
missileType = [OOEquipmentType equipmentTypeWithIdentifier:[missile primaryRole]];
return missileType;
}

// random role 10% of the cases, if a missile role is defined.
if (chance < 0.9f && missileRole != nil) missile = [UNIVERSE newShipWithRole:missileRole]; // retained
if (missile == nil) // no actual role defined?
Expand Down
4 changes: 2 additions & 2 deletions src/Core/OXPVerifier/OOOXPVerifier.m
Original file line number Diff line number Diff line change
Expand Up @@ -739,11 +739,11 @@ static void OpenLogFile(NSString *name)
[[NSWorkspace sharedWorkspace] openFile:OOLogHandlerGetLogPath()];
#elif OOLITE_WINDOWS
// start wordpad (for historical reasons wordpad is called write from the command prompt)
system([[NSString stringWithFormat:@"write \"Logs\\%@.log\"", name] cString]);
system([[NSString stringWithFormat:@"write \"Logs\\%@.log\"", name] UTF8String]);
#elif OOLITE_LINUX
// Nothing to do here, since we dump to stdout instead of to a file.
//OOLogOutputHandlerStopLoggingToStdout();
system([[NSString stringWithFormat:@"cat \"%@\"", OOLogHandlerGetLogPath()] cString]);
system([[NSString stringWithFormat:@"cat \"%@\"", OOLogHandlerGetLogPath()] UTF8String]);
#else
do {} while (0);
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/SDL/MyOpenGLView.m
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ - (id) init
#endif

imagesDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Images"];
icon = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"WMicon.bmp"] cString]);
icon = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"WMicon.bmp"] UTF8String]);

if (icon != NULL)
{
Expand Down Expand Up @@ -516,7 +516,7 @@ - (void) initSplashScreen
NSString *imagesDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Images"];
#endif

image = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"splash.bmp"] cString]);
image = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"splash.bmp"] UTF8String]);

if (image == NULL)
{
Expand Down Expand Up @@ -873,7 +873,7 @@ - (void) snapShot
free(aux);

tmpSurface=SDL_CreateRGBSurfaceFrom(pixls,surface->w,surface->h,24,surface->w*3,0xFF,0xFF00,0xFF0000,0x0);
SDL_SaveBMP(tmpSurface, [pathToPic cString]);
SDL_SaveBMP(tmpSurface, [pathToPic UTF8String]);
SDL_FreeSurface(tmpSurface);
free(pixls);

Expand Down
2 changes: 1 addition & 1 deletion src/SDL/OOSDLConcreteSound.m
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ - (id) initWithContentsOfFile:(NSString *)path
{
if ((self = [super init]))
{
_chunk = Mix_LoadWAV([path cString]);
_chunk = Mix_LoadWAV([path UTF8String]);

if (_chunk != NULL)
{
Expand Down
2 changes: 1 addition & 1 deletion src/SDL/SDLMusic.m
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ - (id) initWithContentsOfFile:(NSString*) filepath

[super init];

music = Mix_LoadMUS([filepath cString]);
music = Mix_LoadMUS([filepath UTF8String]);
if (!music)
{
NSLog(@"Mix_LoadMUS(\"%@\"): %s\n", filepath, Mix_GetError());
Expand Down

0 comments on commit 8731d87

Please sign in to comment.