Skip to content

Commit d2eff1f

Browse files
authored
Merge pull request #5073 from Goober5000/fixed_chain_repeat
restore retail behavior of chaining to repeating events
2 parents 9ce7748 + 0d56bb9 commit d2eff1f

File tree

4 files changed

+27
-2
lines changed

4 files changed

+27
-2
lines changed

code/mission/missiongoals.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -917,7 +917,15 @@ void mission_process_event( int event )
917917
}
918918
}
919919

920-
if (!Mission_events[event - 1].result || !timestamp_elapsed(timestamp_delta(Mission_events[event - 1].timestamp, offset))) {
920+
if (!Mission_events[event - 1].result) {
921+
sindex = -1; // bypass evaluation
922+
}
923+
// For compatibility reasons, simulate the old buggy behavior if we don't explicitly activate the bugfix.
924+
// That is, if the timestamp has been set with an interval, always evaluate the event.
925+
else if (!Fixed_chaining_to_repeat && Mission_events[event - 1].flags & MEF_TIMESTAMP_HAS_INTERVAL) {
926+
/* do not bypass */;
927+
}
928+
else if (!timestamp_elapsed(timestamp_delta(Mission_events[event - 1].timestamp, offset))) {
921929
sindex = -1; // bypass evaluation
922930
}
923931
}

code/mod_table/mod_table.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ bool Fixed_missile_detonation;
3232
bool Damage_impacted_subsystem_first;
3333
bool Cutscene_camera_displays_hud;
3434
bool Alternate_chaining_behavior;
35+
bool Fixed_chaining_to_repeat;
3536
bool Use_host_orientation_for_set_camera_facing;
3637
bool Use_3d_ship_select;
3738
bool Use_3d_ship_icons;
@@ -364,6 +365,16 @@ void parse_mod_table(const char *filename)
364365
}
365366
}
366367

368+
if (optional_string("$Fixed Chaining To Repeating Events:")) {
369+
stuff_boolean(&Fixed_chaining_to_repeat);
370+
if (Fixed_chaining_to_repeat) {
371+
mprintf(("Game Settings Table: Using fixed chaining to repeating events\n"));
372+
}
373+
else {
374+
mprintf(("Game Settings Table: Using retail chaining to repeating events\n"));
375+
}
376+
}
377+
367378
if (optional_string("$Use host orientation for set-camera-facing:")) {
368379
stuff_boolean(&Use_host_orientation_for_set_camera_facing);
369380
if (Use_host_orientation_for_set_camera_facing) {
@@ -1177,6 +1188,7 @@ void mod_table_reset()
11771188
Damage_impacted_subsystem_first = false;
11781189
Cutscene_camera_displays_hud = false;
11791190
Alternate_chaining_behavior = false;
1191+
Fixed_chaining_to_repeat = false;
11801192
Use_host_orientation_for_set_camera_facing = false;
11811193
Default_ship_select_effect = 2;
11821194
Default_weapon_select_effect = 2;
@@ -1284,5 +1296,6 @@ void mod_table_set_version_flags()
12841296
}
12851297
if (mod_supports_version(23, 0, 0)) {
12861298
Shockwaves_inherit_parent_damage_type = true; // people intuitively expect shockwaves to default to the damage type of the weapon that spawned them
1299+
Fixed_chaining_to_repeat = true;
12871300
}
12881301
}

code/mod_table/mod_table.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ extern bool Fixed_missile_detonation;
2727
extern bool Damage_impacted_subsystem_first;
2828
extern bool Cutscene_camera_displays_hud;
2929
extern bool Alternate_chaining_behavior;
30+
extern bool Fixed_chaining_to_repeat;
3031
extern bool Use_host_orientation_for_set_camera_facing;
3132
extern bool Use_3d_ship_select;
3233
extern int Default_ship_select_effect;

code/parse/sexp.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17126,7 +17126,10 @@ int sexp_event_delay_status( int n, int want_true, bool use_msecs = false)
1712617126
}
1712717127

1712817128
// check that the event delay has elapsed, again using the same logic as in mission_process_event()
17129-
if (!timestamp_elapsed(timestamp_delta(Mission_events[i].timestamp, delay))) {
17129+
if (!Fixed_chaining_to_repeat && Mission_events[i].flags & MEF_TIMESTAMP_HAS_INTERVAL) {
17130+
/* do not set rval */;
17131+
}
17132+
else if (!timestamp_elapsed(timestamp_delta(Mission_events[i].timestamp, delay))) {
1713017133
rval = SEXP_FALSE;
1713117134
break;
1713217135
}

0 commit comments

Comments
 (0)