X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=bigscreen%2Fccbs_bigscreen.cpp;h=fb53775f64e9d35ef194fc2e8554610eeac4df10;hb=81ab2a21cc586b81bc6362c0d48c276515caaf50;hp=d28a56fcef2a7707642803ecc9b9e2b2178fead9;hpb=b3ef74a8872266e9162444a6626770b29beb03ca;p=ccbs diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index d28a56f..fb53775 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -17,18 +17,19 @@ Tournament active_tournament; std::vector active_groups; std::vector screens; -SplitScreen *mainscreen = NULL; +GenericScreen *mainscreen = NULL; unsigned char framebuf[800 * 600 * 4], screenbuf[800 * 600 * 4]; void init(pqxx::connection &conn) { + if (screens.size() == 0 || mainscreen != screens[0]) + delete mainscreen; + for (std::vector::const_iterator i = screens.begin(); i != screens.end(); ++i) { delete *i; } screens.erase(screens.begin(), screens.end()); - - delete mainscreen; - + conn.perform(FetchCurrentTournament(&active_tournament)); conn.perform(FetchListOfActiveGroups(&active_groups)); @@ -38,13 +39,15 @@ void init(pqxx::connection &conn) std::fprintf(stderr, "Current tournament is %d\n", active_tournament.id); for (std::vector::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)); + } } } @@ -54,7 +57,11 @@ void init(pqxx::connection &conn) screens.push_back(NULL); screens.push_back(NULL); - mainscreen = new SplitScreen(screens[0], screens[1], screens[2], screens[3]); + if (screens[1] == NULL) { + mainscreen = screens[0]; + } else { + mainscreen = new SplitScreen(screens[0], screens[1], screens[2], screens[3]); + } } void main_loop(pqxx::connection &conn) @@ -65,7 +72,7 @@ void main_loop(pqxx::connection &conn) return; } - if (mainscreen->check_invalidated()) { + if (mainscreen && mainscreen->check_invalidated()) { mainscreen->draw(framebuf); ptc_update(framebuf); conn.await_notification(0, 10000);