private static void TradeComplete(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } Trade Trade = Instance.TradeManager.GetTradeForUser(Session.CharacterId); if (Trade == null) { return; } Session TargetSession = SessionManager.GetSessionByCharacterId(Trade.UserOne == Session.CharacterId ? Trade.UserTwo : Trade.UserOne); if (TargetSession == null || !Trade.AcceptTrade(Trade.UserOne == Session.CharacterId)) { return; } if (Trade.TradeStage == TradeStage.Finalized) { Session User1 = (TargetSession.CharacterId == Trade.UserOne ? TargetSession : Session); Session User2 = (TargetSession.CharacterId == Trade.UserTwo ? TargetSession : Session); Trade.DeliverItems(User1, User2); Session.SendData(TradeFinalizedComposer.Compose()); TargetSession.SendData(TradeFinalizedComposer.Compose()); Instance.TradeManager.StopTradeForUser(Session.CharacterId); Instance.TradeManager.StopTradeForUser(TargetSession.CharacterId); RoomActor Actor1 = Instance.GetActorByReferenceId(Session.CharacterId); RoomActor Actor2 = Instance.GetActorByReferenceId(TargetSession.CharacterId); if (Actor1 != null) { Actor1.RemoveStatus("trd"); Actor1.UpdateNeeded = true; } if (Actor2 != null) { Actor2.RemoveStatus("trd"); Actor2.UpdateNeeded = true; } } }
private static void TradeStop(Session Session, ClientMessage Message) { RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } Trade Trade = Instance.TradeManager.GetTradeForUser(Session.CharacterId); if (Trade == null) { return; } Instance.TradeManager.StopTradeForUser(Session.CharacterId); Session.SendData(TradeAbortedComposer.Compose(Session.CharacterId)); RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor != null) { Actor.RemoveStatus("trd"); Actor.UpdateNeeded = true; } Session TargetSession = SessionManager.GetSessionByCharacterId(Trade.UserOne == Session.CharacterId ? Trade.UserTwo : Trade.UserOne); if (TargetSession != null) { Instance.TradeManager.StopTradeForUser(TargetSession.CharacterId); TargetSession.SendData(TradeAbortedComposer.Compose(Session.CharacterId)); RoomActor TargetActor = Instance.GetActorByReferenceId(TargetSession.CharacterId); if (TargetActor != null) { TargetActor.RemoveStatus("trd"); TargetActor.UpdateNeeded = true; } } }