mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2025-01-08 18:09:45 +01:00
Refactor TRACK_NAMES to take in a blob parameter
I'm going to introduce another binaryBlob object in to the mix, and I want to be able to re-use an existing FOREACH_TRACK #define without having to copy-paste it again. So, TRACK_NAMES now takes in a blob parameter, which will be passed to the temporary FOREACH_TRACK #define.
This commit is contained in:
parent
0ea1a0e28e
commit
f39174b3e3
3 changed files with 27 additions and 27 deletions
|
@ -183,8 +183,8 @@ std::vector<int> binaryBlob::getExtra()
|
|||
for (size_t i = 0; i < SDL_arraysize(m_headers); i += 1)
|
||||
{
|
||||
if (m_headers[i].valid
|
||||
#define FOREACH_TRACK(track_name) && SDL_strcmp(m_headers[i].name, track_name) != 0
|
||||
TRACK_NAMES
|
||||
#define FOREACH_TRACK(_, track_name) && SDL_strcmp(m_headers[i].name, track_name) != 0
|
||||
TRACK_NAMES(_)
|
||||
#undef FOREACH_TRACK
|
||||
) {
|
||||
result.push_back(i);
|
||||
|
|
|
@ -6,23 +6,23 @@
|
|||
/* Laaaazyyyyyyy -flibit */
|
||||
// #define VVV_COMPILEMUSIC
|
||||
|
||||
#define TRACK_NAMES \
|
||||
FOREACH_TRACK("data/music/0levelcomplete.ogg") \
|
||||
FOREACH_TRACK("data/music/1pushingonwards.ogg") \
|
||||
FOREACH_TRACK("data/music/2positiveforce.ogg") \
|
||||
FOREACH_TRACK("data/music/3potentialforanything.ogg") \
|
||||
FOREACH_TRACK("data/music/4passionforexploring.ogg") \
|
||||
FOREACH_TRACK("data/music/5intermission.ogg") \
|
||||
FOREACH_TRACK("data/music/6presentingvvvvvv.ogg") \
|
||||
FOREACH_TRACK("data/music/7gamecomplete.ogg") \
|
||||
FOREACH_TRACK("data/music/8predestinedfate.ogg") \
|
||||
FOREACH_TRACK("data/music/9positiveforcereversed.ogg") \
|
||||
FOREACH_TRACK("data/music/10popularpotpourri.ogg") \
|
||||
FOREACH_TRACK("data/music/11pipedream.ogg") \
|
||||
FOREACH_TRACK("data/music/12pressurecooker.ogg") \
|
||||
FOREACH_TRACK("data/music/13pacedenergy.ogg") \
|
||||
FOREACH_TRACK("data/music/14piercingthesky.ogg") \
|
||||
FOREACH_TRACK("data/music/predestinedfatefinallevel.ogg")
|
||||
#define TRACK_NAMES(blob) \
|
||||
FOREACH_TRACK(blob, "data/music/0levelcomplete.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/1pushingonwards.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/2positiveforce.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/3potentialforanything.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/4passionforexploring.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/5intermission.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/6presentingvvvvvv.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/7gamecomplete.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/8predestinedfate.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/9positiveforcereversed.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/10popularpotpourri.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/11pipedream.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/12pressurecooker.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/13pacedenergy.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/14piercingthesky.ogg") \
|
||||
FOREACH_TRACK(blob, "data/music/predestinedfatefinallevel.ogg")
|
||||
|
||||
struct resourceheader
|
||||
{
|
||||
|
|
|
@ -64,8 +64,8 @@ void musicclass::init()
|
|||
|
||||
#ifdef VVV_COMPILEMUSIC
|
||||
binaryBlob musicWriteBlob;
|
||||
#define FOREACH_TRACK(track_name) musicWriteBlob.AddFileToBinaryBlob(track_name);
|
||||
TRACK_NAMES
|
||||
#define FOREACH_TRACK(blob, track_name) blob.AddFileToBinaryBlob(track_name);
|
||||
TRACK_NAMES(musicWriteBlob)
|
||||
#undef FOREACH_TRACK
|
||||
|
||||
musicWriteBlob.writeBinaryBlob("data/BinaryMusic.vvv");
|
||||
|
@ -87,11 +87,11 @@ void musicclass::init()
|
|||
int index;
|
||||
SDL_RWops *rw;
|
||||
|
||||
#define FOREACH_TRACK(track_name) \
|
||||
index = musicReadBlob.getIndex(track_name); \
|
||||
if (index >= 0 && index < musicReadBlob.max_headers) \
|
||||
#define FOREACH_TRACK(blob, track_name) \
|
||||
index = blob.getIndex(track_name); \
|
||||
if (index >= 0 && index < blob.max_headers) \
|
||||
{ \
|
||||
rw = SDL_RWFromMem(musicReadBlob.getAddress(index), musicReadBlob.getSize(index)); \
|
||||
rw = SDL_RWFromMem(blob.getAddress(index), blob.getSize(index)); \
|
||||
if (rw == NULL) \
|
||||
{ \
|
||||
printf("Unable to read music file header: %s\n", SDL_GetError()); \
|
||||
|
@ -102,7 +102,7 @@ void musicclass::init()
|
|||
} \
|
||||
}
|
||||
|
||||
TRACK_NAMES
|
||||
TRACK_NAMES(musicReadBlob)
|
||||
|
||||
num_mmmmmm_tracks += musicTracks.size();
|
||||
|
||||
|
@ -123,7 +123,7 @@ void musicclass::init()
|
|||
int index;
|
||||
SDL_RWops *rw;
|
||||
|
||||
TRACK_NAMES
|
||||
TRACK_NAMES(musicReadBlob)
|
||||
|
||||
#undef FOREACH_TRACK
|
||||
|
||||
|
|
Loading…
Reference in a new issue