From da88614bd00fe7254bfe009c1fe8b913f1be65b3 Mon Sep 17 00:00:00 2001 From: Will Storey Date: Sun, 27 Mar 2011 11:38:15 -0700 Subject: [PATCH] Put back in duplicate homes drawing. This is needed in the case where homes wrap around torus. Also fix bug where wrapped homes did not score pucks correctly. --- gui.cpp | 2 -- map.cpp | 16 +++++++++++++--- node.cpp | 1 + 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/gui.cpp b/gui.cpp index 0c957e5..a150b98 100644 --- a/gui.cpp +++ b/gui.cpp @@ -318,12 +318,10 @@ DrawAll() { glColor3f( it->colour.r, it->colour.g, it->colour.b ); GlDrawCircle( it->x, it->y, home_radius, 16 ); - /* GlDrawCircle( it->x+world_size, it->y, home_radius, 16 ); GlDrawCircle( it->x-world_size, it->y, home_radius, 16 ); GlDrawCircle( it->x, it->y+world_size, home_radius, 16 ); GlDrawCircle( it->x, it->y-world_size, home_radius, 16 ); - */ glColor3f(0.0, 1.0, 0.0); // Green diff --git a/map.cpp b/map.cpp index b33f4eb..6432449 100644 --- a/map.cpp +++ b/map.cpp @@ -131,11 +131,21 @@ class Map { // of the map and place in another vector for (vector::iterator it = all_homes.begin(); it != all_homes.end(); it++) { Home *h = *it; + // Within our x range if (h->x + antix::home_radius >= my_min_x && h->x - antix::home_radius < my_max_x) { local_homes.push_back(h); -#if DEBUG - cout << "Found a local home for team " << h->team << endl; -#endif + + // On first node, the homes may come from wrapping around the world + } else if (my_min_x == 0) { + if (h->x + antix::home_radius > antix::world_size) { + local_homes.push_back(h); + } + + // On last node, homes may come from wrapping around the world + } else if (my_max_x == antix::world_size) { + if (h->x - antix::home_radius < 0) { + local_homes.push_back(h); + } } } } diff --git a/node.cpp b/node.cpp index 943d1af..01326de 100755 --- a/node.cpp +++ b/node.cpp @@ -904,6 +904,7 @@ main(int argc, char **argv) { // update poses for internal robots my_map->update_poses(); + // Exchange robots/pucks on border, and agree on collisions near borders neighbours_handshake(); // build message for each client of what their robots can see