Merge pull request #166 from Futurabeast/clean-get-tracker-by-id

Change getTrackerById
This commit is contained in:
Eiren Rain authored and GitHub committed 2022-05-03 15:33:18 +03:00
commit 910e32bb3e
1 file changed
+12 -8
+12 -8
View File
@@ -313,15 +313,19 @@ public class VRServer extends Thread {
public Tracker getTrackerById(TrackerIdT id) {
for (Tracker tracker : trackers) {
if (tracker.getTrackerNum() != id.getTrackerNum())
if (tracker.getTrackerNum() != id.getTrackerNum()) {
continue;
if (tracker.getDevice() == null && id.getDeviceId() != null)
continue;
if (tracker.getDevice() != null && id.getDeviceId() == null)
continue;
if (tracker.getDevice().getId() != id.getDeviceId().getId())
continue;
return tracker;
}
// Handle synthetic devices
if (id.getDeviceId() == null && tracker.getDevice() == null) {
return tracker;
}
if (tracker.getDevice() != null && id.getDeviceId() != null && id.getDeviceId().getId() == tracker.getDevice().getId()) {
// This is a physical tracker, and both device id and the tracker num match
return tracker;
}
}
return null;
}