resonance 1.0.1
Loading...
Searching...
No Matches
CampaignStats Class Reference

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 &params)
 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.

Detailed Description

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.

Constructor & Destructor Documentation

◆ CampaignStats()

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.

Ghidra address:
NTSC-U/C: 0x00140580
Ghidra address:
PAL: 0x00140f60

◆ ~CampaignStats()

virtual CampaignStats::~CampaignStats ( )
virtual
Ghidra address:
NTSC-U/C: 0x00140768
Ghidra address:
PAL: 0x00141148

Member Function Documentation

◆ RebuildLevelList()

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.

Ghidra address:
NTSC-U/C: 0x00140908
Ghidra address:
PAL: 0x001412e8

◆ Save()

virtual void CampaignStats::Save ( OBStream & stream)
virtual

Write the whole campaign record.

Vtable slot 2. The record version 2 precedes the level count, and each level writes itself.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x00145110
Ghidra address:
PAL: 0x00145c28

◆ Load()

virtual void CampaignStats::Load ( IBStream & stream)
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.

Parameters
streamThe stream to read from.
Ghidra address:
NTSC-U/C: 0x00141ed8
Ghidra address:
PAL: 0x001429c8

◆ FindLevelIndex()

int CampaignStats::FindLevelIndex ( const HxStr & name)
inline

Find the record for a level by name.

Parameters
nameThe level's name. Inline. Every caller in the unit expands it, and the address is the out-of-line copy the unit emits.
Returns
The index, or the element count when no record matches.
Ghidra address:
NTSC-U/C: 0x00144ba8
Ghidra address:
PAL: 0x001456c0

◆ GetLevelBeaten()

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.

Parameters
nDifficultyThe difficulty, 0 through 2.
nameThe level's name.
Returns
SkillStats::mBeaten of the level at that difficulty.
Ghidra address:
NTSC-U/C: 0x00144f08
Ghidra address:
PAL: 0x00145a20

◆ GetLevelHighScore()

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.

Parameters
nDifficultyThe difficulty, 0 through 2.
nameThe level's name.
Returns
SkillStats::mHighScore of the level at that difficulty.
Ghidra address:
NTSC-U/C: 0x00144ca8
Ghidra address:
PAL: 0x001457c0

◆ RecordLevelBeaten()

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.

Parameters
nDifficultyThe difficulty, 0 through 2.
nameThe level's name.
Ghidra address:
NTSC-U/C: 0x00141798
Ghidra address:
PAL: 0x00142210

◆ RecordHighScore()

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.

Parameters
nDifficultyThe difficulty, 0 through 2.
nameThe level's name.
nScoreThe score.
Ghidra address:
NTSC-U/C: 0x00144d68
Ghidra address:
PAL: 0x00145880

◆ GetStageScoreBeaten()

int CampaignStats::GetStageScoreBeaten ( int nDifficulty,
int nStage )

Report whether a stage's total score has reached its target at a difficulty.

Parameters
nDifficultyThe difficulty, 0 through 2.
nStageThe stage, counted from 1.
Returns
The flag RecountStageScore() last stored.
Ghidra address:
NTSC-U/C: 0x00145028
Ghidra address:
PAL: 0x00145b40

◆ GetStageScore()

int CampaignStats::GetStageScore ( int nDifficulty,
int nStage )

Report a stage's total score at a difficulty.

Parameters
nDifficultyThe difficulty, 0 through 2.
nStageThe stage, counted from 1.
Returns
The total RecountStageScore() last stored.
Ghidra address:
NTSC-U/C: 0x00145048
Ghidra address:
PAL: 0x00145b60

◆ IsStageComplete()

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.

Parameters
nDifficultyThe difficulty, 0 through 2.
nStageThe stage, counted from 1.
Returns
1 when the stage is complete, otherwise 0.
Ghidra address:
NTSC-U/C: 0x00144e58
Ghidra address:
PAL: 0x00145970

◆ IsDifficultyComplete()

int CampaignStats::IsDifficultyComplete ( int nDifficulty)

Report whether every stage of a difficulty is complete and every bonus level beaten.

Parameters
nDifficultyThe difficulty, 0 through 2.
Returns
1 when the difficulty is complete, otherwise 0.
Ghidra address:
NTSC-U/C: 0x00140d40
Ghidra address:
PAL: 0x00141740

◆ GetBonusLevelName()

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.

Parameters
nDifficultyThe difficulty, 0 through 2.
nStageThe stage, counted from 1.
Returns
The name, or an empty string when the stage is empty or has no bonus level at that difficulty.
Ghidra address:
NTSC-U/C: 0x00141690
Ghidra address:
PAL: 0x001420e8

◆ IsSecretUnlocked()

int CampaignStats::IsSecretUnlocked ( )
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.

Returns
1 when unlocked, otherwise 0.
Ghidra address:
NTSC-U/C: 0x00144fc8
Ghidra address:
PAL: 0x00145ae0

◆ IsSuperSecretUnlocked()

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.

Returns
1 when unlocked, otherwise 0.
Ghidra address:
NTSC-U/C: 0x001410f0
Ghidra address:
PAL: 0x00141b10

◆ IsStageCompleteAtAnyDifficulty()

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.

Parameters
nStageThe stage, counted from 1.
Returns
Non-zero when one of those difficulties has completed the stage.
Ghidra address:
NTSC-U/C: 0x00140ef8
Ghidra address:
PAL: 0x00141918

◆ IsLastLevelRemaining()

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.

Parameters
paramsThe session, whose level name and difficulty are read.
Returns
Non-zero when the level is the last one left.
Ghidra address:
NTSC-U/C: 0x00141578
Ghidra address:
PAL: 0x00141fd0

◆ Assign()

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.

Parameters
otherThe record to copy.
Ghidra address:
NTSC-U/C: 0x00142288
Ghidra address:
PAL: 0x00142d78

◆ PrintLevels()

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.

Parameters
streamThe stream to write to.
Ghidra address:
NTSC-U/C: 0x001451e0
Ghidra address:
PAL: 0x00145cf8

◆ MergeLevelList()

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.

Ghidra address:
NTSC-U/C: 0x00142070
Ghidra address:
PAL: 0x00142b60

Member Data Documentation

◆ kDifficultyCount

int CampaignStats::kDifficultyCount = 3
staticconstexpr

The number of difficulties, easy, normal, and expert.

◆ kStageCount

int CampaignStats::kStageCount = 6
staticconstexpr

The number of stages, the secret stage 6 included.

◆ kIndexedStageCount

int CampaignStats::kIndexedStageCount = 5
staticconstexpr

The number of stages whose level indices the record stores, stages 1 through 5.

◆ kDifficultyExpert

int CampaignStats::kDifficultyExpert = 2
staticconstexpr

The expert difficulty, the last of the three.

◆ kSecretStage

int CampaignStats::kSecretStage = 6
staticconstexpr

The secret stage, which follows the last regular stage.

◆ mUnlockLevel

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.


The documentation for this class was generated from the following file: