Browse Source

Add Shadow of the Wyrm to launcher

pull/1/head
Matthew Faltys 5 years ago
parent
commit
39714170a1
  1. 7
      Makefile
  2. 2
      config.gcfg
  3. 17
      deps/Dockerfile
  4. 5
      deps/chowner.sh
  5. 2
      nethack-launcher/nethack-launcher.go
  6. 10
      nethack-launcher/print_user_screen.go
  7. 22
      nethack-launcher/run_game.go

7
Makefile

@ -35,7 +35,7 @@ stat:
dependencies:
go get github.com/gorilla/mux
build_docker:
build_docker: fetch_sotw
mkdir -p stage.tmp/
cp deps/Dockerfile stage.tmp/
cp config.gcfg stage.tmp/config.gcfg
@ -49,6 +49,11 @@ build_docker:
cd stage.tmp/ && \
$(OS_PERMS) docker build -t $(IMAGE_NAME) .
fetch_sotw:
mkdir -p stage.tmp/
wget https://cryo.unixvoid.com/bin/misc/sotw/shadow-of-the-wyrm-release-1.1.2.tar.gz
mv shadow-of-the-wyrm-release-1.1.2.tar.gz stage.tmp/sotw.tar.gz
run_docker:
$(OS_PERMS) docker run \
-d \

2
config.gcfg

@ -6,6 +6,8 @@
nhdatlocation = "/NetHack/dat/nhdat"
recoverbinary = "/NetHack/util/recover"
sysconflocation = "/NetHack/sys/unix/sysconf"
sotwversion = "1.1.2"
sotwroot = "/sotw"
bootstrapdelay = 1
[redis]

17
deps/Dockerfile vendored

@ -1,4 +1,4 @@
FROM debian
FROM debian:stretch
# install needed packages
RUN apt-get update && \
@ -8,6 +8,7 @@ RUN apt-get update && \
autoconf \
bison \
bsdmainutils \
bzip2 \
flex \
gcc \
gdb \
@ -15,14 +16,24 @@ RUN apt-get update && \
groff \
libncursesw5-dev \
libsqlite3-dev \
libboost1.62-dev \
libboost-all-dev \
libncurses5-dev \
libncursesw5-dev \
lua5.1 \
liblua5.1-0-dev \
libsdl2-dev \
libxerces-c-dev \
make \
ncurses-dev \
premake4 \
sqlite3 \
tar \
telnetd \
xinetd \
locales \
git \
wget \
zlibc \
vim
RUN apt-get clean
@ -96,5 +107,7 @@ COPY run.sh /
COPY chowner.sh /bin/
COPY nethackrc /.nethackrc
COPY run_nethack.sh /
ADD sotw.tar.gz /
RUN mv /shadow-of-the-wyrm* /sotw/
CMD ["/run.sh"]

5
deps/chowner.sh vendored

@ -2,7 +2,12 @@
while :
do
# chown nethack directory
chown -R nethack:nethack /hack 2> /dev/null
chmod -R 744 /hack 2> /dev/null
# chown
chown -R nethack:nethack /sotw 2> /dev/null
chmod -R 744 /sotw 2> /dev/null
sleep 2
done

2
nethack-launcher/nethack-launcher.go

@ -20,6 +20,8 @@ type Config struct {
NhdatLocation string
RecoverBinary string
SysconfLocation string
SotwVersion string
SotwRoot string
BootstrapDelay time.Duration
}

10
nethack-launcher/print_user_screen.go

@ -23,6 +23,7 @@ func printUserScreen(redisClient *redis.Client, username string) string {
println(" e) Edit config")
println(" r) Recover from crash")
fmt.Printf(" p) Play NetHack %s\n", config.NethackLauncher.NethackVersion)
fmt.Printf(" o) Play Shadow of the Wyrm %s\n", config.NethackLauncher.SotwVersion)
println(" q) Quit")
println("")
fmt.Printf(">> ")
@ -73,6 +74,15 @@ func printUserScreen(redisClient *redis.Client, username string) string {
wg.Wait()
close(watcher)
printUserScreen(redisClient, username)
case "o":
wg.Add(1)
currentTime := time.Now().UTC()
fulltime := currentTime.Format("2006-01-02.03:04:05")
go runSotwGame(username, fulltime)
watcher := startWatcher(username, fulltime, redisClient)
wg.Wait()
close(watcher)
printUserScreen(redisClient, username)
case "r":
clearScreen()
recoverSave(redisClient, username)

22
nethack-launcher/run_game.go

@ -40,6 +40,28 @@ func runGame(username, timestamp string) {
wg.Done()
}
func runSotwGame(username, timestamp string) {
exec.Command("stty", "-F", "/dev/tty", "echo", "-cbreak").Run()
clearScreen()
// put together users home dir
//homeDir := fmt.Sprintf("%s/user/%s/", config.NethackLauncher.HackDir, username)
ttyrecPath := fmt.Sprintf("%s/user/%s/ttyrec/%s.ttyrec", config.NethackLauncher.HackDir, username, timestamp)
nh := exec.Command("ttyrec", "-f", ttyrecPath, "--", "./ShadowOfTheWyrm")
//nh := exec.Command("./ShadowOfTheWyrm")
nh.Dir = (config.NethackLauncher.SotwRoot)
nh.Stdout = os.Stdout
nh.Stdin = os.Stdin
nh.Stderr = os.Stderr
err := nh.Run()
if err != nil {
fmt.Print(err)
}
exec.Command("exit").Run()
wg.Done()
}
func runtimeRecover(username string) {
fmt.Printf(" %s\n", config.NethackLauncher.ServerDisplay)
println("")

Loading…
Cancel
Save