diff --git a/bin/once b/bin/once index 1f40248..1a91905 100755 --- a/bin/once +++ b/bin/once @@ -35,6 +35,6 @@ if www/cgi-bin/puzzles.cgi > www/puzzles.new; then fi # Generate new points.json -if bin/points state/points.log > www/points.new; then +if bin/points state > www/points.new; then mv www/points.new www/points.json fi diff --git a/bin/points b/bin/points index 5d27027..1ceecd4 100755 --- a/bin/points +++ b/bin/points @@ -1,46 +1,48 @@ -#! /usr/bin/awk -f +#! /usr/bin/lua5.3 -BEGIN { - nteams = 0; - print "{"; - print " \"points\": ["; -} +io.write('{\n "points": [\n') +local teams = {} +local teamnames = {} +local nteams = 0 +local NR = 0 -{ - ts = $1; - hash = $2; - cat = $3; - points = $4; - - teamno = teams[hash]; - if (! teamno) { - teamno = ++nteams; - teams[hash] = teamno; - - getline teamnames[hash] < ("state/teams/" hash) - } - - if (NR > 1) { - # JSON sucks. - print ","; - } - printf("[%d, \"%s\", \"%s\", %d]", ts, hash, cat, points); -} +local statedir = arg[1] -END { - print ""; - print " ],"; - print " \"teams\": {"; +local f = io.open(statedir .. "/points.log") +for line in f:lines() do + ts, hash, cat, points = line:match("(%d+) (%g+) (%g+) (%d+)") + teamno = teams[hash] + if not teamno then + teamno = nteams + teams[hash] = teamno + nteams = nteams + 1 - i = 0 - for (hash in teamnames) { - if (i++) { - print ","; - } - printf("\"%s\": \"%s\"", hash, teamnames[hash]); - } - - print ""; - print " }"; - print "}"; -} + tf = io.open(statedir .. "/teams/" .. hash) + teamname = tf:read() + tf:close() + + teamnames[hash] = teamname + end + + if NR > 0 then + -- JSON sucks, barfs if you have a comma with nothing after it + io.write(",\n") + end + NR = NR + 1 + + io.write(' [' .. ts .. ', "' .. teamno .. '", "' .. cat .. '", ' .. points .. ']') +end + +io.write('\n],\n "teams": {\n') + +NR = 0 +for hash,teamname in pairs(teamnames) do + if NR > 0 then + io.write(",\n") + end + NR = NR + 1 + + teamno = teams[hash] + io.write(' "' .. teamno .. '": "' .. teamname .. '"') +end +io.write('\n }\n}\n') diff --git a/kothd b/kothd deleted file mode 100755 index ffad247..0000000 --- a/kothd +++ /dev/null @@ -1,14 +0,0 @@ -#! /bin/sh - -cd ${1:-$(dirname $0)} -KOTH_BASE=$(pwd) - -echo "Running koth instances in $KOTH_BASE" - -while true; do - for i in $KOTH_BASE/*/assigned.txt; do - dir=${i%/*} - $dir/bin/once - done - sleep 5 -done diff --git a/www/images/sandia.png b/www/images/sandia.png index 149d217..0c4add8 100644 Binary files a/www/images/sandia.png and b/www/images/sandia.png differ diff --git a/www/images/tf6.png b/www/images/tf6.png index bdce56b..7fe0700 100644 Binary files a/www/images/tf6.png and b/www/images/tf6.png differ