Fix event flag get set

yay order of operations
also update prompt messages for more guidance
Closes #1464
This commit is contained in:
Kurt 2017-09-17 10:16:56 -07:00
parent 07d37efd67
commit c07a36c333
2 changed files with 15 additions and 10 deletions

View file

@ -286,7 +286,7 @@ namespace PKHeX.Core
{ {
if (flagNumber > EventFlagMax) if (flagNumber > EventFlagMax)
throw new ArgumentException($"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax})."); throw new ArgumentException($"Event Flag to get ({flagNumber}) is greater than max ({EventFlagMax}).");
int ofs = EventFlag + flagNumber >> 3; int ofs = EventFlag + (flagNumber >> 3);
var n = flagNumber & 7; var n = flagNumber & 7;
return (Data[ofs] >> n & 1) != 0; return (Data[ofs] >> n & 1) != 0;
} }
@ -301,7 +301,7 @@ namespace PKHeX.Core
{ {
if (flagNumber > EventFlagMax) if (flagNumber > EventFlagMax)
throw new ArgumentException($"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax})."); throw new ArgumentException($"Event Flag to set ({flagNumber}) is greater than max ({EventFlagMax}).");
int ofs = EventFlag + flagNumber >> 3; int ofs = EventFlag + (flagNumber >> 3);
var n = flagNumber & 7; var n = flagNumber & 7;
Data[ofs] &= (byte)~(1 << (n & 7)); Data[ofs] &= (byte)~(1 << (n & 7));
Data[ofs] |= (byte)((value ? 1 : 0) << n); Data[ofs] |= (byte)((value ? 1 : 0) << n);

View file

@ -148,7 +148,7 @@ namespace PKHeX.WinForms
const int oldsea = 0x178; const int oldsea = 0x178;
int[] tickets = {0x109, 0x113, 0x172, 0x173, oldsea }; // item IDs int[] tickets = {0x109, 0x113, 0x172, 0x173, oldsea }; // item IDs
if (!SAV.Japanese && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Add {itemlist[oldsea]}?")) if (!SAV.Japanese && DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, $"Non Japanese save file. Add {itemlist[oldsea]} (unreleased)?"))
tickets = tickets.Take(tickets.Length - 1).ToArray(); // remove old sea map tickets = tickets.Take(tickets.Length - 1).ToArray(); // remove old sea map
var p = Pouches.FirstOrDefault(z => z.Type == InventoryType.KeyItems); var p = Pouches.FirstOrDefault(z => z.Type == InventoryType.KeyItems);
@ -174,6 +174,17 @@ namespace PKHeX.WinForms
return; return;
} }
var added = string.Join(", ", missing.Select(u => itemlist[u]));
var addmsg = $"Add the following items?{Environment.NewLine}{added}";
if (have.Any())
{
string had = string.Join(", ", have.Select(u => itemlist[u]));
var havemsg = $"Already have:{Environment.NewLine}{had}";
addmsg += Environment.NewLine + Environment.NewLine + havemsg;
}
if (DialogResult.Yes != WinFormsUtil.Prompt(MessageBoxButtons.YesNo, addmsg))
return;
// insert items at the end // insert items at the end
for (int i = 0; i < missing.Count; i++) for (int i = 0; i < missing.Count; i++)
{ {
@ -182,13 +193,7 @@ namespace PKHeX.WinForms
item.Count = 1; item.Count = 1;
} }
var added = string.Join(", ", missing.Select(u => itemlist[u])); string alert = $"Inserted the following items to the Key Items Pouch:{Environment.NewLine}{added}";
string alert = "Inserted the following items to the Key Items Pouch:" + Environment.NewLine + added;
if (have.Any())
{
string had = string.Join(", ", have.Select(u => itemlist[u]));
alert += string.Format("{0}{0}Already had the following items:{0}{1}", Environment.NewLine, had);
}
WinFormsUtil.Alert(alert); WinFormsUtil.Alert(alert);
SAV.Inventory = Pouches; SAV.Inventory = Pouches;