mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-07-28 01:51:49 +03:00
Load an unlimited amount of loose music (#1171)
* Load an unlimited amount of loose music Binary blobs can now store 128 tracks, and music can now be read from loose files. Unfortunately, the two cannot be used together -- loose music can still only use 16 tracks. This commit attempts to fix that, allowing for music playback by filename. * Rework music track loading The current "loose songs" system does not load files from custom assets. This is from the #412 PR, and is NOT the "extra loose songs" system that this PR implements, but they both work in the same area so I decided to squash both of these bugs at once (plus, it helped clean up the code and make a saner system, so...) This commit also allows "loose music" to override music stored in the `vvvvvvmusic.vvv` binary blob. When reading a blob, it will first check if a loose file exists at the current path it's trying to find a track at; if it exists, it will load that instead. If the blob does not exist, the system will try to locate all expected built-in tracks directly from the assets folder instead of doing that during blob loading. The `play` command has some safety removed due to an old exploit which needs to be kept -- `music(5b)` should play track 5. This is used in many levels and cannot be broken; unfortunately this means that we no longer get the nice error when a song fails to be played, but that's better than breaking a large amount of levels. This commit does NOT address loading a "extra" loose track overtop of a custom blob track, because with the current tooling, and the way it will most likely continue to work in the future, every single custom track in blobs have a completely empty path. If someone decides to modify their blob in a hex editor or makes their own tooling, this issue may show up again, but that is a problem which can and probably should be addressed at a later date. The required code to solve such a problem would be far more than what this PR should address, and for a situation so unlikely, it's easy enough to just avoid adding the same custom song twice, one in a music file, and one loose, because if you're making a level, you're probably going to use one or the other. * Fix mentioned issues from review
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "FileSystemUtils.h"
|
||||
|
||||
#include <physfs.h>
|
||||
#include <physfsrwops.h>
|
||||
#include <SDL.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@@ -959,6 +960,14 @@ fail:
|
||||
}
|
||||
}
|
||||
|
||||
SDL_RWops* FILESYSTEM_loadAssetRWops(const char* name)
|
||||
{
|
||||
char path[MAX_PATH];
|
||||
|
||||
getMountedPath(path, sizeof(path), name);
|
||||
return PHYSFSRWOPS_openRead(path);
|
||||
}
|
||||
|
||||
void FILESYSTEM_loadAssetToMemory(
|
||||
const char* name,
|
||||
unsigned char** mem,
|
||||
|
||||
Reference in New Issue
Block a user