Pokered Save Editor 2
Pokemon Red & Blue save file editor - Qt 6 C++/QML
Toggle main menu visibility
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
33
SaveFileExpanded::SaveFileExpanded
(
SaveFile
* saveFile)
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
46
SaveFileExpanded::~SaveFileExpanded
()
47
{
48
player
->deleteLater();
49
area
->deleteLater();
50
world
->deleteLater();
51
daycare
->deleteLater();
52
hof
->deleteLater();
53
rival
->deleteLater();
54
storage
->deleteLater();
55
}
56
57
void
SaveFileExpanded::load
(
SaveFile
* saveFile)
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
71
void
SaveFileExpanded::save
(
SaveFile
* saveFile)
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
82
void
SaveFileExpanded::reset
()
83
{
84
player
->reset();
85
area
->reset();
86
world
->reset();
87
daycare
->reset();
88
hof
->reset();
89
rival
->reset();
90
storage
->reset();
91
}
92
93
void
SaveFileExpanded::randomize
()
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
}
area.h
Area
The current map's complete live state – everything about "where you are".
Definition
area.h:82
Daycare
The Day Care: at most one deposited Pokemon.
Definition
daycare.h:42
HallOfFame
The Hall of Fame: a rolling list of up to 50 winning-team records.
Definition
halloffame.h:38
Player
The trainer: their basics, bag, pokedex, and party.
Definition
player.h:42
Rival
The rival: their name and chosen starter.
Definition
rival.h:34
SaveFileExpanded::save
void save(SaveFile *saveFile)
Flatten: write the whole tree back into saveFile.
Definition
savefileexpanded.cpp:71
SaveFileExpanded::hof
HallOfFame * hof
Definition
savefileexpanded.h:95
SaveFileExpanded::randomize
void randomize()
Constrained full randomization across the whole tree.
Definition
savefileexpanded.cpp:93
SaveFileExpanded::reset
void reset()
Blank every region (acts like a fresh save's expansion).
Definition
savefileexpanded.cpp:82
SaveFileExpanded::SaveFileExpanded
SaveFileExpanded(SaveFile *saveFile=nullptr)
< The trainer: basics, items, pokedex, party.
Definition
savefileexpanded.cpp:33
SaveFileExpanded::storage
Storage * storage
Definition
savefileexpanded.h:97
SaveFileExpanded::area
Area * area
Definition
savefileexpanded.h:92
SaveFileExpanded::~SaveFileExpanded
virtual ~SaveFileExpanded()
Definition
savefileexpanded.cpp:46
SaveFileExpanded::player
Player * player
Definition
savefileexpanded.h:91
SaveFileExpanded::load
void load(SaveFile *saveFile=nullptr)
Expand: build the whole tree from saveFile's raw bytes.
Definition
savefileexpanded.cpp:57
SaveFileExpanded::rival
Rival * rival
Definition
savefileexpanded.h:96
SaveFileExpanded::world
World * world
Definition
savefileexpanded.h:93
SaveFileExpanded::daycare
Daycare * daycare
Definition
savefileexpanded.h:94
SaveFile
One loaded save: the raw 32 KB bytes, their expanded object tree, and the tools that move between the...
Definition
savefile.h:46
Storage
The PC: the item storage box and all 12 Pokemon boxes.
Definition
storage.h:49
World
Global, map-independent game state – "the state of the world".
Definition
world.h:50
daycare.h
halloffame.h
player.h
rival.h
savefile.h
savefileexpanded.h
storage.h
world.h
projects
savefile
src
pse-savefile
expanded
savefileexpanded.cpp
Generated by
1.17.0