mirror of
https://github.com/veekun/pokedex.git
synced 2024-08-20 18:16:34 +00:00
Save & load trash bytes
This commit is contained in:
parent
8483e57c5d
commit
840c5f368c
2 changed files with 19 additions and 9 deletions
|
@ -324,6 +324,14 @@ class SaveFilePokemon(object):
|
||||||
save(result, 'genes', genes, condition=any_values)
|
save(result, 'genes', genes, condition=any_values)
|
||||||
save(result, 'contest stats', contest_stats, condition=any_values)
|
save(result, 'contest stats', contest_stats, condition=any_values)
|
||||||
|
|
||||||
|
trash = []
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
trash.append(st['trash_{0}'.format(len(trash))])
|
||||||
|
except KeyError:
|
||||||
|
break
|
||||||
|
save(result, 'trash values', trash, condition=any)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def update(self, dct, **kwargs):
|
def update(self, dct, **kwargs):
|
||||||
|
@ -460,6 +468,9 @@ class SaveFilePokemon(object):
|
||||||
('contest stats', 'contest')):
|
('contest stats', 'contest')):
|
||||||
for name, value in dct.get(key, {}).items():
|
for name, value in dct.get(key, {}).items():
|
||||||
st['{}_{}'.format(prefix, name.replace(' ', '_'))] = value
|
st['{}_{}'.format(prefix, name.replace(' ', '_'))] = value
|
||||||
|
if 'trash values' in dct:
|
||||||
|
for i, data in enumerate(dct['trash values']):
|
||||||
|
st['trash_{0}'.format(i)] = data
|
||||||
del self.stats
|
del self.stats
|
||||||
del self.blob
|
del self.blob
|
||||||
return self
|
return self
|
||||||
|
|
|
@ -687,9 +687,9 @@ def make_pokemon_struct(generation):
|
||||||
5: ULInt8('nature_id'),
|
5: ULInt8('nature_id'),
|
||||||
}[generation]
|
}[generation]
|
||||||
|
|
||||||
padding_or_hidden_ability = {
|
hidden_ability_with_padding = {
|
||||||
4: Padding(1),
|
4: ULInt16('trash_1'),
|
||||||
5: Flag('hidden_ability'),
|
5: Embed(Struct('', Flag('hidden_ability'), ULInt8('trash_1'))),
|
||||||
}[generation]
|
}[generation]
|
||||||
|
|
||||||
PokemonStringAdapter = {
|
PokemonStringAdapter = {
|
||||||
|
@ -700,7 +700,7 @@ def make_pokemon_struct(generation):
|
||||||
return Struct('pokemon_struct',
|
return Struct('pokemon_struct',
|
||||||
# Header
|
# Header
|
||||||
ULInt32('personality'), # XXX aughgh http://bulbapedia.bulbagarden.net/wiki/Personality
|
ULInt32('personality'), # XXX aughgh http://bulbapedia.bulbagarden.net/wiki/Personality
|
||||||
Padding(2),
|
ULInt16('trash_0'),
|
||||||
ULInt16('checksum'), # XXX should be checked or calculated
|
ULInt16('checksum'), # XXX should be checked or calculated
|
||||||
|
|
||||||
# Block A
|
# Block A
|
||||||
|
@ -845,14 +845,13 @@ def make_pokemon_struct(generation):
|
||||||
Flag('fateful_encounter'),
|
Flag('fateful_encounter'),
|
||||||
)),
|
)),
|
||||||
leaves_or_nature,
|
leaves_or_nature,
|
||||||
padding_or_hidden_ability,
|
hidden_ability_with_padding,
|
||||||
Padding(1),
|
|
||||||
ULInt16('pt_egg_location_id'),
|
ULInt16('pt_egg_location_id'),
|
||||||
ULInt16('pt_met_location_id'),
|
ULInt16('pt_met_location_id'),
|
||||||
|
|
||||||
# Block C
|
# Block C
|
||||||
PokemonStringAdapter(String('nickname', 22), 22),
|
PokemonStringAdapter(String('nickname', 22), 22),
|
||||||
Padding(1),
|
ULInt8('trash_2'),
|
||||||
LeakyEnum(ULInt8('original_version'),
|
LeakyEnum(ULInt8('original_version'),
|
||||||
sapphire = 1,
|
sapphire = 1,
|
||||||
ruby = 2,
|
ruby = 2,
|
||||||
|
@ -889,7 +888,7 @@ def make_pokemon_struct(generation):
|
||||||
Flag('cool_ribbon_great'),
|
Flag('cool_ribbon_great'),
|
||||||
Flag('cool_ribbon'),
|
Flag('cool_ribbon'),
|
||||||
),
|
),
|
||||||
Padding(4),
|
ULInt32('trash_3'),
|
||||||
|
|
||||||
# Block D
|
# Block D
|
||||||
PokemonStringAdapter(String('original_trainer_name', 16), 16),
|
PokemonStringAdapter(String('original_trainer_name', 16), 16),
|
||||||
|
@ -919,5 +918,5 @@ def make_pokemon_struct(generation):
|
||||||
hgss_gift = 24, # starter; fossil; bebe's eevee (pt only??)
|
hgss_gift = 24, # starter; fossil; bebe's eevee (pt only??)
|
||||||
),
|
),
|
||||||
ULInt8('hgss_pokeball'),
|
ULInt8('hgss_pokeball'),
|
||||||
Padding(1),
|
ULInt8('trash_4'),
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in a new issue