mirror of
https://github.com/kwsch/PKHeX
synced 2024-11-10 14:44:24 +00:00
Misc reductions
same stuff as previous commit but for Gen2 EventConstMax is always > 0, remove guards
This commit is contained in:
parent
4f347fbfa9
commit
f212ba29c9
1 changed files with 19 additions and 45 deletions
|
@ -376,29 +376,13 @@ namespace PKHeX.Core
|
|||
public int Sound
|
||||
{
|
||||
get => (Options & 0x30) >> 4;
|
||||
set
|
||||
{
|
||||
var new_sound = value;
|
||||
if (new_sound > 0)
|
||||
new_sound = 2; // Stereo
|
||||
if (new_sound < 0)
|
||||
new_sound = 0; // Mono
|
||||
Options = (byte)((Options & 0xCF) | (new_sound << 4));
|
||||
}
|
||||
set => Options = (byte)((Options & 0xCF) | ((value != 0 ? 2 : 0) << 4)); // Stereo 2, Mono 0
|
||||
}
|
||||
|
||||
public int TextSpeed
|
||||
{
|
||||
get => Options & 0x7;
|
||||
set
|
||||
{
|
||||
var new_speed = value;
|
||||
if (new_speed > 7)
|
||||
new_speed = 7;
|
||||
if (new_speed < 0)
|
||||
new_speed = 0;
|
||||
Options = (byte)((Options & 0xF8) | new_speed);
|
||||
}
|
||||
set => Options = (byte)((Options & 0xF8) | (value & 7));
|
||||
}
|
||||
|
||||
public override uint Money
|
||||
|
@ -515,22 +499,6 @@ namespace PKHeX.Core
|
|||
return true;
|
||||
}
|
||||
|
||||
public override void SetSeen(int species, bool seen)
|
||||
{
|
||||
int bit = species - 1;
|
||||
int ofs = bit >> 3;
|
||||
SetFlag(Offsets.PokedexSeen + ofs, bit & 7, seen);
|
||||
}
|
||||
|
||||
public override void SetCaught(int species, bool caught)
|
||||
{
|
||||
int bit = species - 1;
|
||||
int ofs = bit >> 3;
|
||||
SetFlag(Offsets.PokedexCaught + ofs, bit & 7, caught);
|
||||
if (caught && species == 201)
|
||||
SetUnownFormFlags();
|
||||
}
|
||||
|
||||
private void SetUnownFormFlags()
|
||||
{
|
||||
// Give all Unown caught to prevent a crash on pokedex view
|
||||
|
@ -606,18 +574,29 @@ namespace PKHeX.Core
|
|||
set => Data[Offsets.PokedexSeen + 0x1F + 28] = (byte)value;
|
||||
}
|
||||
|
||||
public override bool GetSeen(int species)
|
||||
public override bool GetSeen(int species) => GetDexFlag(Offsets.PokedexSeen, species);
|
||||
public override bool GetCaught(int species) => GetDexFlag(Offsets.PokedexCaught, species);
|
||||
public override void SetSeen(int species, bool seen) => SetDexFlag(Offsets.PokedexSeen, species, seen);
|
||||
|
||||
public override void SetCaught(int species, bool caught)
|
||||
{
|
||||
int bit = species - 1;
|
||||
int ofs = bit >> 3;
|
||||
return GetFlag(Offsets.PokedexSeen + ofs, bit & 7);
|
||||
SetDexFlag(Offsets.PokedexCaught, species, caught);
|
||||
if (caught && species == 201)
|
||||
SetUnownFormFlags();
|
||||
}
|
||||
|
||||
public override bool GetCaught(int species)
|
||||
private bool GetDexFlag(int region, int species)
|
||||
{
|
||||
int bit = species - 1;
|
||||
int ofs = bit >> 3;
|
||||
return GetFlag(Offsets.PokedexCaught + ofs, bit & 7);
|
||||
return GetFlag(region + ofs, bit & 7);
|
||||
}
|
||||
|
||||
private void SetDexFlag(int region, int species, bool value)
|
||||
{
|
||||
int bit = species - 1;
|
||||
int ofs = bit >> 3;
|
||||
SetFlag(region + ofs, bit & 7, value);
|
||||
}
|
||||
|
||||
/// <summary>All Event Constant values for the save file</summary>
|
||||
|
@ -626,9 +605,6 @@ namespace PKHeX.Core
|
|||
{
|
||||
get
|
||||
{
|
||||
if (EventConstMax <= 0)
|
||||
return Array.Empty<ushort>();
|
||||
|
||||
ushort[] Constants = new ushort[EventConstMax];
|
||||
for (int i = 0; i < Constants.Length; i++)
|
||||
Constants[i] = Data[EventConst + i];
|
||||
|
@ -636,8 +612,6 @@ namespace PKHeX.Core
|
|||
}
|
||||
set
|
||||
{
|
||||
if (EventConstMax <= 0)
|
||||
return;
|
||||
if (value.Length != EventConstMax)
|
||||
return;
|
||||
|
||||
|
|
Loading…
Reference in a new issue