Don't use split screen if we only have one screen.
authorSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 20 Feb 2005 19:45:52 +0000 (19:45 +0000)
committerSteinar H. Gunderson <sgunderson@bigfoot.com>
Sun, 20 Feb 2005 19:45:52 +0000 (19:45 +0000)
bigscreen/ccbs_bigscreen.cpp

index d28a56f..527e9c5 100644 (file)
 Tournament active_tournament;
 std::vector<SkeletonGroup> active_groups;
 std::vector<GenericScreen *> 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<GenericScreen *>::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));
 
@@ -54,7 +55,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 +70,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);