Skip to content

Commit 7547127

Browse files
committed
Adds "don't autorepair if disabled" to blacklist a specific subsystem.
Obviously won't do anything if "repair disabled subsystems" ship flag isn't set. If both subsystem-specific flags get set at the same time, whichever one would be default behavior (based on the presence or absence of the ship-wide flag) gets removed and a Warning generated.
1 parent 89d6031 commit 7547127

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

code/model/model.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ typedef struct polymodel_instance {
141141
#define MSS_FLAG2_DESTROYED_ROTATION (1 << 4) // allows subobjects to continue to rotate even if they have been destroyed
142142
#define MSS_FLAG2_TURRET_USE_AMMO (1 << 5) // enables ammo consumption for turrets (DahBlount)
143143
#define MSS_FLAG2_AUTOREPAIR_IF_DISABLED (1 << 6) // Allows the subsystem to repair itself even if disabled (MageKing17)
144+
#define MSS_FLAG2_NO_AUTOREPAIR_IF_DISABLED (1 << 7) // Inversion of the previous; disallows this particular subsystem if the ship-wide flag is set (MageKing17)
144145

145146
#define NUM_SUBSYSTEM_FLAGS 33
146147

code/ship/ship.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,7 @@ flag_def_list Subsystem_flags[] = {
258258
{ "allow destroyed rotation", MSS_FLAG2_DESTROYED_ROTATION, 1},
259259
{ "turret use ammo", MSS_FLAG2_TURRET_USE_AMMO, 1},
260260
{ "autorepair if disabled", MSS_FLAG2_AUTOREPAIR_IF_DISABLED, 1},
261+
{ "don't autorepair if disabled", MSS_FLAG2_NO_AUTOREPAIR_IF_DISABLED, 1},
261262
};
262263

263264
const int Num_subsystem_flags = sizeof(Subsystem_flags)/sizeof(flag_def_list);
@@ -4336,6 +4337,15 @@ int parse_ship_values(ship_info* sip, const bool is_template, const bool first_t
43364337
sp->flags |= MSS_FLAG_USE_MULTIPLE_GUNS;
43374338
}
43384339

4340+
if ((sp->flags2 & MSS_FLAG2_AUTOREPAIR_IF_DISABLED) && (sp->flags2 & MSS_FLAG2_NO_AUTOREPAIR_IF_DISABLED)) {
4341+
Warning(LOCATION, "\"autorepair if disabled\" flag used with \"don't autorepair if disabled\" flag on a subsystem on %s '%s'.\nWhichever flag would be default behavior anyway for this ship has been removed.\n", info_type_name, sip->name);
4342+
if (sip->flags2 & SIF2_SUBSYS_REPAIR_WHEN_DISABLED){
4343+
sp->flags2 &= ~MSS_FLAG2_AUTOREPAIR_IF_DISABLED;
4344+
} else {
4345+
sp->flags2 &= ~MSS_FLAG2_NO_AUTOREPAIR_IF_DISABLED;
4346+
}
4347+
}
4348+
43394349
if (old_flags) {
43404350
mprintf(("Use of deprecated subsystem syntax. Please use the $Flags: field for subsystem flags.\n\n" \
43414351
"At least one of the following tags was used on %s '%s', subsystem %s:\n" \
@@ -6311,6 +6321,8 @@ int subsys_set(int objnum, int ignore_subsys_info)
63116321
ship_system->flags |= SSF_NO_DISAPPEAR;
63126322
if (model_system->flags2 & MSS_FLAG2_AUTOREPAIR_IF_DISABLED)
63136323
ship_system->flags |= SSF_AUTOREPAIR_IF_DISABLED;
6324+
if (model_system->flags2 & MSS_FLAG2_NO_AUTOREPAIR_IF_DISABLED)
6325+
ship_system->flags |= SSF_NO_AUTOREPAIR_IF_DISABLED;
63146326

63156327
ship_system->turn_rate = model_system->turn_rate;
63166328

@@ -8778,7 +8790,7 @@ void ship_auto_repair_frame(int shipnum, float frametime)
87788790
if ( ssp->current_hits < ssp->max_hits ) {
87798791

87808792
// only repair those subsystems which are not destroyed
8781-
if ( (ssp->max_hits <= 0) || ((ssp->current_hits <= 0) && !((sip->flags2 & SIF2_SUBSYS_REPAIR_WHEN_DISABLED) || (ssp->flags & SSF_AUTOREPAIR_IF_DISABLED))) )
8793+
if ( (ssp->max_hits <= 0) || ((ssp->current_hits <= 0) && !(((sip->flags2 & SIF2_SUBSYS_REPAIR_WHEN_DISABLED) && !(ssp->flags & SSF_NO_AUTOREPAIR_IF_DISABLED)) || (ssp->flags & SSF_AUTOREPAIR_IF_DISABLED))) )
87828794
continue;
87838795

87848796
// do incremental repair on the subsystem

code/ship/ship.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ typedef struct cockpit_display_info {
295295
#define SSF_PLAY_SOUND_FOR_PLAYER ( 1 << 13) // If this subsystem is a turret on a player ship, play firing sounds - The E
296296
#define SSF_NO_DISAPPEAR ( 1 << 14) // prevents submodel from disappearing when subsys destroyed
297297
#define SSF_AUTOREPAIR_IF_DISABLED (1 << 15) // Allows the subsystem to repair itself even when disabled - MageKing17
298+
#define SSF_NO_AUTOREPAIR_IF_DISABLED (1 << 16) // Inversion of the above; allow a specific subsystem not to repair itself after being disabled if the ship has the "repair disabled subsystems" flag - MageKing17
298299

299300

300301
// Wanderer

0 commit comments

Comments
 (0)