Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Commit

Permalink
Make rlmain runnable again.
Browse files Browse the repository at this point in the history
  • Loading branch information
Heinrich Kuttler committed Feb 11, 2022
1 parent b96ef90 commit 65d3e33
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions sys/unix/rlmain.cc
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,26 @@ main(int argc, char **argv)
fopen("nle.ttyrec.bz2", "a"), fclose);

nle_settings settings;
strncpy(settings.hackdir, getenv("HACKDIR"), sizeof(settings.hackdir));
char *hackdir = getenv("HACKDIR");

if (hackdir)
strncpy(settings.hackdir, hackdir, sizeof(settings.hackdir));
else
throw std::runtime_error(
"Set HACKDIR env variable to NetHack installation");

ScopedTC tc;

Instance nle("libnethack.so", &obs, ttyrec.get(), nullptr, &settings);
char *cwd = getcwd(nullptr, 0); /* glibc's allocating version. */
std::string path(cwd);
free(cwd);

if (path.back() != '/')
path.append("/");

path.append("libnethack.so");

Instance nle(path, &obs, ttyrec.get(), nullptr, &settings);
if (argc > 1 && argv[1][0] == 'r') {
randgame(nle, &obs, 3, &settings);
} else {
Expand Down

0 comments on commit 65d3e33

Please sign in to comment.