public void GiveItem(WWItem item) { WWPacket givePacket = new WWPacket(PacketType.GiveItem); givePacket.data[0] = (byte)item; WritePacket(givePacket); }
public static WWPacket ReadPacket(byte[] buffer) { WWPacket thisPacket = new WWPacket(); thisPacket.type = (PacketType)BitConverter.ToInt32(buffer, 0); switch (thisPacket.type) { case PacketType.None: break; case PacketType.PlayerStatusInfo: thisPacket.data = new byte[PLAYER_STATUS_SIZE]; Array.Copy(buffer, 4, thisPacket.data, 0, PLAYER_STATUS_SIZE); break; case PacketType.WorldState: thisPacket.data = new byte[WORLD_STATE_SIZE]; Array.Copy(buffer, 4, thisPacket.data, 0, WORLD_STATE_SIZE); break; default: thisPacket.type = PacketType.None; break; } return(thisPacket); }
public void SetStatues(byte mask) { WWPacket statuePacket = new WWPacket(PacketType.SetStatues); statuePacket.data[0] = mask; WritePacket(statuePacket); }
public void RemoveSong(WWSongMask song) { WWPacket songPacket = new WWPacket(PacketType.RemoveSong); songPacket.data[0] = (byte)song; WritePacket(songPacket); }
public void RemovePearl(WWPearlMask pearl) { WWPacket pearlPacket = new WWPacket(PacketType.RemovePearl); pearlPacket.data[0] = (byte)pearl; WritePacket(pearlPacket); }
public void SetTriforce(byte mask) { WWPacket triforcePacket = new WWPacket(PacketType.SetTriforce); triforcePacket.data[0] = mask; WritePacket(triforcePacket); }
public void RevokeItem(WWItem item) { WWPacket revokePacket = new WWPacket(PacketType.RevokeItem); revokePacket.data[0] = (byte)item; WritePacket(revokePacket); }
public void DowngradeItem(ItemCode code) { WWPacket downgradePacket = new WWPacket(PacketType.DowngradeItem); byte[] codeBytes = BitConverter.GetBytes((int)code); Array.Copy(codeBytes, downgradePacket.data, 4); WritePacket(downgradePacket); }
public void AddKeys(short keys) { WWPacket keysPacket = new WWPacket(PacketType.GiveKeys); byte[] keyBytes = BitConverter.GetBytes(keys); Array.Copy(keyBytes, keysPacket.data, 2); WritePacket(keysPacket); }
public void RemoveChart(WWChartMask charts) { WWPacket chartPacket = new WWPacket(PacketType.RemoveChart); byte[] chartBytes = BitConverter.GetBytes((long)charts); Array.Copy(chartBytes, chartPacket.data, 8); WritePacket(chartPacket); }
public void SetMailBagSlot(int slot, byte value) { WWPacket mailPacket = new WWPacket(PacketType.SetMailSlot); byte[] slotBytes = BitConverter.GetBytes(slot); Array.Copy(slotBytes, mailPacket.data, 4); mailPacket.data[4] = value; WritePacket(mailPacket); }
public void SetBottleSlot(int slot, byte value) { WWPacket bottlePacket = new WWPacket(PacketType.SetBottleSlot); byte[] slotBytes = BitConverter.GetBytes(slot); Array.Copy(slotBytes, bottlePacket.data, 4); bottlePacket.data[4] = value; WritePacket(bottlePacket); }
public void WritePacket(WWPacket packet) { if (!toDolphin.IsConnected || !started) { return; } byte[] buffer = packet.Pack(); toStream.BaseStream.Write(buffer, 0, buffer.Length); }
public WWPacket ReadPacket() { WWPacket thisPacket = new WWPacket(); if (!fromDolphin.IsConnected || !started) { return(thisPacket); } ZeroReadBuffer(); fromStream.BaseStream.Read(readBuffer, 0, bufferSize); thisPacket = WWPacket.ReadPacket(readBuffer); return(thisPacket); }
private void DolphinListener(object sender, DoWorkEventArgs e) { player = new PlayerState(); PlayerState old = new PlayerState(); playerSize = Marshal.SizeOf(player); playerStateBuffer = Marshal.AllocHGlobal(playerSize); state = new WorldState(); WorldState oldState = new WorldState(); worldStateSize = Marshal.SizeOf(state); worldStateBuffer = Marshal.AllocHGlobal(worldStateSize); bool firstPass = true; while (listeningToDolphin && dolphin.isRunning) { WWPacket msg = dolphin.ReadPacket(); if (msg.type == PacketType.PlayerStatusInfo) { Marshal.Copy(msg.data, 0, playerStateBuffer, playerSize); player = Marshal.PtrToStructure <PlayerState>(playerStateBuffer); if (!trainerModeCheckbox.Enabled) { Invoke(new Action(() => { trainerModeCheckbox.Enabled = true; })); } if (firstPass) { firstPass = false; old = player; } #region GUI Autotracker if (player.inventory.telescope != old.inventory.telescope) { if (player.inventory.telescope == (byte)WWItem.Telecope) { telescopePicture.Image = TWW_Coop.Resources.item_Telescope; } else { telescopePicture.Image = TWW_Coop.Resources.item_TelescopeN; } } if (player.inventory.sail != old.inventory.sail) { if (player.inventory.sail == (byte)WWItem.Sail) { sailPicture.Image = TWW_Coop.Resources.item_SwiftSail; } else { sailPicture.Image = TWW_Coop.Resources.item_SwiftSailN; } } if (player.inventory.windwaker != old.inventory.windwaker) { if (player.inventory.windwaker == (byte)WWItem.WW) { wwPicture.Image = TWW_Coop.Resources.item_WindWaker; } else { wwPicture.Image = TWW_Coop.Resources.item_WindWakerN; } } if (player.inventory.grapplingHook != old.inventory.grapplingHook) { if (player.inventory.grapplingHook == (byte)WWItem.GrapplingHook) { grapplingHookPicture.Image = TWW_Coop.Resources.item_GrapplingHook; } else { grapplingHookPicture.Image = TWW_Coop.Resources.item_GrapplingHookN; } } if (player.inventory.spoilsBag != old.inventory.spoilsBag) { if (player.inventory.spoilsBag == (byte)WWItem.SpoilsBag) { spoilsBagPicture.Image = TWW_Coop.Resources.bag_SpoilsBag; } else { spoilsBagPicture.Image = TWW_Coop.Resources.bag_SpoilsBagN; } } if (player.inventory.boomerang != old.inventory.boomerang) { if (player.inventory.boomerang == (byte)WWItem.Boomerang) { boomerangPicture.Image = TWW_Coop.Resources.item_Boomerang; } else { boomerangPicture.Image = TWW_Coop.Resources.item_BoomerangN; } } if (player.inventory.dekuLeaf != old.inventory.dekuLeaf) { if (player.inventory.dekuLeaf == (byte)WWItem.DekuLeaf) { dekuLeafPicture.Image = TWW_Coop.Resources.item_DekuLeaf; } else { dekuLeafPicture.Image = TWW_Coop.Resources.item_DekuLeafN; } } if (player.inventory.sword != old.inventory.sword) { switch (player.inventory.sword) { case (byte)WWItem.Sword1: swordPicture.Image = TWW_Coop.Resources.item_Sword1; break; case (byte)WWItem.Sword2: swordPicture.Image = TWW_Coop.Resources.item_Sword2; break; case (byte)WWItem.Sword3: swordPicture.Image = TWW_Coop.Resources.item_Sword3; break; case (byte)WWItem.Sword4: swordPicture.Image = TWW_Coop.Resources.item_Sword4; break; default: swordPicture.Image = TWW_Coop.Resources.item_SwordN; break; } } if (player.inventory.tingleTuner != old.inventory.tingleTuner) { if (player.inventory.tingleTuner == (byte)WWItem.TingleTuner) { tingleTunerPicture.Image = TWW_Coop.Resources.item_TingleTuner; } else { tingleTunerPicture.Image = TWW_Coop.Resources.item_TingleTunerN; } } if (player.inventory.pictoBox != old.inventory.pictoBox) { switch (player.inventory.pictoBox) { case (byte)WWItem.PictoBox1: pictoBoxPicture.Image = TWW_Coop.Resources.item_PictoBox1; break; case (byte)WWItem.PictoBox2: pictoBoxPicture.Image = TWW_Coop.Resources.item_PictoBox2; break; default: pictoBoxPicture.Image = TWW_Coop.Resources.item_PictoBoxN; break; } } if (player.inventory.ironBoots != old.inventory.ironBoots) { if (player.inventory.ironBoots == (byte)WWItem.Boots) { ironBootsPicture.Image = TWW_Coop.Resources.item_IronBoots; } else { ironBootsPicture.Image = TWW_Coop.Resources.item_IronBootsN; } } if (player.inventory.magicArmor != old.inventory.magicArmor) { if (player.inventory.magicArmor == (byte)WWItem.MagicArmor) { magicArmorPicture.Image = TWW_Coop.Resources.item_MagicArmor; } else { magicArmorPicture.Image = TWW_Coop.Resources.item_MagicArmorN; } } if (player.inventory.baitBag != old.inventory.baitBag) { if (player.inventory.baitBag == (byte)WWItem.BaitBag) { baitBagPicture.Image = TWW_Coop.Resources.bag_BaitBag; } else { baitBagPicture.Image = TWW_Coop.Resources.bag_BaitBagN; } } if (player.inventory.bow != old.inventory.bow) { switch (player.inventory.bow) { case (byte)WWItem.Bow1: bowPicture.Image = TWW_Coop.Resources.item_Bow1; break; case (byte)WWItem.Bow2: bowPicture.Image = TWW_Coop.Resources.item_Bow2; break; case (byte)WWItem.Bow3: bowPicture.Image = TWW_Coop.Resources.item_Bow3; break; default: bowPicture.Image = TWW_Coop.Resources.item_BowN; break; } } if (player.ammo.bowCapacity != old.ammo.bowCapacity) { ThreadSetText(bowCapacity, player.ammo.bowCapacity.ToString()); } if (player.inventory.bombs != old.inventory.bombs) { if (player.inventory.bombs == (byte)WWItem.Bombs) { bombsPicture.Image = TWW_Coop.Resources.item_Bomb; } else { bombsPicture.Image = TWW_Coop.Resources.item_BombN; } } if (player.ammo.bombCapacity != old.ammo.bombCapacity) { ThreadSetText(bombCapacity, player.ammo.bombCapacity.ToString()); } // Bottle counter if ((player.inventory.bottle1 != old.inventory.bottle1) || (player.inventory.bottle2 != old.inventory.bottle2) || (player.inventory.bottle3 != old.inventory.bottle3) || (player.inventory.bottle4 != old.inventory.bottle4)) { int bottleCount = 0; if (player.inventory.bottle1 != (byte)WWBottleContents.NoBottle) { bottleCount++; } if (player.inventory.bottle2 != (byte)WWBottleContents.NoBottle) { bottleCount++; } if (player.inventory.bottle3 != (byte)WWBottleContents.NoBottle) { bottleCount++; } if (player.inventory.bottle4 != (byte)WWBottleContents.NoBottle) { bottleCount++; } ThreadSetText(bottleCounter, bottleCount.ToString()); if (bottleCount > 0) { bottlePicture.Image = TWW_Coop.Resources.item_Bottle; } else { bottlePicture.Image = TWW_Coop.Resources.item_BottleN; } } if (player.inventory.deliveryBag != old.inventory.deliveryBag) { if (player.inventory.deliveryBag == (byte)WWItem.MailBag) { deliveryBagPicture.Image = TWW_Coop.Resources.bag_DeliveryBag; } else { deliveryBagPicture.Image = TWW_Coop.Resources.bag_DeliveryBagN; } } if (player.inventory.hookshot != old.inventory.hookshot) { if (player.inventory.hookshot == (byte)WWItem.Hookshot) { hookshotPicture.Image = TWW_Coop.Resources.item_Hookshot; } else { hookshotPicture.Image = TWW_Coop.Resources.item_HookshotN; } } if (player.inventory.skullHammer != old.inventory.skullHammer) { if (player.inventory.skullHammer == (byte)WWItem.Hammer) { skullHammerPicture.Image = TWW_Coop.Resources.item_SkullHammer; } else { skullHammerPicture.Image = TWW_Coop.Resources.item_SkullHammerN; } } if (player.inventory.bracelets != old.inventory.bracelets) { if (player.inventory.bracelets == (byte)WWItem.Bracelet) { powerBraceletsPicture.Image = TWW_Coop.Resources.item_PowerBracelets; } else { powerBraceletsPicture.Image = TWW_Coop.Resources.item_PowerBraceletsN; } } if (player.inventory.shield != old.inventory.shield) { switch (player.inventory.shield) { case (byte)WWItem.Shield1: shieldPicture.Image = TWW_Coop.Resources.item_Shield1; break; case (byte)WWItem.Shield2: shieldPicture.Image = TWW_Coop.Resources.item_Shield2; break; default: shieldPicture.Image = TWW_Coop.Resources.item_ShieldN; break; } } if (player.inventory.spinAttack != old.inventory.spinAttack) { if (player.inventory.spinAttack == (byte)0x01) { hurricaneSpinPicture.Image = TWW_Coop.Resources.item_HurricaneSpin; } else { hurricaneSpinPicture.Image = TWW_Coop.Resources.item_HurricaneSpinN; } } if (player.questState.triforce != old.questState.triforce) { ThreadSetText(triforceCounter, player.questState.GetTriforceCount().ToString()); } if (player.questState.statues != old.questState.statues) { ThreadSetText(tingleCounter, player.questState.GetStatueCount().ToString()); } if (player.status.maxHP != old.status.maxHP) { int containers = player.status.maxHP / 4; ThreadSetText(heartCounter, containers.ToString()); } if (player.questState.pearls != old.questState.pearls) { if ((player.questState.pearls & WWPearlMask.Din) != 0) { dinPicture.Image = TWW_Coop.Resources.pearl_Din; } else { dinPicture.Image = TWW_Coop.Resources.pearl_N; } if ((player.questState.pearls & WWPearlMask.Farore) != 0) { farorePicture.Image = TWW_Coop.Resources.pearl_Farore; } else { farorePicture.Image = TWW_Coop.Resources.pearl_N; } if ((player.questState.pearls & WWPearlMask.Nayru) != 0) { nayruPicture.Image = TWW_Coop.Resources.pearl_Nayru; } else { nayruPicture.Image = TWW_Coop.Resources.pearl_N; } } if (player.questState.songs != old.questState.songs) { if ((player.questState.songs & WWSongMask.WindsRequiem) != 0) { windsRequiemPicture.Image = TWW_Coop.Resources.song_WindsRequiem; } else { windsRequiemPicture.Image = TWW_Coop.Resources.item_WindWakerN; } if ((player.questState.songs & WWSongMask.BalladofGales) != 0) { balladOfGalesPicture.Image = TWW_Coop.Resources.song_BalladofGales; } else { balladOfGalesPicture.Image = TWW_Coop.Resources.item_WindWakerN; } if ((player.questState.songs & WWSongMask.CommandMelody) != 0) { commandMelodyPicture.Image = TWW_Coop.Resources.song_CommandMelody; } else { commandMelodyPicture.Image = TWW_Coop.Resources.item_WindWakerN; } if ((player.questState.songs & WWSongMask.EarthGodsLyric) != 0) { earthGodsLyricPicture.Image = TWW_Coop.Resources.song_EarthGodsLyric; } else { earthGodsLyricPicture.Image = TWW_Coop.Resources.item_WindWakerN; } if ((player.questState.songs & WWSongMask.WindGodsAria) != 0) { windGodsAriaPicture.Image = TWW_Coop.Resources.song_WindGodsAria; } else { windGodsAriaPicture.Image = TWW_Coop.Resources.item_WindWakerN; } if ((player.questState.songs & WWSongMask.SongofPassing) != 0) { songOfPassingPicture.Image = TWW_Coop.Resources.song_SongofPassing; } else { songOfPassingPicture.Image = TWW_Coop.Resources.item_WindWakerN; } } if (player.questState.charts != old.questState.charts) { if (player.questState.charts.HasFlag(WWChartMask.GhostShipChart)) { ghostShipChartPicture.Image = TWW_Coop.Resources.item_GhostShipChart; } else { ghostShipChartPicture.Image = TWW_Coop.Resources.item_GhostShipChartN; } } if (player.status.maxMagic != old.status.maxMagic) { switch (player.status.maxMagic) { case 0x10: magicPicture.Image = TWW_Coop.Resources.capacity_Magic1; break; case 0x20: magicPicture.Image = TWW_Coop.Resources.capacity_Magic2; break; default: magicPicture.Image = TWW_Coop.Resources.capacity_MagicN; break; } } if (player.status.wallet != old.status.wallet) { switch (player.status.wallet) { case 0: walletPicture.Image = TWW_Coop.Resources.capacity_WalletN; break; case 1: walletPicture.Image = TWW_Coop.Resources.capacity_Wallet1; break; case 2: walletPicture.Image = TWW_Coop.Resources.capacity_Wallet2; break; default: walletPicture.Image = TWW_Coop.Resources.capacity_WalletN; break; } } // "Disposable" items to keep on the tracker once found if (player.bags.deliveryBag.HasItem(WWItem.CabanaDeed)) { cabanaDeedPicture.Image = TWW_Coop.Resources.item_CabanaDeed; } if (player.bags.deliveryBag.HasItem(WWItem.MaggiesLetter)) { maggiesLetterPicture.Image = TWW_Coop.Resources.mail_MaggiesLetter; } if (player.bags.deliveryBag.HasItem(WWItem.MoblinsLetter)) { moblinsLetterPicture.Image = TWW_Coop.Resources.mail_MoblinsLetter; } if (player.bags.deliveryBag.HasItem(WWItem.NotetoMom)) { noteToMomPicture.Image = TWW_Coop.Resources.mail_NoteToMom; } old = player; #endregion } if (msg.type == PacketType.WorldState) { Marshal.Copy(msg.data, 0, worldStateBuffer, worldStateSize); state = Marshal.PtrToStructure <WorldState>(worldStateBuffer); if (firstPass) { firstPass = false; oldState = state; } //dolphinInQueue.Add("Received world state info"); if ((state.StageName != "sea_T") && (state.StageName != "Name") && (state.StageName != "\0\0\0\0\0\0\0\0")) { if ((state.StageName != oldState.StageName) || (state.zone != oldState.zone) || (state.stageID != oldState.stageID)) { string movedMsg = String.Format("Player '{0}' moved to stage '{1}' (ID {2}), zone {3}", state.PlayerName, state.StageName, state.stageID, state.zone); dolphinInQueue.Add(movedMsg); } } oldState = state; } if (dolphinInQueue.Count > 0) { Invoke(new Action(() => { PrintConsole("Dolphin: {0}", dolphinInQueue[0]); })); dolphinInQueue.RemoveAt(0); } } FreeUnmangagedBuffers(); }