Browse Source

Add score persistence

Add sotw jail
pull/1/head
Matthew Faltys 5 years ago
parent
commit
f6cd22a3b9
  1. 2
      Makefile
  2. 2
      config.gcfg
  3. 2
      deps/Dockerfile
  4. 21
      deps/link_sotw.sh
  5. BIN
      deps/scores.dat
  6. 5
      nethack-launcher/create_initial_files.go
  7. 5
      nethack-launcher/create_user_files.go
  8. 3
      nethack-launcher/run_game.go

2
Makefile

@ -46,6 +46,8 @@ build_docker: fetch_sotw
cp deps/chowner.sh stage.tmp/ cp deps/chowner.sh stage.tmp/
cp deps/run_nethack.sh stage.tmp/ cp deps/run_nethack.sh stage.tmp/
cp deps/reclist.c stage.tmp/ cp deps/reclist.c stage.tmp/
cp deps/link_sotw.sh stage.tmp/
cp deps/scores.dat stage.tmp/
wget -O stage.tmp/redis-server https://cryo.unixvoid.com/bin/redis/5.0.7/redis-server wget -O stage.tmp/redis-server https://cryo.unixvoid.com/bin/redis/5.0.7/redis-server
chmod +x stage.tmp/redis-server chmod +x stage.tmp/redis-server
cd stage.tmp/ && \ cd stage.tmp/ && \

2
config.gcfg

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

2
deps/Dockerfile vendored

@ -109,7 +109,9 @@ COPY run.sh /
COPY chowner.sh /bin/ COPY chowner.sh /bin/
COPY nethackrc /.nethackrc COPY nethackrc /.nethackrc
COPY run_nethack.sh / COPY run_nethack.sh /
COPY link_sotw.sh /bin/
ADD sotw.tar.gz / ADD sotw.tar.gz /
RUN mv /shadow-of-the-wyrm* /sotw/ RUN mv /shadow-of-the-wyrm* /sotw/
COPY scores.dat /sotw/
CMD ["/run.sh"] CMD ["/run.sh"]

21
deps/link_sotw.sh vendored

@ -0,0 +1,21 @@
#!/bin/bash
FILES=/sotw/*
USERDIR=$1
HACKDIR=$2
# create initial dir if it does not exist
mkdir -p $USERDIR/sotw/
# link all game files to user dir
for f in $FILES
do
echo "linking $f"
ln -s $f $USERDIR/sotw/
done
# remove inital score file
rm -rf $USERDIR/sotw/scores.dat
# link in shared score file from hackdir
ln -s $HACKDIR/scores.dat $USERDIR/sotw/

BIN
deps/scores.dat vendored

Binary file not shown.

5
nethack-launcher/create_initial_files.go

@ -51,4 +51,9 @@ func createInitialFiles() {
} }
} }
// make sure initial sotw scores file exists
if _, err := os.Stat(fmt.Sprintf("%s/scores.dat", config.NethackLauncher.HackDir)); os.IsNotExist(err) {
exec.Command("cp", fmt.Sprintf("%s/scores.dat", config.NethackLauncher.SotwRoot), config.NethackLauncher.HackDir).Run()
}
} }

5
nethack-launcher/create_user_files.go

@ -39,4 +39,9 @@ func createUserFiles(username string) {
// move in nhdat file if it does not exist // move in nhdat file if it does not exist
exec.Command("cp", fmt.Sprintf("%s/nhdat", config.NethackLauncher.HackDir), userpath).Run() exec.Command("cp", fmt.Sprintf("%s/nhdat", config.NethackLauncher.HackDir), userpath).Run()
// run sotw prep script
if _, err := os.Stat(fmt.Sprintf("%s/sotw/", userpath)); os.IsNotExist(err) {
exec.Command("/bin/link_sotw.sh", userpath, config.NethackLauncher.HackDir).Run()
}
} }

3
nethack-launcher/run_game.go

@ -49,8 +49,7 @@ func runSotwGame(username, timestamp string) {
ttyrecPath := fmt.Sprintf("%s/user/%s/ttyrec/%s.ttyrec", config.NethackLauncher.HackDir, username, timestamp) ttyrecPath := fmt.Sprintf("%s/user/%s/ttyrec/%s.ttyrec", config.NethackLauncher.HackDir, username, timestamp)
nh := exec.Command("ttyrec", "-f", ttyrecPath, "--", "./ShadowOfTheWyrm") nh := exec.Command("ttyrec", "-f", ttyrecPath, "--", "./ShadowOfTheWyrm")
//nh := exec.Command("./ShadowOfTheWyrm") nh.Dir = (fmt.Sprintf("%s/user/%s/sotw/", config.NethackLauncher.HackDir, username))
nh.Dir = (config.NethackLauncher.SotwRoot)
nh.Stdout = os.Stdout nh.Stdout = os.Stdout
nh.Stdin = os.Stdin nh.Stdin = os.Stdin
nh.Stderr = os.Stderr nh.Stderr = os.Stderr

Loading…
Cancel
Save