Skip to content

Commit

Permalink
Merge pull request #316 from libretro/dev
Browse files Browse the repository at this point in the history
0.26.1
  • Loading branch information
RobLoach authored Sep 20, 2018
2 parents 9b95310 + e4aa141 commit 14a66ea
Show file tree
Hide file tree
Showing 13 changed files with 63 additions and 26 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 0 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ ifneq ($(STATIC_LINKING), 1)
)
endif


# stb_vorbis
#SOURCES_C += $(CORE_DIR)/vendor/stb/stb_vorbis.c
FLAGS += -DHAVE_STB_VORBIS
Expand Down
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion examples/snake/Snake.chai
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/ChaiLove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand All @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions src/ChaiLove.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/love/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
49 changes: 40 additions & 9 deletions src/love/filesystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/love/filesystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/love/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/main.chai
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
7 changes: 3 additions & 4 deletions test/unittests/filesystem.chai
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,19 @@ 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
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()
Expand Down

0 comments on commit 14a66ea

Please sign in to comment.