public static void PartyInvireAnswerRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 12; byte num = packet.ReadByte(); Character activeCharacter = client.ActiveCharacter; IBaseRelation relation = Singleton <RelationMgr> .Instance .GetPassiveRelations(activeCharacter.EntityId.Low, CharacterRelationType.GroupInvite) .FirstOrDefault <IBaseRelation>(); if (relation == null) { return; } Singleton <RelationMgr> .Instance.RemoveRelation(relation); Character character = World.GetCharacter(relation.CharacterId); if (character == null) { return; } if (num == (byte)1) { (character.Group ?? (Group) new PartyGroup(character)).AddMember(activeCharacter, true); Asda2GroupHandler.SendPartyIniteResponseResponse(character.Client, character, activeCharacter, PartyInviteStatusResponse.TheInvitionRequestHasBeenAccepted); Asda2GroupHandler.SendPartyIniteResponseResponse(activeCharacter.Client, character, activeCharacter, PartyInviteStatusResponse.TheInvitionRequestHasBeenAccepted); } else { Asda2GroupHandler.SendPartyIniteResponseResponse(character.Client, character, activeCharacter, PartyInviteStatusResponse.TheInvitionRequestHasBeenDeclined); } }
/// <summary> /// Removes a character relation /// </summary> public bool RemoveRelation(IBaseRelation relation) { HashSet <IBaseRelation> relations; bool success = false; m_lock.EnterWriteLock(); try { if (m_activeRelations[(int)relation.Type].TryGetValue(relation.CharacterId, out relations)) { relations.Remove(relation); } if (m_passiveRelations[(int)relation.Type].TryGetValue(relation.RelatedCharacterId, out relations)) { relations.Remove(relation); success = true; } } finally { m_lock.ExitWriteLock(); } if (relation is PersistedRelation) { ((PersistedRelation)relation).Delete(); } _log.Debug(Resources.CharacterRelationRemoved, relation.CharacterId, relation.RelatedCharacterId, relation.Type, 0); return(success); }
/// <summary>Removes a character relation</summary> public bool RemoveRelation(IBaseRelation relation) { bool flag = false; m_lock.EnterWriteLock(); try { HashSet <IBaseRelation> baseRelationSet; if (m_activeRelations[(int)relation.Type].TryGetValue(relation.CharacterId, out baseRelationSet)) { baseRelationSet.Remove(relation); } if (m_passiveRelations[(int)relation.Type] .TryGetValue(relation.RelatedCharacterId, out baseRelationSet)) { baseRelationSet.Remove(relation); flag = true; } } finally { m_lock.ExitWriteLock(); } if (relation is PersistedRelation) { ((PersistedRelation)relation).Delete(); } _log.Debug(WCell_RealmServer.CharacterRelationRemoved, (object)relation.CharacterId, (object)relation.RelatedCharacterId, (object)relation.Type, (object)0); return(flag); }
private static void OnPartyInviteRequest(IRealmClient client, Character destChr) { if (!destChr.EnablePartyRequest) { client.ActiveCharacter.SendSystemMessage(string.Format("Sorry ,but {0} rejects all party requests.", (object)destChr.Name)); } else if (client.ActiveCharacter.Asda2FactionId != (short)-1 && destChr.Asda2FactionId != (short)-1 && (int)destChr.Asda2FactionId != (int)client.ActiveCharacter.Asda2FactionId) { client.ActiveCharacter.SendSystemMessage(string.Format("Sorry ,but {0} is in other faction.", (object)destChr.Name)); } else { string name = destChr.Name; Character activeCharacter = client.ActiveCharacter; Group group = activeCharacter.Group; IBaseRelation relation1 = Singleton <RelationMgr> .Instance .GetPassiveRelations(destChr.EntityId.Low, CharacterRelationType.GroupInvite) .FirstOrDefault <IBaseRelation>(); if (relation1 != null && Environment.TickCount - int.Parse(relation1.Note) > 30000) { Singleton <RelationMgr> .Instance.RemoveRelation(relation1); } Character target; if (Group.CheckInvite(activeCharacter, out target, name) == GroupResult.NoError) { HashSet <IBaseRelation> relations = Singleton <RelationMgr> .Instance.GetRelations(activeCharacter.EntityId.Low, CharacterRelationType.GroupInvite); if (group != null && relations.Count >= (int)group.InvitesLeft) { return; } BaseRelation relation2 = RelationMgr.CreateRelation(activeCharacter.EntityId.Low, target.EntityId.Low, CharacterRelationType.GroupInvite); relation2.Note = Environment.TickCount.ToString((IFormatProvider)CultureInfo.InvariantCulture); Singleton <RelationMgr> .Instance.AddRelation(relation2); Asda2GroupHandler.SendInviteToPartyResponseOrRequestToAnotherPlayerResponse(target.Client, PartyInviteStatusRequest.Invite, client.ActiveCharacter.Name); Asda2GroupHandler.SendPartyIniteResponseResponse(client, activeCharacter, target, PartyInviteStatusResponse.SomeOneRevicingYourInvation); } else { Asda2GroupHandler.SendPartyIniteResponseResponse(client, activeCharacter, target, PartyInviteStatusResponse.ThereIsNoOneToInvite); } } }
/// <summary>Handles an incoming decline on group invite request</summary> /// <param name="client">the Session the incoming packet belongs to</param> /// <param name="packet">the full packet</param> public static void GroupDecline(IRealmClient client, RealmPacketIn packet) { Character activeCharacter = client.ActiveCharacter; IBaseRelation relation = Singleton <RelationMgr> .Instance .GetPassiveRelations(activeCharacter.EntityId.Low, CharacterRelationType.GroupInvite) .FirstOrDefault(); if (relation == null) { return; } Singleton <RelationMgr> .Instance.RemoveRelation(relation); Character character = World.GetCharacter(relation.CharacterId); if (character == null) { return; } SendGroupDecline(character.Client, activeCharacter.Name); }
/// <summary>Handles an incoming accept on group invite request</summary> /// <param name="client">the Session the incoming packet belongs to</param> /// <param name="packet">the full packet</param> public static void GroupAccept(IRealmClient client, RealmPacketIn packet) { Character activeCharacter = client.ActiveCharacter; IBaseRelation relation = Singleton <RelationMgr> .Instance .GetPassiveRelations(activeCharacter.EntityId.Low, CharacterRelationType.GroupInvite) .FirstOrDefault(); if (relation == null) { return; } Singleton <RelationMgr> .Instance.RemoveRelation(relation); Character character = World.GetCharacter(relation.CharacterId); if (character == null) { return; } (character.Group ?? new PartyGroup(character)).AddMember(activeCharacter, true); }
public RelationListEntry(IBaseRelation relation, RelationTypeFlag flag) { RelatedCharacterId = relation.RelatedCharacterId; Flag = flag; Note = relation.Note; }
public BaseRelationships(IBaseRelation baseRelationships) { this.baseRelationships = baseRelationships; }