From 9318cd802167f448c21c3acf519cc40aece85792 Mon Sep 17 00:00:00 2001 From: Manu <52102823+Manu098vm@users.noreply.github.com> Date: Mon, 28 Nov 2022 00:36:50 +0100 Subject: [PATCH] SV support improved --- .../Classes/BCATManager/BCATManager.cs | 6 +- .../Classes/WCManager/GiftData/OtherGift.cs | 40 +- .../Classes/WCManager/GiftData/PokemonGift.cs | 2 +- .../Classes/WCManager/WC9.cs | 5 +- .../Classes/WCManager/Wondercard.cs | 3 + .../Resources/Items.txt | 586 +++++++++++++++++- .../MainWindow.Designer.cs | 2 +- 7 files changed, 609 insertions(+), 35 deletions(-) diff --git a/SwitchGiftDataManager.Core/Classes/BCATManager/BCATManager.cs b/SwitchGiftDataManager.Core/Classes/BCATManager/BCATManager.cs index 31a2da0..1041d2f 100644 --- a/SwitchGiftDataManager.Core/Classes/BCATManager/BCATManager.cs +++ b/SwitchGiftDataManager.Core/Classes/BCATManager/BCATManager.cs @@ -135,7 +135,7 @@ namespace SwitchGiftDataManager.Core if (WCList is not null && WCList.Count > 0) foreach (var wc in WCList) { - var str = wc.Type!.ToString()!.Equals("Pokemon") ? ((PokemonGift)wc.Content!).GetSpeciesName() : wc.Type!.ToString()!; + var str = wc.Type!.ToString()!.Equals("Pokemon") ? ((PokemonGift)wc.Content!).GetSpeciesName().Replace("\r","") : wc.Type!.ToString()!; list.Add($"{Game} #{wc.WCID}: {str}"); } return list; @@ -168,7 +168,7 @@ namespace SwitchGiftDataManager.Core { foreach (var c in (List)content) { - var item = c.GetItemName(); + var item = c.GetItemName().Replace("\r",""); var qty = c.Quantity; var str = $"{item.Replace("BP", "Battle Points")}"; if (qty != 0x0 && qty != 0xFFFF) @@ -275,7 +275,7 @@ namespace SwitchGiftDataManager.Core private string ForgeWcFileName(Wondercard wc) { var type = wc.Type!.ToString()!; - var content = type.Equals("Pokemon") ? $"{((PokemonGift)wc.Content!).GetSpeciesName()}" : type; + var content = type.Equals("Pokemon") ? $"{((PokemonGift)wc.Content!).GetSpeciesName().Replace("\r","")}" : type; var str = $"{wc.WCID:0000}_{content}"; var sb = new System.Text.StringBuilder(); foreach (char c in str) diff --git a/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/OtherGift.cs b/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/OtherGift.cs index e67e4e7..2d2757d 100644 --- a/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/OtherGift.cs +++ b/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/OtherGift.cs @@ -18,28 +18,28 @@ namespace SwitchGiftDataManager.Core if (type.GetType() == typeof(GiftType7)) { if ((GiftType7)type is GiftType7.Item) - str = Properties.Resources.Items.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id]; + str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id]; else str = ((GiftType7)type).ToString(); } else if (type.GetType() == typeof(GiftType8)) { if ((GiftType8)type is GiftType8.Item) - str = Properties.Resources.Items.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id]; + str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id]; else if ((GiftType8)type is GiftType8.Clothing) { var category = (ClothingType8)id; var description = category switch { - ClothingType8.Glasses => Properties.Resources.SWSHClothingGlasses.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Hats => Properties.Resources.SWSHClothingHats.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Jackets => Properties.Resources.SWSHClothingJackets.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Tops => Properties.Resources.SWSHClothingTops.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Bags => Properties.Resources.SWSHClothingBags.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Gloves => Properties.Resources.SWSHClothingGloves.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Bottoms => Properties.Resources.SWSHClothingBottoms.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Legwear => Properties.Resources.SWSHClothingLegwear.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8.Shoes => Properties.Resources.SWSHClothingShoes.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], + ClothingType8.Glasses => Properties.Resources.SWSHClothingGlasses.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Hats => Properties.Resources.SWSHClothingHats.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Jackets => Properties.Resources.SWSHClothingJackets.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Tops => Properties.Resources.SWSHClothingTops.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Bags => Properties.Resources.SWSHClothingBags.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Gloves => Properties.Resources.SWSHClothingGloves.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Bottoms => Properties.Resources.SWSHClothingBottoms.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Legwear => Properties.Resources.SWSHClothingLegwear.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8.Shoes => Properties.Resources.SWSHClothingShoes.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], _ => throw new ArgumentOutOfRangeException(), }; str = $"[{category}] {description}"; @@ -50,26 +50,26 @@ namespace SwitchGiftDataManager.Core else if(type.GetType() == typeof(GiftType8B)) { if ((GiftType8B)type is GiftType8B.Item) - str = Properties.Resources.Items.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id]; + str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id]; else if ((GiftType8B)type is GiftType8B.Clothing) - str = Properties.Resources.BDSPClothing.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id]; + str = Properties.Resources.BDSPClothing.Split(new String[] { "\n" }, StringSplitOptions.None)[id]; else if ((GiftType8B)type is GiftType8B.Underground) - str = Properties.Resources.UndergroundItems.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id]; + str = Properties.Resources.UndergroundItems.Split(new String[] { "\n" }, StringSplitOptions.None)[id]; else str = ((GiftType8B)type).ToString(); } else if (type.GetType() == typeof(GiftType8A)) { if ((GiftType8A)type is GiftType8A.Item) - str = Properties.Resources.Items.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id]; + str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id]; else if ((GiftType8A)type is GiftType8A.Clothing) { var category = (ClothingType8A)id; var description = category switch { - ClothingType8A.Heads => Properties.Resources.PLAClothingHeads.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8A.Tops => Properties.Resources.PLAClothingTops.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], - ClothingType8A.Bottoms => Properties.Resources.PLAClothingBottoms.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], + ClothingType8A.Heads => Properties.Resources.PLAClothingHeads.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8A.Tops => Properties.Resources.PLAClothingTops.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], + ClothingType8A.Bottoms => Properties.Resources.PLAClothingBottoms.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], ClothingType8A.Outfit => "", ClothingType8A.Shoes => "", ClothingType8A.Glasses => "", @@ -86,13 +86,13 @@ namespace SwitchGiftDataManager.Core else if (type.GetType() == typeof(GiftType9)) { if ((GiftType9)type is GiftType9.Item) - str = Properties.Resources.Items.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[id]; + str = Properties.Resources.Items.Split(new String[] { "\n" }, StringSplitOptions.None)[id]; else if ((GiftType9)type is GiftType9.Clothing) { var category = (ClothingType9)id; var description = category switch { - ClothingType9.Bags => Properties.Resources.SCVIClothingBags.Split(new String[] { Environment.NewLine }, StringSplitOptions.None)[opt], + ClothingType9.Bags => Properties.Resources.SCVIClothingBags.Split(new String[] { "\n" }, StringSplitOptions.None)[opt], _ => "", }; if (string.IsNullOrWhiteSpace(description)) diff --git a/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/PokemonGift.cs b/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/PokemonGift.cs index a684f88..bb882c8 100644 --- a/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/PokemonGift.cs +++ b/SwitchGiftDataManager.Core/Classes/WCManager/GiftData/PokemonGift.cs @@ -23,7 +23,7 @@ namespace SwitchGiftDataManager.Core return false; } - public static string GetSpeciesName(uint species) => Properties.Resources.Species.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)[species].Replace(",", ""); + public static string GetSpeciesName(uint species) => Properties.Resources.Species.Split(new string[] { "\n" }, StringSplitOptions.None)[species].Replace(",", ""); public static bool IsShiny(uint pid, uint tid, uint sid) => sid != 0 || tid != 0 ? (sid ^ tid ^ (pid >> 16) ^ (pid & 0xFFFF)) < 16 : false; diff --git a/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs b/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs index 5fba133..bc966f8 100644 --- a/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs +++ b/SwitchGiftDataManager.Core/Classes/WCManager/WC9.cs @@ -11,7 +11,6 @@ namespace SwitchGiftDataManager.Core private const int QuantityOffset = 0x1A; private const int ClothingOffset = 0x1C; private const int TIDOffset = 0x18; - private const int SIDOffset = 0x1A; private const int PIDOffset = 0x24; private const int SpeciesOffset = 0x238; private const int ShinyTypeOffset = 0x240; @@ -32,8 +31,8 @@ namespace SwitchGiftDataManager.Core { var species = BinaryPrimitives.ReadUInt16LittleEndian(Data.AsSpan(SpeciesOffset)); var pid = BinaryPrimitives.ReadUInt32LittleEndian(Data.AsSpan(PIDOffset)); - var tid = BinaryPrimitives.ReadUInt16LittleEndian(Data.AsSpan(TIDOffset)); - var sid = BinaryPrimitives.ReadUInt16LittleEndian(Data.AsSpan(SIDOffset)); + var tid = (ushort)((BinaryPrimitives.ReadUInt32LittleEndian(Data.AsSpan(TIDOffset)) - (0xF4240 * WCID)) & 0xFFFF); + var sid = (ushort)((BinaryPrimitives.ReadUInt32LittleEndian(Data.AsSpan(TIDOffset)) - (0xF4240 * WCID)) >> 16 & 0xFFFF); var test = (ShinyType9)Data![ShinyTypeOffset]; var pidtype = (ShinyType9)Data![ShinyTypeOffset] switch { diff --git a/SwitchGiftDataManager.Core/Classes/WCManager/Wondercard.cs b/SwitchGiftDataManager.Core/Classes/WCManager/Wondercard.cs index 2470ae6..444e168 100644 --- a/SwitchGiftDataManager.Core/Classes/WCManager/Wondercard.cs +++ b/SwitchGiftDataManager.Core/Classes/WCManager/Wondercard.cs @@ -35,6 +35,9 @@ namespace SwitchGiftDataManager.Core if (Content is null) return false; + //if (!IsChecksumValid()) + //return false; + if (!IsChecksumValid()) UpdateChecksum(); diff --git a/SwitchGiftDataManager.Core/Resources/Items.txt b/SwitchGiftDataManager.Core/Resources/Items.txt index 3d4eca5..5154e40 100644 --- a/SwitchGiftDataManager.Core/Resources/Items.txt +++ b/SwitchGiftDataManager.Core/Resources/Items.txt @@ -431,10 +431,10 @@ Loot Sack Rule Book Poké Radar Point Card -Journal -Seal Case +Guidebook +Sticker Case Fashion Case -Seal Bag +Sticker Bag Pal Pad Works Key Old Charm @@ -480,8 +480,8 @@ Red Scale Lost Item Pass Machine Part -Silver Wing -Rainbow Wing +Silver Feather +Rainbow Feather Mystery Egg Red Apricorn Blue Apricorn @@ -945,7 +945,7 @@ N-Solarizer N-Lunarizer N-Solarizer N-Lunarizer -Ilima Normalium Z +Ilima’s Normalium Z Left Poké Ball Roto Hatch Roto Bargain @@ -1826,4 +1826,576 @@ DS Sounds -Legend Plate \ No newline at end of file +Legend Plate +Rotom Phone +Sandwich +Koraidon’s Poké Ball +Miraidon’s Poké Ball +Tera Orb +Scarlet Book +Violet Book +Kofu’s Wallet + + + + + +Tiny Bamboo Shoot +Big Bamboo Shoot + + + + + + + + + + + + + +Scroll of Darkness +Scroll of Waters + + +Malicious Armor +Normal Tera Shard +Fire Tera Shard +Water Tera Shard +Electric Tera Shard +Grass Tera Shard +Ice Tera Shard +Fighting Tera Shard +Poison Tera Shard +Ground Tera Shard +Flying Tera Shard +Psychic Tera Shard +Bug Tera Shard +Rock Tera Shard +Ghost Tera Shard +Dragon Tera Shard +Dark Tera Shard +Steel Tera Shard +Fairy Tera Shard +Booster Energy +Ability Shield +Clear Amulet +Mirror Herb +Punching Glove +Covert Cloak +Loaded Dice + +Baguette +Mayonnaise +Ketchup +Mustard +Butter +Peanut Butter +Chili Sauce +Salt +Pepper +Yogurt +Whipped Cream +Cream Cheese +Jam +Marmalade +Olive Oil +Vinegar +Sweet Herba Mystica +Salty Herba Mystica +Sour Herba Mystica +Bitter Herba Mystica +Spicy Herba Mystica +Lettuce +Tomato +Cherry Tomatoes +Cucumber +Pickle +Onion +Red Onion +Green Bell Pepper +Red Bell Pepper +Yellow Bell Pepper +Avocado +Bacon +Ham +Prosciutto +Chorizo +Herbed Sausage +Hamburger +Klawf Stick +Smoked Fillet +Fried Fillet +Egg +Potato Tortilla +Tofu +Rice +Noodles +Potato Salad +Cheese +Banana +Strawberry +Apple +Kiwi +Pineapple +Jalapeño +Horseradish +Curry Powder +Wasabi +Watercress +Basil + + + + + + + + + +Venonat Fang +Diglett Dirt +Meowth Fur +Psyduck Down +Mankey Fur +Growlithe Fur +Slowpoke Claw +Magnemite Screw +Grimer Toxin +Shellder Pearl +Gastly Gas +Drowzee Fur +Voltorb Sparks +Scyther Claw +Tauros Hair +Magikarp Scales +Ditto Goo +Eevee Fur +Dratini Scales +Pichu Fur +Igglybuff Fluff +Mareep Wool +Hoppip Leaf +Sunkern Leaf +Murkrow Bauble +Misdreavus Tears +Girafarig Fur +Pineco Husk +Dunsparce Scales +Qwilfish Spines +Heracross Claw +Sneasel Claw +Teddiursa Claw +Delibird Parcel +Houndour Fang +Phanpy Nail +Stantler Hair +Larvitar Claw +Wingull Feather +Ralts Dust +Surskit Syrup +Shroomish Spores +Slakoth Fur +Makuhita Sweat +Azurill Fur +Sableye Gem +Meditite Sweat +Gulpin Mucus +Numel Lava +Torkoal Coal +Spoink Pearl +Cacnea Needle +Swablu Fluff +Zangoose Claw +Seviper Fang +Barboach Slime +Shuppet Scrap +Tropius Leaf +Snorunt Fur +Luvdisc Scales +Bagon Scales +Starly Feather +Kricketot Shell +Shinx Fang +Combee Honey +Pachirisu Fur +Buizel Fur +Shellos Mucus +Drifloon Gas +Stunky Fur +Bronzor Fragment +Bonsly Tears +Happiny Dust +Spiritomb Fragment +Gible Scales +Riolu Fur +Hippopotas Sand +Croagunk Poison +Finneon Scales +Snover Berries +Rotom Sparks +Petilil Leaf +Basculin Fang +Sandile Claw +Zorua Fur +Gothita Eyelash +Deerling Hair +Foongus Spores +Alomomola Mucus +Tynamo Slime +Axew Scales +Cubchoo Fur +Cryogonal Ice +Pawniard Blade +Rufflet Feather +Deino Scales +Larvesta Fuzz +Fletchling Feather +Scatterbug Powder +Litleo Tuft +Flabébé Pollen +Skiddo Leaf +Skrelp Kelp +Clauncher Claw +Hawlucha Down +Dedenne Fur +Goomy Goo +Klefki Key +Bergmite Ice +Noibat Fur +Yungoos Fur +Crabrawler Shell +Oricorio Feather +Rockruff Rock +Mareanie Spike +Mudbray Mud +Fomantis Leaf +Salandit Gas +Bounsweet Sweat +Oranguru Fur +Passimian Fur +Sandygast Sand +Komala Claw +Mimikyu Scrap +Bruxish Tooth +Chewtle Claw +Skwovet Fur +Arrokuda Scales +Rookidee Feather +Toxel Sparks +Falinks Sweat +Cufant Tarnish +Rolycoly Coal +Silicobra Sand +Indeedee Fur +Pincurchin Spines +Snom Thread +Impidimp Hair +Applin Juice +Sinistea Chip +Hatenna Dust +Stonjourner Stone +Eiscue Down +Dreepy Powder + + + +Lechonk Hair +Tarountula Thread +Nymble Claw +Rellor Mud +Greavard Wax +Flittle Down +Wiglett Sand +Dondozo Whisker +Veluza Fillet +Finizen Mucus +Smoliv Oil +Capsakid Seed +Tadbulb Mucus +Varoom Fume +Orthworm Tarnish +Tandemaus Fur +Cetoddle Grease +Frigibax Scales +Tatsugiri Scales +Cyclizar Scales +Pawmi Fur + + +Wattrel Feather +Bombirdier Feather +Squawkabilly Feather +Flamigo Down +Klawf Claw +Nacli Salt +Glimmet Crystal +Shroodle Ink +Fidough Fur +Maschiff Fang +Bramblin Twig +Gimmighoul Coin + + + + + + + + + + + + + + + + + + +Tinkatink Hair +Charcadet Soot +Toedscool Flaps +Wooper Slime +TM100 +TM101 +TM102 +TM103 +TM104 +TM105 +TM106 +TM107 +TM108 +TM109 +TM110 +TM111 +TM112 +TM113 +TM114 +TM115 +TM116 +TM117 +TM118 +TM119 +TM120 +TM121 +TM122 +TM123 +TM124 +TM125 +TM126 +TM127 +TM128 +TM129 +TM130 +TM131 +TM132 +TM133 +TM134 +TM135 +TM136 +TM137 +TM138 +TM139 +TM140 +TM141 +TM142 +TM143 +TM144 +TM145 +TM146 +TM147 +TM148 +TM149 +TM150 +TM151 +TM152 +TM153 +TM154 +TM155 +TM156 +TM157 +TM158 +TM159 +TM160 +TM161 +TM162 +TM163 +TM164 +TM165 +TM166 +TM167 +TM168 +TM169 +TM170 +TM171 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Picnic Set + +Academy Bottle +Academy Bottle +Polka-Dot Bottle +Striped Bottle +Diamond Bottle +Academy Cup +Academy Cup +Striped Cup +Polka-Dot Cup +Flower Pattern Cup +Academy Tablecloth +Academy Tablecloth +Whimsical Tablecloth +Leafy Tablecloth +Spooky Tablecloth + +Academy Ball +Academy Ball +Marill Ball +Yarn Ball +Cyber Ball +Gold Pick +Silver Pick +Red-Flag Pick +Blue-Flag Pick +Pika-Pika Pick +Winking Pika Pick +Vee-Vee Pick +Smiling Vee Pick +Blue Poké Ball Pick + +Auspicious Armor +Leader’s Crest + + +Pink Bottle +Blue Bottle +Yellow Bottle +Steel Bottle (R) +Steel Bottle (Y) +Steel Bottle (B) +Silver Bottle +Barred Cup +Diamond Pattern Cup +Fire Pattern Cup +Pink Cup +Blue Cup +Yellow Cup +Pikachu Cup +Eevee Cup +Slowpoke Cup +Silver Cup +Exercise Ball +Plaid Tablecloth (Y) +Plaid Tablecloth (B) +Plaid Tablecloth (R) +B&W Grass Tablecloth +Battle Tablecloth +Monstrous Tablecloth +Striped Tablecloth +Diamond Tablecloth +Polka-Dot Tablecloth +Lilac Tablecloth +Mint Tablecloth +Peach Tablecloth +Yellow Tablecloth +Blue Tablecloth +Pink Tablecloth +Gold Bottle +Bronze Bottle +Gold Cup +Bronze Cup +Green Poké Ball Pick +Red Poké Ball Pick +Party Sparkler Pick +Heroic Sword Pick +Magical Star Pick +Magical Heart Pick +Parasol Pick +Blue-Sky Flower Pick +Sunset Flower Pick +Sunrise Flower Pick +Blue Dish +Green Dish +Orange Dish +Red Dish +White Dish +Yellow Dish \ No newline at end of file diff --git a/SwitchGiftDataManager.WinForm/MainWindow.Designer.cs b/SwitchGiftDataManager.WinForm/MainWindow.Designer.cs index ac1344d..4552002 100644 --- a/SwitchGiftDataManager.WinForm/MainWindow.Designer.cs +++ b/SwitchGiftDataManager.WinForm/MainWindow.Designer.cs @@ -371,7 +371,7 @@ this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "MainWindow"; - this.Text = "Switch Gift Data Manager v1.0.0"; + this.Text = "Switch Gift Data Manager v1.1.0"; this.DragDrop += new System.Windows.Forms.DragEventHandler(this.FileDragDrop); this.DragEnter += new System.Windows.Forms.DragEventHandler(this.FileDragEnter); this.GrpBCAT.ResumeLayout(false);