Skip to content

Commit 66a07fe

Browse files
committed
fix two timestamp bugs
A timestamp set to 1 means an immediate timestamp, and so the `int` version of `timestamp_elapsed` should account for that, just as it does in the `TIMESTAMP` and `UI_TIMESTAMP` versions. Normally the number comparison means the check will still work, but during mission initialization the timestamp code is not running. This caused destroy-before-mission ships to be added to the arrival list when they shouldn't have been. Also fix logic in `timestamp_elapsed_safe`, where the `TIMESTAMP` and `UI_TIMESTAMP` versions were correct, but the `int` version had a bug dating back to retail that caused it to return true for uninitialized (zero) timestamps rather than false. Practically speaking, this fix has no effect because the function is only used in multiplayer and none of the instances use integer-0 to indicate uninitialized, but this will at least fix any uses in the future.
1 parent 306f34a commit 66a07fe

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

code/io/timer.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,9 @@ bool timestamp_elapsed(int stamp) {
489489
if (stamp == 0) {
490490
return false;
491491
}
492+
if (stamp == 1) {
493+
return true;
494+
}
492495

493496
return timestamp_ms() >= stamp;
494497
}
@@ -539,6 +542,9 @@ bool ui_timestamp_elapsed_last_frame(UI_TIMESTAMP ui_stamp) {
539542

540543
bool timestamp_elapsed_safe(int a, int b) {
541544
if (a == 0) {
545+
return false;
546+
}
547+
if (a == 1) {
542548
return true;
543549
}
544550

0 commit comments

Comments
 (0)