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
19 changes: 13 additions & 6 deletions pkgs/games/openrw/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, stdenv
, fetchFromGitHub
, cmake
, ninja
, sfml
, libGLU
, libGL
Expand All @@ -11,31 +12,37 @@
, openal
, SDL2
, boost
, ffmpeg_4
, ffmpeg_6
, Cocoa
, OpenAL }:

stdenv.mkDerivation {
version = "unstable-2021-10-14";
version = "0-unstable-2024-04-20";
pname = "openrw";

src = fetchFromGitHub {
owner = "rwengine";
repo = "openrw";
rev = "0f83c16f6518c427a4f156497c3edc843610c402";
sha256 = "0i6nx9g0xb8sziak5swi8636fszcjjx8n2jwgz570izw2fl698ff";
rev = "f10a5a8f7abc79a0728847e9a10ee104a1216047";
hash = "sha256-4ydwPh/pCzuZNNOyZuEEeX4wzI+dqTtAxUyXOXz76zk=";
fetchSubmodules = true;
};

patches = [
# SoundSource.cpp: return AVERROR_EOF when buffer is empty
# https://github.com/rwengine/openrw/pull/747
./fix-ffmpeg-6.patch
];

postPatch = lib.optional (stdenv.cc.isClang && (lib.versionAtLeast stdenv.cc.version "9"))''
substituteInPlace cmake_configure.cmake \
--replace 'target_link_libraries(rw_interface INTERFACE "stdc++fs")' ""
'';

nativeBuildInputs = [ cmake ];
nativeBuildInputs = [ cmake ninja ];

buildInputs = [
sfml libGLU libGL bullet glm libmad openal SDL2 boost ffmpeg_4
sfml libGLU libGL bullet glm libmad openal SDL2 boost ffmpeg_6
] ++ lib.optionals stdenv.isDarwin [ OpenAL Cocoa ];

meta = with lib; {
Expand Down
22 changes: 22 additions & 0 deletions pkgs/games/openrw/fix-ffmpeg-6.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From ad7be040894661b708f9c861696499640ac7f9dc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tomi=20L=C3=A4hteenm=C3=A4ki?= <lihis@lihis.net>
Date: Fri, 1 Dec 2023 16:01:59 +0200
Subject: [PATCH] SoundSource.cpp: return AVERROR_EOF when buffer is empty

---
rwengine/src/audio/SoundSource.cpp | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/rwengine/src/audio/SoundSource.cpp b/rwengine/src/audio/SoundSource.cpp
index c93376e73..d355cab74 100644
--- a/rwengine/src/audio/SoundSource.cpp
+++ b/rwengine/src/audio/SoundSource.cpp
@@ -55,7 +55,7 @@ int read_packet(void* opaque, uint8_t* buf, int buf_size) {
memcpy(buf, input->ptr, buf_size);
input->ptr += buf_size;
input->size -= buf_size;
- return buf_size;
+ return buf_size <= 0 ? AVERROR_EOF : buf_size;
}
} // namespace