JubeatPlus 3.9.11
Loading...
Searching...
No Matches
ScoreMigrationPolicy Class Reference

Carries score records across a store version, recovering scores the old schema truncated. More...

#include <ScoreMigrationPolicy.h>

Inheritance diagram for ScoreMigrationPolicy:
Collaboration diagram for ScoreMigrationPolicy:

Instance Methods

(BOOL) - salvageScore:tid:bas:adv:ext:
 Recovers the three original scores by searching for the ones the digest was taken over.
(BOOL) - createDestinationInstancesForSourceInstance:entityMapping:manager:error:
 Creates the migrated record, verifying or recovering its scores first.

Detailed Description

Carries score records across a store version, recovering scores the old schema truncated.

The old store kept each score in a 16-bit field alongside a 16-byte tamper digest computed over the untruncated values. On iOS 5 and later the truncation is visible, so the migration cannot simply copy the fields across: it has to work out what the original 32-bit scores were. It does that by brute force, in -salvageScore:tid:bas:adv:ext:.

Method Documentation

◆ createDestinationInstancesForSourceInstance:entityMapping:manager:error:

- (BOOL) createDestinationInstancesForSourceInstance: (NSManagedObject *) sInstance
entityMapping: (NSEntityMapping *) mapping
manager: (NSMigrationManager *) manager
error: (NSError **) error 

Creates the migrated record, verifying or recovering its scores first.

Ignores every entity but "ScoreRecord". Below iOS 5.0 it takes the stored scores at face value and only checks the digest; from 5.0 upwards it goes through -salvageScore:tid:bas:adv:ext:. A record whose scores cannot be verified either way is silently dropped — no destination object is created and no error is reported.

Ghidra address:
0x15b5d4
Ghidra address:
0x15b5d4

◆ salvageScore:tid:bas:adv:ext:

- (BOOL) salvageScore: (NSManagedObject *) source
tid: (int) tuneID
bas: (int *) bas
adv: (int *) adv
ext: (int *) ext 

Recovers the three original scores by searching for the ones the digest was taken over.

Each stored score is the low 16 bits of the original. The method tries every high half from 0 to 16 for each of the three charts, rejects any candidate above one million, recomputes the digest with +[ScoreRecord hashScoreforTune:bas:adv:ext:hash:], and compares all 16 bytes against the stored "chksco". The first exact match wins and is written back through the out-parameters.

A stored value of 0xFFFF combined with the first high half is treated as the sentinel 0xFFFFFFFF, which is how the schema spells "no score recorded" rather than a score of 65535.

Parameters
sourceThe record being migrated.
tuneIDThe tune identifier, which is part of the digest.
basOut-parameter for the recovered basic score. Untouched unless the method answers YES.
advOut-parameter for the recovered advanced score.
extOut-parameter for the recovered extreme score.
Returns
YES when a candidate reproduced the stored digest exactly.
Ghidra address:
0x15add0
Ghidra address:
0x15add0

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