mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 18:31:26 -10:00
fix an edge case in is-event-true-delay and related sexps
Originally the check for event delay was this:
```
if ( (fix) Mission_events[i].timestamp + delay >= Missiontime )
return SEXP_FALSE;
```
This returns false even when the mission time is equal to the timestamp. Therefore the timestamp check needs to use >, not >=.
Thanks to Durandal and ShivanSpS for helping to track this down.
This commit is contained in:
1 parent
32cfb59a9e
commit
eed50619ca
3 files changed
+25
-1
No files matched your search
@@ -482,6 +482,28 @@ bool ui_timestamp_elapsed(UI_TIMESTAMP ui_stamp) {
|
||||
return timer_get_milliseconds() >= ui_stamp.value();
|
||||
}
|
||||
|
||||
bool timestamp_elapsed_last_frame(TIMESTAMP stamp) {
|
||||
if (!stamp.isValid() || stamp.isNever()) {
|
||||
return false;
|
||||
}
|
||||
if (stamp.isImmediate()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return timestamp_ms() > stamp.value();
|
||||
}
|
||||
|
||||
bool ui_timestamp_elapsed_last_frame(UI_TIMESTAMP ui_stamp) {
|
||||
if (!ui_stamp.isValid() || ui_stamp.isNever()) {
|
||||
return false;
|
||||
}
|
||||
if (ui_stamp.isImmediate()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return timer_get_milliseconds() > ui_stamp.value();
|
||||
}
|
||||
|
||||
bool timestamp_elapsed_safe(int a, int b) {
|
||||
if (a == 0) {
|
||||
return true;
|
||||
|
||||
@@ -203,7 +203,9 @@ bool ui_timestamp_in_between(UI_TIMESTAMP stamp, UI_TIMESTAMP before, UI_TIMESTA
|
||||
|
||||
bool timestamp_elapsed( int stamp );
|
||||
bool timestamp_elapsed( TIMESTAMP stamp );
|
||||
bool timestamp_elapsed_last_frame( TIMESTAMP stamp );
|
||||
bool ui_timestamp_elapsed( UI_TIMESTAMP stamp );
|
||||
bool ui_timestamp_elapsed_last_frame( UI_TIMESTAMP stamp );
|
||||
|
||||
// safer version of timestamp
|
||||
bool timestamp_elapsed_safe(int a, int b);
|
||||
|
||||
+1
-1
@@ -17471,7 +17471,7 @@ int sexp_event_delay_status( int n, int want_true, bool use_msecs = false)
|
||||
if (!Fixed_chaining_to_repeat && Mission_events[i].flags & MEF_TIMESTAMP_HAS_INTERVAL) {
|
||||
/* do not set rval */;
|
||||
}
|
||||
else if (!timestamp_elapsed(timestamp_delta(Mission_events[i].timestamp, delay))) {
|
||||
else if (!timestamp_elapsed_last_frame(timestamp_delta(Mission_events[i].timestamp, delay))) {
|
||||
rval = SEXP_FALSE;
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user