]> git.sesse.net Git - ccbs/commitdiff
Make tourn a global variable (ick?), and do some placeholder logic in main_loop(...
authorSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 01:23:45 +0000 (01:23 +0000)
committerSteinar H. Gunderson <sesse@samfundet.no>
Sat, 19 Feb 2005 01:23:45 +0000 (01:23 +0000)
bigscreen/ccbs_bigscreen.cpp

index 09aa59cdedc504eeaddc30806e283f31a0f06789..d5bb931ba5799c902e5068e4fa29b2b7249614d2 100644 (file)
@@ -3,6 +3,14 @@
 #include <pqxx/pqxx>
 #include "glwindow.h"
 
+class Tournament {
+public:
+       int id;
+       std::string name;
+};
+
+Tournament tourn;
+
 /* A trigger that sets a flag whenever it's trigged. */
 class FlagTrigger : pqxx::trigger {
 private:
@@ -30,12 +38,6 @@ public:
        }
 };
 
-class Tournament {
-public:
-       int id;
-       std::string name;
-};
-
 /* A transactor that fetches the current tournament and some information about it. */
 class FetchCurrentTournament : public pqxx::transactor<> {
 private:
@@ -60,7 +62,6 @@ public:
 
 void init(pqxx::connection &conn)
 {
-       Tournament tourn;
        conn.perform(FetchCurrentTournament(&tourn));
 
        if (tourn.id == -1) {
@@ -73,12 +74,18 @@ void init(pqxx::connection &conn)
 
 void main_loop(pqxx::connection &conn)
 {
+       if (tourn.id == -1) {
+               // No active tournament, sleep a second or so and exit
+               sleep(1);
+               return;
+       }
+       
        pqxx::work t(conn, "trx");
 
        // fetch all songs
        pqxx::result res( t.exec("SELECT * FROM songs") );
        for (pqxx::result::const_iterator i = res.begin(); i != res.end(); ++i) {
-               // std::fprintf(stderr, "%s\n", i["title"].c_str());
+               std::fprintf(stderr, "%s\n", i["title"].c_str());
        }
        t.commit();