_    _    _           _      
 | |_ (_)__| |_ ___ _ _(_)__ _ 
 | ' \| (_-<  _/ _ \ '_| / _` |
 |_||_|_/__/\__\___/_| |_\__,_|
                    historia.vg

How to run Dark Castle MUD

The Docker image at https://docker.io/jhhudso/darkcastle:latest mentioned in the README seems to be gone, but you can still run the game with the included Dockerfile or build and run it locally.

Clone the repo

git clone https://github.com/DarkCastleMUD/DarkCastle
cd DarkCastle

Run Dark Castle with Docker

Edit compose.ymland expose port 4000 and map the save directory to the save directory in the repo. If you don’t do this, your characters will be wiped every time you restart the container:

services:
  darkcastle:
    image: darkcastle
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - "4000:4000"
    volumes:
      - ./save:/srv/dcastle/git/DarkCastle/save

Run the container with docker compose:

docker compose up

Then connect to the server with telnet 127.0.0.1 4000

You’ll get a Postgres error from the container but for just running the game you don’t need that database. I thought character data was stored in the database so I messed around getting the database working, but it turned out I just needed the to add ./save as a volume.

I used this compose.yml file to get the database working, but again I don’t think it’s necessary:

services:
  db:
    image: postgres:16-alpine
    restart: unless-stopped
    environment:
      POSTGRES_USER: dcastle
      POSTGRES_PASSWORD: dcastle
      POSTGRES_DB: dcastle
    volumes:
      - pgdata:/var/lib/postgresql/data
    healthcheck:
      test: ["CMD-SHELL", "pg_isready -U dcastle -d dcastle"]
      interval: 3s
      timeout: 3s
      retries: 5

  darkcastle:
    build:
      context: .
      dockerfile: ./Dockerfile
    restart: unless-stopped
    ports:
      - "4000:4000"
      - "6666:6666"
      - "6667:6667"
      - "6668:6668"
      - "6669:6669"
    environment:
      - PGHOST=db
      - PGUSER=dcastle
      - PGPASSWORD=dcastle
      - PGDATABASE=dcastle
    volumes:
      - ./save:/srv/dcastle/git/DarkCastle/save
    depends_on:
      db:
        condition: service_healthy

volumes:
  pgdata:

Compile and run Dark Castle + Postgres locally

I needed to edit some code to get this to compile on Arch Linux, which isn’t uncommon for 30 year old MUDs but probably isn’t the correct thing to do. There’s probably some compiler option I’m missing. It is a way to get the game going though!

Install the prerequisites.

Debian:
sudo apt install g++-12-multilib g++-12 libstdc++-12-dev g++ scons libcurl4 libpq-dev libpq5 libcurl4-openssl-dev unzip zlib1g-dev libfmt-dev cmake qt6-base-dev

Arch Linux:
sudo pacman -S gcc gcc-multilib scons curl postgresql-libs postgresql unzip zlib fmt cmake qt6-base

Edit src/utility.cpp and add this definition to the end of the file:

void make_prompt(Connection *d, std::string &prompt) {
    prompt = "> ";
}

Edit src/debug.cpp and add (void) in front of this line to void cast this expression:

  (void)debug.create_blank_item(1);

Edit src/comm.cpp and change the line fd_set &input_set = input_set; to the below (this was line 644 for me):

  fd_set input_set;
  FD_ZERO(&input_set);

Build the project. The docs say to run cmake with -S src but the CMakeLists.txt file is in the root directory, so run it from the root directory with -S ..

cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
make -C build clean
make -C build -j64

You run the game from the lib directory like this:

cd lib
../build/dcastle

Telnet to port 4000 to connect. Have fun.

telnet 10.20.30.40 4000

Postgres Database

I saw the database error upon launching and thought you needed a Postgres database (you don’t!). You can set up a local postgresql database named dcastle with username dcastle

sudo systemctl start postgresql
sudo -u postgres initdb --locale=C.UTF-8 --encoding=UTF8 -D '/var/lib/postgres/data'
sudo -iu postgres
createuser dcastle
createdb -O dcastle dcastle
exit

You need to set these environmental variables before starting the game

export PGUSER=dcastle
export PGDATABASE=dcastle

I don’t know what the database does. Your character is stored in the save directory. I’m just putting this here in case you need to make the error go away for some reason.