]> git.sesse.net Git - ccbs/blobdiff - bigscreen/ccbs_bigscreen.cpp
Fetch the list of auxilliary screens.
[ccbs] / bigscreen / ccbs_bigscreen.cpp
index 527e9c5ab671c6ae33677ed95145456709f82946..8180724c33bbb8f20231048fce44046f9357baa2 100644 (file)
@@ -9,6 +9,7 @@
 #include "fetch_current_tournament.h"
 #include "fetch_list_of_active_groups.h"
 #include "fetch_group.h"
+#include "fetch_auxilliary_screens.h"
 #include "fonts.h"
 #include "groupscreen.h"
 #include "splitscreen.h"
@@ -22,6 +23,8 @@ unsigned char framebuf[800 * 600 * 4], screenbuf[800 * 600 * 4];
 
 void init(pqxx::connection &conn)
 {
+       std::vector<widestring> aux_screens;
+               
        if (screens.size() == 0 || mainscreen != screens[0])
                delete mainscreen;
        
@@ -39,16 +42,23 @@ void init(pqxx::connection &conn)
                std::fprintf(stderr, "Current tournament is %d\n", active_tournament.id);
 
                for (std::vector<SkeletonGroup>::const_iterator i = active_groups.begin(); i != active_groups.end(); ++i) {
-                       std::fprintf(stderr, "tourn: %u  round: %u   parallel: %u\n",
-                               i->tournament, i->round, i->parallel);
+                       std::fprintf(stderr, "tourn: %u  round: %u  parallel: %u  num_machines: %u\n",
+                               i->tournament, i->round, i->parallel, i->num_machines);
 
                        // memory leaks here?
-                       RotateScreen *rs = new RotateScreen();
-                       screens.push_back(rs);
-                       rs->add_screen(new GroupScreen(conn, i->tournament, i->round, i->parallel));
+                       for (unsigned j = 0; j < i->num_machines; ++j) {
+                               RotateScreen *rs = new RotateScreen();
+                               screens.push_back(rs);
+                               rs->add_screen(new GroupScreen(conn, i->tournament, i->round, i->parallel, j, i->num_machines));
+                       }
                }
        }
 
+       conn.perform(FetchAuxilliaryScreens(&aux_screens));
+       for (std::vector<widestring>::const_iterator i = aux_screens.begin(); i != aux_screens.end(); ++i) {
+//             std::fprintf(stderr, "Auxilliary screen '%s'\n", i->c_str());
+       }
+       
        // hack
        screens.push_back(NULL);
        screens.push_back(NULL);