Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 147 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ on:
branches: ["main"]
workflow_dispatch:

# The default for every job. The four that publish a release ask for
# contents: write themselves - nothing else needs to change the repository.
permissions:
contents: read

# A new push to a branch makes the run already going on it pointless.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down Expand Up @@ -48,7 +53,7 @@ jobs:
run: sudo apt install -y libnotcurses-dev libnotcurses++-dev
if: contains(matrix.configuration, 'notcurses=1')
- name: Build ${{ matrix.configuration || 'release' }}
run: make -j$(nproc) CX=${{ matrix.cxx }} LD=${{ matrix.cxx }} ${{ matrix.configuration }}
run: make -j$(nproc) CXX=${{ matrix.cxx }} ${{ matrix.configuration }}
- name: Check the binary starts
run: ${{ contains(matrix.configuration, 'debug=1') && './avanor-d' || './avanor' }} --version
- name: Test
Expand All @@ -57,12 +62,117 @@ jobs:
CONFIGURATION: ${{ matrix.configuration }}
run: ./.github/run-tests.sh

# The Debian package, on a tag only. Pinned to the same 26.04 the build
# matrix uses, for the same reason: sol2-dev arrived there and exists in
# nothing older.
debian:
name: debian package
runs-on: ubuntu-latest
# Built on the oldest release it is meant to install on, not the
# newest available: dpkg works the libc dependency out from what the
# binary actually references, so a package built against a newer glibc
# than the target has refuses to install there. Debian 13 carries
# glibc 2.41; building on Ubuntu 26.04 asked for 2.43 and would not go
# onto Debian at all. Move this forward only when dropping support for
# what it currently reaches.
container: debian:13
if: github.ref_type == 'tag'
permissions:
contents: write
steps:
# git before the checkout, as in the Fedora job - without it
# actions/checkout falls back to a REST tarball and leaves no .git.
- name: Install packaging dependencies
run: |
apt update
apt install -y build-essential debhelper devscripts git wget \
libargparse-dev libcereal-dev libfmt-dev libluajit-5.1-dev \
libzstd-dev pkg-config
# Everything else is packaged in Debian 13; sol2 is not - it arrived
# in forky. It is header-only, so the headers are put where the
# compiler looks and Build-Depends still names the package for the
# day trixie has one.
- name: Install sol2 headers
run: |
wget -q -O /tmp/sol2.tar.gz \
https://github.com/ThePhD/sol2/archive/refs/tags/v3.5.0.tar.gz
tar xzf /tmp/sol2.tar.gz -C /tmp
cp -r /tmp/sol2-3.5.0/include/sol /usr/local/include/
- uses: actions/checkout@v7
- name: Build the package
run: |
# See the Fedora job: a container's workspace belongs to somebody
# else as far as git is concerned.
git config --global --add safe.directory "$GITHUB_WORKSPACE"

dch --newversion "$(make -s version)-1" --distribution unstable "Automated build."

# -d because sol2-dev is declared in Build-Depends but installed
# by hand above; the check would otherwise refuse to start.
dpkg-buildpackage -us -uc -b -d
- name: Collect the package
run: mv ../avanor_*.deb .
- name: Add it to the release
uses: softprops/action-gh-release@v3
with:
files: avanor_*.deb
fail_on_unmatched_files: true

# The Fedora package, on a tag only.
fedora:
name: fedora package
runs-on: ubuntu-latest
container: fedora:latest
if: github.ref_type == 'tag'
permissions:
contents: write
steps:
# git has to be there before the checkout: without it actions/checkout
# quietly falls back to fetching a tarball through the REST API, and
# the workspace ends up with no .git for `make version` to read.
- name: Install packaging dependencies
run: dnf install -y rpm-build gcc-c++ make git pkgconf-pkg-config argparse-devel cereal-devel fmt-devel libzstd-devel luajit-devel sol2-devel
- uses: actions/checkout@v7
- name: Build the package
run: |
# This job runs in a container, so the workspace belongs to the
# host's runner user while the step runs as root, and git refuses
# to touch a repository somebody else owns. actions/checkout
# works around that for itself in a temporary global config that
# later steps do not inherit, so it has to be said again here -
# before make or git archive, both of which ask git for things.
git config --global --add safe.directory "$GITHUB_WORKSPACE"

# An RPM version may not contain a hyphen, so the "-g<commit>" a
# non-release build carries becomes ".g<commit>".
VERSION=$(make -s version | tr '-' '.')
mkdir -p rpmbuild/{SOURCES,SPECS,BUILD,RPMS,SRPMS,BUILDROOT}
sed "s/^Version:.*/Version: $VERSION/" avanor.spec > rpmbuild/SPECS/avanor.spec

# -o rather than piping into gzip: a pipeline reports the exit
# status of its last command, so a git archive that failed was
# hidden behind a gzip that cheerfully succeeded, and rpmbuild
# got a valid-looking archive of nothing.
git archive --prefix avanor-$VERSION/ --format=tar.gz \
-o rpmbuild/SOURCES/avanor-$VERSION.tar.gz HEAD

rpmbuild --define "_topdir $PWD/rpmbuild" -bb rpmbuild/SPECS/avanor.spec
- name: Collect the package
run: mv rpmbuild/RPMS/*/avanor-[0-9]*.rpm .
- name: Add it to the release
uses: softprops/action-gh-release@v3
with:
files: avanor-[0-9]*.rpm
fail_on_unmatched_files: true

# Nothing here is run: the Windows console under Actions is not a
# console either backend will open, so this proves the two builds still
# compile and link, no more.
windows:
name: windows ${{ matrix.configuration || 'release' }}
runs-on: windows-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
Expand All @@ -79,11 +189,13 @@ jobs:
git
make
wget
diffutils
mingw-w64-ucrt-x86_64-gcc
mingw-w64-ucrt-x86_64-cereal
mingw-w64-ucrt-x86_64-fmt
mingw-w64-ucrt-x86_64-luajit
mingw-w64-ucrt-x86_64-notcurses
mingw-w64-ucrt-x86_64-nsis
mingw-w64-ucrt-x86_64-pkgconf
mingw-w64-ucrt-x86_64-sol2
mingw-w64-ucrt-x86_64-zstd
Expand All @@ -93,23 +205,55 @@ jobs:
- name: Check the binary starts
run: ${{ contains(matrix.configuration, 'debug=1') && './avanor-d.exe' || './avanor.exe' }} --version

# Only on a tag, and only from the release build of the default
# backend: the other three would each write the same file name, and
# a debug or notcurses build is not what anybody installs.
- name: Build the installer
if: github.ref_type == 'tag' && matrix.configuration == ''
run: make installer
- name: Add it to the release
if: github.ref_type == 'tag' && matrix.configuration == ''
uses: softprops/action-gh-release@v3
with:
# [0-9] so this cannot pick up avanor-d.exe by accident
files: avanor-[0-9]*.exe
fail_on_unmatched_files: true

macos:
name: macos ${{ matrix.configuration || 'release' }}
runs-on: macos-latest
permissions:
contents: write
strategy:
fail-fast: false
matrix:
configuration: ["", "debug=1", "notcurses=1", "notcurses=1 debug=1"]
steps:
- uses: actions/checkout@v7
- name: Install dependencies
run: brew install argparse cereal coreutils fmt luajit notcurses pkgconf sol2 wget zstd
run: brew install argparse cereal coreutils create-dmg dylibbundler fmt luajit make notcurses pkgconf sol2 wget zstd
# gmake, not make: macOS still ships GNU Make 3.81 from 2006, which
# reads a "#" inside $(shell ...) as the start of a comment and cuts
# the line in half. Homebrew's is the same 4.x every other platform
# builds with, so there is one make to support rather than two.
- name: Build ${{ matrix.configuration || 'release' }}
run: make -j$(sysctl -n hw.ncpu) ${{ matrix.configuration }}
run: gmake -j$(sysctl -n hw.ncpu) ${{ matrix.configuration }}
- name: Check the binary starts
run: ${{ contains(matrix.configuration, 'debug=1') && './avanor-d' || './avanor' }} --version
- name: Test
if: ${{ !contains(matrix.configuration, 'notcurses=1') }}
env:
CONFIGURATION: ${{ matrix.configuration }}
run: ./.github/run-tests.sh

# As on Windows: only on a tag, and only from the release build of
# the default backend, since all four would write the same file.
- name: Build the disk image
if: github.ref_type == 'tag' && matrix.configuration == ''
run: gmake dmg
- name: Add it to the release
if: github.ref_type == 'tag' && matrix.configuration == ''
uses: softprops/action-gh-release@v3
with:
files: avanor-[0-9]*.dmg
fail_on_unmatched_files: true
25 changes: 25 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,31 @@ avanor-d
avanor.exe
avanor-d.exe

# Generated by the installer target
mainfiles.nsh
datafiles.nsh
avanor-*.exe
avanor-*.dmg

# Generated by dpkg-buildpackage
debian/avanor/
debian/files
debian/*.substvars
debian/*.debhelper
debian/debhelper-build-stamp
debian/.debhelper/
avanor_*.deb

# Generated by rpmbuild
rpmbuild/
avanor-*.rpm
dmgroot/
resources/Avanor.icns

# Source archives
avanor-*-src.tar.gz
avanor-*-src.zip

# Game state
avanor.hsc
dmp*.txt
Expand Down
16 changes: 11 additions & 5 deletions Main.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/*
This file is part of "Avanor, the Land of Mystery" roguelike game
Home page: http://www.avanor.com/
Copyright (C) 2000-2003 Vadim Gaidukevich

Copyright (C) 2000-2006 Vadim Gaidukevich
Copyright (C) 2025,2026 Joachim de Groot

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -545,12 +546,13 @@ const char* logo_text[] = {
" T h e L a n d o f M y s t e r y",
"",
MSG_GREEN
" version " GAME_VERSION "\n",
" version " GAME_VERSION_FULL "\n",
MSG_YELLOW,
" (c) 2000 - 2006 by Vadim Gaidukevich",
" (c) 2025 - 2026 by Joachim de Groot",
"",
MSG_YELLOW
" http://www.avanor.com",
" http://avanor.sourceforge.net",
"",
"",
" "
Expand Down Expand Up @@ -587,7 +589,7 @@ XGame Game;

int main(int argc, char* argv[])
{
argparse::ArgumentParser program("avanor", GAME_VERSION);
argparse::ArgumentParser program("avanor", GAME_VERSION_FULL);
program.add_description("Avanor, the Land of Mystery - a roguelike.");

program.add_argument("-g", "--god")
Expand Down Expand Up @@ -642,6 +644,10 @@ int main(int argc, char* argv[])
return 1;
}

// Before anything opens a file: the world, the manual and the score
// table are all named relative to where the game runs from.
vEnterDataDir();

vRandSeed(program.is_used("--seed") ? program.get<unsigned long>("--seed")
: static_cast<unsigned long>(time(nullptr)));
vInit();
Expand Down
Loading
Loading