|
|
@ -20,14 +20,14 @@ import ( |
|
|
|
|
|
|
|
|
|
|
|
type Config struct { |
|
|
|
type Config struct { |
|
|
|
NethackLauncher struct { |
|
|
|
NethackLauncher struct { |
|
|
|
Loglevel string |
|
|
|
Loglevel string |
|
|
|
ServerDisplay string |
|
|
|
ServerDisplay string |
|
|
|
NethackVersion string |
|
|
|
NethackVersion string |
|
|
|
InProgressDir string |
|
|
|
InProgressDir string |
|
|
|
UserDir string |
|
|
|
UserDir string |
|
|
|
RecordLocation string |
|
|
|
RecordFileLocation string |
|
|
|
ReclistLocation string |
|
|
|
ReclistLocation string |
|
|
|
BootstrapDelay time.Duration |
|
|
|
BootstrapDelay time.Duration |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
Redis struct { |
|
|
|
Redis struct { |
|
|
@ -98,8 +98,8 @@ func initRedisConnection() (*redis.Client, error) { |
|
|
|
|
|
|
|
|
|
|
|
func checkFiles() { |
|
|
|
func checkFiles() { |
|
|
|
// make sure record file exists
|
|
|
|
// make sure record file exists
|
|
|
|
if _, err := os.Stat(config.NethackLauncher.RecordLocation); os.IsNotExist(err) { |
|
|
|
if _, err := os.Stat(config.NethackLauncher.RecordFileLocation); os.IsNotExist(err) { |
|
|
|
glogger.Info.Printf("record file not found in %s\n", config.NethackLauncher.RecordLocation) |
|
|
|
glogger.Info.Printf("record file not found in %s\n", config.NethackLauncher.RecordFileLocation) |
|
|
|
fmt.Printf("%s\n", err) |
|
|
|
fmt.Printf("%s\n", err) |
|
|
|
os.Exit(1) |
|
|
|
os.Exit(1) |
|
|
|
} |
|
|
|
} |
|
|
@ -195,11 +195,12 @@ func printUserScreen(redisClient *redis.Client, username string) string { |
|
|
|
// restart display
|
|
|
|
// restart display
|
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run() |
|
|
|
clearScreen() |
|
|
|
clearScreen() |
|
|
|
nh := exec.Command("nethack", "-u", username) |
|
|
|
nh := exec.Command("ttyrec", "yeto.ttyrec", "-e", "nethack", "-u", username) |
|
|
|
nh.Stdout = os.Stdout |
|
|
|
nh.Stdout = os.Stdout |
|
|
|
nh.Stdin = os.Stdin |
|
|
|
nh.Stdin = os.Stdin |
|
|
|
nh.Stderr = os.Stderr |
|
|
|
nh.Stderr = os.Stderr |
|
|
|
nh.Run() |
|
|
|
nh.Run() |
|
|
|
|
|
|
|
exec.Command("exit").Run() |
|
|
|
printUserScreen(redisClient, username) |
|
|
|
printUserScreen(redisClient, username) |
|
|
|
case "q": |
|
|
|
case "q": |
|
|
|
clearScreen() |
|
|
|
clearScreen() |
|
|
@ -433,7 +434,7 @@ func gethighscore(w http.ResponseWriter, r *http.Request) { |
|
|
|
// run script
|
|
|
|
// run script
|
|
|
|
output, err := exec.Command(config.NethackLauncher.ReclistLocation, |
|
|
|
output, err := exec.Command(config.NethackLauncher.ReclistLocation, |
|
|
|
"-f", |
|
|
|
"-f", |
|
|
|
config.NethackLauncher.RecordLocation).CombinedOutput() |
|
|
|
config.NethackLauncher.RecordFileLocation).CombinedOutput() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|
fmt.Printf("%s\n", err) |
|
|
|
fmt.Printf("%s\n", err) |
|
|
|
} |
|
|
|
} |
|
|
|