Exemple #1
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (!AuctionSystem.Running)
            {
                sender.Mobile.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[15]);

                m_Auction.Cancel();

                return;
            }

            bool allowBuyNow = info.Switches.Length > 0;             // Just one switch

            switch (info.ButtonID)
            {
            case 0:                     // Cancel the auction

                m_Auction.Cancel();
                m_User.SendGump(new AuctionGump(m_User));
                break;

            case 1:                     // Commit the auction

                // Collect information
                int    minbid      = 0;               // text 0
                int    reserve     = 0;               // text 1
                int    days        = 0;               // text 2
                string name        = "";              // text 3
                string description = "";              // text 4
                string weblink     = "";              // text 5
                int    buynow      = 0;               // text 6

                // The 3D client sucks

                string[] tr = new string[7];

                foreach (TextRelay t in info.TextEntries)
                {
                    tr[t.EntryID] = t.Text;
                }

                try { minbid = (int)uint.Parse(tr[0], NumberStyles.AllowThousands); }
                catch {}

                try { reserve = (int)uint.Parse(tr[1], NumberStyles.AllowThousands); }
                catch {}

                try { days = (int)uint.Parse(tr[2]); }
                catch {}

                try { buynow = (int)uint.Parse(tr[6], NumberStyles.AllowThousands); }
                catch {}

                if (tr[3] != null)
                {
                    name = tr[3];
                }

                if (tr[4] != null)
                {
                    description = tr[4];
                }

                if (tr[5] != null)
                {
                    weblink = tr[5];
                }

                bool ok = true;

                if (minbid < 1)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[109]);
                    ok = false;
                }

                if (reserve < 1 || reserve < minbid)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[110]);
                    ok = false;
                }

                if (days < AuctionSystem.MinAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster || days < 1)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[111], AuctionSystem.MinAuctionDays);
                    ok = false;
                }

                if (days > AuctionSystem.MaxAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[112], AuctionSystem.MaxAuctionDays);
                    ok = false;
                }

                if (name.Length == 0)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[113]);
                    ok = false;
                }

                if (minbid * AuctionConfig.MaxReserveMultiplier < reserve && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[114]);
                    ok = false;
                }

                if (allowBuyNow && buynow <= reserve)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[209]);
                    ok = false;
                }

                if (ok && AuctionConfig.CostOfAuction > 0.0)
                {
                    int toPay = 0;

                    if (AuctionConfig.CostOfAuction <= 1.0)
                    {
                        toPay = (int)(Math.Max(minbid, reserve) * AuctionConfig.CostOfAuction);
                    }
                    else
                    {
                        toPay = (int)AuctionConfig.CostOfAuction;
                    }

                    if (toPay > 0)
                    {
                        if (Server.Mobiles.Banker.Withdraw(m_User, toPay))
                        {
                            m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[228], toPay);
                        }
                        else
                        {
                            m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[229], toPay);
                            goto case 0;                                     // Pretty much cancel the auction
                        }
                    }
                }

                m_Auction.MinBid      = minbid;
                m_Auction.Reserve     = reserve;
                m_Auction.ItemName    = name;
                m_Auction.Duration    = TimeSpan.FromDays(days);
                m_Auction.Description = description;
                m_Auction.WebLink     = weblink;
                m_Auction.BuyNow      = allowBuyNow ? buynow : 0;

                if (ok && AuctionSystem.Running)
                {
                    m_Auction.Confirm();
                    m_User.SendGump(new AuctionViewGump(m_User, m_Auction, new AuctionGumpCallback(AuctionCallback)));
                }
                else if (AuctionSystem.Running)
                {
                    m_User.SendGump(new NewAuctionGump(m_User, m_Auction));
                }
                else
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[115]);
                }

                break;
            }
        }
Exemple #2
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (!AuctionSystem.Running)
            {
                sender.Mobile.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[15]);

                m_Auction.Cancel();

                return;
            }

            int buttonid = info.ButtonID;

            //right click
            if (buttonid == 0)
            {
                m_Auction.Cancel();
                m_User.SendGump(new AuctionGump(m_User));
                return;
            }

            if (buttonid > 1)
            {
                m_User.SendMessage("Invalid option.  Please try again.");
                return;
            }
            bool   allowBuyNow  = info.Switches.Length > 0;          // Just one switch
            String errormessage = "";

            switch (info.ButtonID)
            {
            case 0:                     // Cancel the auction

                m_Auction.Cancel();
                m_User.SendGump(new AuctionGump(m_User));
                break;

            case 1:                     // Commit the auction

                // Collect information
                int    minbid      = 100;                // text 0
                int    reserve     = minbid;             // text 1
                int    days        = 7;                  // text 2
                string name        = m_Auction.ItemName; // text 3
                string description = " ";                // text 4
                string weblink     = " ";                // text 5
                int    buynow      = 0;                  // text 6

                // The 3D client sucks

                string[] tr = new string[7];

                foreach (TextRelay t in info.TextEntries)
                {
                    try
                    {
                        tr[t.EntryID] = t.Text;
                    }
                    catch (Exception e)
                    {
                        errormessage = e.Message;
                    }
                }


                try { minbid = (int)uint.Parse(tr[0], NumberStyles.AllowThousands); }
                catch {}

                try { reserve = (int)uint.Parse(tr[1], NumberStyles.AllowThousands); }
                catch { }

                try { days = (int)uint.Parse(tr[2]); }
                catch {}

                try { buynow = (int)uint.Parse(tr[6], NumberStyles.AllowThousands); }
                catch {}

                if (buynow < 1)
                {
                    allowBuyNow = false;
                }

                if (tr[3] != null)
                {
                    if (NameVerification.Validate(tr[3], 2, 40, true, true, true, 2, NameVerification.Empty))
                    {
                        string[] disallowed = ProfanityProtection.Disallowed;

                        for (int i = 0; i < disallowed.Length; i++)
                        {
                            if (tr[3].IndexOf(disallowed[i]) != -1)
                            {
                                m_User.SendLocalizedMessage(1072622); // That name isn't very polite.
                                goto case 0;                          // Pretty much cancel the auction
                            }
                        }
                    }
                    else
                    {
                        name = tr[3];
                    }
                    name = tr[3];
                }

                if (tr[4] != null)
                {
                    if (NameVerification.Validate(tr[4], 0, 100, true, true, true, 2, NameVerification.Empty))
                    {
                        string[] disallowed = ProfanityProtection.Disallowed;

                        for (int i = 0; i < disallowed.Length; i++)
                        {
                            if (tr[4].IndexOf(disallowed[i]) != -1)
                            {
                                m_User.SendLocalizedMessage(1072622); // That name isn't very polite.
                                goto case 0;                          // Pretty much cancel the auction
                            }
                        }
                    }
                    else
                    {
                        description = tr[4];
                        //name = tr[3];
                    }
                    description = tr[4];
                }

                if (tr[5] != null)
                {
                    weblink = tr[5];
                }

                bool ok = true;

                if (minbid < 1)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[109]);
                    ok = false;
                }
                if (reserve < 1)
                {
                    reserve = minbid;
                }

                if (reserve < minbid)
                {
                    reserve = minbid;
                    m_User.SendMessage(214, AuctionSystem.ST[110]);
                    ok = false;
                }

                if (days < AuctionSystem.MinAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster || days < 1)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[111], AuctionSystem.MinAuctionDays);
                    ok = false;
                }

                if (days > AuctionSystem.MaxAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[112], AuctionSystem.MaxAuctionDays);
                    ok = false;
                }

                if (name.Length == 0)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[113]);
                    ok = false;
                }

                if (minbid * AuctionConfig.MaxReserveMultiplier < reserve && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[114]);
                    ok = false;
                }

                if (allowBuyNow && buynow < reserve)
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[209]);
                    ok = false;
                }

                if (ok && AuctionConfig.CostOfAuction > 0.0)
                {
                    int toPay = 0;

                    if (AuctionConfig.CostOfAuction <= 1.0)
                    {
                        toPay = (int)(Math.Max(minbid, reserve) * AuctionConfig.CostOfAuction);
                    }
                    else
                    {
                        toPay = (int)AuctionConfig.CostOfAuction;
                    }

                    if (toPay > 0)
                    {
                        if (Server.Mobiles.Banker.Withdraw(m_User, toPay))
                        {
                            m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[228], toPay);
                        }
                        else
                        {
                            m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[229], toPay);
                            goto case 0;     // Pretty much cancel the auction
                        }
                    }
                }

                m_Auction.MinBid      = minbid;
                m_Auction.Reserve     = reserve;
                m_Auction.ItemName    = name;
                m_Auction.Duration    = TimeSpan.FromDays(days);
                m_Auction.Description = description;
                m_Auction.WebLink     = weblink;
                m_Auction.BuyNow      = allowBuyNow ? buynow : 0;

                if (ok && AuctionSystem.Running)
                {
                    World.Broadcast(0x35, true, "A {0} just became available on [Myauction for {1}", m_Auction.ItemName, minbid);
                    m_Auction.Confirm();
                    m_User.SendGump(new AuctionViewGump(m_User, m_Auction, new AuctionGumpCallback(AuctionCallback)));
                }
                else if (AuctionSystem.Running)
                {
                    m_User.SendGump(new NewAuctionGump(m_User, m_Auction));
                }
                else
                {
                    m_User.SendMessage(AuctionConfig.MessageHue, AuctionSystem.ST[115]);
                }

                break;
            }
        }
Exemple #3
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (!m_Buttons.Contains(info.ButtonID))
            {
                Console.WriteLine(@"The auction system located a potential exploit. 
					Player {0} (Acc. {1}) tried to press an unregistered button in a gump of type: {2}"                    ,
                                  sender.Mobile != null ? sender.Mobile.ToString() : "Unkown",
                                  sender.Mobile != null && sender.Mobile.Account != null ? (sender.Mobile.Account as Server.Accounting.Account).Username : "******",
                                  this.GetType().Name);

                return;
            }

            if (!AuctionSystem.Running)
            {
                sender.Mobile.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[15]);

                m_Auction.Cancel();

                return;
            }

            bool allowBuyNow = info.Switches.Length > 0;             // Just one switch

            switch (info.ButtonID)
            {
            case 0:                     // Cancel the auction

                m_Auction.Cancel();
                m_User.SendGump(new AuctionGump(m_User));
                break;

            case 1:                     // Commit the auction

                // Collect information
                int    minbid      = 0;               // text 0
                int    reserve     = 0;               // text 1
                int    days        = 0;               // text 2
                string name        = "";              // text 3
                string description = "";              // text 4
                string weblink     = "";              // text 5
                int    buynow      = 0;               // text 6

                // The 3D client sucks

                string[] tr = new string[7];

                foreach (TextRelay t in info.TextEntries)
                {
                    tr[t.EntryID] = t.Text;
                }

                try { minbid = (int)uint.Parse(tr[0]); }
                catch {}

                try { reserve = (int)uint.Parse(tr[1]); }
                catch {}

                try { days = (int)uint.Parse(tr[2]); }
                catch {}

                try { buynow = (int)uint.Parse(tr[6]); }
                catch {}

                if (tr[3] != null)
                {
                    name = tr[3];
                }

                if (tr[4] != null)
                {
                    description = tr[4];
                }

                if (tr[5] != null)
                {
                    weblink = tr[5];
                }

                bool ok = true;

                if (minbid < 1)
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[109]);
                    ok = false;
                }

                if (reserve < 1 || reserve < minbid)
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[110]);
                    ok = false;
                }

                if (days < AuctionSystem.MinAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster || days < 1)
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[111], AuctionSystem.MinAuctionDays);
                    ok = false;
                }

                if (days > AuctionSystem.MaxAuctionDays && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[112], AuctionSystem.MaxAuctionDays);
                    ok = false;
                }

                if (name.Length == 0)
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[113]);
                    ok = false;
                }

                if (minbid * AuctionSystem.MaxReserveMultiplier < reserve && m_User.AccessLevel < AccessLevel.GameMaster)
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[114]);
                    ok = false;
                }

                if (allowBuyNow && buynow <= reserve)
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[209]);
                    ok = false;
                }

                m_Auction.MinBid      = minbid;
                m_Auction.Reserve     = reserve;
                m_Auction.ItemName    = name;
                m_Auction.Duration    = TimeSpan.FromDays(days);
                m_Auction.Description = description;
                m_Auction.WebLink     = weblink;
                m_Auction.BuyNow      = allowBuyNow ? buynow : 0;

                if (ok && AuctionSystem.Running)
                {
                    m_Auction.Confirm();
                    m_User.SendGump(new AuctionViewGump(m_User, m_Auction, new AuctionGumpCallback(AuctionCallback)));
                }
                else if (AuctionSystem.Running)
                {
                    m_User.SendGump(new NewAuctionGump(m_User, m_Auction));
                }
                else
                {
                    m_User.SendMessage(AuctionSystem.MessageHue, AuctionSystem.ST[115]);
                }

                break;
            }
        }