Skip to content

Commit

Permalink
Merge branch 'master' into feature/latrine
Browse files Browse the repository at this point in the history
  • Loading branch information
dvincent56 authored May 30, 2024
2 parents d3f2841 + e5c653a commit 4b17f80
Show file tree
Hide file tree
Showing 777 changed files with 5,558 additions and 2,672 deletions.
10 changes: 7 additions & 3 deletions .ci_scripts/build_upload.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if ("${env:COMPILER}" -eq "msvc") {
CopyFile ext\SDL2\SDL2-${env:SDL_VERSION}\lib\x64\SDL2.dll .
CopyFile ext\SDL2\SDL2_mixer-${env:SDL_MIXER_VERSION}\lib\x64\SDL2_mixer.dll .
} elseif ("${env:COMPILER}" -eq "msvc-arm64") {
$suffix = "windows-msvc-arm64"
$suffix = "windows-arm64"
CopyFile build/RelWithDebInfo/augustus.exe .
CopyFile build/RelWithDebInfo/augustus.pdb .
CopyFile ext\SDL2\SDL2\SDL2.dll .
Expand Down Expand Up @@ -107,13 +107,17 @@ if (!$env:UPLOAD_TOKEN) {
exit
}

echo "Uploading $deploy_file to $repo/windows/$version"
curl -u "$env:UPLOAD_TOKEN" -T "deploy/$deploy_file" "https://augustus.josecadete.net/upload/$repo/windows/$version/${deploy_file}"
echo "Uploading $deploy_file to $repo/$suffix/$version"
curl -u "$env:UPLOAD_TOKEN" -T "deploy/$deploy_file" "https://augustus.josecadete.net/upload/$repo/$suffix/$version/${deploy_file}"
if (!$?) {
throw "Unable to upload"
}
echo "Uploaded. URL: https://augustus.josecadete.net/$repo.html"

if ($suffix -ne "windows") {
exit
}

if (!$packed_assets) {
echo "Packing the assets"

Expand Down
7 changes: 7 additions & 0 deletions .ci_scripts/build_upload.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ case "$DEPLOY" in
DEPLOY_FILE=augustus-$VERSION-linux-x86_64.zip
cp "${build_dir}/augustus.zip" "deploy/$DEPLOY_FILE"
;;
"flatpak")
PACKAGE=linux-flatpak
DEPLOY_FILE=augustus-$VERSION-linux.flatpak
flatpak build-export export repo
flatpak build-bundle export augustus.flatpak com.github.keriew.augustus --runtime-repo=https://flathub.org/repo/flathub.flatpakrepo
cp augustus.flatpak "deploy/$DEPLOY_FILE"
;;
"vita")
PACKAGE=vita
DEPLOY_FILE=augustus-$VERSION-vita.vpk
Expand Down
6 changes: 6 additions & 0 deletions .ci_scripts/install_dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ mkdir -p deps
if [ "$BUILD_TARGET" == "appimage" ] || [ "$BUILD_TARGET" == "codeql-cpp" ]
then
sudo add-apt-repository universe && sudo add-apt-repository ppa:savoury1/multimedia && sudo apt-get update && sudo apt-get -y install libgl1-mesa-dev libsdl2-dev libsdl2-mixer-dev libfuse2
elif [ "$BUILD_TARGET" == "flatpak" ]
then
sudo apt-get update && sudo apt-get -y install flatpak-builder
sudo flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
sudo flatpak-builder repo res/com.github.keriew.augustus.json --install-deps-from=flathub --install-deps-only --delete-build-dirs
sudo rm -R .flatpak-builder
elif [ ! -z "$SDL_VERSION" ] && [ ! -z "$SDL_MIXER_VERSION" ]
then
if [ "$BUILD_TARGET" == "mac" ]
Expand Down
4 changes: 4 additions & 0 deletions .ci_scripts/run_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ case "$BUILD_TARGET" in
zip -r augustus.zip augustus.dmg
fi
;;
"flatpak")
flatpak-builder repo res/com.github.keriew.augustus.json --install-deps-from=flathub --keep-build-dirs
cp .flatpak-builder/build/augustus/res/version.txt res/version.txt
;;
"appimage")
cp -r res/maps ./build
cp -r res/manual ./build
Expand Down
2 changes: 2 additions & 0 deletions .ci_scripts/run_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ case "$BUILD_TARGET" in
"mac")
mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" ..
;;
"flatpak")
;;
"appimage")
mkdir build && cd build && cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
;;
Expand Down
4 changes: 2 additions & 2 deletions .ci_scripts/setup_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ case "$BUILD_TARGET" in
# Note: Using a tagged version of the container to make sure that it's not updated unexpectedly
# You can update the tag by obtaining a recent one from here: https://hub.docker.com/r/gnuton/vitasdk-docker/tags
# Make sure that it compiles correctly and runs on a Vita prior to pushing the change
docker run -d --name vitasdk --workdir /build/git -v "${PWD}:/build/git" gnuton/vitasdk-docker:20230823 tail -f /dev/null
docker run -d --name vitasdk --workdir /build/git -v "${PWD}:/build/git" gnuton/vitasdk-docker:20240412 tail -f /dev/null
;;
"switch")
# You can obtain a recent devkitA64 image from https://hub.docker.com/repository/docker/devkitpro/devkita64/general
# As for Vita above, make sure that it compiles correctly and runs on a Switch prior to pushing the change
docker run -d --name switchdev --workdir /build/git -v "${PWD}:/build/git" devkitpro/devkita64:20231108 tail -f /dev/null
docker run -d --name switchdev --workdir /build/git -v "${PWD}:/build/git" devkitpro/devkita64:20240324 tail -f /dev/null
;;
"android")
# Decrypt the key files
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ jobs:
fail-fast: false
matrix:
include:
- name: Linux Flatpak
os: ubuntu-20.04
BUILD_TARGET: flatpak
DEPLOY: flatpak
- name: Linux AppImage
os: ubuntu-20.04
BUILD_TARGET: appimage
Expand Down Expand Up @@ -129,7 +133,6 @@ jobs:
- name: Windows MSVC ARM64
cache-key: msvc-arm64
COMPILER: msvc-arm64
SKIP_UPLOAD: true
name: ${{ matrix.name }}
runs-on: windows-latest
env:
Expand Down
12 changes: 7 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/")

set(CMAKE_C_STANDARD 99)

if(CMAKE_COMPILER_IS_GNUCC)
if(CMAKE_COMPILER_IS_GNUCC OR MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Werror=implicit-function-declaration")
if(CMAKE_C_COMPILER_VERSION VERSION_GREATER 5.0)
if(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_GREATER 5.0)
set(CMAKE_C_FLAGS "-Werror=incompatible-pointer-types -Werror=int-conversion -Wstrict-prototypes ${CMAKE_C_FLAGS}")
endif()

if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 7.0)
set_source_files_properties(${SOURCE_FILES} PROPERTIES COMPILE_FLAGS "-Walloc-zero -Wdouble-promotion -Wduplicated-branches -Wduplicated-cond -Wformat=2 -Wformat-signedness -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-prototypes -Wshadow -Wundef -Wunused-macros -Wwrite-strings")
endif()
elseif(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND "${CMAKE_BUILD_TYPE}" MATCHES "Debug" AND NOT ${TARGET_PLATFORM} STREQUAL "android")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=undefined -Wall -Wextra -Wpedantic -Wdocumentation -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-compare -Wno-unused-but-set-variable")
endif()

set(PROJECT_VERSION_MAJOR 4)
Expand Down Expand Up @@ -88,7 +88,7 @@ elseif (EXISTS "${CMAKE_SOURCE_DIR}/.git")
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND git diff-index --quiet HEAD --
COMMAND git diff --quiet HEAD --
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
RESULT_VARIABLE VERSION_COMMIT_DIRTY
)
Expand Down Expand Up @@ -202,6 +202,7 @@ set(PLATFORM_FILES
${PROJECT_SOURCE_DIR}/src/platform/screen.c
${PROJECT_SOURCE_DIR}/src/platform/sound_device.c
${PROJECT_SOURCE_DIR}/src/platform/touch.c
${PROJECT_SOURCE_DIR}/src/platform/user_path.c
${PROJECT_SOURCE_DIR}/src/platform/version.c
${PROJECT_SOURCE_DIR}/src/platform/virtual_keyboard.c
)
Expand Down Expand Up @@ -654,6 +655,7 @@ set(WINDOW_FILES
${PROJECT_SOURCE_DIR}/src/window/text_input.c
${PROJECT_SOURCE_DIR}/src/window/trade_opened.c
${PROJECT_SOURCE_DIR}/src/window/trade_prices.c
${PROJECT_SOURCE_DIR}/src/window/user_path_setup.c
${PROJECT_SOURCE_DIR}/src/window/victory_dialog.c
${PROJECT_SOURCE_DIR}/src/window/video.c
)
Expand Down Expand Up @@ -780,7 +782,7 @@ endif()

if(${TARGET_PLATFORM} STREQUAL "emscripten")
set(CMAKE_EXECUTABLE_SUFFIX .html)
set_target_properties(${SHORT_NAME} PROPERTIES LINK_FLAGS "-lidbfs.js -s SINGLE_FILE=1 -s DEMANGLE_SUPPORT=1 -s DYNCALLS=1 --shell-file ${PROJECT_SOURCE_DIR}/res/shell.html --embed-file ${ASSETS_DIR}@/assets -s INITIAL_MEMORY=268435456 -s ALLOW_MEMORY_GROWTH=1 -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -s SAFE_HEAP=1 -s INVOKE_RUN=0 -s EXPORTED_FUNCTIONS=[\"_main\"] -s EXPORTED_RUNTIME_METHODS=[\"callMain\",\"FS\"] -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[\"$autoResumeAudioContext\"] --bind")
set_target_properties(${SHORT_NAME} PROPERTIES LINK_FLAGS "-lidbfs.js -s SINGLE_FILE=1 -s DYNCALLS=1 --shell-file ${PROJECT_SOURCE_DIR}/res/shell.html --embed-file ${ASSETS_DIR}@/assets -s INITIAL_MEMORY=268435456 -s ALLOW_MEMORY_GROWTH=1 -s DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=0 -s SAFE_HEAP=1 -s INVOKE_RUN=0 -s EXPORTED_FUNCTIONS=[\"_main\"] -s EXPORTED_RUNTIME_METHODS=[\"callMain\",\"FS\"] -s DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[\"$autoResumeAudioContext\"] --bind")
endif()

if(MSVC)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Chat: [Discord](http://www.discord.gg/GamerZakh) (kindly hosted by GamerZakh)
|----------|----------------|----------------|
| Windows | [![Download](https://augustus.josecadete.net/badge/release/windows.svg)](https://augustus.josecadete.net/download/latest/release/windows) | [![Download](https://augustus.josecadete.net/badge/development/windows.svg)](https://augustus.josecadete.net/download/latest/development/windows) [(Download development assets)](https://augustus.josecadete.net/download/latest/development/assets) |
| Linux AppImage | [![Download](https://augustus.josecadete.net/badge/release/linux-appimage.svg)](https://augustus.josecadete.net/download/latest/release/linux-appimage) | [![Download](https://augustus.josecadete.net/badge/development/linux-appimage.svg)](https://augustus.josecadete.net/download/latest/development/linux-appimage)
| Linux Flatpak | Next release! | [![Download](https://augustus.josecadete.net/badge/development/linux-flatpak.svg)](https://augustus.josecadete.net/download/latest/development/linux-flatpak)
| Mac | [![Download](https://augustus.josecadete.net/badge/release/mac.svg)](https://augustus.josecadete.net/download/latest/release/mac) | [![Download](https://augustus.josecadete.net/badge/development/mac.svg)](https://augustus.josecadete.net/download/latest/development/mac) |
| PS Vita | [![Download](https://augustus.josecadete.net/badge/release/vita.svg)](https://augustus.josecadete.net/download/latest/release/vita)| [![Download](https://augustus.josecadete.net/badge/development/vita.svg)](https://augustus.josecadete.net/download/latest/development/vita) |
| Switch | [![Download](https://augustus.josecadete.net/badge/release/switch.svg)](https://augustus.josecadete.net/download/latest/release/switch) | [![Download](https://augustus.josecadete.net/badge/development/switch.svg)](https://augustus.josecadete.net/download/latest/development/switch) |
Expand Down
2 changes: 1 addition & 1 deletion android/SDL2/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ tasks.register('findSDL2Mixer') {
}

android {
ndkVersion "26.2.11394342"
ndkVersion "26.3.11579264"

defaultConfig {
compileSdk 34
Expand Down
2 changes: 1 addition & 1 deletion android/augustus/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ tasks.register('getVersion') {
}

android {
ndkVersion "26.2.11394342"
ndkVersion "26.3.11579264"

defaultConfig {
compileSdk 34
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
}
}

@SuppressWarnings("unused")
public float getScreenDensity() {
return getResources().getDisplayMetrics().density;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,23 +83,32 @@ private static FileInfo findFile(Activity activity, FileInfo folder, String file
}

private static FileInfo getDirectoryFromPath(Activity activity, String[] path) {
FileInfo currentDir = FileInfo.base;
ArrayList<FileInfo> dirList = new ArrayList<>();
dirList.add(FileInfo.base);

for (int i = 0; i < path.length - 1; ++i) {
currentDir = findFile(activity, currentDir, path[i]);
if (currentDir == null || !currentDir.isDirectory()) {
return null;
if (path[i].equals("..")) {
if (dirList.size() == 1) {
return null;
}
dirList.remove(dirList.size() - 1);
} else if (!path[i].isEmpty() && !path[i].equals(".")) {
FileInfo currentDir = findFile(activity, dirList.get(dirList.size() - 1), path[i]);
if (currentDir == null || !currentDir.isDirectory()) {
return null;
}
dirList.add(currentDir);
}
}
return currentDir;
return dirList.get(dirList.size() - 1);
}

private static FileInfo getFileFromPath(AugustusMainActivity activity, String filePath) {
try {
if (baseUri == Uri.EMPTY) {
return null;
}
String[] filePart = filePath.split("(\\|/)");
String[] filePart = filePath.split("[\\\\/]");
FileInfo dirInfo = getDirectoryFromPath(activity, filePart);
if (dirInfo == null) {
return null;
Expand Down Expand Up @@ -146,6 +155,7 @@ public static FileInfo[] getDirectoryFileList(AugustusMainActivity activity, Str
return fileList.toArray(result);
}

@SuppressWarnings("unused")
public static boolean deleteFile(AugustusMainActivity activity, String filePath) {
try {
FileInfo fileInfo = getFileFromPath(activity, filePath);
Expand Down Expand Up @@ -212,8 +222,9 @@ public static int openFileDescriptor(AugustusMainActivity activity, String fileP
fileInfo.updateModifiedTime();
}
}
ParcelFileDescriptor pfd = activity.getContentResolver().openFileDescriptor(fileUri, internalMode);
return (pfd == null) ? 0 : pfd.detachFd();
try (ParcelFileDescriptor pfd = activity.getContentResolver().openFileDescriptor(fileUri, internalMode)) {
return (pfd == null) ? 0 : pfd.detachFd();
}
} catch (Exception e) {
Log.e("augustus", "Error in openFileDescriptor: " + e);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:8.3.0'
classpath 'com.android.tools.build:gradle:8.4.0'
classpath 'com.github.triplet.gradle:play-publisher:3.7.0'
}
}
Expand Down
1 change: 0 additions & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,5 @@ org.gradle.configureondemand=true
org.gradle.caching=true
android.useAndroidX=true
android.enableJetifier=false
android.defaults.buildfeatures.buildconfig=true
android.nonTransitiveRClass=true
android.nonFinalResIds=false
2 changes: 1 addition & 1 deletion android/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
6 changes: 3 additions & 3 deletions ext/spng/spng.c
Original file line number Diff line number Diff line change
Expand Up @@ -2362,7 +2362,7 @@ static int read_non_idat_chunks(spng_ctx *ctx)
ctx->undo = NULL;
ctx->prev_stored = ctx->stored;

while( !(ret = read_header(ctx)))
while( (ret = read_header(ctx)) == 0 )
{
if(ctx->discard)
{
Expand Down Expand Up @@ -3914,7 +3914,7 @@ int spng_decode_image(spng_ctx *ctx, void *out, size_t len, int fmt, int flags)

if(f.apply_trns)
{
uint16_t mask = ~0;
uint16_t mask = (uint16_t)~0;
if(ctx->ihdr.bit_depth < 16) mask = (1 << ctx->ihdr.bit_depth) - 1;

if(fmt & (SPNG_FMT_RGBA8 | SPNG_FMT_RGBA16))
Expand Down Expand Up @@ -4933,7 +4933,7 @@ spng_ctx *spng_ctx_new2(struct spng_alloc *alloc, int flags)
ctx->image_options = image_defaults;
ctx->text_options = text_defaults;

ctx->optimize_option = ~0;
ctx->optimize_option = ~0u;
ctx->encode_flags.filter_choice = SPNG_FILTER_CHOICE_ALL;

ctx->flags = flags;
Expand Down
6 changes: 3 additions & 3 deletions ext/sxml/sxml.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ static const char* str_findstr (const char* start, const char* end, const char*

static BOOL str_startswith (const char* start, const char* end, const char* prefix)
{
long nbytes;
size_t nbytes;
assert (start <= end);

nbytes= strlen (prefix);
if (end - start < nbytes)
if ((size_t) (end - start) < nbytes)
return FALSE;

return memcmp (prefix, start, nbytes) == 0;
Expand Down Expand Up @@ -543,7 +543,7 @@ sxmlerr_t sxml_parse(sxml_t *state, const char *buffer, UINT bufferlen, sxmltok_
const char* lt= str_findchr (start, end, '<');
while (buffer_fromoffset (&args, temp.bufferpos) != lt)
{
sxmlerr_t err= parse_characters (&temp, &args, lt);
err= parse_characters (&temp, &args, lt);
if (err != SXML_SUCCESS)
return err;

Expand Down
Loading

0 comments on commit 4b17f80

Please sign in to comment.