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
142 changes: 142 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
name: Build and package

on:
workflow_call:
inputs:
include_addons:
description: Generate the Windows add-ons from the dedicated server's game files
type: boolean
default: false

permissions:
contents: read

jobs:
windows:
name: Windows x86
runs-on: windows-2025-vs2026
timeout-minutes: 60
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
lfs: true

- name: Locate the Visual Studio toolchain
shell: pwsh
run: |
$vswhere = Join-Path ${env:ProgramFiles(x86)} 'Microsoft Visual Studio/Installer/vswhere.exe'
$vcvars = & $vswhere -latest -products '*' -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -find 'VC\Auxiliary\Build\vcvarsall.bat'
if (-not $vcvars) { throw 'Visual Studio x86 tools were not found' }
"VCVARSALL=$vcvars" >> $env:GITHUB_ENV

- name: Configure, build, and test Release
shell: cmd
run: |
call "%VCVARSALL%" x86 || exit /b 1
set "VCPKG_ROOT=%VCPKG_INSTALLATION_ROOT%"
cmake --preset x86-Release || exit /b 1
cmake --build --preset Release || exit /b 1
ctest --test-dir build/x86-Release --output-on-failure --no-tests=error || exit /b 1

- uses: actions/setup-python@6d4fd22b20465ccc0f7354476588e8df7c9ca0e0 # v7.1.0
if: inputs.include_addons
with:
python-version: '3.12'

- name: Download game files for the add-ons
if: inputs.include_addons
shell: pwsh
timeout-minutes: 35
run: |
python -m pip install Pillow==12.3.0
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }

$steamDir = Join-Path $env:RUNNER_TEMP 'steamcmd'
$gameDir = Join-Path $env:RUNNER_TEMP 'l4d2-server'
$zip = Join-Path $env:RUNNER_TEMP 'steamcmd.zip'
Invoke-WebRequest 'https://steamcdn-a.akamaihd.net/client/installer/steamcmd.zip' -OutFile $zip
Expand-Archive -LiteralPath $zip -DestinationPath $steamDir

$steamCmd = Join-Path $steamDir 'steamcmd.exe'
$steamArgs = '+@ShutdownOnFailedCommand 1 +@NoPromptForPassword 1 +@sSteamCmdForcePlatformType windows +force_install_dir "{0}" +login anonymous +app_info_update 1 +app_info_print 222860 +app_update 222860 +quit' -f $gameDir
for ($attempt = 1; $attempt -le 3; $attempt++) {
Write-Host "Installing the dedicated server with SteamCMD (attempt $attempt)"
# Wait for SteamCMD's self-update child process. The launcher can exit 7 after handing off.
$steam = Start-Process -FilePath $steamCmd -WorkingDirectory $steamDir -ArgumentList $steamArgs -WindowStyle Hidden -Wait -PassThru
$manifest = Get-Content (Join-Path $gameDir 'steamapps/appmanifest_222860.acf') -Raw -ErrorAction SilentlyContinue
if ($steam.ExitCode -in 0, 7 -and $manifest -match '"StateFlags"\s+"4"' -and
(Test-Path (Join-Path $gameDir 'update/pak01_dir.vpk')) -and
(Test-Path (Join-Path $gameDir 'left4dead2/pak01_dir.vpk'))) {
"L4D2_GAME_DIR=$gameDir" >> $env:GITHUB_ENV
exit 0
}
Get-Content (Join-Path $steamDir 'logs/content_log.txt') -Tail 25 -ErrorAction SilentlyContinue
if ($attempt -lt 3) { Start-Sleep -Seconds 10 }
}
throw "SteamCMD could not install the dedicated server (exit $($steam.ExitCode))"

- name: Package the player ZIP
shell: pwsh
env:
INCLUDE_ADDONS: ${{ inputs.include_addons }}
run: |
./tools/make_dist.ps1 -SkipBuild -SkipTests -ArchiveName inventory-mod-windows-x86.zip `
-SkipAddons:($env:INCLUDE_ADDONS -ne 'true') -GameDir $env:L4D2_GAME_DIR

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: inventory-mod-windows-x86
path: dist/inventory-mod-windows-x86.zip
if-no-files-found: error
compression-level: 0
retention-days: 14

linux:
name: Linux dedicated server x86
runs-on: ubuntu-22.04
timeout-minutes: 20
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false

- name: Install the x86 toolchain and Source SDK
shell: bash
env:
SDK_REVISION: ee978cde412bb8720453f1f89e5748ec1449a4b3
run: |
sudo apt-get update
sudo apt-get install -y g++-multilib ninja-build
git init "$RUNNER_TEMP/hl2sdk-l4d2"
git -C "$RUNNER_TEMP/hl2sdk-l4d2" fetch --depth 1 https://github.com/alliedmodders/hl2sdk.git "$SDK_REVISION"
git -C "$RUNNER_TEMP/hl2sdk-l4d2" checkout --detach FETCH_HEAD
# GCC 11 rejects the template argument list on this constructor in C++20.
sed -i 's/CAutoLockT<MUTEX_TYPE>( const CAutoLockT/CAutoLockT( const CAutoLockT/' \
"$RUNNER_TEMP/hl2sdk-l4d2/public/tier0/threadtools.h"

- name: Configure, build, and test Release
shell: bash
run: |
cmake -S . -B build/linux-x86 -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-m32 \
-DINVENTORY_LINUX_SERVER=ON -DINVENTORY_L4D2_SDK_DIR="$RUNNER_TEMP/hl2sdk-l4d2"
cmake --build build/linux-x86
ctest --test-dir build/linux-x86 --output-on-failure --no-tests=error

- name: Package the dedicated server archive
shell: bash
run: |
package="$RUNNER_TEMP/linux-package"
install -Dm755 build/linux-x86/inventory_mod_server.so "$package/left4dead2/addons/inventory_mod_server.so"
install -Dm644 inventory_mod.example.toml "$package/left4dead2/addons/inventory_mod/inventory_mod.example.toml"
install -Dm644 build/linux-x86/_deps/tomlplusplus-src/LICENSE "$package/tomlplusplus-LICENSE.txt"
mkdir -p dist
tar -czf dist/inventory-mod-linux-x86.tar.gz -C "$package" left4dead2 tomlplusplus-LICENSE.txt

- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: inventory-mod-linux-x86
path: dist/inventory-mod-linux-x86.tar.gz
if-no-files-found: error
compression-level: 0
retention-days: 14
20 changes: 20 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: CI

on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:

permissions:
contents: read

concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build and test
uses: ./.github/workflows/build.yml
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Release

on:
pull_request:
branches: [main]
paths:
- '.github/workflows/build.yml'
- '.github/workflows/release.yml'
- 'assets/**'
- 'packaging/**'
- 'tools/make_dist.ps1'
- 'tools/make_menu_addon.py'
- 'tools/make_rounds_addon.py'
- 'tools/re/vpk.py'
- 'tools/re/vtf_to_png.py'
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-[0-9A-Za-z]+*'
workflow_dispatch:

permissions:
contents: read

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
build:
name: Build and test release packages
uses: ./.github/workflows/build.yml
with:
include_addons: true

publish:
name: Publish GitHub Release
if: github.event_name == 'push'
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
contents: write
steps:
- uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
pattern: inventory-mod-*-x86
path: release
merge-multiple: true

- name: Publish binaries and SHA-256 checksums
working-directory: release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*)?$ ]]; then
echo "Invalid release tag: $RELEASE_TAG" >&2
exit 1
fi

windows="inventory-mod-${RELEASE_TAG}-windows-x86.zip"
linux="inventory-mod-${RELEASE_TAG}-linux-x86.tar.gz"
mv -- inventory-mod-windows-x86.zip "$windows"
mv -- inventory-mod-linux-x86.tar.gz "$linux"
sha256sum "$windows" "$linux" > SHA256SUMS.txt

prerelease=false
if [[ "$RELEASE_TAG" == *-* ]]; then
prerelease=true
fi

if draft=$(gh release view "$RELEASE_TAG" --json isDraft --jq .isDraft 2>/dev/null); then
if [[ "$draft" == true ]]; then
gh release upload "$RELEASE_TAG" "$windows" "$linux" SHA256SUMS.txt --clobber
gh release edit "$RELEASE_TAG" --draft=false --prerelease="$prerelease"
else
echo "Release $RELEASE_TAG is already published."
fi
else
gh release create "$RELEASE_TAG" "$windows" "$linux" SHA256SUMS.txt \
--verify-tag --generate-notes --prerelease="$prerelease"
fi
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ if(NOT WIN32)
return()
endif()

set(INVENTORY_NULLCORE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../imgui-nullcore" CACHE PATH "Checkout of imgui-nullcore")
set(INVENTORY_NULLCORE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/third_party/imgui-nullcore" CACHE PATH "Checkout of imgui-nullcore")
if(NOT EXISTS "${INVENTORY_NULLCORE_DIR}/include/imgui_nullcore/imgui_nullcore.hpp")
message(FATAL_ERROR "imgui-nullcore not found at ${INVENTORY_NULLCORE_DIR} (set INVENTORY_NULLCORE_DIR)")
endif()
Expand Down
31 changes: 22 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

An inventory system for Left 4 Dead 2, as a DLL loaded into `left4dead2.exe`. The HUD (boxes, ammo counter, stamina
bar, melee ring, radial wheel) is drawn by the game itself, with its VGUI surface, fonts and icons; the inventory window
(I) uses the [imgui-nullcore](../imgui-nullcore) look, drawn over the game by hooking `IDirect3DDevice9::Present`. The inventory
(I) uses the [imgui-nullcore](third_party/imgui-nullcore/UPSTREAM.md) look, drawn over the game by hooking `IDirect3DDevice9::Present`. The inventory
talks to the game's own functions (found by reverse engineering, see [docs/game-notes.md](docs/game-notes.md)).

L4D2 is a **32-bit** process, so everything here is built for x86.
Expand Down Expand Up @@ -362,9 +362,9 @@ build.bat Release inventory_mod

`build.bat` uses the Visual Studio 18 toolchain (vcvarsall x86, its bundled CMake, Ninja and vcpkg). Libraries come
from vcpkg in manifest mode ([vcpkg.json](vcpkg.json), triplet `x86-windows-static`, pinned by `builtin-baseline`):
MinHook and toml++; `VCPKG_ROOT` picks another vcpkg. ImGui 1.92.8 is fetched by CMake, since imgui-nullcore builds
against its sources; imgui-nullcore is taken from the sibling folder (`-DINVENTORY_NULLCORE_DIR=...` to change). A
build folder configured before vcpkg needs a fresh configure (delete `build\x86-Release\CMakeCache.txt`).
MinHook and toml++. `VCPKG_ROOT` picks another vcpkg. CMake fetches ImGui 1.92.8 and builds it with the pinned
C++ snapshot in `third_party/imgui-nullcore`. Set `INVENTORY_NULLCORE_DIR` in CMake to use a different checkout.
If an existing CMake cache still points at the old sibling checkout, clear that cache entry to use the bundled copy.

Outputs in `out\Release`: `inventory_mod.dll`, `injector.exe`, `inventory_tests.exe` (the inventory model's tests).

Expand All @@ -381,6 +381,8 @@ SDK headers. The commands below fetch the tested SDK revision.
git init ../hl2sdk-l4d2
git -C ../hl2sdk-l4d2 fetch --depth 1 https://github.com/alliedmodders/hl2sdk.git ee978cde412bb8720453f1f89e5748ec1449a4b3
git -C ../hl2sdk-l4d2 checkout --detach FETCH_HEAD
# Fix the SDK's copy constructor declaration for GCC 11 in C++20 mode.
sed -i 's/CAutoLockT<MUTEX_TYPE>( const CAutoLockT/CAutoLockT( const CAutoLockT/' ../hl2sdk-l4d2/public/tier0/threadtools.h
cmake -S . -B build/linux-x86 -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS=-m32 \
-DINVENTORY_LINUX_SERVER=ON -DINVENTORY_L4D2_SDK_DIR="$PWD/../hl2sdk-l4d2"
cmake --build build/linux-x86
Expand Down Expand Up @@ -409,16 +411,27 @@ and durability display.

## Release

The **CI** workflow builds, tests and uploads a Windows x86 ZIP and a Linux x86 dedicated server tarball for pull
requests into `main` and pushes to `main`. The Windows CI package contains the binaries, rules and player guide.

The **Release** workflow also generates both Windows add-ons using the dedicated server's SteamCMD download.
Packaging changes trigger this check on pull requests. Run it manually from the Actions tab for an on-demand build.
Push a version tag such as `v0.1.0` to publish both archives and `SHA256SUMS.txt` after both builds and tests pass.
Tags with a suffix such as `v0.1.0-rc.1` publish as prereleases. The Linux tarball can be unpacked at the dedicated
server root and loaded as described in [Linux dedicated server](#linux-dedicated-server).

For a local Windows release, run the following commands.

```
make_dist.bat # build, test, then dist\inventory-mod and dist\inventory-mod-<date>.zip
make_dist.bat -SkipBuild # the DLL already built (e.g. while the game has it loaded)
make_dist.bat -SkipAddons # package the binaries without needing the game installed
```

[tools/make_dist.ps1](tools/make_dist.ps1) runs `build.bat Release` and the tests (it stops on a failure, or when the
game has the DLL loaded: unload it with `Ctrl+End` first), builds the addon into the release, and puts together
`inventory_mod.dll`, `injector.exe`, `load-mod.bat` and `HOW-TO.txt` (from [packaging](packaging), the players'
instructions), `inventory_mod.example.toml`, `inventory_mod_screamer.jpg` and `addons\inventory_mod_rounds.vpk`, then
zips the folder. `dist` is not in git.
[tools/make_dist.ps1](tools/make_dist.ps1) runs `build.bat Release` and the tests. Unload the DLL with `Ctrl+End`
before rebuilding if the game is running. The script packages the DLL, injector, launcher, player guide, sample
rules, screamer image and both add-ons. Pass `-GameDir` with a game or dedicated server installation path if Steam
installed it outside the default location. Packages are written to `dist`.

## Run

Expand Down
2 changes: 1 addition & 1 deletion make_dist.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@echo off
rem Builds the mod and the release for players (dist\inventory-mod and dist\inventory-mod-<date>.zip).
rem make_dist.bat [-SkipBuild] [-SkipTests] see tools\make_dist.ps1
rem make_dist.bat [-SkipBuild] [-SkipTests] [-SkipAddons] [-GameDir PATH] see tools\make_dist.ps1
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0tools\make_dist.ps1" %*
exit /b %ERRORLEVEL%
3 changes: 2 additions & 1 deletion packaging/HOW-TO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ What is in this folder
load-mod.bat runs the injector for you
inventory_mod.example.toml rules (box count, weight limit, item weights), for whoever hosts
inventory_mod_screamer.jpg the infection's screamer picture
addons\ the mod's addons, which the mod loads from there (keep the folder next to the DLL):
addons\ included in full releases (keep the folder next to the DLL):
inventory_mod_rounds.vpk the ammo pack of each round type
inventory_mod_menu.vpk the Options > Inventory Mod page


1. Start the game in insecure mode (important)
Expand Down
18 changes: 18 additions & 0 deletions third_party/imgui-nullcore/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
MIT License

Copyright (c) 2026 orange

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
associated documentation files (the "Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the
following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial
portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT
LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO
EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
USE OR OTHER DEALINGS IN THE SOFTWARE.
6 changes: 6 additions & 0 deletions third_party/imgui-nullcore/UPSTREAM.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
The Windows client builds the C++ sources from imgui-nullcore revision
`83682c5ca08ea240ed477db52f959e84d0db5936`. This snapshot contains the
upstream `include/` and `src/` directories and the MIT license.

- [Upstream repository](https://git.libomath.org/orange/imgui-nullcore)
- [License](LICENSE)
Loading