From 16d44dda496bb6fec27aeea13decaae16fd08f7e Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Sat, 23 Apr 2005 17:41:08 +0000 Subject: [PATCH] Various changes and fixes for CC1. --- bigscreen/Makefile | 4 +- bigscreen/ccbs_bigscreen.cpp | 50 +++---------------- bigscreen/fetch_top_scores_for_tournament.cpp | 2 +- bigscreen/groupscreen.cpp | 6 ++- bigscreen/resolution.h | 6 +-- bigscreen/tinyptc/test.c | 4 +- bigscreen/tinyptc/tinyptc.h | 6 +-- html/ccbs.pm | 4 +- 8 files changed, 26 insertions(+), 56 deletions(-) diff --git a/bigscreen/Makefile b/bigscreen/Makefile index d58b48e..e95b4af 100644 --- a/bigscreen/Makefile +++ b/bigscreen/Makefile @@ -1,9 +1,9 @@ CC=gcc CXX=g++ CPPFLAGS=-I/usr/include/postgresql $(shell freetype-config --cflags) -Itinyptc/ -CXXFLAGS=-g -Wall +CXXFLAGS=-O2 -Wall LDFLAGS=-L/usr/X11R6/lib -LIBS=$(shell freetype-config --libs) $(shell libpq3-config) -lpqxx tinyptc/libtinyptc.a -lX11 -lXext +LIBS=$(shell freetype-config --libs) $(shell libpq3-config) -lpqxx tinyptc/libtinyptc.a -lX11 -lXext -lXxf86vm -lXxf86dga CCBS_BIGSCREEN_SQL_OBJS=fetch_current_tournament.o fetch_list_of_active_groups.o \ fetch_list_of_finished_groups.o \ diff --git a/bigscreen/ccbs_bigscreen.cpp b/bigscreen/ccbs_bigscreen.cpp index 8e65990..b32c5b1 100644 --- a/bigscreen/ccbs_bigscreen.cpp +++ b/bigscreen/ccbs_bigscreen.cpp @@ -27,7 +27,7 @@ unsigned char framebuf[SCREEN_WIDTH * SCREEN_HEIGHT * 4], screenbuf[SCREEN_WIDTH void init(pqxx::connection &conn) { std::vector aux_screens; - + if (screens.size() == 0 || mainscreen != screens[0]) delete mainscreen; @@ -36,6 +36,9 @@ void init(pqxx::connection &conn) } screens.erase(screens.begin(), screens.end()); + RotateScreen *rs = new RotateScreen(); + mainscreen = rs; + conn.perform(FetchCurrentTournament(&active_tournament)); conn.perform(FetchListOfActiveGroups(&active_groups)); @@ -50,60 +53,23 @@ void init(pqxx::connection &conn) // memory leaks here? 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, i->players_per_machine)); } } } - // show auxilliary screens if we have zero, two or three other screens going - if (screens.size() < 4 && screens.size() != 1) { - RotateScreen *aux_screen = new RotateScreen(); - screens.push_back(aux_screen); - + { conn.perform(FetchAuxilliaryScreens(&aux_screens)); for (std::vector::const_iterator i = aux_screens.begin(); i != aux_screens.end(); ++i) { if (*i == widestring("top10scores")) { - aux_screen->add_screen(new Top10ScoreScreen(conn, active_tournament.id)); + rs->add_screen(new Top10ScoreScreen(conn, active_tournament.id)); continue; } if (*i == widestring("top5chosen")) { - aux_screen->add_screen(new Top5ChosenScreen(conn, active_tournament.id)); + rs->add_screen(new Top5ChosenScreen(conn, active_tournament.id)); continue; } - std::fprintf(stderr, "Foobarbaz?\n"); - } - - /* - * If we still have room, make yet another rotational screen with - * results from previous groups -- otherwise tack them onto the end - * of the auxilliary screens. - */ - RotateScreen *finished_groups_screen = aux_screen; - if (screens.size() < 4 && screens.size() != 1) { - finished_groups_screen = new RotateScreen(); - screens.push_back(finished_groups_screen); } - - std::vector finished_groups; - conn.perform(FetchListOfFinishedGroups(active_tournament.id, &finished_groups)); - - for (std::vector::const_iterator i = finished_groups.begin(); i != finished_groups.end(); ++i) { - finished_groups_screen->add_screen(new GroupScreen(conn, i->tournament, i->round, i->parallel, 0, 1, 1)); - } - } - - // hack - screens.push_back(NULL); - screens.push_back(NULL); - screens.push_back(NULL); - screens.push_back(NULL); - - if (screens[1] == NULL) { - mainscreen = screens[0]; - } else { - mainscreen = new SplitScreen(screens[0], screens[1], screens[2], screens[3]); } } @@ -131,7 +97,7 @@ int main(int argc, char **argv) try { init_freetype(); - pqxx::connection conn("dbname=ccbs host=altersex.samfundet.no user=ccbs password=GeT|>>B_"); + pqxx::connection conn("dbname=ccbs host=www.positivegaming.com user=ccbs password=GeT|>>B_"); FlagTrigger tournament_changed(conn, "active_tournament"); FlagTrigger rounds_changed(conn, "active_groups"); diff --git a/bigscreen/fetch_top_scores_for_tournament.cpp b/bigscreen/fetch_top_scores_for_tournament.cpp index 9c38f51..dd70331 100644 --- a/bigscreen/fetch_top_scores_for_tournament.cpp +++ b/bigscreen/fetch_top_scores_for_tournament.cpp @@ -19,7 +19,7 @@ void FetchTopScoresForTournament::operator() (pqxx::transaction<> &t) // Again, this will break if a song has more than one short title pqxx::result res( t.exec( - "SELECT nick, title, shorttitle, score FROM scores NATURAL JOIN tournaments NATURAL JOIN players NATURAL JOIN songs NATURAL LEFT JOIN songshorttitles WHERE tournament=" + + "SELECT nick, title, shorttitle, score FROM scores NATURAL JOIN tournaments JOIN players ON scores.player=players.player NATURAL JOIN songs NATURAL LEFT JOIN songshorttitles WHERE tournament=" + pqxx::to_string(tournament) + " AND score IS NOT NULL ORDER BY score DESC LIMIT " + pqxx::to_string(num)) ); diff --git a/bigscreen/groupscreen.cpp b/bigscreen/groupscreen.cpp index 750cec4..c13c332 100644 --- a/bigscreen/groupscreen.cpp +++ b/bigscreen/groupscreen.cpp @@ -194,9 +194,13 @@ void GroupScreen::find_column_widths(const Group &group, std::vector & for (unsigned i = 0; i <= num_scores + 2; ++i) sumcolwidth += colwidth[i] + 20; - + if (sumcolwidth < 780) break; + + if (mode == 0) { + colwidth.erase(colwidth.begin(), colwidth.end()); + } } /* diff --git a/bigscreen/resolution.h b/bigscreen/resolution.h index a27b336..20125eb 100644 --- a/bigscreen/resolution.h +++ b/bigscreen/resolution.h @@ -1,9 +1,9 @@ #ifndef _RESOLUTION_H #define _RESOLUTION_H 1 -#define SCREEN_WIDTH 800 -#define SCREEN_HEIGHT 600 -#define SCREEN_LCD 1 +#define SCREEN_WIDTH 640 +#define SCREEN_HEIGHT 480 +#define SCREEN_LCD 0 /* * This is used in the screens, mostly for historical reasons (they were diff --git a/bigscreen/tinyptc/test.c b/bigscreen/tinyptc/test.c index cc6ccaf..2b28c70 100644 --- a/bigscreen/tinyptc/test.c +++ b/bigscreen/tinyptc/test.c @@ -25,8 +25,8 @@ #include -#define WIDTH 320 -#define HEIGHT 200 +#define WIDTH 800 +#define HEIGHT 600 #define SIZE WIDTH*HEIGHT static int noise; diff --git a/bigscreen/tinyptc/tinyptc.h b/bigscreen/tinyptc/tinyptc.h index a6cf0aa..cf2b621 100644 --- a/bigscreen/tinyptc/tinyptc.h +++ b/bigscreen/tinyptc/tinyptc.h @@ -43,7 +43,7 @@ typedef unsigned char char8; /* This directive enables mmx-optimized pixelformat conversions */ -/* #define __PTC_MMX__ */ +#define __PTC_MMX__ /* This directive enables little-endian pixelformat converters - ignored for * the XVideo+Mit-Shm target */ @@ -67,7 +67,7 @@ typedef unsigned char char8; /* If you uncomment this directive, you'll choose X Shared memory extension * video rendering */ -#define __PTC_XSHM__ +#define __PTC_XSHM__ /* If you uncomment this directive, you'll choose X Double buffer extension * video rendering */ @@ -77,7 +77,7 @@ typedef unsigned char char8; /* If you uncomment this directive, you'll choose X Direct Graphics Access * extension (version 1.x) video rendering */ -/* #define __PTC_XDGA1__ */ +/* #define __PTC_XDGA1__ */ /* If you uncomment this directive, you'll choose X Direct Graphics Access * extension (version 2.x) video rendering */ diff --git a/html/ccbs.pm b/html/ccbs.pm index 61dadf8..f5deada 100755 --- a/html/ccbs.pm +++ b/html/ccbs.pm @@ -25,14 +25,14 @@ sub print_see_other { my $location = shift; print CGI::header(-status=>'303 See other', - -location=>'http://ccbs.sesse.net/' . $location, + -location=>'http://192.168.1.200/' . $location, -type=>'text/html; charset=utf-8'); } sub db_connect { $ccbs_dbdebug = defined(shift) ? 1 : 0; - my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=altersex.samfundet.no", "ccbs", "GeT|>>B_") + my $dbh = DBI->connect("dbi:Pg:dbname=ccbs;host=www.positivegaming.com", "ccbs", "GeT|>>B_") or die "Couldn't connect to database"; $dbh->{RaiseError} = 1; return $dbh; -- 2.39.2