|
resonance 1.0.1
|
Persisted progress across the whole campaign. More...
#include <campaignstats.h>
Public Member Functions | |
| CampaignStats () | |
| Construct empty progress. | |
| virtual | ~CampaignStats () |
| void | RebuildLevelList () |
| Clear the level vector and rebuild it from the global level list. | |
| virtual void | Save (OBStream &stream) |
| Write the whole campaign record. | |
| virtual void | Load (IBStream &stream) |
| Read the whole campaign record. | |
| int | FindLevelIndex (const HxStr &name) |
| Find the record for a level by name. | |
| int | GetLevelBeaten (int nDifficulty, const HxStr &name) |
| Report whether a level has been beaten at a difficulty. | |
| int | GetLevelHighScore (int nDifficulty, const HxStr &name) |
| Report a level's high score at a difficulty. | |
| void | RecordLevelBeaten (int nDifficulty, const HxStr &name) |
| Record a level as beaten at a difficulty and recount what depends on it. | |
| void | RecordHighScore (int nDifficulty, const HxStr &name, int nScore) |
| Record a score for a level at a difficulty when it beats the high score. | |
| int | GetStageScoreBeaten (int nDifficulty, int nStage) |
| Report whether a stage's total score has reached its target at a difficulty. | |
| int | GetStageScore (int nDifficulty, int nStage) |
| Report a stage's total score at a difficulty. | |
| int | IsStageComplete (int nDifficulty, int nStage) |
| Report whether every required level of a stage is beaten at a difficulty. | |
| int | IsDifficultyComplete (int nDifficulty) |
| Report whether every stage of a difficulty is complete and every bonus level beaten. | |
| HxStr | GetBonusLevelName (int nDifficulty, int nStage) |
| Report the name of a stage's bonus level. | |
| int | IsSecretUnlocked () |
| Report whether the secret stage is unlocked. | |
| int | IsSuperSecretUnlocked () |
| Report whether the super secret is unlocked. | |
| int | IsStageCompleteAtAnyDifficulty (int nStage) |
| Report whether a stage is complete at any difficulty that plays it as a main stage. | |
| int | IsLastLevelRemaining (const GameParams ¶ms) |
| Report whether a session's level is the one level left unbeaten at its difficulty. | |
| void | Assign (const CampaignStats &other) |
| Copy another record's levels into this one and recount everything. | |
| void | PrintLevels (std::ostream &stream) |
| Write every level to a text stream, one line each as levels[<i>] and the level's own text. | |
| void | MergeLevelList () |
| Rebuild the level vector from the global level list after a load. | |
Public Attributes | |
| int | mUnlockLevel |
| The number of arenas unlocked, 1 through 8, as UpdateUnlockLevel() last computed it. | |
Static Public Attributes | |
| static constexpr int | kDifficultyCount = 3 |
| The number of difficulties, easy, normal, and expert. | |
| static constexpr int | kStageCount = 6 |
| The number of stages, the secret stage 6 included. | |
| static constexpr int | kIndexedStageCount = 5 |
| The number of stages whose level indices the record stores, stages 1 through 5. | |
| static constexpr int | kDifficultyExpert = 2 |
| The expert difficulty, the last of the three. | |
| static constexpr int | kSecretStage = 6 |
| The secret stage, which follows the last regular stage. | |
Persisted progress across the whole campaign.
Its RTTI descriptor is at 0x007d3d98. It has no base. The compiler places the vptr after the data at +0x13c, and the class is 0x140 bytes. Its vtable is at 0x007d3d70 and runs the type function, the destructor, Save(), and Load(). MetPersonaData embeds one instance at offset 0 and fixes the size from the outside as well.
Sixty per-stage counters span +0x10 to +0xff, each row six stages wide, and ResetCounters() zeroes them in one loop. They are the level count of each stage, then three-by-six blocks, one row per difficulty, of the completed level count, the stage-score flag, and the stage score. The stride of 0x18 at which IsStageComplete(), GetStageScoreBeaten(), and GetStageScore() index them fixes the blocks.
Five vectors of level indices follow at +0x100, one per stage. RecountStageCompleted() and RecountStageScore() walk the vector of the stage they recount.
RecountAll() files each album level's index under its stage through RebuildStageLevels(), and then recounts every stage at every difficulty and the unlock level. ResetCounters(), Assign(), and MergeLevelList() end with it, the last two with it expanded inline.
| CampaignStats::CampaignStats | ( | ) |
Construct empty progress.
The vectors are zeroed by the compiler-generated member initialisation, and the written body is the ResetCounters() call. The member at +0x0c is not initialised.
|
virtual |
| void CampaignStats::RebuildLevelList | ( | ) |
Clear the level vector and rebuild it from the global level list.
One stack LevelStats is reset, named, and staged for each album level and appended. The counters are not recounted. MetFreqLoader runs it on each persona it parses.
|
virtual |
Write the whole campaign record.
Vtable slot 2. The record version 2 precedes the level count, and each level writes itself.
| stream | The stream to write to. |
|
virtual |
Read the whole campaign record.
Vtable slot 3. The version word goes straight into g_nStatsRecordVersion, which is how LevelStats and SkillStats learn which layout to expect. The level vector is resized to the stored count before any element reads itself.
| stream | The stream to read from. |
|
inline |
Find the record for a level by name.
| name | The level's name. Inline. Every caller in the unit expands it, and the address is the out-of-line copy the unit emits. |
| int CampaignStats::GetLevelBeaten | ( | int | nDifficulty, |
| const HxStr & | name ) |
Report whether a level has been beaten at a difficulty.
The level is found by name, and an unknown name reads one record past the end.
| nDifficulty | The difficulty, 0 through 2. |
| name | The level's name. |
| int CampaignStats::GetLevelHighScore | ( | int | nDifficulty, |
| const HxStr & | name ) |
Report a level's high score at a difficulty.
The level is found as GetLevelBeaten() finds it.
| nDifficulty | The difficulty, 0 through 2. |
| name | The level's name. |
| void CampaignStats::RecordLevelBeaten | ( | int | nDifficulty, |
| const HxStr & | name ) |
Record a level as beaten at a difficulty and recount what depends on it.
A level already beaten changes nothing. Otherwise the level's stage (from GetAlbumLevelStage()) is recounted for completion and for score, and the unlock level is recomputed. MetStageFinishScreen's slot 5 is the caller.
| nDifficulty | The difficulty, 0 through 2. |
| name | The level's name. |
| void CampaignStats::RecordHighScore | ( | int | nDifficulty, |
| const HxStr & | name, | ||
| int | nScore ) |
Record a score for a level at a difficulty when it beats the high score.
A new high score also recounts the stage score of the level's stage.
| nDifficulty | The difficulty, 0 through 2. |
| name | The level's name. |
| nScore | The score. |
| int CampaignStats::GetStageScoreBeaten | ( | int | nDifficulty, |
| int | nStage ) |
Report whether a stage's total score has reached its target at a difficulty.
| nDifficulty | The difficulty, 0 through 2. |
| nStage | The stage, counted from 1. |
| int CampaignStats::GetStageScore | ( | int | nDifficulty, |
| int | nStage ) |
Report a stage's total score at a difficulty.
| nDifficulty | The difficulty, 0 through 2. |
| nStage | The stage, counted from 1. |
| int CampaignStats::IsStageComplete | ( | int | nDifficulty, |
| int | nStage ) |
Report whether every required level of a stage is beaten at a difficulty.
Easy has stages 1 through 3, normal stages 1 through 4, and expert stages 1 through 5, and a stage outside that range is never complete. A stage whose album value (GetAlbumLevelValue()) is set requires one level fewer than it has, because its last level is a bonus level.
| nDifficulty | The difficulty, 0 through 2. |
| nStage | The stage, counted from 1. |
| int CampaignStats::IsDifficultyComplete | ( | int | nDifficulty | ) |
Report whether every stage of a difficulty is complete and every bonus level beaten.
| nDifficulty | The difficulty, 0 through 2. |
| HxStr CampaignStats::GetBonusLevelName | ( | int | nDifficulty, |
| int | nStage ) |
Report the name of a stage's bonus level.
The bonus level is the last level of the stage's list. The body does not read this object.
| nDifficulty | The difficulty, 0 through 2. |
| nStage | The stage, counted from 1. |
|
inline |
Report whether the secret stage is unlocked.
Expert must be complete and stage 6 must have levels.
Inline. Every caller in the unit expands it, and the address is the out-of-line copy the unit emits for callers in other units.
| int CampaignStats::IsSuperSecretUnlocked | ( | ) |
Report whether the super secret is unlocked.
The secret stage must be unlocked, the first level of stage 6 beaten on expert, and stage 6 must have at least two levels.
| int CampaignStats::IsStageCompleteAtAnyDifficulty | ( | int | nStage | ) |
Report whether a stage is complete at any difficulty that plays it as a main stage.
Stages 1 and 2 test every difficulty, stage 3 tests normal and expert, stages 4 and 5 test expert, and any other stage reports zero. That is the same set of difficulties UpdateUnlockLevel() tests. Every test is IsStageComplete() expanded inline. The two callers sit in the routine at 0x003a7f38. The title is inferred.
| nStage | The stage, counted from 1. |
| int CampaignStats::IsLastLevelRemaining | ( | const GameParams & | params | ) |
Report whether a session's level is the one level left unbeaten at its difficulty.
A level already beaten at the difficulty reports zero. Otherwise the completed counts and the level counts of stages 1 through difficulty + 3 are totalled, and the result is whether the completed total is one short of the level total. MetLoadGameScreen's slot 5 is the caller. The title is inferred.
| params | The session, whose level name and difficulty are read. |
| void CampaignStats::Assign | ( | const CampaignStats & | other | ) |
Copy another record's levels into this one and recount everything.
The level vector is emptied, resized to the other's length, and assigned level by level through LevelStats::Assign(). RecountAll() then follows, expanded inline. MetPersonaData's assignment operator is the caller. The routine writes no return value. The title is inferred.
| other | The record to copy. |
| void CampaignStats::PrintLevels | ( | std::ostream & | stream | ) |
Write every level to a text stream, one line each as levels[<i>] and the level's own text.
LevelStats::Print() writes nothing, so each line carries only the label. The routine at 0x0032e380 is the caller.
| stream | The stream to write to. |
| void CampaignStats::MergeLevelList | ( | ) |
Rebuild the level vector from the global level list after a load.
Each name in the global level list either updates the stage of the level with that name or, when no level has it, appends a new level through a stack LevelStats reset for it. Unlike RebuildLevelList() the pass does not test IsAlbumLevel(). RecountAll() then follows, expanded inline. Public because MetExpansionPakScreen::UpdateIdle() calls it on every persona once the expansion disc is mounted.
|
staticconstexpr |
The number of difficulties, easy, normal, and expert.
|
staticconstexpr |
The number of stages, the secret stage 6 included.
|
staticconstexpr |
The number of stages whose level indices the record stores, stages 1 through 5.
|
staticconstexpr |
The expert difficulty, the last of the three.
|
staticconstexpr |
The secret stage, which follows the last regular stage.
| int CampaignStats::mUnlockLevel |
The number of arenas unlocked, 1 through 8, as UpdateUnlockLevel() last computed it.
+0x0c
Not initialised by the constructor. Public because MetStageFinishScreen::EnterAndShow() reads it directly before and after recording a stage, and the image has no accessor.