Skip to content

Commit 8077da4

Browse files
committed
enhance and clean up scannable ship types
The `$Scannable` field in objecttypes.tbl controls whether a ship can be targeted by the "target unscanned ship" key. This is independent of which ship types can actually be *scanned*, which is not connected to any field in objecttypes.tbl. So, this PR renames the `$Scannable` field to `$Targetable as unscanned:`, to be clearer about what it actually does; and adds the missing counterpart `$Scannable by default:` flag to specify which ship types can actually be scanned. Note that this is only relevant for legacy scanning behavior. Mods which use `$Unify scanning behavior:` do not need either of the ship type flags.
1 parent 88c3cea commit 8077da4

File tree

5 files changed

+15
-10
lines changed

5 files changed

+15
-10
lines changed

code/def_files/data/tables/objecttypes.tbl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@ $AI:
5353
+Ignored on cripple by: ( "navbuoy" "sentry gun" "escape pod" "cargo" "support" "fighter" "bomber" "transport" "freighter" "awacs" "gas miner" "cruiser" "corvette" "capital" "super cap" "drydock" "knossos device" )
5454
$Skip Death Roll Percent Chance: 0.0
5555

56-
$Name: Cargo
57-
$Scannable: YES
56+
$Name: Cargo
57+
$Targetable as unscanned: YES
58+
$Scannable by default: YES
5859
$Max Debris Speed: 200
5960
$FF Multiplier: 0.10
6061
$EMP Multiplier: 10.0
@@ -156,7 +157,8 @@ $Praise Destruction: YES
156157
$On Hotkey List: YES
157158
$Target as Threat: YES
158159
$Show Attack Direction: YES
159-
$Scannable: YES
160+
$Targetable as unscanned: YES
161+
$Scannable by default: YES
160162
$Max Debris Speed: 150
161163
$FF Multiplier: 1.0
162164
$EMP Multiplier: 2.0

code/hud/hudtarget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1608,7 +1608,7 @@ int hud_target_ship_can_be_scanned(ship *shipp)
16081608
return 1;
16091609
} else if (Use_new_scanning_behavior) {
16101610
return 0;
1611-
} else if ((sip->class_type < 0) || !(Ship_types[sip->class_type].flags[Ship::Type_Info_Flags::Scannable])) {
1611+
} else if ((sip->class_type < 0) || !(Ship_types[sip->class_type].flags[Ship::Type_Info_Flags::Targetable_as_unscanned])) {
16121612
return 0;
16131613
}
16141614

code/playerman/playercontrol.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1690,7 +1690,7 @@ bool player_inspect_cargo(float frametime, char *outstr)
16901690
// scannable cargo behaves differently. Scannable cargo is either "scanned" or "not scanned". This flag
16911691
// can be set on any ship. Any ship with this set won't have "normal" cargo behavior
16921692
if (!(cargo_sp->flags[Ship::Ship_Flags::Scannable])) {
1693-
if (!(cargo_sip->flags[Ship::Info_Flags::Cargo] || cargo_sip->flags[Ship::Info_Flags::Transport])) {
1693+
if ((cargo_sip->class_type < 0) || !(Ship_types[cargo_sip->class_type].flags[Ship::Type_Info_Flags::Scannable_by_default])) {
16941694
return false;
16951695
}
16961696
}
@@ -1710,8 +1710,6 @@ bool player_inspect_cargo(float frametime, char *outstr)
17101710
auto cargo_name = (cargo_sp->cargo1 & CARGO_INDEX_MASK) == 0
17111711
? XSTR("Nothing", 1674)
17121712
: Cargo_names[cargo_sp->cargo1 & CARGO_INDEX_MASK];
1713-
//Why was this assert here? I'm not sure it makes much sense because any ship can be scanned and have cargo revealed...
1714-
//Assert(cargo_sip->flags[Ship::Info_Flags::Cargo] || cargo_sip->flags[Ship::Info_Flags::Transport]);
17151713

17161714
if (cargo_sp->cargo_title[0] != '\0') {
17171715
if (cargo_sp->cargo_title[0] == '#') {

code/ship/ship.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6145,8 +6145,12 @@ static void parse_ship_type(const char *filename, const bool replace)
61456145
stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Show_attack_direction);
61466146
}
61476147

6148-
if(optional_string("$Scannable:")) {
6149-
stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Scannable);
6148+
if(optional_string("$Scannable:") || optional_string("$Targetable as unscanned:")) {
6149+
stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Targetable_as_unscanned);
6150+
}
6151+
6152+
if(optional_string("$Scannable by default:")) {
6153+
stuff_boolean_flag(stp->flags, Ship::Type_Info_Flags::Scannable_by_default);
61506154
}
61516155

61526156
if(optional_string("$Warp Pushes:")) {

code/ship/ship_flags.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,8 @@ namespace Ship {
230230
Target_as_threat,
231231
Show_attack_direction,
232232
No_class_display,
233-
Scannable,
233+
Targetable_as_unscanned,
234+
Scannable_by_default,
234235
Warp_pushes,
235236
Warp_pushable,
236237
Turret_tgt_ship_tgt,

0 commit comments

Comments
 (0)