private static Tuple<Gossip, ImmutableHashSet<UniqueAddress>> Converge(Gossip gossip) { var seed = Tuple.Create(gossip, ImmutableHashSet.Create<UniqueAddress>()); return gossip.Members.Aggregate(seed, (t, m) => Tuple.Create(t.Item1.Seen(m.UniqueAddress), t.Item2.Add(m.UniqueAddress))); }
public void DomainEvents_must_be_empty_for_the_same_gossip() { var g1 = new Gossip(ImmutableSortedSet.Create(aUp)); ClusterEvent.DiffUnreachable(g1, g1, selfDummyAddress) .Should() .BeEquivalentTo(ImmutableList.Create<ClusterEvent.UnreachableMember>()); }
public void A_gossip_must_not_reach_convergence_when_unreachable() { var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1), new GossipOverview(r1)) .Seen(a1.UniqueAddress).Seen(b1.UniqueAddress); g1.Convergence(b1.UniqueAddress).Should().BeFalse(); // but from a1's point of view (it knows that itself is not unreachable) g1.Convergence(a1.UniqueAddress).Should().BeTrue(); }
public void DomainEventMustBeProducedForMembersInUnreachable() { var reachability1 = Reachability.Empty. Unreachable(aUp.UniqueAddress, cUp.UniqueAddress). Unreachable(aUp.UniqueAddress, eUp.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, cUp, eUp), new GossipOverview(reachability1)); var reachability2 = reachability1. Unreachable(aUp.UniqueAddress, bDown.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(aUp, cUp, bDown, eDown), new GossipOverview(reachability2)); Assert.Equal(ImmutableList.Create(new ClusterEvent.UnreachableMember(bDown)), ClusterEvent.DiffUnreachable(g1, g2)); Assert.Equal(ImmutableList.Create<ClusterEvent.SeenChanged>(), ClusterEvent.DiffSeen(g1, g2)); }
public void ClusterMessages_must_be_serializable() { var address = new Address("akka.tcp", "system", "some.host.org", 4711); var uniqueAddress = new UniqueAddress(address, 17); var address2 = new Address("akka.tcp", "system", "other.host.org", 4711); var uniqueAddress2 = new UniqueAddress(address2, 18); CheckSerialization(new InternalClusterAction.Join(uniqueAddress, ImmutableHashSet.Create("foo","bar"))); CheckSerialization(new ClusterUserAction.Leave(address)); CheckSerialization(new ClusterUserAction.Down(address)); CheckSerialization(new InternalClusterAction.InitJoin()); CheckSerialization(new InternalClusterAction.InitJoinAck(address)); CheckSerialization(new InternalClusterAction.InitJoinNack(address)); CheckSerialization(new ClusterHeartbeatSender.Heartbeat(address)); CheckSerialization(new ClusterHeartbeatSender.HeartbeatRsp(uniqueAddress)); var node1 = new VectorClock.Node("node1"); var node2 = new VectorClock.Node("node2"); var node3 = new VectorClock.Node("node3"); var node4 = new VectorClock.Node("node4"); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(node1) .Increment(node2) .Seen(a1.UniqueAddress) .Seen(b1.UniqueAddress); var g2 = g1.Increment(node3).Increment(node4).Seen(a1.UniqueAddress).Seen(c1.UniqueAddress); var reachability3 = Reachability.Empty.Unreachable(a1.UniqueAddress, e1.UniqueAddress) .Unreachable(b1.UniqueAddress, e1.UniqueAddress); var g3 = g2.Copy(members: ImmutableSortedSet.Create(a1, b1, c1, d1, e1), overview: g2.Overview.Copy(reachability: reachability3)); CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g1)); CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g2)); CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g3)); CheckSerialization(new GossipStatus(a1.UniqueAddress, g1.Version)); CheckSerialization(new GossipStatus(a1.UniqueAddress, g2.Version)); CheckSerialization(new GossipStatus(a1.UniqueAddress, g3.Version)); CheckSerialization(new InternalClusterAction.Welcome(uniqueAddress, g2)); var mg = new MetricsGossip(ImmutableHashSet.Create<NodeMetrics>(new[] { new NodeMetrics(a1.Address, 4711, ImmutableHashSet.Create<Metric>(new Metric("foo", 1.2, null))), new NodeMetrics(b1.Address, 4712, ImmutableHashSet.Create<Metric>(new Metric("foo", 2.1, new EWMA(100.0, 0.18)) , new Metric("bar1", Double.MinValue, null), new Metric("bar2", float.MaxValue, null), new Metric("bar3", int.MaxValue, null), new Metric("bar4", long.MaxValue, null), new Metric("bar5", double.MaxValue, null))) })); CheckSerialization(new MetricsGossipEnvelope(a1.Address, mg, true)); }
public void AGossipMustMergeMembersByRemovingRemovedMembers() { // c3 removed var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1), new GossipOverview(r1)); var r2 = r1.Unreachable(b1.UniqueAddress, c3.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c3), new GossipOverview(r2)); var merged1 = g1.Merge(g2); Assert.Equal(ImmutableHashSet.Create(a1, b1), merged1.Members); Assert.Equal(ImmutableHashSet.Create(a1.UniqueAddress), merged1.Overview.Reachability.AllUnreachable); var merged2 = g2.Merge(g1); Assert.Equal(merged2.Overview.Reachability.AllUnreachable, merged1.Overview.Reachability.AllUnreachable); Assert.Equal(merged1.Members, merged2.Members); }
public void AGossipMustMergeUnreachable() { var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress) .Unreachable(b1.UniqueAddress, c1.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1), new GossipOverview(r1)); var r2 = Reachability.Empty.Unreachable(a1.UniqueAddress, d1.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1), new GossipOverview(r2)); var merged1 = g1.Merge(g2); XAssert.Equivalent(ImmutableHashSet.Create(a1.UniqueAddress, c1.UniqueAddress, d1.UniqueAddress), merged1.Overview.Reachability.AllUnreachable); var merged2 = g2.Merge(g1); XAssert.Equivalent(merged1.Overview.Reachability.AllUnreachable, merged2.Overview.Reachability.AllUnreachable ); }
public void ClusterMessages_must_be_serializable() { var address = new Address("akka.tcp", "system", "some.host.org", 4711); var uniqueAddress = new UniqueAddress(address, 17); var address2 = new Address("akka.tcp", "system", "other.host.org", 4711); var uniqueAddress2 = new UniqueAddress(address2, 18); CheckSerialization(new InternalClusterAction.Join(uniqueAddress, ImmutableHashSet.Create("foo","bar"))); CheckSerialization(new ClusterUserAction.Leave(address)); CheckSerialization(new ClusterUserAction.Down(address)); CheckSerialization(new InternalClusterAction.InitJoin()); CheckSerialization(new InternalClusterAction.InitJoinAck(address)); CheckSerialization(new InternalClusterAction.InitJoinNack(address)); CheckSerialization(new ClusterHeartbeatSender.Heartbeat(address)); CheckSerialization(new ClusterHeartbeatSender.HeartbeatRsp(uniqueAddress)); var node1 = new VectorClock.Node("node1"); var node2 = new VectorClock.Node("node2"); var node3 = new VectorClock.Node("node3"); var node4 = new VectorClock.Node("node4"); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(node1) .Increment(node2) .Seen(a1.UniqueAddress) .Seen(b1.UniqueAddress); var g2 = g1.Increment(node3).Increment(node4).Seen(a1.UniqueAddress).Seen(c1.UniqueAddress); var reachability3 = Reachability.Empty.Unreachable(a1.UniqueAddress, e1.UniqueAddress) .Unreachable(b1.UniqueAddress, e1.UniqueAddress); var g3 = g2.Copy(members: ImmutableSortedSet.Create(a1, b1, c1, d1, e1), overview: g2.Overview.Copy(reachability: reachability3)); CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g1)); CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g2)); CheckSerialization(new GossipEnvelope(a1.UniqueAddress, uniqueAddress2, g3)); CheckSerialization(new GossipStatus(a1.UniqueAddress, g1.Version)); CheckSerialization(new GossipStatus(a1.UniqueAddress, g2.Version)); CheckSerialization(new GossipStatus(a1.UniqueAddress, g3.Version)); CheckSerialization(new InternalClusterAction.Welcome(uniqueAddress, g2)); }
public void DomainEventMustBeProducedForMembersBecomingReachableAfterUnreachable() { var reachability1 = Reachability.Empty. Unreachable(aUp.UniqueAddress, cUp.UniqueAddress).Reachable(aUp.UniqueAddress, cUp.UniqueAddress). Unreachable(aUp.UniqueAddress, eUp.UniqueAddress). Unreachable(aUp.UniqueAddress, bUp.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, cUp, eUp), new GossipOverview(reachability1)); var reachability2 = reachability1. Unreachable(aUp.UniqueAddress, cUp.UniqueAddress). Reachable(aUp.UniqueAddress, bUp.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(aUp, cUp, bUp, eUp), new GossipOverview(reachability2)); Assert.Equal(ImmutableList.Create(new ClusterEvent.UnreachableMember(cUp)), ClusterEvent.DiffUnreachable(g1, g2)); Assert.Equal(ImmutableList.Create(new ClusterEvent.ReachableMember(bUp)), ClusterEvent.DiffReachable(g1,g2)); }
public void DomainEventsMustBeEmptyForTheSameGossip() { var g1 = new Gossip(ImmutableSortedSet.Create(aUp)); Assert.Equal(ImmutableSortedSet.Create<object>(), ClusterEvent.DiffUnreachable(g1, g1)); }
public void DomainEventMustBeProducedForConvergenceChanges() { var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, eJoining)).Seen(aUp.UniqueAddress) .Seen(bUp.UniqueAddress) .Seen(eJoining.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, eJoining)).Seen(aUp.UniqueAddress).Seen(bUp.UniqueAddress); Assert.Equal(ImmutableList.Create<ClusterEvent.IMemberEvent>(), ClusterEvent.DiffMemberEvents(g1, g2)); Assert.Equal(ImmutableList.Create<ClusterEvent.UnreachableMember>(), ClusterEvent.DiffUnreachable(g1, g2)); Assert.Equal(ImmutableList.Create(new ClusterEvent.SeenChanged(true, ImmutableHashSet.Create(aUp.Address, bUp.Address))), ClusterEvent.DiffSeen(g1, g2)); Assert.Equal(ImmutableList.Create<ClusterEvent.IMemberEvent>(), ClusterEvent.DiffMemberEvents(g2, g1)); Assert.Equal(ImmutableList.Create<ClusterEvent.UnreachableMember>(), ClusterEvent.DiffUnreachable(g2, g1)); Assert.Equal(ImmutableList.Create(new ClusterEvent.SeenChanged(true, ImmutableHashSet.Create(aUp.Address, bUp.Address, eJoining.Address))), ClusterEvent.DiffSeen(g2, g1)); }
public static void HandleNpcGossip(Packet packet) { var gossip = new Gossip(); var guid = packet.ReadPackedGuid128("GossipGUID"); gossip.ObjectType = guid.GetObjectType(); gossip.ObjectEntry = guid.GetEntry(); var menuId = packet.ReadInt32("GossipID"); packet.ReadInt32("FriendshipFactionID"); var textId = packet.ReadInt32("TextID"); var int44 = packet.ReadInt32("GossipOptions"); var int60 = packet.ReadInt32("GossipText"); // ClientGossipOptions gossip.GossipOptions = new List <GossipOption>(int44); for (var i = 0; i < int44; ++i) { var gossipOption = new GossipOption(); gossipOption.Index = (uint)packet.ReadInt32("ClientOption", i); packet.ReadByte("OptionNPC", i); packet.ReadByte("OptionFlags", i); gossipOption.RequiredMoney = (uint)packet.ReadInt32("OptionCost", i); var bits3 = packet.ReadBits(12); var bits753 = packet.ReadBits(12); gossipOption.OptionText = packet.ReadWoWString("Text", bits3, i); gossipOption.BoxText = packet.ReadWoWString("Confirm", bits753, i); gossip.GossipOptions.Add(gossipOption); } // ClientGossipOptions for (var i = 0; i < int60; ++i) { packet.ReadInt32("QuestID", i); packet.ReadInt32("QuestType", i); packet.ReadInt32("QuestLevel", i); for (var j = 0; j < 2; ++j) { packet.ReadInt32("QuestFlags", i, j); } packet.ResetBitReader(); packet.ReadBit("Repeatable"); var bits13 = packet.ReadBits(9); packet.ReadWoWString("QuestTitle", bits13, i); if (guid.GetObjectType() == ObjectType.Unit) { if (Storage.Objects.ContainsKey(guid)) { ((Unit)Storage.Objects[guid].Item1).GossipId = (uint)menuId; } } if (Storage.Gossips.ContainsKey(Tuple.Create((uint)menuId, (uint)textId))) { var oldGossipOptions = Storage.Gossips[Tuple.Create((uint)menuId, (uint)textId)]; if (oldGossipOptions != null) { foreach (var gossipOptions in gossip.GossipOptions) { oldGossipOptions.Item1.GossipOptions.Add(gossipOptions); } } } else { Storage.Gossips.Add(Tuple.Create((uint)menuId, (uint)textId), gossip, packet.TimeSpan); } packet.AddSniffData(StoreNameType.Gossip, menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture)); } }
public void AGossipMustKnowWhoIsYoungest() { // a2 and e1 is Joining var g1 = new Gossip(ImmutableSortedSet.Create(a2, b1.CopyUp(3), e1), new GossipOverview(Reachability.Empty.Unreachable(a2.UniqueAddress, e1.UniqueAddress))); Assert.Equal(b1, g1.YoungestMember); var g2 = new Gossip(ImmutableSortedSet.Create(a2, b1.CopyUp(3), e1), new GossipOverview(Reachability.Empty.Unreachable(a2.UniqueAddress, b1.UniqueAddress).Unreachable(a2.UniqueAddress, e1.UniqueAddress))); Assert.Equal(b1, g2.YoungestMember); var g3 = new Gossip(ImmutableSortedSet.Create(a2, b1.CopyUp(3), e2.CopyUp(4))); Assert.Equal(e2, g3.YoungestMember); }
public void DomainEvents_must_be_produced_for_role_leader_changes() { var g0 = Gossip.Empty; var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, cUp, dLeaving, eJoining)); var g2 = new Gossip(ImmutableSortedSet.Create(bUp, cUp, dExiting, eJoining)); var expected = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", aUp.Address), new ClusterEvent.RoleLeaderChanged("AB", aUp.Address), new ClusterEvent.RoleLeaderChanged("BB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DD", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("DE", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("EE", eUp.Address)); ClusterEvent.DiffRolesLeader(g0, g1, selfDummyAddress).Should().BeEquivalentTo(expected); var expected2 = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", null), new ClusterEvent.RoleLeaderChanged("AB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DE", eJoining.Address)); ClusterEvent.DiffRolesLeader(g1, g2, selfDummyAddress).Should().BeEquivalentTo(expected2); }
public static void HandleNpcGossip(Packet packet) { var guidBytes = new byte[8]; packet.StartBitStream(guidBytes, 0, 1); var questgossips = packet.ReadBits("Amount of Quest gossips", 19); guidBytes[2] = packet.ReadBit(); var amountOfOptions = packet.ReadBits("Amount of Options", 20); var titleLen = new uint[questgossips]; for (var i = 0; i < questgossips; ++i) { packet.ReadBit("Change Icon", i); titleLen[i] = packet.ReadBits(9); } guidBytes[3] = packet.ReadBit(); var optionTextLen = new uint[amountOfOptions]; var boxTextLen = new uint[amountOfOptions]; for (var i = 0; i < amountOfOptions; ++i) { boxTextLen[i] = packet.ReadBits(12); optionTextLen[i] = packet.ReadBits(12); } packet.StartBitStream(guidBytes, 5, 4, 6, 7); packet.ResetBitReader(); packet.ReadXORByte(guidBytes, 6); var gossip = new Gossip(); gossip.GossipOptions = new List <GossipOption>((int)amountOfOptions); for (var i = 0; i < amountOfOptions; ++i) { var gossipOption = new GossipOption { OptionText = packet.ReadWoWString("Text", optionTextLen[i], i), BoxText = packet.ReadWoWString("Box Text", boxTextLen[i], i), RequiredMoney = packet.ReadUInt32("Required money", i), OptionIcon = packet.ReadByteE <GossipOptionIcon>("Icon", i), Box = packet.ReadBool("Box", i), Index = packet.ReadUInt32("Index", i) }; gossip.GossipOptions.Add(gossipOption); } packet.ReadXORByte(guidBytes, 0); for (var i = 0; i < questgossips; i++) { packet.ReadUInt32E <QuestFlags>("Flags", i); packet.ReadWoWString("Title", titleLen[i], i); packet.ReadUInt32("Icon", i); packet.ReadUInt32E <QuestFlags2>("Flags 2", i); packet.ReadInt32("Level", i); packet.ReadUInt32 <QuestId>("Quest ID", i); } var textId = packet.ReadUInt32("Text Id"); packet.ReadXORBytes(guidBytes, 4, 3); var menuId = packet.ReadUInt32("Menu Id"); packet.ReadUInt32("Friendship Faction"); packet.ReadXORBytes(guidBytes, 7, 1, 5, 2); var guid = packet.WriteGuid("GUID", guidBytes); gossip.ObjectType = guid.GetObjectType(); gossip.ObjectEntry = guid.GetEntry(); if (guid.GetObjectType() == ObjectType.Unit) { if (Storage.Objects.ContainsKey(guid)) { ((Unit)Storage.Objects[guid].Item1).GossipId = menuId; } } if (Storage.Gossips.ContainsKey(Tuple.Create(menuId, textId))) { var oldGossipOptions = Storage.Gossips[Tuple.Create(menuId, textId)]; if (oldGossipOptions != null) { foreach (var gossipOptions in gossip.GossipOptions) { oldGossipOptions.Item1.GossipOptions.Add(gossipOptions); } } } else { Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan); } packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture)); }
void BlankStats() { GossipValue.text = ""; _gossip = null; }
void DisplayGossip(Gossip gossip) { _gossip = gossip; GossipValue.text = "£" + _gossip.LivreValue().ToString("### ###"); }
public override void Run() { if (_listOfTeachers.Count <= 0) { return; } Npc bestTeacher = new Npc(); for (int i = 0; i < _listOfTeachers.Count; i++) { Npc teacher = _listOfTeachers[i]; if (bestTeacher.Entry > 0) { // priority checks first switch (Products.Products.ProductName) { case "Gatherer": if (bestTeacher.Type == Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.RidingTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.HerbalismTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.MiningTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.HerbalismTrainer) { continue; } if (teacher.Type == Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.HerbalismTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.HerbalismTrainer) { bestTeacher = teacher; } break; case "Quester": case "Grinder": if (bestTeacher.Type == Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.RidingTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.MiningTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.SkinningTrainer) { continue; } if (bestTeacher.Type == Npc.NpcType.HerbalismTrainer && teacher.Type != Npc.NpcType.RidingTrainer && teacher.Type != Npc.NpcType.SkinningTrainer && teacher.Type != Npc.NpcType.MiningTrainer) { continue; } if (teacher.Type == Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.MiningTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.SkinningTrainer) { bestTeacher = teacher; } else if (teacher.Type == Npc.NpcType.HerbalismTrainer && bestTeacher.Type != Npc.NpcType.RidingTrainer && bestTeacher.Type != Npc.NpcType.SkinningTrainer && bestTeacher.Type != Npc.NpcType.MiningTrainer) { bestTeacher = teacher; } break; } if (bestTeacher == teacher) { continue; // We just set a best from priority checks, so distance check is not important anymore } if (ObjectManager.ObjectManager.Me.Position.DistanceTo(teacher.Position) < ObjectManager.ObjectManager.Me.Position.DistanceTo(bestTeacher.Position)) { bestTeacher = teacher; // We do not have priority between teacher and the actual bestTeacher, so we use distance instead } } else { bestTeacher = teacher; } } if (bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 800) { if (Quest.TravelToQuestZone(bestTeacher.Position, ref _doTravel, bestTeacher.ContinentIdInt, false, bestTeacher.Type.ToString())) { return; } } uint baseAddress = MovementManager.FindTarget(ref bestTeacher); if (MovementManager.InMovement) { return; } if (baseAddress == 0 && bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) < 10) { NpcDB.DelNpc(bestTeacher); } else if (baseAddress > 0) { if (bestTeacher.Position.DistanceTo(ObjectManager.ObjectManager.Me.Position) > 5f) { return; } string[] skillInfo = bestTeacher.InternalData.Split(','); if (skillInfo.Length == 2) { SkillLine skillLine = (SkillLine)Others.ToInt32(skillInfo[0]); SkillRank skillRank = (SkillRank)Others.ToInt32(skillInfo[1]); SkillRank nextRank; if (skillRank == SkillRank.ZenMaster) { nextRank = skillRank + 100; } else { nextRank = skillRank + 75; } string oldRank = ""; if (skillRank != SkillRank.None) { oldRank = " We were only " + skillRank.ToString() + " of " + skillLine.ToString() + "."; } Logging.Write("We have just reached the Teacher of " + skillLine.ToString() + ", " + bestTeacher.Name + ". We are now going to learn " + nextRank.ToString() + " of " + skillLine.ToString() + "." + oldRank); } Interact.InteractWith(baseAddress); Thread.Sleep(500 + Usefuls.Latency); Quest.CompleteQuest(); Gossip.TrainAllAvailableSpells(); TeacherFoundNoSpam.Remove(bestTeacher); SpellManager.UpdateSpellBook(); _doTravel = true; } // still on the road, but not in movement for some reasons }
public static void HandleNpcGossip(Packet packet) { var guid = new byte[8]; uint[] titleLen; uint[] OptionTextLen; uint[] BoxTextLen; packet.StartBitStream(guid, 0, 1); var questgossips = packet.ReadBits("Amount of Quest gossips", 19); guid[2] = packet.ReadBit(); var AmountOfOptions = packet.ReadBits("Amount of Options", 20); titleLen = new uint[questgossips]; for (var i = 0; i < questgossips; ++i) { packet.ReadBit("Change Icon", i); titleLen[i] = packet.ReadBits(9); } guid[3] = packet.ReadBit(); OptionTextLen = new uint[AmountOfOptions]; BoxTextLen = new uint[AmountOfOptions]; for (var i = 0; i < AmountOfOptions; ++i) { BoxTextLen[i] = packet.ReadBits(12); OptionTextLen[i] = packet.ReadBits(12); } packet.StartBitStream(guid, 5, 4, 6, 7); packet.ResetBitReader(); packet.ReadXORByte(guid, 6); var gossip = new Gossip(); gossip.GossipOptions = new List <GossipOption>((int)AmountOfOptions); for (var i = 0; i < AmountOfOptions; ++i) { var gossipOption = new GossipOption { OptionText = packet.ReadWoWString("Text", OptionTextLen[i], i), BoxText = packet.ReadWoWString("Box Text", BoxTextLen[i], i), RequiredMoney = packet.ReadUInt32("Required money", i), OptionIcon = packet.ReadEnum <GossipOptionIcon>("Icon", TypeCode.Byte, i), Box = packet.ReadBoolean("Box", i), Index = packet.ReadUInt32("Index", i) }; gossip.GossipOptions.Add(gossipOption); } packet.ReadXORByte(guid, 0); for (var i = 0; i < questgossips; i++) { packet.ReadEnum <QuestFlags>("Flags", TypeCode.UInt32, i); packet.ReadWoWString("Title", titleLen[i], i); packet.ReadUInt32("Icon", i); packet.ReadEnum <QuestFlags2>("Flags 2", TypeCode.UInt32, i); packet.ReadInt32("Level", i); packet.ReadEntryWithName <UInt32>(StoreNameType.Quest, "Quest ID", i); } var textId = packet.ReadUInt32("Text Id"); packet.ReadXORBytes(guid, 4, 3); var menuId = packet.ReadUInt32("Menu Id"); packet.ReadUInt32("Friendship Faction"); packet.ReadXORBytes(guid, 7, 1, 5, 2); packet.WriteGuid("GUID", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); gossip.ObjectType = GUID.GetObjectType(); gossip.ObjectEntry = GUID.GetEntry(); Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan); packet.AddSniffData(StoreNameType.Gossip, (int)menuId, GUID.GetEntry().ToString(CultureInfo.InvariantCulture)); }
public void A_gossip_must_reach_convergence_for_one_node() { var g1 = new Gossip(ImmutableSortedSet.Create(a1)).Seen(a1.UniqueAddress); State(g1).Convergence(ImmutableHashSet <UniqueAddress> .Empty).Should().BeTrue(); }
private MembershipState State(Gossip g, Member selfMember = null) { selfMember = selfMember ?? a1; return(new MembershipState(g, selfMember.UniqueAddress)); }
public void LoadGossips() { Log.Message(LogType.DB, "Loading creature gossips..."); SQLResult result = DB.World.Select("SELECT * FROM creature_gossips cg RIGHT JOIN gossip_data gd ON cg.GossipDataId = gd.Id RIGHT JOIN broadcast_texts bt " + "ON cg.BroadcastTextId = bt.Id WHERE cg.GossipDataId IS NOT NULL AND cg.BroadcastTextId IS NOT NULL"); for (int i = 0; i < result.Count; i++) { var guid = result.Read <ulong>(i, "Guid"); var gossipData = new Gossip { Id = result.Read <int>(i, "GossipDataId"), FriendshipFactionID = result.Read <int>(i, "FriendshipFactionID"), TextID = result.Read <int>(i, "TextID"), OptionsCount = result.Read <int>(i, "OptionsCount"), QuestsCount = result.Read <int>(i, "QuestsCount") }; gossipData.BroadCastText = new BroadcastText { Id = result.Read <int>(i, "BroadCastTextID"), Language = result.Read <int>(i, "Language"), Text = result.Read <string>(i, "Text"), AlternativeText = result.Read <string>(i, "AlternativeText") }; for (int j = 0; j < gossipData.BroadCastText.Emotes.Capacity; j++) { gossipData.BroadCastText.Emotes.Add(result.Read <int>(0, "Emote" + j)); } CreatureGossips.TryAdd(guid, gossipData); } Log.Message(LogType.DB, "Loaded {0} creature gossips.", CreatureGossips.Count); Log.Message(); Log.Message(LogType.DB, "Loading gameobject gossips..."); result = DB.World.Select("SELECT * FROM gameobject_gossips gg RIGHT JOIN gossip_data gd ON gg.GossipDataId = gd.Id RIGHT JOIN broadcast_texts bt " + "ON gg.BroadcastTextId = bt.Id WHERE gg.GossipDataId IS NOT NULL AND gg.BroadcastTextId IS NOT NULL"); for (int i = 0; i < result.Count; i++) { var guid = result.Read <ulong>(i, "Guid"); var gossipData = new Gossip { Id = result.Read <int>(i, "GossipDataId"), FriendshipFactionID = result.Read <int>(i, "FriendshipFactionID"), TextID = result.Read <int>(i, "TextID"), OptionsCount = result.Read <int>(i, "OptionsCount"), QuestsCount = result.Read <int>(i, "QuestsCount") }; gossipData.BroadCastText = new BroadcastText { Id = result.Read <int>(i, "BroadCastTextID"), Language = result.Read <int>(i, "Language"), Text = result.Read <string>(i, "Text"), AlternativeText = result.Read <string>(i, "AlternativeText") }; for (int j = 0; j < gossipData.BroadCastText.Emotes.Capacity; j++) { gossipData.BroadCastText.Emotes.Add(result.Read <int>(0, "Emote" + j)); } GameObjectGossips.TryAdd(guid, gossipData); } Log.Message(LogType.DB, "Loaded {0} gameobject gossips.", GameObjectGossips.Count); Log.Message(); }
public void A_gossip_must_reach_convergence_for_two_nodes() { var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1)).Seen(a1.UniqueAddress).Seen(b1.UniqueAddress); g1.Convergence(a1.UniqueAddress, new HashSet <UniqueAddress>()).Should().BeTrue(); }
public void DomainEventsMustBeEmptyForTheSameGossip() { var g1 = new Gossip(ImmutableSortedSet.Create(aUp)); Assert.Equal(ImmutableSortedSet.Create <object>(), ClusterEvent.DiffUnreachable(g1, g1)); }
public void DomainEvents_must_be_produced_for_members_becoming_reachable_after_unreachable() { var reachability1 = Reachability.Empty. Unreachable(aUp.UniqueAddress, cUp.UniqueAddress). Reachable(aUp.UniqueAddress, cUp.UniqueAddress). Unreachable(aUp.UniqueAddress, eUp.UniqueAddress). Unreachable(aUp.UniqueAddress, bUp.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, cUp, eUp), new GossipOverview(reachability1)); var reachability2 = reachability1. Unreachable(aUp.UniqueAddress, cUp.UniqueAddress). Reachable(aUp.UniqueAddress, bUp.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(aUp, cUp, bUp, eUp), new GossipOverview(reachability2)); ClusterEvent.DiffUnreachable(g1, g2, selfDummyAddress) .Should() .BeEquivalentTo(ImmutableList.Create(new ClusterEvent.UnreachableMember(cUp))); // never include self member in unreachable ClusterEvent.DiffUnreachable(g1, g2, cUp.UniqueAddress) .Should() .BeEquivalentTo(ImmutableList.Create<ClusterEvent.UnreachableMember>()); ClusterEvent.DiffReachable(g1, g2, selfDummyAddress) .Should() .BeEquivalentTo(ImmutableList.Create(new ClusterEvent.ReachableMember(bUp))); // never include self member in reachable ClusterEvent.DiffReachable(g1, g2, bUp.UniqueAddress) .Should() .BeEquivalentTo(ImmutableList.Create<ClusterEvent.ReachableMember>()); }
private void StartListening() { Gossip.StartListening(); }
public ActionResult Edit(Gossip gossip) { _db.Entry(gossip).State = EntityState.Modified; _db.SaveChanges(); return(RedirectToAction("Index")); }
public void AddNewGossipToQueue(Gossip gossip) { gossipRepo.AddNewGossipToQueue(gossip); }
public void DomainEvents_must_be_empty_for_the_same_gossip() { var g1 = new Gossip(ImmutableSortedSet.Create(aUp)); Assert.Equal(ImmutableSortedSet.Create <object>(), ClusterEvent.DiffUnreachable(g1, g1)); }
public static void HandleNpcGossip(Packet packet) { var gossip = new Gossip(); var guid = packet.ReadGuid("GUID"); gossip.ObjectType = guid.GetObjectType(); gossip.ObjectEntry = guid.GetEntry(); var menuId = packet.ReadUInt32("Menu Id"); if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria)) { packet.ReadUInt32("Friendship Faction"); } var textId = packet.ReadUInt32("Text Id"); if (guid.GetObjectType() == ObjectType.Unit) { if (Storage.Objects.ContainsKey(guid)) { ((Unit)Storage.Objects[guid].Item1).GossipId = menuId; } } var count = packet.ReadUInt32("Amount of Options"); gossip.GossipOptions = new List <GossipOption>((int)count); for (var i = 0; i < count; i++) { var gossipOption = new GossipOption { Index = packet.ReadUInt32("Index", i), OptionIcon = packet.ReadEnum <GossipOptionIcon>("Icon", TypeCode.Byte, i), Box = packet.ReadBoolean("Box", i), RequiredMoney = packet.ReadUInt32("Required money", i), OptionText = packet.ReadCString("Text", i), BoxText = packet.ReadCString("Box Text", i) }; gossip.GossipOptions.Add(gossipOption); } if (Storage.Gossips.ContainsKey(Tuple.Create(menuId, textId))) { var oldGossipOptions = Storage.Gossips[Tuple.Create(menuId, textId)]; if (oldGossipOptions != null) { foreach (var gossipOptions in gossip.GossipOptions) { oldGossipOptions.Item1.GossipOptions.Add(gossipOptions); } } } else { Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan); } packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture)); var questgossips = packet.ReadUInt32("Amount of Quest gossips"); for (var i = 0; i < questgossips; i++) { packet.ReadEntry <UInt32>(StoreNameType.Quest, "Quest ID", i); packet.ReadUInt32("Icon", i); packet.ReadInt32("Level", i); packet.ReadEnum <QuestFlags>("Flags", TypeCode.UInt32, i); if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309)) { packet.ReadEnum <QuestFlags2>("Flags 2", TypeCode.UInt32, i); } packet.ReadBoolean("Change Icon", i); packet.ReadCString("Title", i); } }
public static void HandleNpcGossip(Packet packet) { var gossip = new Gossip(); var guidBytes = new byte[8]; guidBytes[7] = packet.ReadBit(); guidBytes[6] = packet.ReadBit(); guidBytes[1] = packet.ReadBit(); var questgossips = packet.ReadBits(19); guidBytes[0] = packet.ReadBit(); guidBytes[4] = packet.ReadBit(); guidBytes[5] = packet.ReadBit(); guidBytes[2] = packet.ReadBit(); guidBytes[3] = packet.ReadBit(); var amountOfOptions = packet.ReadBits(20); var boxTextLen = new uint[amountOfOptions]; var optionTextLen = new uint[amountOfOptions]; for (var i = 0; i < amountOfOptions; ++i) { boxTextLen[i] = packet.ReadBits(12); optionTextLen[i] = packet.ReadBits(12); } var titleLen = new uint[questgossips]; for (var i = 0; i < questgossips; ++i) { packet.ReadBit("Change Icon", i); titleLen[i] = packet.ReadBits(9); } for (var i = 0; i < questgossips; ++i) { packet.ReadEnum <QuestFlags2>("Flags 2", TypeCode.UInt32, i); packet.ReadEntry <UInt32>(StoreNameType.Quest, "Quest ID", i); packet.ReadInt32("Level", i); packet.ReadUInt32("Icon", i); packet.ReadEnum <QuestFlags>("Flags", TypeCode.UInt32, i); packet.ReadWoWString("Title", titleLen[i], i); } packet.ReadXORByte(guidBytes, 6); gossip.GossipOptions = new List <GossipOption>((int)amountOfOptions); for (var i = 0; i < amountOfOptions; ++i) { var gossipOption = new GossipOption { RequiredMoney = packet.ReadUInt32("Required money", i), OptionText = packet.ReadWoWString("Text", optionTextLen[i], i), Index = packet.ReadUInt32("Index", i), OptionIcon = packet.ReadEnum <GossipOptionIcon>("Icon", TypeCode.Byte, i), BoxText = packet.ReadWoWString("Box Text", boxTextLen[i], i), Box = packet.ReadBoolean("Box", i), }; gossip.GossipOptions.Add(gossipOption); } packet.ReadXORByte(guidBytes, 2); var textId = packet.ReadUInt32("Text Id"); packet.ReadXORByte(guidBytes, 1); packet.ReadXORByte(guidBytes, 5); var menuId = packet.ReadUInt32("Menu Id"); packet.ReadUInt32("Friendship Faction"); packet.ReadXORByte(guidBytes, 4); packet.ReadXORByte(guidBytes, 7); packet.ReadXORByte(guidBytes, 3); packet.ReadXORByte(guidBytes, 0); packet.WriteGuid("Guid", guidBytes); var guid = new WowGuid(BitConverter.ToUInt64(guidBytes, 0)); gossip.ObjectType = guid.GetObjectType(); gossip.ObjectEntry = guid.GetEntry(); if (guid.GetObjectType() == ObjectType.Unit) { if (Storage.Objects.ContainsKey(guid)) { ((Unit)Storage.Objects[guid].Item1).GossipId = menuId; } } if (Storage.Gossips.ContainsKey(Tuple.Create(menuId, textId))) { var oldGossipOptions = Storage.Gossips[Tuple.Create(menuId, textId)]; if (oldGossipOptions != null) { foreach (var gossipOptions in gossip.GossipOptions) { oldGossipOptions.Item1.GossipOptions.Add(gossipOptions); } } } else { Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan); } packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture)); }
private MembershipState State(Gossip g) { return(new MembershipState(g, selfDummyAddress)); }
public void DomainEventMustBeProducedForRoleLeaderChanges() { var g0 = Gossip.Empty; var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, cUp, dLeaving, eJoining)); var g2 = new Gossip(ImmutableSortedSet.Create(bUp, cUp, dExiting, eJoining)); var expected = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", aUp.Address), new ClusterEvent.RoleLeaderChanged("AB", aUp.Address), new ClusterEvent.RoleLeaderChanged("BB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DD", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("DE", dLeaving.Address), new ClusterEvent.RoleLeaderChanged("EE", eUp.Address) ); Assert.Equal(expected, ClusterEvent.DiffRolesLeader(g0, g1)); var expected2 = ImmutableHashSet.Create( new ClusterEvent.RoleLeaderChanged("AA", null), new ClusterEvent.RoleLeaderChanged("AB", bUp.Address), new ClusterEvent.RoleLeaderChanged("DE", eJoining.Address) ); Assert.Equal(expected2, ClusterEvent.DiffRolesLeader(g1, g2)); }
public void A_gossip_must_merge_unreachable() { var r1 = Reachability.Empty. Unreachable(b1.UniqueAddress, a1.UniqueAddress). Unreachable(b1.UniqueAddress, c1.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1), new GossipOverview(r1)); var r2 = Reachability.Empty.Unreachable(a1.UniqueAddress, d1.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1), new GossipOverview(r2)); var merged1 = g1.Merge(g2); merged1.Overview.Reachability.AllUnreachable.Should() .BeEquivalentTo(ImmutableHashSet.Create(a1.UniqueAddress, c1.UniqueAddress, d1.UniqueAddress)); var merged2 = g2.Merge(g1); merged2.Overview.Reachability.AllUnreachable.Should() .BeEquivalentTo(merged1.Overview.Reachability.AllUnreachable); }
public ActionResult PostGossip(FormCollection collection) { string userId = collection["userId"]; string content = collection["content"]; string radio = collection["category"]; int category = 0; if (radio == "1") { category = 1; } else if (radio == "2") { category = 2; } else if (radio == "3") { category = 3; } var newGossip = new Gossip(); newGossip.category = category; newGossip.content = content; newGossip.dateCreated = DateTime.Now; newGossip.isAccepted = false; newGossip.isSeen = false; newGossip.isDeclined = false; var gossipService = new GossipService(); gossipService.AddNewGossipToQueue(newGossip); return Redirect(HttpContext.Request.UrlReferrer.AbsoluteUri); }
public void A_gossip_must_merge_members_by_removing_removed_members() { // c3 removed var r1 = Reachability.Empty.Unreachable(b1.UniqueAddress, a1.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1), new GossipOverview(r1)); var r2 = r1.Unreachable(b1.UniqueAddress, c3.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c3), new GossipOverview(r2)); var merged1 = g1.Merge(g2); merged1.Members.Should().BeEquivalentTo(ImmutableHashSet.Create(a1, b1)); merged1.Overview.Reachability.AllUnreachable.Should() .BeEquivalentTo(ImmutableHashSet.Create(a1.UniqueAddress)); var merged2 = g2.Merge(g1); merged2.Overview.Reachability.AllUnreachable.Should() .BeEquivalentTo(merged1.Overview.Reachability.AllUnreachable); merged2.Members.Should().BeEquivalentTo(merged1.Members); }
public static void LaunchTaxi() { try { if (_availableTaxis == null) { _availableTaxis = XmlSerializer.Deserialize <List <Taxi> >(Application.StartupPath + @"\Data\TaxiList.xml"); } if (_availableTaxiLinks == null) { _availableTaxiLinks = XmlSerializer.Deserialize <List <TaxiLink> >(Application.StartupPath + @"\Data\TaxiLinks.xml"); } uint firstTaxiId = 0; while (true) { _availableTaxis = XmlSerializer.Deserialize <List <Taxi> >(Application.StartupPath + @"\Data\TaxiList.xml"); _availableTaxiLinks = XmlSerializer.Deserialize <List <TaxiLink> >(Application.StartupPath + @"\Data\TaxiLinks.xml"); if (IsTaxiOpen()) { if (firstTaxiId != 0 && firstTaxiId == ObjectManager.Me.Target.GetWoWId) { Logging.Write("The continent have been parsed !"); break; } if (firstTaxiId == 0) { firstTaxiId = ObjectManager.Me.Target.GetWoWId; } if (TaxiListContainsTaxiId(ObjectManager.Me.Target.GetWoWId)) { Logging.WriteDebug("The taxi from NPC " + ObjectManager.Target.Name + " is already in our database."); Taxi myTaxi = GetTaxiFromTaxiId(ObjectManager.Me.Target.GetWoWId); if (myTaxi.Faction != Npc.FactionType.Neutral && ObjectManager.Me.PlayerFaction != myTaxi.Faction.ToString()) { for (int i = 0; i < _availableTaxis.Count; i++) { if (myTaxi.Id == _availableTaxis[i].Id) { _availableTaxis[i].Faction = Npc.FactionType.Neutral; } } } } else { var localTaxi = new Taxi(); localTaxi.Id = ObjectManager.Me.Target.GetWoWId; localTaxi.Position = ObjectManager.Target.Position; string taxiInfo = ExtractCurrentTaxiInfo(); localTaxi.Name = taxiInfo.Split('#')[0]; localTaxi.ContinentId = Usefuls.ContinentId; localTaxi.Xcoord = taxiInfo.Split('#')[1].Split('^')[0]; localTaxi.Ycoord = taxiInfo.Split('^')[1].Split('@')[0]; localTaxi.Faction = ObjectManager.Me.PlayerFaction == "Alliance" ? Npc.FactionType.Alliance : Npc.FactionType.Horde; _availableTaxis.Add(localTaxi); foreach (TaxiLink taxiLink in _availableTaxiLinks) { if (taxiLink.PointB == 0 && taxiLink.PointB_XY == localTaxi.Xcoord + localTaxi.Ycoord) { taxiLink.PointB = localTaxi.Id; taxiLink.PointB_XY = ""; } } } foreach (string ctaxi in ExtractDirectPathTaxiInfoList()) { string taxiInfo = ctaxi; var localTaxi = new Taxi(); localTaxi.Name = taxiInfo.Split('#')[0]; localTaxi.ContinentId = Usefuls.ContinentId; localTaxi.Xcoord = taxiInfo.Split('#')[1].Split('^')[0]; localTaxi.Ycoord = taxiInfo.Split('^')[1].Split('@')[0]; bool taxiExist = false; var taxiFound = new Taxi(); foreach (Taxi taxi in _availableTaxis) { if (taxi.Xcoord == localTaxi.Xcoord && taxi.Ycoord == localTaxi.Ycoord) { // this taxi exist in the list so we have its ID taxiExist = true; taxiFound = taxi; } } bool found = false; foreach (TaxiLink taxiLink in _availableTaxiLinks) { if (taxiExist && taxiLink.PointA == ObjectManager.Me.Target.GetWoWId && taxiLink.PointB == taxiFound.Id) { found = true; break; } if (taxiExist && taxiLink.PointB == ObjectManager.Me.Target.GetWoWId && taxiLink.PointA == taxiFound.Id) { found = true; break; } if (taxiLink.PointA == ObjectManager.Me.Target.GetWoWId && taxiLink.PointB_XY == localTaxi.Xcoord + localTaxi.Ycoord) { found = true; break; } } if (!found) { _availableTaxiLinks.Add(taxiExist ? new TaxiLink { PointA = ObjectManager.Me.Target.GetWoWId, PointB = taxiFound.Id } : new TaxiLink { PointA = ObjectManager.Me.Target.GetWoWId, PointB_XY = localTaxi.Xcoord + localTaxi.Ycoord }); } } XmlSerializer.Serialize(Application.StartupPath + @"\Data\TaxiList.xml", _availableTaxis); XmlSerializer.Serialize(Application.StartupPath + @"\Data\TaxiLinks.xml", _availableTaxiLinks); string nextHop = ExtractNextTaxiInfo(); Logging.Write("Taking taxi from " + ExtractCurrentTaxiInfo().Split('#')[0] + " to " + nextHop.Split('#')[0]); Gossip.TakeTaxi(nextHop.Split('#')[1].Split('^')[0], nextHop.Split('^')[1].Split('@')[0]); Thread.Sleep(1000); } if (ObjectManager.Me.OnTaxi) { Travel.TravelPatientlybyTaxiOrPortal(true); Thread.Sleep(2000); continue; } WoWUnit taxiUnit = ObjectManager.GetNearestWoWUnit(ObjectManager.GetWoWUnitFlightMaster()); uint baseAddress = MovementManager.FindTarget(taxiUnit); if (MovementManager.InMovement) { continue; } if (baseAddress > 0) { Interact.InteractWith(baseAddress); Thread.Sleep(500); if (!Gossip.IsTaxiWindowOpen()) { Gossip.SelectGossip(Gossip.GossipOption.Taxi); Thread.Sleep(250 + Usefuls.Latency); } } Thread.Sleep(200); } } catch (Exception e) { Logging.WriteDebug(e.ToString()); } }
public void A_gossip_must_merge_seen_table_correctly() { var vclockNode = VectorClock.Node.Create("something"); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode) .Seen(a1.UniqueAddress) .Seen(b1.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode) .Seen(a1.UniqueAddress) .Seen(c1.UniqueAddress); var g3 = g1.Copy(version: g2.Version).Seen(d1.UniqueAddress); Action<Gossip> checkMerge = merged => { var seen = merged.Overview.Seen; seen.Count.Should().Be(0); merged.SeenByNode(a1.UniqueAddress).Should().BeFalse(); merged.SeenByNode(b1.UniqueAddress).Should().BeFalse(); merged.SeenByNode(c1.UniqueAddress).Should().BeFalse(); merged.SeenByNode(d1.UniqueAddress).Should().BeFalse(); merged.SeenByNode(e1.UniqueAddress).Should().BeFalse(); }; checkMerge(g3.Merge(g2)); checkMerge(g2.Merge(g3)); }
public void A_gossip_must_not_reach_convergence_until_all_have_seen_version() { var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1)).Seen(a1.UniqueAddress); g1.Convergence(a1.UniqueAddress, new HashSet <UniqueAddress>()).Should().BeFalse(); }
public void A_gossip_must_know_who_is_youngest() { // a2 and e1 is Joining var g1 = new Gossip(ImmutableSortedSet.Create(a2, b1.CopyUp(3), e1), new GossipOverview(Reachability.Empty.Unreachable(a2.UniqueAddress, e1.UniqueAddress))); g1.YoungestMember.Should().Be(b1); var g2 = new Gossip(ImmutableSortedSet.Create(a2, b1.CopyUp(3), e1), new GossipOverview(Reachability.Empty.Unreachable(a2.UniqueAddress, b1.UniqueAddress).Unreachable(a2.UniqueAddress, e1.UniqueAddress))); g2.YoungestMember.Should().Be(b1); var g3 = new Gossip(ImmutableSortedSet.Create(a2, b1.CopyUp(3), e2.CopyUp(4))); g3.YoungestMember.Should().Be(e2); }
private Msg.Welcome WelcomeToProto(UniqueAddress node, Gossip gossip) { return(Msg.Welcome.CreateBuilder().SetFrom(UniqueAddressToProto(node)) .SetGossip(GossipToProto(gossip)).Build()); }
public void A_gossip_must_not_reach_convergence_until_all_have_seen_version() { var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1)).Seen(a1.UniqueAddress); g1.Convergence(a1.UniqueAddress).Should().BeFalse(); }
public void A_gossip_must_not_reach_reach_convergence_for_two_nodes() { var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1)).Seen(a1.UniqueAddress).Seen(b1.UniqueAddress); g1.Convergence(a1.UniqueAddress).Should().BeTrue(); }
public void DomainEvents_must_be_empty_for_the_same_gossip() { var g1 = new Gossip(ImmutableSortedSet.Create(aUp)); Assert.Equal(ImmutableSortedSet.Create<object>(), ClusterEvent.DiffUnreachable(g1, g1)); }
public void DomainEvents_must_be_produced_for_convergence_changes() { var g1 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, eJoining)) .Seen(aUp.UniqueAddress) .Seen(bUp.UniqueAddress) .Seen(eJoining.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(aUp, bUp, eJoining)) .Seen(aUp.UniqueAddress) .Seen(bUp.UniqueAddress); ClusterEvent.DiffMemberEvents(g1, g2) .Should() .BeEquivalentTo(ImmutableList.Create<ClusterEvent.IMemberEvent>()); ClusterEvent.DiffUnreachable(g1, g2, selfDummyAddress) .Should() .BeEquivalentTo(ImmutableList.Create<ClusterEvent.UnreachableMember>()); ClusterEvent.DiffSeen(g1, g2, selfDummyAddress) .Should() .BeEquivalentTo(ImmutableList.Create(new ClusterEvent.SeenChanged(true, ImmutableHashSet.Create(aUp.Address, bUp.Address)))); ClusterEvent.DiffMemberEvents(g2, g1) .Should() .BeEquivalentTo(ImmutableList.Create<ClusterEvent.IMemberEvent>()); ClusterEvent.DiffUnreachable(g1, g1, selfDummyAddress) .Should() .BeEquivalentTo(ImmutableList.Create<ClusterEvent.UnreachableMember>()); ClusterEvent.DiffSeen(g2, g1, selfDummyAddress) .Should() .BeEquivalentTo(ImmutableList.Create(new ClusterEvent.SeenChanged(true, ImmutableHashSet.Create(aUp.Address, bUp.Address, eJoining.Address)))); }
public ActionResult Create(Gossip gossip) { _db.Gossips.Add(gossip); _db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult unseeGossip(Gossip gossip) { var gossipService = new GossipService(); gossipService.unSeeGossip(gossip.Id); return Json(new { success = true }); }
public void A_gossip_must_reach_convergence_when_downed_node_has_observed_unreachable() { // e3 is Down var r1 = Reachability.Empty.Unreachable(e3.UniqueAddress, a1.UniqueAddress); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, e3), new GossipOverview(r1)) .Seen(a1.UniqueAddress).Seen(b1.UniqueAddress).Seen(e3.UniqueAddress); g1.Convergence(b1.UniqueAddress).Should().BeTrue(); }
public ActionResult Edit(int id) { Gossip thisGossip = _db.Gossips.FirstOrDefault(gossips => gossips.GossipId == id); return(View(thisGossip)); }
public static void HandleNpcGossip(Packet packet) { var gossip = new Gossip(); var guid = new byte[8]; uint[] titleLen; uint[] BoxTextLen; uint[] OptionTextLen; guid[7] = packet.ReadBit(); guid[6] = packet.ReadBit(); guid[0] = packet.ReadBit(); var questgossips = (int)packet.ReadBits(19); guid[4] = packet.ReadBit(); titleLen = new uint[questgossips]; for (var i = 0; i < questgossips; ++i) { titleLen[i] = packet.ReadBits(9); packet.ReadBit("Change Icon", i); } guid[3] = packet.ReadBit(); guid[2] = packet.ReadBit(); var AmountOfOptions = packet.ReadBits(20); BoxTextLen = new uint[AmountOfOptions]; OptionTextLen = new uint[AmountOfOptions]; for (var i = 0; i < AmountOfOptions; ++i) { BoxTextLen[i] = packet.ReadBits(12); OptionTextLen[i] = packet.ReadBits(12); } guid[1] = packet.ReadBit(); guid[5] = packet.ReadBit(); packet.ReadXORByte(guid, 2); gossip.GossipOptions = new List <GossipOption>((int)AmountOfOptions); for (var i = 0; i < AmountOfOptions; ++i) { var gossipOption = new GossipOption { BoxText = packet.ReadWoWString("Box Text", BoxTextLen[i], i), OptionText = packet.ReadWoWString("Text", OptionTextLen[i], i), Index = packet.ReadUInt32("Index", i), Box = packet.ReadBoolean("Box", i), OptionIcon = packet.ReadEnum <GossipOptionIcon>("Icon", TypeCode.Byte, i), RequiredMoney = packet.ReadUInt32("Required money", i), }; gossip.GossipOptions.Add(gossipOption); } for (var i = 0; i < questgossips; ++i) { packet.ReadInt32("Level", i); packet.ReadEnum <QuestFlags>("Flags", TypeCode.UInt32, i); packet.ReadUInt32("Icon", i); packet.ReadWoWString("Title", titleLen[i], i); packet.ReadEntryWithName <UInt32>(StoreNameType.Quest, "Quest ID", i); packet.ReadEnum <QuestFlags2>("Flags 2", TypeCode.UInt32, i); } packet.ReadXORByte(guid, 7); packet.ReadUInt32("Friendship Faction"); packet.ReadXORByte(guid, 3); packet.ReadXORByte(guid, 1); var textId = packet.ReadUInt32("Text Id"); packet.ReadXORByte(guid, 5); var menuId = packet.ReadUInt32("Menu Id"); packet.ReadXORByte(guid, 6); packet.ReadXORByte(guid, 4); packet.ReadXORByte(guid, 0); packet.WriteGuid("Guid", guid); var GUID = new Guid(BitConverter.ToUInt64(guid, 0)); gossip.ObjectType = GUID.GetObjectType(); gossip.ObjectEntry = GUID.GetEntry(); if (Storage.Gossips.ContainsKey(Tuple.Create(menuId, textId))) { var oldGossipOptions = Storage.Gossips[Tuple.Create(menuId, textId)]; if (oldGossipOptions != null) { foreach (var gossipOptions in gossip.GossipOptions) { oldGossipOptions.Item1.GossipOptions.Add(gossipOptions); } } } else { Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan); } packet.AddSniffData(StoreNameType.Gossip, (int)menuId, GUID.GetEntry().ToString(CultureInfo.InvariantCulture)); }
public void A_gossip_must_reach_convergence_skipping_down() { // e3 is down var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, e3)).Seen(a1.UniqueAddress).Seen(b1.UniqueAddress); g1.Convergence(a1.UniqueAddress).Should().BeTrue(); }
public bool GossipMatch(Gossip gossip) { return(gossip.Faction == Faction); }
public void AGossipMustMergeSeenTableCorrectly() { var vclockNode = VectorClock.Node.Create("something"); var g1 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode) .Seen(a1.UniqueAddress) .Seen(b1.UniqueAddress); var g2 = new Gossip(ImmutableSortedSet.Create(a1, b1, c1, d1)).Increment(vclockNode) .Seen(a1.UniqueAddress) .Seen(c1.UniqueAddress); var g3 = g1.Copy(version: g2.Version).Seen(d1.UniqueAddress); Action<Gossip> checkMerge = (m) => { var seen = m.Overview.Seen; Assert.Equal(0, seen.Count()); Assert.False(m.SeenByNode(a1.UniqueAddress)); Assert.False(m.SeenByNode(b1.UniqueAddress)); Assert.False(m.SeenByNode(c1.UniqueAddress)); Assert.False(m.SeenByNode(d1.UniqueAddress)); Assert.False(m.SeenByNode(e1.UniqueAddress)); }; checkMerge(g3.Merge(g2)); checkMerge(g2.Merge(g3)); }
public void AddNewGossipToQueue(Gossip gossip) { gossip.authorId = HttpContext.Current.User.Identity.GetUserId(); db.Gossips.Add(gossip); db.SaveChanges(); }