diff --git a/CHANGELOG.md b/CHANGELOG.md index 21f826216..d0f0ad1d4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,14 @@ All notable changes to [ChaiLove](https://github.com/RobLoach/ChaiLove) will be The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## 0.26.1 - 2018-09-19 +### Fixes +- Fixed `mount()` with relative paths +- Fixed mounting of saves and system directories +- Fix for compiling `nearest_resampler.c` without `STATIC_LINKING` ([#312](https://github.com/libretro/libretro-chailove/pull/312)) + - By [@twinaphex](https://github.com/twinaphex) +- Fix rewind by removing compression of save states + ## 0.26.0 - 2018-09-13 ### Features - Added a global `require()` function to load modules ([#308](https://github.com/libretro/libretro-chailove/pull/308)) diff --git a/Makefile.common b/Makefile.common index 56f92884d..ac37104ce 100644 --- a/Makefile.common +++ b/Makefile.common @@ -48,7 +48,6 @@ ifneq ($(STATIC_LINKING), 1) ) endif - # stb_vorbis #SOURCES_C += $(CORE_DIR)/vendor/stb/stb_vorbis.c FLAGS += -DHAVE_STB_VORBIS diff --git a/docs/Doxyfile b/docs/Doxyfile index 44e127ada..ee1fc3823 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -23,7 +23,7 @@ PROJECT_NAME = "ChaiLove API" # This could be handy for archiving the generated documentation or # if some version control system is used. -PROJECT_NUMBER = "0.26.0" +PROJECT_NUMBER = "0.26.1" # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. diff --git a/examples/snake/Snake.chai b/examples/snake/Snake.chai index b74adf73b..a077d63c7 100644 --- a/examples/snake/Snake.chai +++ b/examples/snake/Snake.chai @@ -47,7 +47,7 @@ global T def conf(t) { t.window.width = WIDTH * gridScale t.window.height = HEIGHT * gridScale - t.version = "0.26.0" + t.version = "0.26.1" } /** diff --git a/src/ChaiLove.cpp b/src/ChaiLove.cpp index 427da1a59..dc75b9393 100644 --- a/src/ChaiLove.cpp +++ b/src/ChaiLove.cpp @@ -56,7 +56,7 @@ void ChaiLove::quit(void) { window.unload(); } -bool ChaiLove::load(const std::string& file) { +bool ChaiLove::load(const std::string& file, const void* data) { // Display a welcome message from ChaiLove. #ifndef GIT_VERSION #define GIT_VERSION "" @@ -68,7 +68,7 @@ bool ChaiLove::load(const std::string& file) { sound.load(); // Initalize the file system. - bool loaded = filesystem.init(file); + bool loaded = filesystem.init(file, data); if (!loaded) { std::cout << "[ChaiLove] [filesystem] Error loading " << file << std::endl; return false; diff --git a/src/ChaiLove.h b/src/ChaiLove.h index 242747b2f..e8b39e980 100644 --- a/src/ChaiLove.h +++ b/src/ChaiLove.h @@ -48,8 +48,8 @@ #define CHAILOVE_VERSION_MAJOR 0 #define CHAILOVE_VERSION_MINOR 26 -#define CHAILOVE_VERSION_PATCH 0 -#define CHAILOVE_VERSION_STRING "0.26.0" +#define CHAILOVE_VERSION_PATCH 1 +#define CHAILOVE_VERSION_STRING "0.26.1" #include "SDL.h" #include "libretro.h" @@ -105,7 +105,7 @@ class ChaiLove { ~ChaiLove(); void quit(void); - bool load(const std::string& file); + bool load(const std::string& file, const void* data); void update(); void draw(); void reset(); diff --git a/src/libretro.cpp b/src/libretro.cpp index f988016c4..ee6aee428 100644 --- a/src/libretro.cpp +++ b/src/libretro.cpp @@ -328,7 +328,7 @@ bool retro_load_game(const struct retro_game_info *info) { if (gamePath == ".") { gamePath = "main.chai"; } - return ChaiLove::getInstance()->load(gamePath); + return ChaiLove::getInstance()->load(gamePath, info->data); } /** diff --git a/src/love/config.h b/src/love/config.h index 955579c11..9e97f2011 100644 --- a/src/love/config.h +++ b/src/love/config.h @@ -19,7 +19,7 @@ namespace love { * * @code * def conf(t) { - * t.version = "0.26.0" // Version of ChaiLove + * t.version = "0.26.1" // Version of ChaiLove * t.identity = "mygame" // Machine name of your game * t.window.title = "My Game" // Human-readable name * t.window.width = 1024 // Game width diff --git a/src/love/filesystem.cpp b/src/love/filesystem.cpp index d2e701ff5..7df8e11f2 100644 --- a/src/love/filesystem.cpp +++ b/src/love/filesystem.cpp @@ -17,7 +17,7 @@ namespace love { /** * Initialize the file system. */ -bool filesystem::init(const std::string& file) { +bool filesystem::init(const std::string& file, const void* data) { if (PHYSFS_isInit() == 0) { // Initialize PhysFS if (PHYSFS_init(NULL) == 0) { @@ -57,16 +57,16 @@ void filesystem::mountlibretro() { const char *assets_dir = NULL; const char *save_dir = NULL; if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY, &system_dir) && system_dir) { - mount(system_dir, "libretro/system"); + mount(system_dir, "/libretro/system"); } if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_CORE_ASSETS_DIRECTORY, &assets_dir) && assets_dir) { - mount(assets_dir, "libretro/assets"); + mount(assets_dir, "/libretro/assets"); } if (ChaiLove::environ_cb(RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY, &save_dir) && save_dir) { save_dir = *save_dir ? save_dir : system_dir; - mount(save_dir, "libretro/saves"); + mount(save_dir, "/libretro/saves"); } else { - mount(save_dir = system_dir, "libretro/saves"); + mount(save_dir = system_dir, "/libretro/saves"); } // Ensure the write directory is set to the Save Directory. @@ -227,13 +227,44 @@ bool filesystem::mount(const std::string& archive, const std::string& mountpoint if (archive.length() <= 0 || mountpoint.length() <= 0) { return false; } + + // Display a message. std::cout << "[ChaiLove] [filesystem] Mounting " << archive << " as " << mountpoint << std::endl; - int returnValue = PHYSFS_mount(archive.c_str(), mountpoint.c_str(), 0); - if (returnValue == 0) { - std::cout << "[ChaiLove] [filesystem] Error mounting: " << getLastError() << std::endl; + + // Use the simple mount method if we're mounting the root directory. + if (mountpoint == "/") { + int returnValue = PHYSFS_mount(archive.c_str(), mountpoint.c_str(), 0); + if (returnValue == 0) { + std::cout << "[ChaiLove] [filesystem] Error mounting /: " << getLastError() << std::endl; + return false; + } + return true; + } + + // See if we're mounting a file. + if (isFile(archive)) { + // Mount using a handle instead, since we're doing another archive. + PHYSFS_File* file = openFile(archive); + if (file != NULL) { + if (PHYSFS_mountHandle(file, archive.c_str(), mountpoint.c_str(), 1) == 0) { + std::cout << "[ChaiLove] [filesystem] Error mounting file: " << getLastError() << std::endl; + return false; + } + return true; + } return false; } - return true; + + // Check if we're mounting a directory. + if (isDirectory(archive)) { + int returnVal = PHYSFS_mount(archive.c_str(), mountpoint.c_str(), 0); + if (returnVal == 0) { + std::cout << "[ChaiLove] [filesystem] Error mounting directory: " << getLastError() << std::endl; + return false; + } + return true; + } + return false; } /** diff --git a/src/love/filesystem.h b/src/love/filesystem.h index da400cf70..bcbaa8fb6 100644 --- a/src/love/filesystem.h +++ b/src/love/filesystem.h @@ -35,7 +35,7 @@ class filesystem { bool load(const std::string& file); void mountlibretro(); - bool init(const std::string& file); + bool init(const std::string& file, const void* data); bool unload(); SDL_RWops* openRW(const std::string& filename); char* readChar(const std::string& filename); diff --git a/src/love/script.h b/src/love/script.h index f660f1b43..73f89eb18 100644 --- a/src/love/script.h +++ b/src/love/script.h @@ -53,7 +53,7 @@ class script { * t.console = false * * // The ChaiLove version this game was made for. - * t.version = "0.26.0" + * t.version = "0.26.1" * * // The width and height of the game. * t.window.width = 1024 diff --git a/test/main.chai b/test/main.chai index 14f7e41dc..26e605b42 100644 --- a/test/main.chai +++ b/test/main.chai @@ -15,7 +15,7 @@ def conf(t) { t.window.width = 460 t.window.height = 320 t.console = true - t.version = "0.26.0" + t.version = "0.26.1" } def load() { diff --git a/test/unittests/filesystem.chai b/test/unittests/filesystem.chai index 943224e1b..057ff65a3 100644 --- a/test/unittests/filesystem.chai +++ b/test/unittests/filesystem.chai @@ -65,8 +65,7 @@ var writeFileReturn = love.filesystem.write("test/createDirectoryTest/test.md", assert(writeFileReturn, "love.filesystem.write()") // mount() -// @TODO: Figure out how to have the mount() point be relative to the origin. -var mountResult = love.filesystem.mount("test/unittests/assets/hello.zip", "hello") +var mountResult = love.filesystem.mount("assets/hello.zip", "hello") assert(mountResult, "love.filesystem.mount()") // mount() - Load @@ -74,11 +73,11 @@ var mountLoadResult = love.filesystem.read("hello/hello.txt") var mountLoadResultType = is_type(mountLoadResult, "string") assert(mountLoadResultType, " read()") if (mountLoadResultType) { - assert_equal(mountLoadResult.trim(), "Hello World!", " contents") + assert_equal(mountLoadResult.trim(), "Hello World!", " contents") } // unmount() -love.filesystem.unmount("test/unittests/assets/hello.zip") +love.filesystem.unmount("assets/hello.zip") assert_not(love.filesystem.exists("hello/hello.txt"), "love.filesystem.unmount()") // require()