Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Loading...
Searching...
No Matches
savefileexpanded.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2019 Twilight
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16
22#include "savefileexpanded.h"
23#include "../savefile.h"
24
25#include "./player/player.h"
26#include "./area/area.h"
27#include "./world/world.h"
28#include "./daycare.h"
29#include "./halloffame.h"
30#include "./rival.h"
31#include "./storage.h"
32
34{
35 player = new Player;
36 area = new Area;
37 world = new World;
38 daycare = new Daycare;
39 hof = new HallOfFame;
40 rival = new Rival;
41 storage = new Storage;
42
43 load(saveFile);
44}
45
47{
48 player->deleteLater();
49 area->deleteLater();
50 world->deleteLater();
51 daycare->deleteLater();
52 hof->deleteLater();
53 rival->deleteLater();
54 storage->deleteLater();
55}
56
58{
59 if(saveFile == nullptr)
60 return reset();
61
62 player->load(saveFile);
63 area->load(saveFile);
64 world->load(saveFile);
65 daycare->load(saveFile);
66 hof->load(saveFile);
67 rival->load(saveFile);
68 storage->load(saveFile);
69}
70
72{
73 player->save(saveFile);
74 area->save(saveFile);
75 world->save(saveFile);
76 daycare->save(saveFile);
77 hof->save(saveFile);
78 rival->save(saveFile);
79 storage->save(saveFile);
80}
81
83{
84 player->reset();
85 area->reset();
86 world->reset();
87 daycare->reset();
88 hof->reset();
89 rival->reset();
90 storage->reset();
91}
92
94{
95 player->randomize();
96
97 // Map/area randomization is intentionally disabled until the map randomizer is
98 // finished. Area::randomize() relocates the player to a random "good" map (its
99 // warps, sprites, tileset, ...), which depends on map data that isn't fully wired
100 // yet and currently crashes in the sprite path (SpriteData::load() on an
101 // unresolved getToSprite() link). Skipping it leaves the area as-loaded, so the
102 // player stays on their real current map -- valid and playable. Re-enable this
103 // once maps are set up. (Twilight-authorised, 2026-06-07.)
104 // area->randomize();
105
106 world->randomize();
107 daycare->randomize(player->basics);
108
109 // Hall of Fame isn't a set-up screen yet, so don't randomize it -- leave it as
110 // loaded. Re-enable when the HoF screen is implemented. (Twilight-authorised,
111 // 2026-06-07.)
112 // hof->randomize();
113
114 rival->randomize();
115 storage->randomize(player->basics);
116}
The current map's complete live state – everything about "where you are".
Definition area.h:82
The Day Care: at most one deposited Pokemon.
Definition daycare.h:42
The Hall of Fame: a rolling list of up to 50 winning-team records.
Definition halloffame.h:38
The trainer: their basics, bag, pokedex, and party.
Definition player.h:42
The rival: their name and chosen starter.
Definition rival.h:34
void save(SaveFile *saveFile)
Flatten: write the whole tree back into saveFile.
void randomize()
Constrained full randomization across the whole tree.
void reset()
Blank every region (acts like a fresh save's expansion).
SaveFileExpanded(SaveFile *saveFile=nullptr)
< The trainer: basics, items, pokedex, party.
void load(SaveFile *saveFile=nullptr)
Expand: build the whole tree from saveFile's raw bytes.
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition savefile.h:46
The PC: the item storage box and all 12 Pokemon boxes.
Definition storage.h:49
Global, map-independent game state – "the state of the world".
Definition world.h:50