Skip to content

Commit 81eed68

Browse files
committed
lgtm
1 parent f9439e2 commit 81eed68

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

selfdrive/ui/replay/main.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ void keyboardThread(Replay *replay_) {
5959
qDebug() << "invalid argument";
6060
}
6161
getch(); // remove \n from entering seek
62+
} else if (c == 'e') {
63+
replay_->seekToFlag(FindFlag::nextEngagement);
64+
} else if (c == 'd') {
65+
replay_->seekToFlag(FindFlag::nextDisEngagement);
6266
} else if (c == 'm') {
6367
replay_->seekTo(+60, true);
6468
} else if (c == 'M') {
@@ -69,10 +73,6 @@ void keyboardThread(Replay *replay_) {
6973
replay_->seekTo(-10, true);
7074
} else if (c == 'G') {
7175
replay_->seekTo(0, true);
72-
} else if (c == 'e') {
73-
replay_->seekToFlag(FindFlag::nextEngagement);
74-
} else if (c == 'd') {
75-
replay_->seekToFlag(FindFlag::nextDisEngagement);
7676
} else if (c == ' ') {
7777
replay_->pause(!replay_->isPaused());
7878
}

selfdrive/ui/replay/replay.cc

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,12 @@ std::optional<uint64_t> Replay::find(FindFlag flag) {
152152
if (!log.load(route_->at(n).qlog.toStdString(), nullptr, cache_to_local, 0, 3)) continue;
153153

154154
for (const Event *e : log.events) {
155-
if (e->mono_time > cur_mono_time_) {
156-
if (flag == FindFlag::nextEngagement) {
157-
if (e->which == cereal::Event::Which::CONTROLS_STATE && e->event.getControlsState().getEnabled()) {
158-
return e->mono_time;
159-
}
160-
} else if (flag == FindFlag::nextDisEngagement) {
161-
if (e->which == cereal::Event::Which::CONTROLS_STATE && !e->event.getControlsState().getEnabled()) {
162-
return e->mono_time;
163-
}
155+
if (e->mono_time > cur_mono_time_ && e->which == cereal::Event::Which::CONTROLS_STATE) {
156+
const auto cs = e->event.getControlsState();
157+
if (flag == FindFlag::nextEngagement && cs.getEnabled()) {
158+
return e->mono_time;
159+
} else if (flag == FindFlag::nextDisEngagement && !cs.getEnabled()) {
160+
return e->mono_time;
164161
}
165162
}
166163
}

0 commit comments

Comments
 (0)