mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-11-16 16:09:42 +01:00
3f46c5ac5c
This seems to be a comment left by Ethan that he never got around to. So I did it for him. What I've done is made it so FileSystemUtils.cpp knows what a binary blob is, and moved the binary blob loading code directly to FileSystemUtils.cpp. To do this, I removed the private access modifier from binaryBlob - I don't think we'll need it, and anyways when we move to C we can't use it. Along the way, I also cleaned up the style of the function a bit - the null termination offset is no longer hardcoded, and the function no longer mixes code and declarations together in the same block. I also noticed that when printing all the filenames at the end, a single invalid header would stop the whole loop instead of just being skipped over... this seems to be a bug to me, so I've made it so invalid headers just get skipped over instead of stopping the whole loop. In FileSystemUtils.h, I used a forward declaration. In hindsight, incomplete forward declarations should basically always be done in header files if possible, otherwise this introduces the possibility of transitive includes - if a file includes this header and it does a full include, the file is silently able to use the full header, whereas if it's a forward declaration, then the moment the file tries to use the full header it fails, and then it's forced to include the full header for itself. But uh, that's a code cleanup for later.
66 lines
1.7 KiB
C++
66 lines
1.7 KiB
C++
#ifndef BINARYBLOB_H
|
|
#define BINARYBLOB_H
|
|
|
|
#include <stddef.h>
|
|
|
|
/* Laaaazyyyyyyy -flibit */
|
|
// #define VVV_COMPILEMUSIC
|
|
|
|
#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
|
|
{
|
|
char name[48];
|
|
int start_UNUSED;
|
|
int size;
|
|
bool valid;
|
|
};
|
|
|
|
class binaryBlob
|
|
{
|
|
public:
|
|
binaryBlob(void);
|
|
|
|
#ifdef VVV_COMPILEMUSIC
|
|
void AddFileToBinaryBlob(const char* _path);
|
|
|
|
void writeBinaryBlob(const char* _name);
|
|
#endif
|
|
|
|
bool unPackBinary(const char* _name);
|
|
|
|
int getIndex(const char* _name);
|
|
|
|
int getSize(int _index);
|
|
|
|
bool nextExtra(size_t* start);
|
|
|
|
char* getAddress(int _index);
|
|
|
|
void clear(void);
|
|
|
|
static const int max_headers = 128;
|
|
|
|
int numberofHeaders;
|
|
resourceheader m_headers[max_headers];
|
|
char* m_memblocks[max_headers];
|
|
};
|
|
|
|
|
|
#endif /* BINARYBLOB_H */
|