From: Steinar H. Gunderson Date: Sat, 19 Feb 2005 01:23:45 +0000 (+0000) Subject: Make tourn a global variable (ick?), and do some placeholder logic in main_loop(... X-Git-Url: https://git.sesse.net/?p=ccbs;a=commitdiff_plain;h=7b04e82cf97ac4f23290222ee4614f926515ac3b Make tourn a global variable (ick?), and do some placeholder logic in main_loop() if there is an active tournament. --- diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index 09aa59c..d5bb931 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -3,6 +3,14 @@ #include #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();