Enforced use of accessors to get at Entity status property in order to help track down status-is-DOCKED-but-dockedStation-is-nil messages when scripts test whether player is docked; as a side effect, the bug seems to have gone away.

git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@2043 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
Jens Ayton 2009-02-08 15:46:23 +00:00
parent 8d9611ea8b
commit 63a6ba94a3
21 changed files with 215 additions and 188 deletions

View File

@ -537,7 +537,7 @@ BOOL testEntityOccludedByEntity(Entity* e1, Entity* e2, PlanetEntity* the_sun)
{
e1 = entity_array[i];
BOOL occluder_moved = NO;
if (e1->status == STATUS_COCKPIT_DISPLAY)
if ([e1 status] == STATUS_COCKPIT_DISPLAY)
{
e1->isSunlit = YES;
e1->shadingEntityID = NO_TARGET;

View File

@ -56,7 +56,7 @@ MA 02110-1301, USA.
dust_color = [[OOColor colorWithCalibratedRed:0.5 green:1.0 blue:1.0 alpha:1.0] retain];
displayListName = 0;
status = STATUS_ACTIVE;
[self setStatus:STATUS_ACTIVE];
[[OOGraphicsResetManager sharedManager] registerClient:self];

View File

@ -109,7 +109,6 @@ typedef struct
isExplicitlyNotMainStation: 1;
OOScanClass scanClass;
OOEntityStatus status;
GLfloat zero_distance;
GLfloat no_draw_distance; // 10 km initially
@ -164,16 +163,17 @@ typedef struct
@private
OOWeakReference *_owner;
OOEntityStatus _status;
}
- (BOOL)isShip;
- (BOOL)isStation;
- (BOOL)isSubEntity;
- (BOOL)isPlayer;
- (BOOL)isPlanet;
- (BOOL)isSun;
- (BOOL)isSky;
- (BOOL)isWormhole;
- (BOOL) isShip;
- (BOOL) isStation;
- (BOOL) isSubEntity;
- (BOOL) isPlayer;
- (BOOL) isPlanet;
- (BOOL) isSun;
- (BOOL) isSky;
- (BOOL) isWormhole;
- (BOOL) validForAddToUniverse;
- (void) addToLinkedLists;
@ -264,8 +264,8 @@ typedef struct
- (void) takeEnergyDamage:(double) amount from:(Entity *) ent becauseOf:(Entity *) other;
- (void)dumpState; // General "describe situtation verbosely in log" command.
- (void)dumpSelfState; // Subclasses should override this, not -dumpState, and call throught to super first.
- (void) dumpState; // General "describe situtation verbosely in log" command.
- (void) dumpSelfState; // Subclasses should override this, not -dumpState, and call throught to super first.
// Subclass repsonsibilities
- (double) findCollisionRadius;
@ -273,8 +273,8 @@ typedef struct
- (void) drawEntity:(BOOL)immediate :(BOOL)translucent;
// For shader bindings.
- (GLfloat)universalTime;
- (GLfloat)spawnTime;
- (GLfloat)timeElapsedSinceSpawn;
- (GLfloat) universalTime;
- (GLfloat) spawnTime;
- (GLfloat) timeElapsedSinceSpawn;
@end

View File

@ -71,7 +71,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
collidingEntities = [[NSMutableArray alloc] init];
scanClass = CLASS_NOT_SET;
status = STATUS_COCKPIT_DISPLAY;
[self setStatus:STATUS_COCKPIT_DISPLAY];
spawnTime = [UNIVERSE getTime];
@ -654,13 +654,13 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
- (void) setStatus:(OOEntityStatus) stat
{
status = stat;
_status = stat;
}
- (OOEntityStatus) status
{
return status;
return _status;
}
@ -787,7 +787,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
PlayerEntity *player = [PlayerEntity sharedPlayer];
if (player)
{
if (status != STATUS_COCKPIT_DISPLAY)
if ([self status] != STATUS_COCKPIT_DISPLAY)
relativePosition = vector_between(player->position, position);
else
relativePosition = position;
@ -1052,7 +1052,7 @@ static NSString * const kOOLogEntityUpdateError = @"entity.linkedList.update.
OOLog(@"dumpState.entity", @"Universal ID: %u", universalID);
OOLog(@"dumpState.entity", @"Scan class: %@", ScanClassToString(scanClass));
OOLog(@"dumpState.entity", @"Status: %@", EntityStatusToString(status));
OOLog(@"dumpState.entity", @"Status: %@", EntityStatusToString([self status]));
OOLog(@"dumpState.entity", @"Position: %@", VectorDescription(position));
OOLog(@"dumpState.entity", @"Orientation: %@", QuaternionDescription(orientation));
OOLog(@"dumpState.entity", @"Distance travelled: %g", distanceTravelled);

View File

@ -171,7 +171,7 @@ static NSString * const kOOLogEntityTooManyFaces = @"entity.loadMesh.failed.to
return; // TOO FAR AWAY
}
}
if (status == STATUS_ACTIVE)
if ([self status] == STATUS_ACTIVE)
{
Vector abspos = position; // STATUS_ACTIVE means it is in control of it's own orientation
Entity *last = nil;

View File

@ -153,7 +153,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
particle_type = PARTICLE_TEST;
isParticle = YES;
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
basefile = @"Particle";
[self setTexture:@"blur256.png"];
@ -178,7 +178,7 @@ static Vector circleVertex[65]; // holds vector coordinates for a unit circle
if (ship == nil) goto FAIL;
#endif
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
if (ship == srcEntity) position = [ship position];
else
{
@ -264,7 +264,7 @@ FAIL:
scale.z = [values floatAtIndex:5];
exhaustScale = scale;
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
particle_type = PARTICLE_EXHAUST;
@ -291,7 +291,7 @@ FAIL:
duration = ECM_EFFECT_DURATION;
position = [ship position];
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_NO_DRAW;
particle_type = PARTICLE_ECM_MINE;
@ -326,7 +326,7 @@ FAIL:
alpha = 0.5;
collision_radius = 0;
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_MINE;
particle_type = PARTICLE_ENERGY_MINE;
@ -360,7 +360,7 @@ FAIL:
[self setOrientation:ship->orientation];
[self setVelocity:[ship velocity]];
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_NO_DRAW;
particle_type = PARTICLE_HYPERRING;
@ -413,7 +413,7 @@ FAIL:
faces[i].normal.x = 16.0 * speed_low / speed;
}
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_NO_DRAW;
particle_type = PARTICLE_FRAGBURST;
@ -468,7 +468,7 @@ FAIL:
faces[i].normal.z = 1.0;
}
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_NO_DRAW;
particle_type = PARTICLE_BURST2;
@ -514,7 +514,7 @@ FAIL:
[self setColor:flashColor];
color_fv[3] = 1.0;
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_NO_DRAW;
particle_type = PARTICLE_FLASH;
@ -550,7 +550,7 @@ FAIL:
[self setColor:[OOColor whiteColor]];
color_fv[3] = 1.0;
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_NO_DRAW;
particle_type = PARTICLE_BILLBOARD;
@ -1357,7 +1357,7 @@ FAIL:
return; // TOO FAR AWAY TO DRAW
}
if ((particle_type == PARTICLE_FLASHER)&&(status != STATUS_INACTIVE))
if (particle_type == PARTICLE_FLASHER && [self status] != STATUS_INACTIVE)
{
Vector abspos = position; // in control of it's own orientation
int view_dir = [UNIVERSE viewDirection];

View File

@ -616,7 +616,7 @@ static GLfloat texture_uv_array[10400 * 2];
collision_radius = [planet collisionRadius] * PLANET_MINIATURE_FACTOR; // teeny tiny
scanClass = CLASS_NO_DRAW;
status = STATUS_COCKPIT_DISPLAY;
[self setStatus:STATUS_COCKPIT_DISPLAY];
orientation.w = M_SQRT1_2;
orientation.x = M_SQRT1_2;

View File

@ -1155,7 +1155,7 @@ static PlayerEntity *sSharedPlayer = nil;
- (BOOL) canCollide
{
switch (status)
switch ([self status])
{
case STATUS_START_GAME:
case STATUS_DOCKING:
@ -1202,6 +1202,7 @@ static PlayerEntity *sSharedPlayer = nil;
[self updateTrumbles:delta_t];
OOEntityStatus status = [self status];
if (status == STATUS_START_GAME && gui_screen != GUI_SCREEN_INTRO1 && gui_screen != GUI_SCREEN_INTRO2)
{
[self setGuiToIntro1Screen]; //set up demo mode
@ -1370,6 +1371,7 @@ static PlayerEntity *sSharedPlayer = nil;
}
//Bug #11692 CmdrJames added Status entering witchspace
OOEntityStatus status = [self status];
if ((status != STATUS_AUTOPILOT_ENGAGED)&&(status != STATUS_ESCAPE_SEQUENCE) && (status != STATUS_ENTERING_WITCHSPACE))
{
// work on the cabin temperature
@ -1595,7 +1597,7 @@ static PlayerEntity *sSharedPlayer = nil;
{
if (script_time <= script_time_check) return;
if (status != STATUS_IN_FLIGHT)
if ([self status] != STATUS_IN_FLIGHT)
{
switch (gui_screen)
{
@ -1722,7 +1724,7 @@ static PlayerEntity *sSharedPlayer = nil;
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:[NSString stringWithFormat:DESC(@"witch-blocked-by-@"), [blocker name]] forCount: 4.5];
[self playWitchjumpBlocked];
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self doScriptEvent:@"playerJumpFailed" withArgument:@"blocked"];
go = NO;
}
@ -1737,7 +1739,7 @@ static PlayerEntity *sSharedPlayer = nil;
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:DESC(@"witch-too-far") forCount: 4.5];
[self playWitchjumpDistanceTooGreat];
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self doScriptEvent:@"playerJumpFailed" withArgument:@"too far"];
go = NO;
}
@ -1752,7 +1754,7 @@ static PlayerEntity *sSharedPlayer = nil;
[UNIVERSE clearPreviousMessage];
[UNIVERSE addMessage:DESC(@"witch-no-fuel") forCount: 4.5];
[self playWitchjumpInsufficientFuel];
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self doScriptEvent:@"playerJumpFailed" withArgument:@"insufficient fuel"];
go = NO;
}
@ -1786,7 +1788,7 @@ static PlayerEntity *sSharedPlayer = nil;
else
[UNIVERSE addMessage:DESC(@"witch-engine-malfunction") forCount:3.0];
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self doScriptEvent:@"shipExitedWitchspace"];
suppressAegisMessages=NO;
}
@ -1801,7 +1803,7 @@ static PlayerEntity *sSharedPlayer = nil;
[self checkScript];
// next check in 10s
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
#ifdef DOCKING_CLEARANCE_ENABLED
[self setDockingClearanceStatus:DOCKING_CLEARANCE_STATUS_NONE];
@ -1899,7 +1901,7 @@ static PlayerEntity *sSharedPlayer = nil;
if (missile_status == MISSILE_STATUS_ARMED &&
(ident_engaged || [missile_entity[activeMissile] isMissile]) &&
(status == STATUS_IN_FLIGHT || status == STATUS_WITCHSPACE_COUNTDOWN))
([self status] == STATUS_IN_FLIGHT || [self status] == STATUS_WITCHSPACE_COUNTDOWN))
{
ShipEntity *target = [UNIVERSE getFirstEntityTargettedByPlayer];
if (target != nil) [self addTarget:target];
@ -2071,10 +2073,19 @@ static PlayerEntity *sSharedPlayer = nil;
- (void) drawEntity:(BOOL) immediate :(BOOL) translucent
{
if ((status == STATUS_DEAD)||(status == STATUS_COCKPIT_DISPLAY)||(status == STATUS_DOCKED)||(status == STATUS_START_GAME)||[UNIVERSE breakPatternHide])
return; // don't draw
[super drawEntity: immediate : translucent];
switch ([self status])
{
case STATUS_DEAD:
case STATUS_COCKPIT_DISPLAY:
case STATUS_DOCKED:
case STATUS_START_GAME:
return;
default:
if ([UNIVERSE breakPatternHide]) return;
}
[super drawEntity:immediate :translucent];
}
@ -2110,7 +2121,7 @@ static PlayerEntity *sSharedPlayer = nil;
- (void) setDockedAtMainStation
{
dockedStation = [UNIVERSE station];
status=STATUS_DOCKED;
[self setStatus:STATUS_DOCKED];
}
- (StationEntity *) dockedStation
@ -2643,7 +2654,9 @@ static PlayerEntity *sSharedPlayer = nil;
{
OOAlertCondition old_alert_condition = alertCondition;
alertCondition = ALERT_CONDITION_GREEN;
[self setAlertFlag:ALERT_FLAG_DOCKED to:(status == STATUS_DOCKED)];
[self setAlertFlag:ALERT_FLAG_DOCKED to:[self status] == STATUS_DOCKED];
if (alertFlags & ALERT_FLAG_DOCKED)
{
alertCondition = ALERT_CONDITION_DOCKED;
@ -2687,13 +2700,13 @@ static PlayerEntity *sSharedPlayer = nil;
if ([ms isEqual:@"ECM"]) [self playHitByECMSound];
if ([ms isEqual:@"DOCKING_REFUSED"]&&(status == STATUS_AUTOPILOT_ENGAGED))
if ([ms isEqual:@"DOCKING_REFUSED"] && [self status] == STATUS_AUTOPILOT_ENGAGED)
{
[self playDockingDenied];
[UNIVERSE addMessage:DESC(@"autopilot-denied") forCount:4.5];
autopilot_engaged = NO;
primaryTarget = NO_TARGET;
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[[OOMusicController sharedController] stopDockingMusic];
[self doScriptEvent:@"playerDockingRefused"];
}
@ -3038,7 +3051,7 @@ static PlayerEntity *sSharedPlayer = nil;
double d_forward;
BOOL internal_damage = NO; // base chance
if (status == STATUS_DEAD) return;
if ([self status] == STATUS_DEAD) return;
if (amount == 0.0) return;
[[ent retain] autorelease];
@ -3116,7 +3129,7 @@ static PlayerEntity *sSharedPlayer = nil;
double d_forward;
BOOL internal_damage = NO; // base chance
if (status == STATUS_DEAD)
if ([self status] == STATUS_DEAD)
return;
[[ent retain] autorelease];
@ -3177,7 +3190,7 @@ static PlayerEntity *sSharedPlayer = nil;
- (void) takeHeatDamage:(double) amount
{
if (status == STATUS_DEAD) // it's too late for this one!
if ([self status] == STATUS_DEAD) // it's too late for this one!
return;
if (amount < 0.0)
@ -3237,7 +3250,7 @@ static PlayerEntity *sSharedPlayer = nil;
int result = NO;
Quaternion q1 = orientation;
status = STATUS_ESCAPE_SEQUENCE; // firstly
[self setStatus:STATUS_ESCAPE_SEQUENCE]; // firstly
ship_clock_adjust += 43200 + 5400 * (ranrot_rand() & 127); // add up to 8 days until rescue!
#ifdef DOCKING_CLEARANCE_ENABLED
dockingClearanceStatus = DOCKING_CLEARANCE_STATUS_NOT_REQUIRED;
@ -3525,7 +3538,7 @@ static PlayerEntity *sSharedPlayer = nil;
[self playGameOver];
flightSpeed = 160.0f;
status = STATUS_DEAD;
[self setStatus:STATUS_DEAD];
[UNIVERSE displayMessage:DESC(@"gameoverscreen-game-over") forCount:30.0];
[UNIVERSE displayMessage:@"" forCount:30.0];
[UNIVERSE displayMessage:scoreMS forCount:30.0];
@ -3570,10 +3583,10 @@ static PlayerEntity *sSharedPlayer = nil;
- (void) enterDock:(StationEntity *)station
{
if (status == STATUS_DEAD)
if ([self status] == STATUS_DEAD)
return;
status = STATUS_DOCKING;
[self setStatus:STATUS_DOCKING];
[self doScriptEvent:@"shipWillDockWithStation" withArgument:station];
ident_engaged = NO;
@ -3693,6 +3706,15 @@ static PlayerEntity *sSharedPlayer = nil;
}
#if 0
- (void) setStatus:(OOEntityStatus)val
{
[super setStatus:val];
OOLog(@"player.temp.status", @"Player status set to %@", EntityStatusToString(val));
}
#endif
- (void) leaveDock:(StationEntity *)station
{
if (station == nil) return;
@ -3767,7 +3789,7 @@ static PlayerEntity *sSharedPlayer = nil;
- (void) enterGalacticWitchspace
{
status = STATUS_ENTERING_WITCHSPACE;
[self setStatus:STATUS_ENTERING_WITCHSPACE];
[self doScriptEvent:@"shipWillEnterWitchspace" withArgument:@"galactic jump"];
[self transitionToAegisNone];
suppressAegisMessages=YES;
@ -3858,7 +3880,7 @@ static PlayerEntity *sSharedPlayer = nil;
- (void) enterWormhole:(WormholeEntity *) w_hole replacing:(BOOL)replacing
{
target_system_seed = [w_hole destination];
status = STATUS_ENTERING_WITCHSPACE;
[self setStatus:STATUS_ENTERING_WITCHSPACE];
[self doScriptEvent:@"shipWillEnterWitchspace" withArgument:@"wormhole"];
[self transitionToAegisNone];
suppressAegisMessages=YES;
@ -3905,7 +3927,7 @@ static PlayerEntity *sSharedPlayer = nil;
{
double distance = distanceBetweenPlanetPositions(target_system_seed.d,target_system_seed.b,galaxy_coordinates.x,galaxy_coordinates.y);
status = STATUS_ENTERING_WITCHSPACE;
[self setStatus:STATUS_ENTERING_WITCHSPACE];
[self doScriptEvent:@"shipWillEnterWitchspace" withArgument:@"standard jump"];
[self transitionToAegisNone];
suppressAegisMessages=YES;
@ -4011,7 +4033,7 @@ static PlayerEntity *sSharedPlayer = nil;
flightPitch = 0.0f;
flightYaw = 0.0f;
flightSpeed = maxFlightSpeed * 0.25f;
status = STATUS_EXITING_WITCHSPACE;
[self setStatus:STATUS_EXITING_WITCHSPACE];
gui_screen = GUI_SCREEN_MAIN;
being_fined = NO; // until you're scanned by a copper!
[self clearTargetMemory];
@ -4635,9 +4657,9 @@ static PlayerEntity *sSharedPlayer = nil;
MyOpenGLView *gameView = [UNIVERSE gameView];
GameController *controller = [UNIVERSE gameController];
if (status == STATUS_DOCKED)
if ([self status] == STATUS_DOCKED)
{
if (!dockedStation)
if (dockedStation == nil)
dockedStation = [UNIVERSE station];
canLoadOrSave = (dockedStation == [UNIVERSE station]);
}
@ -5598,7 +5620,7 @@ static int last_outfitting_index;
[gui setText:[NSString stringWithFormat:DESC(@"cash-@-load-d-of-d"), OOCredits(credits), current_cargo, max_cargo] forRow: GUI_ROW_MARKET_CASH];
if (status == STATUS_DOCKED) // can only buy or sell in dock
if ([self status] == STATUS_DOCKED) // can only buy or sell in dock
{
[gui setSelectableRange:NSMakeRange(start_row,row - start_row)];
if (([gui selectedRow] < start_row)||([gui selectedRow] >=row))
@ -5618,10 +5640,10 @@ static int last_outfitting_index;
OOGUIScreenID oldScreen = gui_screen;
gui_screen = GUI_SCREEN_MARKET;
[self setShowDemoShips: NO];
[UNIVERSE setDisplayText: YES];
[UNIVERSE setDisplayCursor: (status == STATUS_DOCKED)];
[UNIVERSE setViewDirection: VIEW_GUI_DISPLAY];
[self setShowDemoShips:NO];
[UNIVERSE setDisplayText:YES];
[UNIVERSE setDisplayCursor:[self status] == STATUS_DOCKED];
[UNIVERSE setViewDirection:VIEW_GUI_DISPLAY];
[self noteGuiChangeFrom:oldScreen to:gui_screen];
}
@ -6204,7 +6226,7 @@ static int last_outfitting_index;
// override shipentity addTarget to implement target_memory
- (void) addTarget:(Entity *) targetEntity
{
if (status != STATUS_IN_FLIGHT && status != STATUS_WITCHSPACE_COUNTDOWN) return;
if ([self status] != STATUS_IN_FLIGHT && [self status] != STATUS_WITCHSPACE_COUNTDOWN) return;
if (targetEntity == self) return;
if (missile_status == MISSILE_STATUS_SAFE)
@ -6468,7 +6490,7 @@ static int last_outfitting_index;
{
BOOL isDockedStatus = NO;
switch (status)
switch ([self status])
{
case STATUS_DOCKED:
case STATUS_DOCKING:
@ -6502,8 +6524,8 @@ static int last_outfitting_index;
if (dockedStation == nil)
{
//there are a number of possible current statuses, not just STATUS_DOCKED
OOLog(kOOLogInconsistentState, @"ERROR: status is %@, but dockedStation is nil; treating as not docked. This is an internal error, please report it.", EntityStatusToString(status));
status = STATUS_IN_FLIGHT;
OOLog(kOOLogInconsistentState, @"ERROR: status is %@, but dockedStation is nil; treating as not docked. This is an internal error, please report it.", EntityStatusToString([self status]));
[self setStatus:STATUS_IN_FLIGHT];
isDockedStatus = NO;
}
}
@ -6511,8 +6533,8 @@ static int last_outfitting_index;
{
if (dockedStation != nil)
{
OOLog(kOOLogInconsistentState, @"ERROR: status is %@, not STATUS_DOCKED, but dockedStation is not nil; treating as docked. This is an internal error, please report it.", EntityStatusToString(status));
status = STATUS_DOCKED;
OOLog(kOOLogInconsistentState, @"ERROR: status is %@, not STATUS_DOCKED, but dockedStation is not nil; treating as docked. This is an internal error, please report it.", EntityStatusToString([self status]));
[self setStatus:STATUS_DOCKED];
isDockedStatus = YES;
}
}

View File

@ -886,7 +886,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
}
if (status == STATUS_DOCKED)
if ([self status] == STATUS_DOCKED)
{
unsigned n_commodities = [shipCommodityData count];
current_cargo = 0; // for calculating remaining hold space
@ -902,7 +902,7 @@ static NSString * const kOOLogNoteShowShipyardModel = @"script.debug.note.showSh
[gui clear];
[gui setTitle:DESC(@"manifest-title")];
[gui setText:[NSString stringWithFormat:DESC(@"manifest-cargo-d-d"), (status == STATUS_DOCKED)? current_cargo : [cargo count], max_cargo] forRow:cargo_row - 1];
[gui setText:[NSString stringWithFormat:DESC(@"manifest-cargo-d-d"), ([self status] == STATUS_DOCKED)? current_cargo : [cargo count], max_cargo] forRow:cargo_row - 1];
[gui setText:DESC(@"manifest-none") forRow:cargo_row];
[gui setColor:[OOColor yellowColor] forRow:cargo_row - 1];
[gui setColor:[OOColor greenColor] forRow:cargo_row];
@ -1516,7 +1516,7 @@ static NSMutableDictionary* currentShipyard = nil;
NSDictionary* cmdr_dict = [self commanderDataDictionary]; // gather up all the info
if (![self setCommanderDataFromDictionary:cmdr_dict]) return NO;
status = STATUS_DOCKED;
[self setStatus:STATUS_DOCKED];
// adjust the clock forward by an hour
ship_clock_adjust += 3600.0;

View File

@ -253,7 +253,7 @@ static NSTimeInterval time_last_frame;
{
// poll the gameView keyboard things
[self pollApplicationControls]; // quit command-f etc.
switch (status)
switch ([self status])
{
case STATUS_WITCHSPACE_COUNTDOWN:
case STATUS_IN_FLIGHT:
@ -387,7 +387,7 @@ static NSTimeInterval time_last_frame;
#endif
// handle pressing Q or [esc] in error-handling mode
if (status == STATUS_HANDLING_ERROR)
if ([self status] == STATUS_HANDLING_ERROR)
{
if ([gameView isDown:113]||[gameView isDown:81]||[gameView isDown:27]) // 'q' | 'Q' | esc
{
@ -801,7 +801,7 @@ static NSTimeInterval time_last_frame;
ident_engaged = NO;
[self safeAllMissiles];
velocity = kZeroVector;
status = STATUS_AUTOPILOT_ENGAGED;
[self setStatus:STATUS_AUTOPILOT_ENGAGED];
[shipAI setState:@"GLOBAL"]; // reboot the AI
[self playAutopilotOn];
#ifdef DOCKING_CLEARANCE_ENABLED
@ -839,7 +839,7 @@ static NSTimeInterval time_last_frame;
ident_engaged = NO;
[self safeAllMissiles];
velocity = kZeroVector;
status = STATUS_AUTOPILOT_ENGAGED;
[self setStatus:STATUS_AUTOPILOT_ENGAGED];
[shipAI setState:@"GLOBAL"]; // restart the AI
[self playAutopilotOn];
#ifdef DOCKING_CLEARANCE_ENABLED
@ -880,7 +880,7 @@ static NSTimeInterval time_last_frame;
{
if (legalStatus > 50)
{
status = STATUS_AUTOPILOT_ENGAGED;
[self setStatus:STATUS_AUTOPILOT_ENGAGED];
[self interpretAIMessage:@"DOCKING_REFUSED"];
}
else
@ -974,12 +974,12 @@ static NSTimeInterval time_last_frame;
jumpOK = NO;
}
if (status == STATUS_WITCHSPACE_COUNTDOWN)
if ([self status] == STATUS_WITCHSPACE_COUNTDOWN)
{
// abort!
jumpOK = NO;
galactic_witchjump = NO;
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self playHyperspaceAborted];
// say it!
[UNIVERSE clearPreviousMessage];
@ -992,7 +992,7 @@ static NSTimeInterval time_last_frame;
{
galactic_witchjump = NO;
witchspaceCountdown = hyperspaceMotorSpinTime;
status = STATUS_WITCHSPACE_COUNTDOWN;
[self setStatus:STATUS_WITCHSPACE_COUNTDOWN];
[self playStandardHyperspace];
// say it!
[UNIVERSE clearPreviousMessage];
@ -1015,12 +1015,12 @@ static NSTimeInterval time_last_frame;
{
BOOL jumpOK = YES;
if (status == STATUS_WITCHSPACE_COUNTDOWN)
if ([self status] == STATUS_WITCHSPACE_COUNTDOWN)
{
// abort!
jumpOK = NO;
galactic_witchjump = NO;
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self playHyperspaceAborted];
// say it!
[UNIVERSE clearPreviousMessage];
@ -1033,7 +1033,7 @@ static NSTimeInterval time_last_frame;
{
galactic_witchjump = YES;
witchspaceCountdown = hyperspaceMotorSpinTime;
status = STATUS_WITCHSPACE_COUNTDOWN;
[self setStatus:STATUS_WITCHSPACE_COUNTDOWN];
[self playGalacticHyperspace];
// say it!
[UNIVERSE addMessage:[NSString stringWithFormat:ExpandDescriptionForCurrentSystem(@"[witch-galactic-in-f-seconds]"), witchspaceCountdown] forCount:1.0];
@ -1331,7 +1331,7 @@ static NSTimeInterval time_last_frame;
afterburner_engaged = NO;
}
if (status != STATUS_WITCHSPACE_COUNTDOWN)
if ([self status] != STATUS_WITCHSPACE_COUNTDOWN)
{
if ([gameView isDown:gvMouseLeftButton])
{
@ -1409,7 +1409,7 @@ static NSTimeInterval time_last_frame;
}
case GUI_SCREEN_SYSTEM_DATA:
if ((status == STATUS_DOCKED)&&([gameView isDown:key_contract_info])) // '?' toggle between maps/info and contract screen
if ([self status] == STATUS_DOCKED && [gameView isDown:key_contract_info]) // '?' toggle between maps/info and contract screen
{
if (!queryPressed)
{
@ -1572,7 +1572,7 @@ static NSTimeInterval time_last_frame;
}
leftRightKeyPressed = [gameView isDown:gvArrowKeyRight]|[gameView isDown:gvArrowKeyLeft];
if ([gameView isDown:13]||[gameView isDown:gvMouseDoubleClick]) // 'enter'
if ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick]) // 'enter'
{
if ([gameView isDown:gvMouseDoubleClick])
{
@ -1592,7 +1592,7 @@ static NSTimeInterval time_last_frame;
break;
case GUI_SCREEN_MARKET:
if (status == STATUS_DOCKED)
if ([self status] == STATUS_DOCKED)
{
[self handleGUIUpDownArrowKeys];
@ -1678,12 +1678,12 @@ static NSTimeInterval time_last_frame;
break;
case GUI_SCREEN_CONTRACTS:
if (status == STATUS_DOCKED)
if ([self status] == STATUS_DOCKED)
{
if ([self handleGUIUpDownArrowKeys])
[self setGuiToContractsScreen];
if ((status == STATUS_DOCKED)&&([gameView isDown:13]||[gameView isDown:gvMouseDoubleClick])) // 'enter' | doubleclick
if ([self status] == STATUS_DOCKED && ([gameView isDown:13] || [gameView isDown:gvMouseDoubleClick])) // 'enter' | doubleclick
{
if ([gameView isDown:gvMouseDoubleClick])
[gameView clearMouse];
@ -2453,7 +2453,7 @@ static NSTimeInterval time_last_frame;
GuiDisplayGen *gui = [UNIVERSE gui];
MyOpenGLView *gameView = [UNIVERSE gameView];
BOOL docked_okay = (status == STATUS_DOCKED);
BOOL docked_okay = ([self status] == STATUS_DOCKED);
// text displays
if (([gameView isDown:gvFunctionKey5])||([gameView isDown:gvNumberKey5]))
@ -2622,7 +2622,7 @@ static BOOL toggling_music;
frustration = 0.0;
autopilot_engaged = NO;
primaryTarget = NO_TARGET;
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self playAutopilotOff];
[UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[autopilot-off]") forCount:4.5];
#ifdef DOCKING_CLEARANCE_ENABLED

View File

@ -304,7 +304,8 @@ static BOOL TestScriptConditions(NSArray *conditions)
OOINLINE OOEntityStatus RecursiveRemapStatus(OOEntityStatus status)
{
// Some player stutuses should only be seen once per "event". This remaps them to something innocuous in case of recursion.
// Some player stutuses should only be seen once per "event".
// This remaps them to something innocuous in case of recursion.
if (status == STATUS_DOCKING ||
status == STATUS_LAUNCHING ||
status == STATUS_ENTERING_WITCHSPACE ||
@ -325,7 +326,7 @@ static BOOL sRunningScript = NO;
- (void) checkScript
{
BOOL wasRunningScript = sRunningScript;
OOEntityStatus restoreStatus;
OOEntityStatus status, restoreStatus;
[self setScriptTarget:self];
@ -348,13 +349,19 @@ static BOOL sRunningScript = NO;
In summary, scriptActionOnTarget: is bad, and calling it from scripts
rather than AIs is very bad.
-- Ahruman, 20080302
Addendum: scriptActionOnTarget: is currently not in the whitelist for
script methods. Let's hope this doesn't turn out to be a problem.
-- Ahruman, 20090208
*/
status = [self status];
restoreStatus = status;
NS_DURING
if (sRunningScript)
{
status = RecursiveRemapStatus(status);
if (status != restoreStatus)
[self setStatus:status];
if (RecursiveRemapStatus(status) != restoreStatus)
{
OOLog(@"script.trace.runWorld.recurse.lying", @"----- Running world script recursively and temporarily changing player status from %@ to %@.", EntityStatusToString(restoreStatus), EntityStatusToString(status));
}
@ -373,20 +380,14 @@ static BOOL sRunningScript = NO;
// Restore anti-recursion measures.
sRunningScript = wasRunningScript;
status = restoreStatus;
if (status != restoreStatus) [self setStatus:restoreStatus];
OOLogPopIndent();
}
- (void)runScriptActions:(NSArray *)actions withContextName:(NSString *)contextName forTarget:(ShipEntity *)target
{/*
[self setScriptTarget:target];
sCurrentMissionKey = scriptName;
[self scriptActions:scriptActions forTarget:target missionKey:scriptName];
sCurrentMissionKey = nil;
*/
{
NSAutoreleasePool *pool = nil;
NSString *oldMissionKey = nil;
NSString * volatile theMissionKey = contextName; // Work-around for silly exception macros
@ -872,7 +873,7 @@ static BOOL sRunningScript = NO;
- (NSString *) status_string
{
return EntityStatusToString(status);
return EntityStatusToString([self status]);
}
@ -1055,7 +1056,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
- (NSString *) dockedStationName_string // returns 'NONE' if the player isn't docked, [station name] if it is, 'UNKNOWN' otherwise (?)
{
NSString *result = nil;
if (status != STATUS_DOCKED) return @"NONE";
if ([self status] != STATUS_DOCKED) return @"NONE";
result = [self dockedStationName];
if (result == nil) result = @"UNKNOWN";
@ -1375,7 +1376,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
if (scriptTarget != self) return;
if (status != STATUS_DOCKED && !forceRemoval)
if ([self status] != STATUS_DOCKED && !forceRemoval)
{
OOLog(kOOLogRemoveAllCargoNotDocked, @"SCRIPT ERROR in %@ ***** Error: removeAllCargo only works when docked.", CurrentScriptDesc());
return;
@ -1402,7 +1403,7 @@ static int scriptRandomSeed = -1; // ensure proper random function
}
}
if(forceRemoval && status != STATUS_DOCKED)
if(forceRemoval && [self status] != STATUS_DOCKED)
{
int i;
for (i = [cargo count]-1; i >=0; i--)

View File

@ -460,7 +460,7 @@
[UNIVERSE setUpSpace];
[UNIVERSE setAutoSaveNow:NO];
status = STATUS_DOCKED;
[self setStatus:STATUS_DOCKED];
[UNIVERSE setViewDirection:VIEW_GUI_DISPLAY];
dockedStation = [UNIVERSE station];

View File

@ -88,7 +88,7 @@ MA 02110-1301, USA.
- (BOOL) dockedAtMainStation
{
return status == STATUS_DOCKED && dockedStation == [UNIVERSE station];
return [self status] == STATUS_DOCKED && dockedStation == [UNIVERSE station];
}
@ -117,7 +117,7 @@ MA 02110-1301, USA.
unit = [commodityArray intAtIndex:MARKET_UNITS];
if (status != STATUS_DOCKED)
if ([self status] != STATUS_DOCKED)
{
// in-flight
while (amount)

View File

@ -79,7 +79,7 @@ Ringdata ringentity;
}
lifetime = 50.0;
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
velocity.x = 0.0;
velocity.y = 0.0;

View File

@ -120,7 +120,7 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
isShip = YES;
entity_personality = ranrot_rand() & 0x7FFF;
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
zero_distance = SCANNER_MAX_RANGE2 * 2.0;
weapon_recharge_rate = 6.0;
@ -745,7 +745,7 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
if (universalID != NO_TARGET)
{
// set up escorts
if (status == STATUS_IN_FLIGHT && _pendingEscortCount != 0) // just popped into existence
if ([self status] == STATUS_IN_FLIGHT && _pendingEscortCount != 0) // just popped into existence
{
[self setUpEscorts];
}
@ -987,7 +987,7 @@ static NSString * const kOOLogEntityBehaviourChanged = @"entity.behaviour.change
BOOL ship_canCollide (ShipEntity* ship)
{
int s_status = ship->status;
int s_status = [ship status];
int s_scan_class = ship->scanClass;
if ((s_status == STATUS_COCKPIT_DISPLAY)||(s_status == STATUS_DEAD)||(s_status == STATUS_BEING_SCOOPED))
return NO;
@ -1415,7 +1415,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
aegis_status = [self checkForAegis]; // is a station or something nearby??
//scripting
if (!haveExecutedSpawnAction && script != nil && status == STATUS_IN_FLIGHT)
if (!haveExecutedSpawnAction && script != nil && [self status] == STATUS_IN_FLIGHT)
{
[[PlayerEntity sharedPlayer] setScriptTarget:self];
[self doScriptEvent:@"shipSpawned"];
@ -1424,11 +1424,11 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
// behaviours according to status and behaviour
//
if (status == STATUS_LAUNCHING)
if ([self status] == STATUS_LAUNCHING)
{
if ([UNIVERSE getTime] > launch_time + LAUNCH_DELAY) // move for while before thinking
{
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[self doScriptEvent:@"shipLaunchedFromStation"];
[shipAI reactToMessage: @"LAUNCHED OKAY"];
}
@ -1460,19 +1460,19 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
//
// double check scooped behaviour
//
if (status == STATUS_BEING_SCOOPED)
if ([self status] == STATUS_BEING_SCOOPED)
{
//if we are being tractored, but we have no owner, then we have a problem
if (behaviour != BEHAVIOUR_TRACTORED || [self owner] == nil || [self owner] == self || [self owner] == NO_TARGET)
{
// escaped tractor beam
status = STATUS_IN_FLIGHT; // should correct 'uncollidable objects' bug
[self setStatus:STATUS_IN_FLIGHT]; // should correct 'uncollidable objects' bug
behaviour = BEHAVIOUR_IDLE;
frustration = 0.0;
}
}
if (status == STATUS_COCKPIT_DISPLAY)
if ([self status] == STATUS_COCKPIT_DISPLAY)
{
[self applyRoll: delta_t * flightRoll andClimb: delta_t * flightPitch];
GLfloat range2 = 0.1 * distance2(position, destination) / (collision_radius * collision_radius);
@ -2072,7 +2072,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
if (distance < desired_range)
{
behaviour = BEHAVIOUR_TUMBLE;
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
[hauler scoopUp:self];
return;
}
@ -2101,7 +2101,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
velocity.z += moment * dp.z;
}
//
if (status == STATUS_BEING_SCOOPED)
if ([self status] == STATUS_BEING_SCOOPED)
{
BOOL lost_contact = (distance > hauler->collision_radius + collision_radius + 250.0f); // 250m range for tractor beam
if ([hauler isPlayer])
@ -2118,7 +2118,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
if (lost_contact) // 250m range for tractor beam
{
// escaped tractor beam
status = STATUS_IN_FLIGHT;
[self setStatus:STATUS_IN_FLIGHT];
behaviour = BEHAVIOUR_IDLE;
frustration = 0.0;
[shipAI exitStateMachine]; // exit nullAI.plist
@ -2951,7 +2951,7 @@ ShipEntity* doOctreesCollide(ShipEntity* prime, ShipEntity* other)
}
}
if (status == STATUS_ACTIVE)
if ([self status] == STATUS_ACTIVE)
{
Vector abspos = position; // STATUS_ACTIVE means it is in control of it's own orientation
Entity *last = nil;
@ -3849,9 +3849,11 @@ NSComparisonResult planetSort(id i1, id i2, void* context)
- (void) setStatus:(OOEntityStatus) stat
{
status = stat;
if ((status == STATUS_LAUNCHING)&&(UNIVERSE))
[super setStatus:stat];
if (stat == STATUS_LAUNCHING)
{
launch_time = [UNIVERSE getTime];
}
}
@ -4352,12 +4354,12 @@ NSComparisonResult planetSort(id i1, id i2, void* context)
int speed_low = 200;
int n_alloys = floor(sqrtf(sqrtf(mass / 25000.0)));
if (status == STATUS_DEAD)
if ([self status] == STATUS_DEAD)
{
[UNIVERSE removeEntity:self];
return;
}
status = STATUS_DEAD;
[self setStatus:STATUS_DEAD];
if ([self isThargoid]) [self broadcastThargoidDestroyed];
@ -4836,8 +4838,8 @@ Vector positionOffsetForShipInRotationToAlignment(ShipEntity* ship, Quaternion q
OOCargoQuantity n_cargo = (ranrot_rand() % (likely_cargo + 1));
OOCargoQuantity cargo_to_go;
if (status == STATUS_DEAD) return;
status = STATUS_DEAD;
if ([self status] == STATUS_DEAD) return;
[self setStatus:STATUS_DEAD];
//scripting
if (script != nil)
@ -5229,7 +5231,7 @@ BOOL class_masslocks(int some_class)
quaternion_rotate_about_axis(&orientation, axis_to_track_by, thrust * delta_t);
[self orientationChanged];
status = STATUS_ACTIVE;
[self setStatus:STATUS_ACTIVE];
return aim_cos;
}
@ -5325,7 +5327,7 @@ BOOL class_masslocks(int some_class)
quaternion_rotate_about_axis(&orientation, axis_to_track_by, thrust * delta_t);
[self orientationChanged];
status = STATUS_ACTIVE;
[self setStatus:STATUS_ACTIVE];
return aim_cos;
}
@ -5794,12 +5796,14 @@ BOOL class_masslocks(int some_class)
Vector rel_pos, urp;
int weapon_type = (fwd_weapon)? forward_weapon_type : aft_weapon_type;
if (weapon_type == WEAPON_THARGOID_LASER)
{
return (randf() < 0.05); // one in twenty shots on target
}
Entity *target = [self primaryTarget];
if (target == nil) // leave now!
return NO;
if (target->status == STATUS_DEAD)
return NO;
if (target == nil) return NO;
if ([target status] == STATUS_DEAD) return NO;
if (isSunlit && (target->isSunlit == NO) && (randf() < 0.75))
return NO; // 3/4 of the time you can't see from a lit place into a darker place
radius = target->collision_radius;
@ -6910,7 +6914,7 @@ BOOL class_masslocks(int some_class)
desired_speed = 0.0;
[self setAITo:@"nullAI.plist"]; // prevent AI from changing status or behaviour
behaviour = BEHAVIOUR_TRACTORED;
status = STATUS_BEING_SCOOPED;
[self setStatus:STATUS_BEING_SCOOPED];
[self addTarget:other];
[self setOwner:other];
}
@ -7046,7 +7050,7 @@ BOOL class_masslocks(int some_class)
- (void) takeEnergyDamage:(double)amount from:(Entity *)ent becauseOf:(Entity *)other
{
if (status == STATUS_DEAD) return;
if ([self status] == STATUS_DEAD) return;
if (amount <= 0.0) return;
// If it's an energy mine...
@ -7222,11 +7226,11 @@ BOOL class_masslocks(int some_class)
- (void) takeScrapeDamage:(double) amount from:(Entity *) ent
{
if (status == STATUS_DEAD) return;
if ([self status] == STATUS_DEAD) return;
if (status == STATUS_LAUNCHING) // no collisions during launches please
if ([self status] == STATUS_LAUNCHING) // no collisions during launches please
return;
if (ent && ent->status == STATUS_LAUNCHING) // no collisions during launches please
if ([ent status] == STATUS_LAUNCHING) // no collisions during launches please
return;
energy -= amount;
@ -7253,7 +7257,7 @@ BOOL class_masslocks(int some_class)
- (void) takeHeatDamage:(double) amount
{
if (status == STATUS_DEAD) // it's too late for this one!
if ([self status] == STATUS_DEAD) // it's too late for this one!
return;
if (amount < 0.0)
@ -7306,7 +7310,7 @@ BOOL class_masslocks(int some_class)
flightPitch = 0.0;
flightSpeed = maxFlightSpeed * 0.5;
status = STATUS_LAUNCHING;
[self setStatus:STATUS_LAUNCHING];
[self doScriptEvent:@"shipWillLaunchFromStation" withArgument:station];
[shipAI message:@"LAUNCHED"];
@ -7379,7 +7383,7 @@ int w_space_seed = 1234567;
flightRoll = 0.0;
flightPitch = 0.0;
flightSpeed = maxFlightSpeed * 0.25;
status = STATUS_LAUNCHING;
[self setStatus:STATUS_LAUNCHING];
[shipAI message:@"EXITED_WITCHSPACE"];
[UNIVERSE addEntity:self];

View File

@ -426,7 +426,7 @@ MA 02110-1301, USA.
for (i = 0; i < n_scanned_ships ; i++)
{
ship = scanned_ships[i];
if ([ship isPirateVictim] && (ship->status != STATUS_DEAD) && (ship->status != STATUS_DOCKED))
if ([ship isPirateVictim] && ([ship status] != STATUS_DEAD) && ([ship status] != STATUS_DOCKED))
{
d2 = distance2_scanned_ships[i];
if (PIRATES_PREFER_PLAYER && (d2 < desired_range * desired_range) && ship->isPlayer && [self isPirate])
@ -459,7 +459,7 @@ MA 02110-1301, USA.
for (i = 0; i < n_scanned_ships ; i++)
{
ShipEntity *ship = scanned_ships[i];
if ((ship->status != STATUS_DEAD) && (ship->status != STATUS_DOCKED) && [ship isPirateVictim])
if (([ship status] != STATUS_DEAD) && ([ship status] != STATUS_DOCKED) && [ship isPirateVictim])
ids_found[n_found++] = ship->universalID;
}
if (n_found == 0)
@ -896,7 +896,7 @@ MA 02110-1301, USA.
for (i = 0; i < n_scanned_ships ; i++)
{
ShipEntity *ship = scanned_ships[i];
if ((ship->scanClass != CLASS_CARGO)&&(ship->status != STATUS_DEAD)&&(ship->status != STATUS_DOCKED))
if ((ship->scanClass != CLASS_CARGO)&&([ship status] != STATUS_DEAD)&&([ship status] != STATUS_DOCKED))
{
GLfloat d2 = distance2_scanned_ships[i];
float legal_factor = [ship legalStatus] * gov_factor;
@ -1102,10 +1102,10 @@ static WormholeEntity *whole = nil;
{
ShipEntity *thing = scanned_ships[i];
GLfloat d2 = distance2_scanned_ships[i];
if ((thing->scanClass != CLASS_CARGO) && (thing->status != STATUS_DOCKED) && ![thing isThargoid] && (d2 < found_d2))
if (([thing scanClass] != CLASS_CARGO) && ([thing status] != STATUS_DOCKED) && ![thing isThargoid] && (d2 < found_d2))
{
found_target = [thing universalID];
if (thing->isPlayer) d2 = 0.0; // prefer the player
if ([thing isPlayer]) d2 = 0.0; // prefer the player
found_d2 = d2;
}
}
@ -1470,7 +1470,7 @@ static WormholeEntity *whole = nil;
- (void) sendTargetCommsMessage:(NSString*) message
{
ShipEntity *ship = [self primaryTarget];
if ((ship == nil) || (ship->status == STATUS_DEAD) || (ship->status == STATUS_DOCKED))
if ((ship == nil) || ([ship status] == STATUS_DEAD) || ([ship status] == STATUS_DOCKED))
{
[self noteLostTarget];
return;
@ -1482,7 +1482,7 @@ static WormholeEntity *whole = nil;
- (void) markTargetForFines
{
ShipEntity *ship = [self primaryTarget];
if ((ship == nil) || (ship->status == STATUS_DEAD) || (ship->status == STATUS_DOCKED))
if ((ship == nil) || ([ship status] == STATUS_DEAD) || ([ship status] == STATUS_DOCKED))
{
[self noteLostTarget];
return;
@ -1496,7 +1496,7 @@ static WormholeEntity *whole = nil;
if ((isStation)||(scanClass == CLASS_POLICE))
{
ShipEntity *ship = [self primaryTarget];
if ((ship == nil) || (ship->status == STATUS_DEAD) || (ship->status == STATUS_DOCKED))
if ((ship == nil) || ([ship status] == STATUS_DEAD) || ([ship status] == STATUS_DOCKED))
{
[self noteLostTarget];
return;
@ -2165,7 +2165,7 @@ static WormholeEntity *whole = nil;
{
candidate = scanned_ships[i];
d2 = distance2_scanned_ships[i];
if ((d2 < found_d2) && (candidate->scanClass != CLASS_CARGO) && (candidate->status != STATUS_DOCKED) && predicate(candidate, parameter))
if ((d2 < found_d2) && (candidate->scanClass != CLASS_CARGO) && ([candidate status] != STATUS_DOCKED) && predicate(candidate, parameter))
{
found_target = candidate->universalID;
found_d2 = d2;

View File

@ -112,7 +112,7 @@ MA 02110-1301, USA.
[self setDrawable:skyDrawable];
[skyDrawable release];
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
isSky = YES;
return self;

View File

@ -249,7 +249,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
#ifdef DOCKING_CLEARANCE_ENABLED
PlayerEntity *player = [PlayerEntity sharedPlayer];
BOOL isDockingStation = (self == [player getTargetDockStation]);
if (isDockingStation && player && player->status == STATUS_IN_FLIGHT &&
if (isDockingStation && player && [player status] == STATUS_IN_FLIGHT &&
[player getDockingClearanceStatus] >= DOCKING_CLEARANCE_STATUS_REQUESTED)
{
[self sendExpandedMessage:DESC(@"docking-clearance-abort-cancelled") toShip:player];
@ -349,7 +349,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
PlayerEntity *player = [PlayerEntity sharedPlayer];
BOOL isDockingStation = self == [player getTargetDockStation];
if (isDockingStation && ![shipsOnApproach objectForKey:shipID] &&
player && player->status == STATUS_IN_FLIGHT &&
player && [player status] == STATUS_IN_FLIGHT &&
[player getDockingClearanceStatus] >= DOCKING_CLEARANCE_STATUS_REQUESTED)
{
return instructions(universalID, ship->position, 0, 100, @"TRY_AGAIN_LATER", nil, NO);
@ -897,7 +897,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
//
}
if (ship->status == STATUS_LAUNCHING)
if ([ship status] == STATUS_LAUNCHING)
return YES;
// if close enough (within 50%) correct and add damage
@ -966,7 +966,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
{
ShipEntity* ship = (ShipEntity*)my_entities[i];
double d2 = distance2(position, ship->position);
if ((ship != self)&&(d2 < 25000000)&&(ship->status != STATUS_DOCKED)) // within 5km
if ((ship != self)&&(d2 < 25000000)&&([ship status] != STATUS_DOCKED)) // within 5km
{
Vector ppos = [self getPortPosition];
d2 = distance2(ppos, ship->position);
@ -1020,7 +1020,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
{
ShipEntity* ship = (ShipEntity*)my_entities[i];
double d2 = distance2(position, ship->position);
if ((ship != self)&&(d2 < 25000000)&&(ship->status != STATUS_DOCKED)) // within 5km
if ((ship != self)&&(d2 < 25000000)&&([ship status] != STATUS_DOCKED)) // within 5km
{
Vector ppos = [self getPortPosition];
float time_out = -15.00; // 15 secs
@ -1081,7 +1081,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
#ifdef DOCKING_CLEARANCE_ENABLED
PlayerEntity *player = [PlayerEntity sharedPlayer];
BOOL isDockingStation = (self == [player getTargetDockStation]);
if (isDockingStation && player->status == STATUS_IN_FLIGHT &&
if (isDockingStation && [player status] == STATUS_IN_FLIGHT &&
[player getDockingClearanceStatus] >= DOCKING_CLEARANCE_STATUS_GRANTED)
{
if (last_launch_time-20 < unitime && [player getDockingClearanceStatus] != DOCKING_CLEARANCE_STATUS_TIMING_OUT)
@ -1097,7 +1097,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
}
// TODO: If player is waiting for docking clearance, send him an update
// every X seconds telling him where he's at in the queue.
if (isDockingStation && player->status == STATUS_IN_FLIGHT && [player getDockingClearanceStatus] == DOCKING_CLEARANCE_STATUS_REQUESTED &&
if (isDockingStation && [player status] == STATUS_IN_FLIGHT && [player getDockingClearanceStatus] == DOCKING_CLEARANCE_STATUS_REQUESTED &&
[shipsOnApproach count] == 0 && [launchQueue count] == 0)
{
last_launch_time = unitime + DOCKING_CLEARANCE_WINDOW;
@ -1826,7 +1826,7 @@ static NSDictionary* instructions(int station_id, Vector coords, float speed, fl
// launch docked ships if possible
PlayerEntity* player = [PlayerEntity sharedPlayer];
if ((player)&&(player->status == STATUS_DOCKED)&&([player dockedStation] == self))
if ((player)&&([player status] == STATUS_DOCKED)&&([player dockedStation] == self))
{
// undock the player!
[player leaveDock:self];

View File

@ -55,7 +55,7 @@ static void DrawWormholeCorona(GLfloat inner_radius, GLfloat outer_radius, int s
witch_mass = 0.0;
shipsInTransit = [[NSMutableArray arrayWithCapacity:4] retain];
collision_radius = 0.0;
status = STATUS_EFFECT;
[self setStatus:STATUS_EFFECT];
scanClass = CLASS_MINE;
position = [ship position];
zero_distance = distance2([[PlayerEntity sharedPlayer] position], position);

View File

@ -894,12 +894,12 @@ static BOOL hostiles;
glEnd();
glLineWidth(line_width); // thinner
PlanetEntity* the_sun = [UNIVERSE sun];
PlanetEntity* the_planet = [UNIVERSE planet];
StationEntity* the_station = [UNIVERSE station];
Entity* the_target = [player primaryTarget];
Entity* the_next_beacon = [UNIVERSE entityForUniversalID:[player nextBeaconID]];
int p_status = player->status;
PlanetEntity *the_sun = [UNIVERSE sun];
PlanetEntity *the_planet = [UNIVERSE planet];
StationEntity *the_station = [UNIVERSE station];
Entity *the_target = [player primaryTarget];
Entity *the_next_beacon = [UNIVERSE entityForUniversalID:[player nextBeaconID]];
OOEntityStatus p_status = [player status];
if (((p_status == STATUS_IN_FLIGHT)
||(p_status == STATUS_AUTOPILOT_ENGAGED)
||(p_status == STATUS_LAUNCHING)
@ -1432,7 +1432,7 @@ static BOOL hostiles;
GLColorWithOverallAlpha(red_color, overallAlpha);
if ((flash)&&(temp > .90))
GLColorWithOverallAlpha(redplus_color, overallAlpha);
[player setAlertFlag:ALERT_FLAG_TEMP to:((temp > .90)&&(player->status == STATUS_IN_FLIGHT))];
[player setAlertFlag:ALERT_FLAG_TEMP to:((temp > .90)&&([player status] == STATUS_IN_FLIGHT))];
hudDrawBarAt(x, y, z1, siz, temp);
}
@ -1484,7 +1484,7 @@ static BOOL hostiles;
hudDrawBarAt(x, y, z1, siz, alt);
[player setAlertFlag:ALERT_FLAG_ALT to:((alt < .10)&&(player->status == STATUS_IN_FLIGHT))];
[player setAlertFlag:ALERT_FLAG_ALT to:((alt < .10)&&([player status] == STATUS_IN_FLIGHT))];
}

View File

@ -608,7 +608,7 @@ static OOComparisonResult comparePrice(id dict1, id dict2, void * context);
{
// deal with the machine going to sleep
PlayerEntity *player = [PlayerEntity sharedPlayer];
if ((player)&&(player->status == STATUS_IN_FLIGHT))
if ((player)&&([player status] == STATUS_IN_FLIGHT))
{
[self displayMessage:@" Paused (press 'p') " forCount:1.0];
[[gameView gameController] pause_game];
@ -2817,7 +2817,7 @@ static BOOL IsCandidateMainStationPredicate(Entity *entity, void *parameter)
- (BOOL) breakPatternHide
{
Entity* player = [PlayerEntity sharedPlayer];
return ((breakPatternCounter > 5)||(!player)||(player->status == STATUS_DOCKING));
return ((breakPatternCounter > 5)||(!player)||([player status] == STATUS_DOCKING));
}
@ -3548,16 +3548,15 @@ static const OOMatrix starboard_matrix =
// DRAW ALL THE OPAQUE ENTITIES
for (i = furthest; i >= nearest; i--)
{
int d_status;
drawthing = my_entities[i];
d_status = drawthing->status;
OOEntityStatus d_status = [drawthing status];
if (bpHide && !drawthing->isImmuneToBreakPatternHide) continue;
GLfloat flat_ambdiff[4] = {1.0, 1.0, 1.0, 1.0}; // for alpha
GLfloat mat_no[4] = {0.0, 0.0, 0.0, 1.0}; // nothing
if (((d_status == STATUS_COCKPIT_DISPLAY)&&(inGUIMode)) || ((d_status != STATUS_COCKPIT_DISPLAY)&&(!inGUIMode)))
if ((d_status == STATUS_COCKPIT_DISPLAY && inGUIMode) || (d_status != STATUS_COCKPIT_DISPLAY && !inGUIMode))
{
// reset material properties
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, flat_ambdiff);
@ -3629,13 +3628,12 @@ static const OOMatrix starboard_matrix =
for (i = furthest; i >= nearest; i--)
{
int d_status;
drawthing = my_entities[i];
d_status = drawthing->status;
OOEntityStatus d_status = [drawthing status];
if (bpHide && !drawthing->isImmuneToBreakPatternHide) continue;
if (((d_status == STATUS_COCKPIT_DISPLAY)&&(inGUIMode)) || ((d_status != STATUS_COCKPIT_DISPLAY)&&(!inGUIMode)))
if ((d_status == STATUS_COCKPIT_DISPLAY && inGUIMode) || (d_status != STATUS_COCKPIT_DISPLAY && !inGUIMode))
{
// experimental - atmospheric fog
BOOL fogging = (airResistanceFactor > 0.01);
@ -3802,13 +3800,15 @@ static const OOMatrix starboard_matrix =
return nil;
Entity *ent = entity_for_uid[u_id];
if (ent->isParticle) // particles SHOULD NOT HAVE U_IDs!
if ([ent isParticle]) // particles SHOULD NOT HAVE U_IDs!
{
return nil;
int ent_status = ent->status;
if (ent_status == STATUS_DEAD)
return nil;
if (ent_status == STATUS_DOCKED)
}
if ([ent status] == STATUS_DEAD || [ent status] == STATUS_DOCKED)
{
return nil;
}
return ent;
}