From bde0379e8512bed1f6611f49927a05e63fcf4ede Mon Sep 17 00:00:00 2001 From: Marc Date: Mon, 12 May 2008 05:06:09 +0000 Subject: [PATCH] Bugfix for bug #13041:resolved odd behaviour with 'U': 1) if scanner enhancement is present, the hud will confirm both missiles on safety & ident system deactivation. 2) Scrolling through targets from inactive ident system doesn't change missiles status anymore. Added Ship.commsMessage('msg') to replace Ship.call('commsMessage:','msg') - no apparent conflict with Player.commsMessage(); git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@1630 127b21dd-08f5-0310-b4b7-95ae10353056 --- src/Core/Entities/PlayerEntity.m | 1 + src/Core/Entities/PlayerEntityControls.m | 20 ++++++++++---------- src/Core/Scripting/OOJSShip.m | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 10 deletions(-) diff --git a/src/Core/Entities/PlayerEntity.m b/src/Core/Entities/PlayerEntity.m index 59770fe6..7e281953 100644 --- a/src/Core/Entities/PlayerEntity.m +++ b/src/Core/Entities/PlayerEntity.m @@ -6161,6 +6161,7 @@ OOSound* burnersound; if (potential_target->zero_distance < SCANNER_MAX_RANGE2) { [super addTarget:potential_target]; + if (missile_status == MISSILE_STATUS_SAFE) ident_engaged = YES; missile_status = MISSILE_STATUS_TARGET_LOCKED; [self printIdentLockedOnForMissile:!ident_engaged]; [self playTargetSwitched]; diff --git a/src/Core/Entities/PlayerEntityControls.m b/src/Core/Entities/PlayerEntityControls.m index 4c5abf55..c633b329 100644 --- a/src/Core/Entities/PlayerEntityControls.m +++ b/src/Core/Entities/PlayerEntityControls.m @@ -659,7 +659,7 @@ static NSTimeInterval time_last_frame; primaryTarget = NO_TARGET; ident_engaged = YES; [self playIdentOn]; - [UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[ident-on]") forCount:2.0]; + [UNIVERSE addMessage:DESC(@"ident-on") forCount:2.0]; } ident_pressed = YES; } @@ -690,13 +690,13 @@ static NSTimeInterval time_last_frame; { if (missile_entity[activeMissile]) [missile_entity[activeMissile] removeTarget:nil]; - [UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[missile-armed]") forCount:2.0]; + [UNIVERSE addMessage:DESC(@"missile-armed") forCount:2.0]; [self playMissileArmed]; } } if ([missile_entity[activeMissile] isMine]) { - [UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[mine-armed]") forCount:4.5]; + [UNIVERSE addMessage:DESC(@"mine-armed") forCount:4.5]; [self playMineArmed]; } ident_engaged = NO; @@ -711,22 +711,22 @@ static NSTimeInterval time_last_frame; { if (!safety_pressed) { + //targetting off in both cases! if (!ident_engaged) { - // targetting 'off' here - missile_status = MISSILE_STATUS_SAFE; + if (missile_status !=MISSILE_STATUS_SAFE) + [UNIVERSE addMessage:[NSString stringWithFormat:@"%@ %@", DESC(@"missile-safe"), (primaryTarget != NO_TARGET && [self hasEquipmentItem:@"EQ_SCANNER_SHOW_MISSILE_TARGET"])? DESC(@"ident-off") : @""] forCount:2.5]; primaryTarget = NO_TARGET; [self safeAllMissiles]; [self playMissileSafe]; - [UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[missile-safe]") forCount:2.0]; + } else { - // targetting 'back on' here - primaryTarget = [missile_entity[activeMissile] primaryTargetID]; - missile_status = (primaryTarget != NO_TARGET)? MISSILE_STATUS_TARGET_LOCKED : MISSILE_STATUS_SAFE; + primaryTarget = NO_TARGET; + [self safeAllMissiles]; [self playIdentOff]; - [UNIVERSE addMessage:ExpandDescriptionForCurrentSystem(@"[ident-off]") forCount:2.0]; + [UNIVERSE addMessage:DESC(@"ident-off") forCount:2.0]; } ident_engaged = NO; } diff --git a/src/Core/Scripting/OOJSShip.m b/src/Core/Scripting/OOJSShip.m index ee8ad492..2fee0d95 100644 --- a/src/Core/Scripting/OOJSShip.m +++ b/src/Core/Scripting/OOJSShip.m @@ -56,6 +56,7 @@ static JSBool ShipDumpCargo(JSContext *context, JSObject *this, uintN argc, jsva static JSBool ShipSpawn(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult); static JSBool ShipExplode(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult); static JSBool ShipRunLegacyScriptActions(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult); +static JSBool ShipCommsMessage(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult); static JSExtendedClass sShipClass = @@ -191,6 +192,7 @@ static JSFunctionSpec sShipMethods[] = { "runLegacyScriptActions", ShipRunLegacyScriptActions, 2 }, { "spawn", ShipSpawn, 1 }, { "explode", ShipExplode, 0 }, + { "commsMessage", ShipCommsMessage, 1 }, { 0 } }; @@ -866,3 +868,22 @@ static JSBool ShipRunLegacyScriptActions(JSContext *context, JSObject *this, uin return YES; } + +static JSBool ShipCommsMessage(JSContext *context, JSObject *this, uintN argc, jsval *argv, jsval *outResult) +{ + ShipEntity *thisEnt = nil; + NSString *msg = nil; + + if (!JSShipGetShipEntity(context, this, &thisEnt)) return YES; // stale reference, no-op. + msg = [NSString stringWithJavaScriptValue:*argv inContext:context]; + + if (msg != nil) + { + if (!thisEnt->isPlayer) + { + [thisEnt commsMessage:msg withUnpilotedOverride:YES]; + } + //else: player.commsMessage handles this already. + } + return YES; +}