OpenTTD in CLion devcontainer: Difference between revisions

From Pengwings
No edit summary
No edit summary
 
Line 45: Line 45:
     ],
     ],
  }
  }
Run game and immediately exit
Build and run game from CLion using cmake lists file and immediately exit


Edit openttd.cfg
Edit openttd.cfg

Latest revision as of 14:07, 15 February 2026

Clone game and create directories

mkdir -p /home/ruby/dev/OpenTTD
cd /home/ruby/dev/OpenTTD
hg clone git+ssh://git@github.com:Theleruby/OpenTTD.git
mkdir config
mkdir data
mkdir .devcontainer

Edit Dockerfile

vim .devcontainer/Dockerfile
FROM ubuntu:24.04
ENV DEBIAN_FRONTEND=noninteractive
RUN apt-get update
# requirements for openttd
RUN apt-get install -y --no-install-recommends build-essential gcc pkg-config cmake liballegro4-dev libcurl4-openssl-dev libfluidsynth-dev libfontconfig-dev libharfbuzz-dev libicu-dev liblzma-dev liblzo2-dev libogg-dev libopus-dev libopusfile-dev libpng-dev zlib1g-dev
# requirements for devcontainer
RUN apt-get install -y --no-install-recommends mercurial ca-certificates pipewire-alsa pipewire
# prep container
RUN mkdir -p /run/user/1000
RUN chown ubuntu:ubuntu /run/user/1000
USER ubuntu
ENTRYPOINT ["/bin/bash"]

Edit devcontainer.json

vim .devcontainer/devcontainer.json
{
    "name": "OpenTTD",
    "dockerFile": "Dockerfile",
    "containerUser": "ubuntu",
    "runArgs": [
        "--device=/dev/snd",
        "--gpus",
        "all"
    ],
    "containerEnv": {
        "DISPLAY": "unix:0",
        "XDG_RUNTIME_DIR": "/run/user/1000"
    },
    "mounts": [
        "source=/opt/soundfonts/gm.sf2,target=/opt/soundfonts/gm.sf2,type=bind,consistency=cached",
        "source=/home/ruby/dev/OpenTTD/data,target=/.jbdevcontainer/data/openttd,type=bind,consistency=cached",
        "source=/home/ruby/dev/OpenTTD/config,target=/.jbdevcontainer/config/openttd,type=bind,consistency=cached",
        "source=/tmp/.X11-unix,target=/tmp/.X11-unix,type=bind,consistency=cached",
        "source=/run/user/1000/pipewire-0,target=/run/user/1000/pipewire-0,type=bind,consistency=cached"
    ],
}

Build and run game from CLion using cmake lists file and immediately exit

Edit openttd.cfg

vim config/openttd.cfg

Set fluidsynth soundfont to gm2.sf2 in [misc] section

musicdriver = "fluidsynth:soundfont=/opt/soundfonts/gm.sf2"