support auto-add of recordless replays
authorShiar <shiar@shiar.org>
Sat, 12 Jan 2008 21:23:23 +0000 (21:23 +0000)
committerShiar <shiar@shiar.org>
Sat, 12 Jan 2008 21:25:08 +0000 (21:25 +0000)
new

diff --git a/new b/new
index 9c0e6ef01ce5678d8d6889145ec849a73be3d1e2..5490d07df9f989186bd70f9701242a356339858d 100755 (executable)
--- a/new
+++ b/new
@@ -1,13 +1,19 @@
-#!/bin/sh
+#!/bin/bash
 
 cd /var/log/pvpgn/reports
-ls -tgG | head -n 5 | tail -n 4
+ls -tgG | head -n 5 | tail -n 4 | nl
+psetreport=($(ls -t | head -n 4))
 read -ep 'report: ' report
-if [ ! "$report" ]; then
-       report=$(ls -t | head -n 1)
-       echo "Report file unspecified; using $report"
-fi
-if [ ! -r "$report" ]; then
+case "$report" in
+'')
+       echo "No report file; using replay only"
+       ;;
+[1-5])
+       report=${psetreport[$((report - 1))]}
+       echo "Report preset: $report"
+       ;;
+esac
+if [ -n "$report" ] && [ ! -r "$report" ]; then
        echo "Report file $report not found"
 fi
 cd - > /dev/null
@@ -29,13 +35,13 @@ case "$name" in
 esac
 echo
 
-REPLAYPSET='shiar@shiar.demon.nl:sc.rep/replays/'
-echo $REPLAYPSET
+psetreplay=('shiar@shiar.demon.nl:sc.rep/replays')
+echo $psetreplay | nl
 read -p 'replay location: ' replay
 case "$replay" in
 *.rep) ;;
 1 | '')
-       replay="$REPLAYPSET/$name.rep"
+       replay="${psetreplay[0]}/$name.rep"
        echo "Using preset replay location $replay"
        ;;
 *)
@@ -45,7 +51,6 @@ case "$replay" in
 esac
 echo
 
-cp -ip "/var/log/pvpgn/reports/$report" "../replay/$name.txt" || exit 1
 case "$replay" in
 http:*)
        wget "$replay" -O "../replay/$name.rep"
@@ -57,11 +62,20 @@ http:*)
        cp -p "$replay" "../replay/$name.rep" || exit 1
        ;;
 esac
+echo
 
-./pvpgnreport ../replay/$name
 ./screpextract ../replay/$name.rep | ./screp -a ../replay/$name.apm
-read -p 'retype replay id? ' gameid
-./screpextract ../replay/$name.rep | ./screp -d $gameid
+echo
+
+if [ -n "$report" ]; then
+       cp -ip "/var/log/pvpgn/reports/$report" "../replay/$name.txt" || exit 1
+       ./pvpgnreport ../replay/$name
+       read -p 'retype replay id? ' gameid
+       ./screpextract ../replay/$name.rep | ./screp -d $gameid
+else
+       read -p 'who won? ' winner
+       ./screpextract ../replay/$name.rep | ./screp -D ../replay/$name.rep "$winner"
+fi
 
 # UPDATE game SET speed = frames*.042 / extract('epoch' FROM COALESCE(duration, durationguess - '15 sec'));