FileSystem: Change file lookup to match all extensions
Previously, file lookup (ie. extension supplementing) would only try out a few predetermined extensions based on the asset type. This was not accurate in regard to RMXP's behavior, which will happily match "some_asset" against "some_asset.abcef" and try to open it. Some games make use of this quirk and rename their ogg audio files to "*.dat" or similar to thwart users from copying them. This change also makes it easier to read arbitrary formats supported by SDL_image without modifying mkxp.
This commit is contained in:
parent
87462fd7b0
commit
44eaaf5985
5 changed files with 172 additions and 167 deletions
src
|
@ -236,9 +236,10 @@ struct BitmapPrivate
|
|||
Bitmap::Bitmap(const char *filename)
|
||||
{
|
||||
SDL_RWops ops;
|
||||
const char *extension;
|
||||
shState->fileSystem().openRead(ops, filename, FileSystem::Image, false, &extension);
|
||||
SDL_Surface *imgSurf = IMG_LoadTyped_RW(&ops, 1, extension);
|
||||
char ext[8];
|
||||
|
||||
shState->fileSystem().openRead(ops, filename, false, ext, sizeof(ext));
|
||||
SDL_Surface *imgSurf = IMG_LoadTyped_RW(&ops, 1, ext);
|
||||
|
||||
if (!imgSurf)
|
||||
throw Exception(Exception::SDLError, "Error loading image '%s': %s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue