Skip to content

Commit

Permalink
Use CMAKE_INSTALL_PREFIX instead of hardcoded "/usr", prefer user f…
Browse files Browse the repository at this point in the history
…iles instead of system-wide, optimizations
  • Loading branch information
deathkiller committed Dec 16, 2024
1 parent ce3c6ac commit dc48325
Show file tree
Hide file tree
Showing 19 changed files with 153 additions and 102 deletions.
17 changes: 12 additions & 5 deletions .github/workflows/uwp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,19 @@ jobs:
rm -force ".\Content\Translations\*.po"
$currentDirectory = Get-Location
$certBytes = [System.Convert]::FromBase64String("${{ secrets.UWP_CERTIFICATE_FILE }}")
$certPath = Join-Path -Path $currentDirectory -ChildPath "_cert.pfx"
[IO.File]::WriteAllBytes("$certPath", $certBytes)
if ($env:GITHUB_EVENT_NAME -eq 'pull_request') {
Write-Output "Pull requests are not signed!"
$certPath = ""
$certPass = ""
} else {
$currentDirectory = Get-Location
$certBytes = [System.Convert]::FromBase64String("${{ secrets.UWP_CERTIFICATE_FILE }}")
$certPath = Join-Path -Path $currentDirectory -ChildPath "_cert.pfx"
[IO.File]::WriteAllBytes("$certPath", $certBytes)
$certPass = "${{ secrets.UWP_CERTIFICATE_PASSWORD }}"
}
cmake -B ".\_build\" -D CMAKE_BUILD_TYPE=${{ matrix.BuildType }} -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION="10.0" -A $arch -D CMAKE_SYSTEM_PROCESSOR=$arch -D NCINE_ARCH_EXTENSIONS="${{ matrix.ArchExts }}" -D NCINE_STRIP_BINARIES=ON -D NCINE_UWP_CERTIFICATE_PATH="$certPath" -D NCINE_UWP_CERTIFICATE_PASSWORD="${{ secrets.UWP_CERTIFICATE_PASSWORD }}" -D NCINE_WITH_ANGLE="$withAngle" -D DEATH_TRACE=OFF
cmake -B ".\_build\" -D CMAKE_BUILD_TYPE=${{ matrix.BuildType }} -D CMAKE_SYSTEM_NAME=WindowsStore -D CMAKE_SYSTEM_VERSION="10.0" -A $arch -D CMAKE_SYSTEM_PROCESSOR=$arch -D NCINE_ARCH_EXTENSIONS="${{ matrix.ArchExts }}" -D NCINE_STRIP_BINARIES=ON -D NCINE_UWP_CERTIFICATE_PATH="$certPath" -D NCINE_UWP_CERTIFICATE_PASSWORD="$certPass" -D NCINE_WITH_ANGLE="$withAngle" -D DEATH_TRACE=OFF
- name: 'Build'
run: |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Jazz² Resurrection is reimplementation of the game **Jazz Jackrabbit 2** releas
* Install dependencies: `sudo apt install libglew2.2 libglfw3 libsdl2-2.0-0 libopenal1 libvorbisfile3 libopenmpt0`
* Alternatively, install provided `.deb` or `.rpm` package and dependencies should be installed automatically
* Copy contents of original *Jazz Jackrabbit 2* directory to `‹Game›/Source/`
* If packages are used, the files must be copied to `~/.local/share/Jazz² Resurrection/Source/` or `/usr/share/Jazz² Resurrection/Source/` instead
* If packages are used, the files must be copied to `~/.local/share/Jazz² Resurrection/Source/` or `/usr/local/share/Jazz² Resurrection/Source/` instead, please follow instructions of specific package
* Run `‹Game›/jazz2` or `‹Game›/jazz2_sdl2` application
* If packages are used, the game should be visible in application list

Expand Down
4 changes: 4 additions & 0 deletions Sources/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@

#include <stdlib.h>

#if !defined(NCINE_INSTALL_PREFIX) && defined(DEATH_TARGET_UNIX)
# define NCINE_INSTALL_PREFIX "/usr/local"
#endif

// Check platform-specific capabilities
#if defined(WITH_SDL) || defined(DEATH_TARGET_WINDOWS_RT)
# define NCINE_HAS_GAMEPAD_RUMBLE
Expand Down
15 changes: 11 additions & 4 deletions Sources/Jazz2/ContentResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ namespace Jazz2
# elif defined(NCINE_OVERRIDE_CONTENT_PATH)
_contentPath = NCINE_OVERRIDE_CONTENT_PATH;
# else
_contentPath = INSTALL_PREFIX "/share/" NCINE_LINUX_PACKAGE "/Content/";
_contentPath = NCINE_INSTALL_PREFIX "/share/" NCINE_LINUX_PACKAGE "/Content/";
# endif
# if defined(NCINE_PACKAGED_CONTENT_PATH)
// If Content is packaged with binaries, always use standard XDG paths for everything else
Expand All @@ -235,9 +235,16 @@ namespace Jazz2
} else {
_cachePath = "Cache/"_s;
}
_sourcePath = INSTALL_PREFIX "/share/" NCINE_LINUX_PACKAGE "/Source/";
if (!fs::DirectoryExists(_sourcePath)) {
_sourcePath = fs::CombinePath(fs::GetDirectoryName(_cachePath), "Source/"_s);

// Prefer system-wide Source only if it exists and local one doesn't exist
_sourcePath = fs::CombinePath(fs::GetDirectoryName(_cachePath), "Source/"_s);
if (!fs::FindPathCaseInsensitive(fs::CombinePath(_sourcePath, "Anims.j2a"_s)) &&
!fs::FindPathCaseInsensitive(fs::CombinePath(_sourcePath, "AnimsSw.j2a"_s))) {
auto systemWideSource = NCINE_INSTALL_PREFIX "/share/" NCINE_LINUX_PACKAGE "/Source/";
if (fs::FindPathCaseInsensitive(fs::CombinePath(systemWideSource, "Anims.j2a"_s)) ||
fs::FindPathCaseInsensitive(fs::CombinePath(systemWideSource, "AnimsSw.j2a"_s))) {
_sourcePath = systemWideSource;
}
}
} else {
// Fallback to relative paths
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/LevelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1997,7 +1997,7 @@ namespace Jazz2

void LevelHandler::UpdateRichPresence()
{
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH))
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)
if (!PreferencesCache::EnableDiscordIntegration || !UI::DiscordRpcClient::Get().IsSupported()) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jazz2/PreferencesCache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace Jazz2
#endif
bool PreferencesCache::EnableLedgeClimb = true;
WeaponWheelStyle PreferencesCache::WeaponWheel = WeaponWheelStyle::Enabled;
#if defined(DEATH_TARGET_ANDROID) || defined(DEATH_TARGET_EMSCRIPTEN) || defined(DEATH_TARGET_IOS) || !defined(DEATH_TARGET_SWITCH) || defined(DEATH_TARGET_WINDOWS_RT)
#if defined(DEATH_TARGET_ANDROID) || defined(DEATH_TARGET_EMSCRIPTEN) || defined(DEATH_TARGET_IOS) || defined(DEATH_TARGET_SWITCH) || defined(DEATH_TARGET_WINDOWS_RT)
bool PreferencesCache::EnableRgbLights = false;
#else
bool PreferencesCache::EnableRgbLights = true;
Expand Down Expand Up @@ -347,7 +347,7 @@ namespace Jazz2
auto& resolver = ContentResolver::Get();
fs::CreateDirectories(resolver.GetSourcePath());

# if defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH)
# if defined(DEATH_TARGET_UNIX)
StringView isSteamDeck = ::getenv("SteamDeck");
if (isSteamDeck == "1"_s) {
GamepadButtonLabels = GamepadType::Steam;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/DiscordRpcClient.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "DiscordRpcClient.h"

#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH))
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)

#include "../../nCine/Base/Algorithms.h"

Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/DiscordRpcClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include "../../Common.h"

#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH))
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)

#include "../../nCine/Threading/Thread.h"

Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/Menu/GameplayOptionsSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ namespace Jazz2::UI::Menu
_animation = 0.0f;
break;
}
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH))
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)
case GameplayOptionsItemType::EnableDiscordIntegration: {
PreferencesCache::EnableDiscordIntegration = !PreferencesCache::EnableDiscordIntegration;
if (!PreferencesCache::EnableDiscordIntegration) {
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/Menu/HighscoresSection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ namespace Jazz2::UI::Menu

String name;
std::uint64_t id = 0;
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH))
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)
if (PreferencesCache::EnableDiscordIntegration && DiscordRpcClient::Get().IsSupported()) {
name = DiscordRpcClient::Get().GetUserDisplayName();
id = DiscordRpcClient::Get().GetUserId();
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/UI/Menu/MainMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ namespace Jazz2::UI::Menu

void MainMenu::UpdateRichPresence()
{
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH))
#if (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT)) || defined(DEATH_TARGET_UNIX)
if (!PreferencesCache::EnableDiscordIntegration || !DiscordRpcClient::Get().IsSupported()) {
return;
}
Expand Down
14 changes: 7 additions & 7 deletions Sources/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -159,18 +159,18 @@ class GameEventHandler : public IAppEventHandler, public IInputEventHandler, pub
#if defined(DEATH_TARGET_ANDROID)
void ApplyActivityIcon();
#endif
static void WriteCacheDescriptor(const StringView path, std::uint64_t currentVersion, std::int64_t animsModified);
static void WriteCacheDescriptor(StringView path, std::uint64_t currentVersion, std::int64_t animsModified);
static void SaveEpisodeEnd(const LevelInitialization& levelInit);
static void SaveEpisodeContinue(const LevelInitialization& levelInit);
static bool TryParseAddressAndPort(const StringView input, String& address, std::uint16_t& port);
static void ExtractPakFile(const StringView pakFile, const StringView targetPath);
static bool TryParseAddressAndPort(StringView input, String& address, std::uint16_t& port);
static void ExtractPakFile(StringView pakFile, StringView targetPath);
};

void GameEventHandler::OnPreInitialize(AppConfiguration& config)
{
ZoneScopedC(0x888888);

#if defined(DEATH_TARGET_APPLE) || (defined(DEATH_TARGET_UNIX) && !defined(DEATH_TARGET_SWITCH)) || (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT))
#if defined(DEATH_TARGET_APPLE) || defined(DEATH_TARGET_UNIX) || (defined(DEATH_TARGET_WINDOWS) && !defined(DEATH_TARGET_WINDOWS_RT))
// Allow `/extract-pak` only on PC platforms
if (config.argc() >= 3) {
for (std::int32_t i = 0; i < config.argc() - 2; i++) {
Expand Down Expand Up @@ -1585,7 +1585,7 @@ void GameEventHandler::HandleEndOfGame(const LevelInitialization& levelInit, boo
SetStateHandler(std::move(mainMenu));
}

void GameEventHandler::WriteCacheDescriptor(const StringView path, std::uint64_t currentVersion, std::int64_t animsModified)
void GameEventHandler::WriteCacheDescriptor(StringView path, std::uint64_t currentVersion, std::int64_t animsModified)
{
auto so = fs::Open(path, FileAccess::Write);
so->WriteValue<std::uint64_t>(0x2095A59FF0BFBBEF); // Signature
Expand Down Expand Up @@ -1681,7 +1681,7 @@ void GameEventHandler::SaveEpisodeContinue(const LevelInitialization& levelInit)
}
}

bool GameEventHandler::TryParseAddressAndPort(const StringView input, String& address, std::uint16_t& port)
bool GameEventHandler::TryParseAddressAndPort(StringView input, String& address, std::uint16_t& port)
{
auto portSep = input.findLast(':');
if (portSep) {
Expand Down Expand Up @@ -1714,7 +1714,7 @@ bool GameEventHandler::TryParseAddressAndPort(const StringView input, String& ad
}
}

void GameEventHandler::ExtractPakFile(const StringView pakFile, const StringView targetPath)
void GameEventHandler::ExtractPakFile(StringView pakFile, StringView targetPath)
{
PakFile pak(pakFile);
if (!pak.IsValid()) {
Expand Down
16 changes: 8 additions & 8 deletions Sources/Shared/IO/Compression/Lz4Stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ namespace Death { namespace IO { namespace Compression {

auto result = LZ4F_createDecompressionContext(&_ctx, LZ4F_VERSION);
if (LZ4F_isError(result)) {
LOGE("LZ4F_createDecompressionContext() failed with error %0x%zx (%s)", result, LZ4F_getErrorName(result));
LOGE("LZ4F_createDecompressionContext() failed with error 0x%zx (%s)", result, LZ4F_getErrorName(result));
_state = State::Failed;
}
}
Expand Down Expand Up @@ -237,7 +237,7 @@ namespace Death { namespace IO { namespace Compression {
std::size_t consumedSize = bytesRead;
std::size_t result = LZ4F_getFrameInfo(_ctx, &info, _inBuffer, &consumedSize);
if (LZ4F_isError(result)) {
LOGE("LZ4F_getFrameInfo() failed with error %0x%zx (%s)", result, LZ4F_getErrorName(result));
LOGE("LZ4F_getFrameInfo() failed with error 0x%zx (%s)", result, LZ4F_getErrorName(result));
_state = State::Failed;
return;
}
Expand Down Expand Up @@ -292,7 +292,7 @@ namespace Death { namespace IO { namespace Compression {
std::size_t srcSize = _inLength - _inPos;
auto result = LZ4F_decompress(_ctx, &_outBuffer[0], &dstSize, &_inBuffer[_inPos], &srcSize, nullptr);
if (LZ4F_isError(result)) {
LOGE("LZ4F_decompress() failed with error %0x%zx (%s)", result, LZ4F_getErrorName(result));
LOGE("LZ4F_decompress() failed with error 0x%zx (%s)", result, LZ4F_getErrorName(result));
_state = State::Failed;
return Stream::Invalid;
}
Expand Down Expand Up @@ -336,7 +336,7 @@ namespace Death { namespace IO { namespace Compression {
{
auto result = LZ4F_createCompressionContext(&_ctx, LZ4F_VERSION);
if (LZ4F_isError(result)) {
LOGE("LZ4F_createCompressionContext() failed with error %0x%zx (%s)", result, LZ4F_getErrorName(result));
LOGE("LZ4F_createCompressionContext() failed with error 0x%zx (%s)", result, LZ4F_getErrorName(result));
_state = State::Failed;
}

Expand All @@ -353,7 +353,7 @@ namespace Death { namespace IO { namespace Compression {

std::size_t headerSize = LZ4F_compressBegin(_ctx, &_outBuffer[0], _outCapacity, &kPrefs);
if (LZ4F_isError(result)) {
LOGE("LZ4F_compressBegin() failed with error %0x%zx (%s)", headerSize, LZ4F_getErrorName(headerSize));
LOGE("LZ4F_compressBegin() failed with error 0x%zx (%s)", headerSize, LZ4F_getErrorName(headerSize));
_state = State::Failed;
}

Expand Down Expand Up @@ -431,7 +431,7 @@ namespace Death { namespace IO { namespace Compression {
{
std::size_t compressedSize = LZ4F_flush(_ctx, &_outBuffer[0], _outCapacity, nullptr);
if (LZ4F_isError(compressedSize)) {
LOGE("LZ4F_flush() failed with error %0x%zx (%s)", compressedSize, LZ4F_getErrorName(compressedSize));
LOGE("LZ4F_flush() failed with error 0x%zx (%s)", compressedSize, LZ4F_getErrorName(compressedSize));
_state = State::Failed;
return false;
}
Expand Down Expand Up @@ -471,7 +471,7 @@ namespace Death { namespace IO { namespace Compression {
std::size_t compressedSize = LZ4F_compressUpdate(_ctx, &_outBuffer[0], _outCapacity,
buffer, bytesToWrite, nullptr);
if (LZ4F_isError(compressedSize)) {
LOGE("LZ4F_compressUpdate() failed with error %0x%zx (%s)", compressedSize, LZ4F_getErrorName(compressedSize));
LOGE("LZ4F_compressUpdate() failed with error 0x%zx (%s)", compressedSize, LZ4F_getErrorName(compressedSize));
_state = State::Failed;
return Stream::Invalid;
}
Expand All @@ -484,7 +484,7 @@ namespace Death { namespace IO { namespace Compression {
if (finish) {
std::size_t compressedSize = LZ4F_compressEnd(_ctx, &_outBuffer[0], _outCapacity, nullptr);
if (LZ4F_isError(compressedSize)) {
LOGE("LZ4F_compressEnd() failed with error %0x%zx (%s)", compressedSize, LZ4F_getErrorName(compressedSize));
LOGE("LZ4F_compressEnd() failed with error 0x%zx (%s)", compressedSize, LZ4F_getErrorName(compressedSize));
_state = State::Failed;
return Stream::Invalid;
}
Expand Down
Loading

0 comments on commit dc48325

Please sign in to comment.