mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 17:38:16 +03:00
Refactor how custom level stats are stored, read, and written
There were a few problems with the old way of doing things: (1) Level stats were an ad-hoc object. Basically, it's an object whose attributes are stored in separate arrays, instead of being an actual object with its attributes stored in one array. (2) Level filenames with pipes in them could cause trouble. This is because the filename attribute array was stored in the XML by being separated by pipes. (3) There was an arbitrary limit of only having 200 level stats, for whatever reason. To remedy this issue, I've made a new struct named CustomLevelStat that is a proper object. The separate attribute arrays have been replaced with a proper vector, which also doesn't have a size limit. For compatibility with versions 2.2 and below, I've kept being able to read the old format. This only happens if the new format doesn't exist. However, I also WRITE the old format as well, in case you want to go back to version 2.2 or below for whatever reason. It's slightly wasteful to have both, but that way there's no risk of breaking compatibility.
This commit is contained in:
@@ -76,6 +76,12 @@ struct MenuStackFrame
|
||||
enum Menu::MenuName name;
|
||||
};
|
||||
|
||||
struct CustomLevelStat
|
||||
{
|
||||
std::string name;
|
||||
int score; //0 - not played, 1 - finished, 2 - all trinkets, 3 - finished, all trinkets
|
||||
};
|
||||
|
||||
|
||||
class Game
|
||||
{
|
||||
@@ -363,9 +369,7 @@ public:
|
||||
void savecustomlevelstats();
|
||||
void updatecustomlevelstats(std::string clevel, int cscore);
|
||||
|
||||
std::string customlevelstats[200]; //string array containing level filenames
|
||||
int customlevelscore[200];//0 - not played, 1 - finished, 2 - all trinkets, 3 - finished, all trinkets
|
||||
int numcustomlevelstats;
|
||||
std::vector<CustomLevelStat> customlevelstats;
|
||||
bool customlevelstatsloaded;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user