diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2017-06-18 18:57:31 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2017-06-18 18:57:31 +0200 |
commit | a0750afba4269cab9658abf7453e99660f0cb095 (patch) | |
tree | 8e1d1ae0ec70bfb2164798e9328f2af66fff2f9d /tracker-udp | |
parent | 68040f27c2931cd74ea3d3a40585b4ca3ce2ca95 (diff) |
tracker/udp: use std::distance
Diffstat (limited to 'tracker-udp')
-rw-r--r-- | tracker-udp/ftnoir_tracker_udp.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/tracker-udp/ftnoir_tracker_udp.cpp b/tracker-udp/ftnoir_tracker_udp.cpp index e2d6fc93..b3df5e60 100644 --- a/tracker-udp/ftnoir_tracker_udp.cpp +++ b/tracker-udp/ftnoir_tracker_udp.cpp @@ -11,6 +11,8 @@ #include "compat/nan.hpp" #include "compat/util.hpp" +#include <iterator> + udp::udp() : last_recv_pose { 0,0,0, 0,0,0 }, last_recv_pose2 { 0,0,0, 0,0,0 } @@ -94,8 +96,9 @@ void udp::data(double *data) for (int i = 0; i < 3; i++) { - const unsigned k = clamp(unsigned(indices[i]), 0u, sizeof(values)/sizeof(*values) - 1u); - data[Yaw + i] += values[k]; + const int k = indices[i]; + if (k >= 0 && k < std::distance(std::begin(values), std::end(values))) + data[Yaw + i] += values[k]; } } |