74 for(
int i = 0; i <
boxCount(); i++) {
75 if(
boxAt(i)->pokemonCount() <
boxAt(i)->pokemonMax())
85 if(storage ==
nullptr)
88 storage->pokemon.append(
pokemon);
89 storage->pokemonChanged();
97 if(saveFile ==
nullptr)
100 auto toolset = saveFile->
toolset;
110 curBox = (toolset->getByte(0x284C) & 0b01111111);
126 items->load(saveFile, 0x27E6);
138 pokemon[0]->load(saveFile, 0x4000, curSetB ? -1 : cur);
139 pokemon[1]->load(saveFile, 0x6000, curSetB ? cur : -1);
144 pokemon[curSetB ? 1 : 0]->loadSpecific(saveFile, 0x30C0, cur);
149 auto toolset = saveFile->
toolset;
155 items->save(saveFile, 0x27E6);
165 pokemon[0]->save(saveFile, 0x4000, curSetB ? -1 : cur);
166 pokemon[1]->save(saveFile, 0x6000, curSetB ? cur : -1);
171 pokemon[curSetB ? 1 : 0]->saveSpecific(saveFile, 0x30C0, cur);
A container of Items – either the trainer's bag or a PC item box.
The trainer's headline values: name, ID, money, coins, badges, starter.
A single Pokemon record – the most property-rich object in the tree.
Holds contents of a single Pokemon storage box.
Holds contents of a single box set, basically a row or array of boxes each holding Pokemon.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
SaveFileToolset * toolset
Tools to operate directly on the raw sav file data.
int boxCount()
Total boxes across both sets (12).
Storage(SaveFile *saveFile=nullptr)
< The PC item box.
void randomizeItems()
Randomize just the PC items.
PokemonStorageSet * pokemon[maxPokemonStorageSets]
The two box sets (6 boxes each).
void reset()
Blank the whole PC.
void randomize(PlayerBasics *basics)
Randomize items and Pokemon.
PokemonStorageBox * freeSpace()
First box with room, or null if all full.
void save(SaveFile *saveFile)
Flatten the PC back to the save.
void load(SaveFile *saveFile=nullptr)
Expand the PC (items + both box sets) from the save.
void randomizePokemon(PlayerBasics *basics)
Randomize just the boxed Pokemon.
void boxesFormattedChanged()
PokemonStorageBox * boxAt(int ind)
Box ind in the flattened 0..11 space (GC-protected return).
bool depositPokemon(PokemonBox *pokemon)
Put pokemon in the first box with space.
var8e var8
Everyday 8-bit alias. Exact (not "fastest") to dodge the pointer-width bug noted above.
constexpr var8 setMaxBoxes
Boxes per storage set (a save has two sets = 12 boxes).
qmlCppOwned() – protect Q_INVOKABLE QObject returns from QML's GC.
static T * qmlCppOwned(T *obj)
Hand QML CppOwnership of a C++-owned QObject returned from a Q_INVOKABLE.
constexpr var8 maxPokemonBoxes
Total PC boxes (12).
constexpr var8 maxPokemonStorageSets
PC Pokemon-box banks (2 sets).