|
|
|
@ -1,5 +1,8 @@
|
|
|
|
|
package main |
|
|
|
|
|
|
|
|
|
// TODO make poll time faster
|
|
|
|
|
// TODO password redo field
|
|
|
|
|
|
|
|
|
|
import ( |
|
|
|
|
"bufio" |
|
|
|
|
"fmt" |
|
|
|
@ -47,15 +50,15 @@ func main() {
|
|
|
|
|
// init redis connection
|
|
|
|
|
redisClient, redisErr := initRedisConnection() |
|
|
|
|
if redisErr != nil { |
|
|
|
|
glogger.Debug.Printf("redis connection cannot be made, trying again in %s second(s)\n", config.NethackLauncher.BootstrapDelay*time.Second) |
|
|
|
|
//glogger.Debug.Printf("redis connection cannot be made, trying again in %s second(s)\n", config.NethackLauncher.BootstrapDelay*time.Second)
|
|
|
|
|
time.Sleep(config.NethackLauncher.BootstrapDelay * time.Second) |
|
|
|
|
redisClient, redisErr = initRedisConnection() |
|
|
|
|
if redisErr != nil { |
|
|
|
|
glogger.Error.Println("redis connection cannot be made, exiting.") |
|
|
|
|
//glogger.Error.Println("redis connection cannot be made, exiting.")
|
|
|
|
|
panic(redisErr) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
glogger.Debug.Println("connection to redis succeeded.") |
|
|
|
|
//glogger.Debug.Println("connection to redis succeeded.")
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// create initial files needed by nethack
|
|
|
|
@ -438,7 +441,8 @@ func printProgressScreen(redisClient *redis.Client, username string) {
|
|
|
|
|
// restart display
|
|
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
|
clearScreen() |
|
|
|
|
nh := exec.Command("ttyplay", "-p", ttyrecPath) |
|
|
|
|
//nh := exec.Command("ttyplay", "-p", ttyrecPath)
|
|
|
|
|
nh := exec.Command("termplay", "-f", "live", ttyrecPath) |
|
|
|
|
nh.Stdout = os.Stdout |
|
|
|
|
nh.Stdin = os.Stdin |
|
|
|
|
nh.Stderr = os.Stderr |
|
|
|
@ -459,7 +463,13 @@ func runGame(username, timestamp string) {
|
|
|
|
|
ttyrecPath := fmt.Sprintf("%s/user/%s/ttyrec/%s.ttyrec", config.NethackLauncher.HackDir, username, timestamp) |
|
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
|
clearScreen() |
|
|
|
|
nh := exec.Command("/run_nethack.sh", ttyrecPath, homeDir, config.NethackLauncher.HackDir, username) |
|
|
|
|
//nh := exec.Command("ttyrec", ttyrecPath, "-e", "nethack")
|
|
|
|
|
nh := exec.Command("termrec", ttyrecPath, "-e", "nethack") |
|
|
|
|
//nh := exec.Command("termrec", ttyrecPath, "-e", "nethack")
|
|
|
|
|
nh.Env = os.Environ() |
|
|
|
|
nh.Env = append(nh.Env, fmt.Sprintf("HOME=%s", homeDir)) |
|
|
|
|
nh.Env = append(nh.Env, fmt.Sprintf("USER=%s", username)) |
|
|
|
|
nh.Env = append(nh.Env, fmt.Sprintf("NETHACKDIR=%s", config.NethackLauncher.HackDir)) |
|
|
|
|
nh.Stdout = os.Stdout |
|
|
|
|
nh.Stdin = os.Stdin |
|
|
|
|
nh.Stderr = os.Stderr |
|
|
|
@ -467,6 +477,9 @@ func runGame(username, timestamp string) {
|
|
|
|
|
if err != nil { |
|
|
|
|
fmt.Print(err) |
|
|
|
|
} |
|
|
|
|
fmt.Printf("%v\n", nh.Stdout) |
|
|
|
|
fmt.Printf("%v\n", nh.Stdin) |
|
|
|
|
fmt.Printf("%v\n", nh.Stderr) |
|
|
|
|
exec.Command("exit").Run() |
|
|
|
|
wg.Done() |
|
|
|
|
} |
|
|
|
|