Skip to content

Commit

Permalink
Work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
skhaz committed Oct 28, 2023
1 parent 7c2880e commit 88d9953
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 7 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
runs-on: windows-latest

steps:
- name: Check Installed Software
run: where git & where python & where pip
shell: cmd

- name: Checkout
uses: actions/checkout@v4

- name: Install Conan
uses: conan-io/conan-setup-python@v2
with:
python-version: 3.12
conan-version: 2.0.13

- name: Set Conan Folder
run: conan config set storage.path=${{ github.workspace }}\packages

- name: Install Dependencies
run: conan install . -if build
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ find_package(nlohmann_json CONFIG REQUIRED)
find_package(openal CONFIG REQUIRED)
find_package(PhysFS CONFIG REQUIRED)
find_package(SDL2 CONFIG REQUIRED)
find_package(sol2 CONFIG REQUIRED)
find_package(SQLite3 CONFIG REQUIRED)
find_package(zeromq CONFIG REQUIRED)
find_package(zstd CONFIG REQUIRED)
Expand All @@ -46,6 +47,7 @@ target_link_libraries(${PROJECT_NAME} OpenAL::OpenAL)
target_link_libraries(${PROJECT_NAME} physfs-static)
target_link_libraries(${PROJECT_NAME} SDL2::SDL2-static)
target_link_libraries(${PROJECT_NAME} SDL2::SDL2main)
target_link_libraries(${PROJECT_NAME} sol2::sol2)
target_link_libraries(${PROJECT_NAME} SQLite::SQLite3)
target_link_libraries(${PROJECT_NAME} libzmq-static)
target_link_libraries(${PROJECT_NAME} zstd::libzstd_static)
1 change: 1 addition & 0 deletions conanfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ nlohmann_json/3.11.2
openal/1.22.2
physfs/3.0.2
sdl/2.28.3
sol2/3.3.1
sqlite3/3.43.2
zeromq/4.3.4
zstd/1.5.5
Expand Down
7 changes: 4 additions & 3 deletions src/filesystem.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "filesystem.hpp"

void filesystem::mount(const std::string &filename, const std::string &mountpoint) {
if (PHYSFS_mount(filename.c_str(), mountpoint.c_str(), true) == 0) {
throw std::runtime_error(fmt::format("[PHYSFS_mount] Failed to mount {} to {}", filename, mountpoint));
void filesystem::mount(const std::string_view &filename, const std::string_view &mountpoint) {
if (PHYSFS_mount(filename.data(), mountpoint.data(), true) == 0) {
throw std::runtime_error(fmt::format(
"[PHYSFS_mount] Failed to mount '{}' to '{}'. Reason: '{}'", filename, mountpoint, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())));
}
}
2 changes: 1 addition & 1 deletion src/filesystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class filesystem {
public:
static void mount(const std::string &filename, const std::string &mountpoint);
static void mount(const std::string_view &filename, const std::string_view &mountpoint);

private:
filesystem() = default;
Expand Down
1 change: 1 addition & 0 deletions src/internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <curl/curl.h>
#include <fmt/core.h>
#include <physfs.h>
#include <sol/sol.hpp>

#include <cassert>
#include <iostream>
Expand Down
6 changes: 3 additions & 3 deletions src/pixmap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ pixmap::pixmap(const std::shared_ptr<renderer> renderer, const std::string &file
result = avifDecoderSetIOMemory(decoder, reinterpret_cast<const uint8_t *>(&buffer[0]), buffer.size());
if (result != AVIF_RESULT_OK) {
avifDecoderDestroy(decoder);
throw std::runtime_error(fmt::format("[avifDecoderSetIOMemory] Error while setting IO on avifDecoder: {}, error: {}", filename, avifResultToString(result)));
throw std::runtime_error(fmt::format("[avifDecoderSetIOMemory] Error while setting IO on AVIF: {}, error: {}", filename, avifResultToString(result)));
}

result = avifDecoderParse(decoder);
if (result != AVIF_RESULT_OK) {
avifDecoderDestroy(decoder);
throw std::runtime_error(fmt::format("[avifDecoderParse] Error while parsing avifDecoder: {}, error: {}", filename, avifResultToString(result)));
throw std::runtime_error(fmt::format("[avifDecoderParse] Error while parsing AVIF: {}, error: {}", filename, avifResultToString(result)));
}

result = avifDecoderNextImage(decoder);
if (result != AVIF_RESULT_OK) {
avifDecoderDestroy(decoder);
throw std::runtime_error(fmt::format("[avifDecoderNextImage] Error while decoding avifDecoder: {}, error: {}", filename, avifResultToString(result)));
throw std::runtime_error(fmt::format("[avifDecoderNextImage] Error while decoding AVIF: {}, error: {}", filename, avifResultToString(result)));
}

_width = decoder->image->width;
Expand Down

0 comments on commit 88d9953

Please sign in to comment.