Suprcode / Crystal

Legend of Mir 2 - Official Public Crystal Source
1.22k stars 711 forks source link

Fix #1023 #1027

Closed damianday closed 4 days ago

cantea commented 4 days ago

@damianday still not fixed with your last push tested and this seems to working fine

            if (mode == 2)
            {
                if (auction.Expired)
                {
                    if (!CanGainItem(auction.Item))
                    {
                        Enqueue(new S.MarketFail { Reason = 5 });
                        return false;
                    }

                    GainItem(auction.Item);
                    return true;
                }
            }

            if (mode == 1)
            {
                if (auction.Sold)
                {
                    uint cost = auction.ItemType == MarketItemType.Consign ? auction.Price : auction.CurrentBid;

                    if (!CanGainGold(cost))
                    {
                        Enqueue(new S.MarketFail { Reason = 8 });
                        return false;
                    }

                    uint gold = (uint)Math.Max(0, cost - cost * Globals.Commission);

                    GainGold(gold);
                    Enqueue(new S.MarketSuccess { Message = string.Format("You sold {0} for {1:#,##0} Gold. \nEarnings: {2:#,##0} Gold.\nCommision: {3:#,##0} Gold.‎", auction.Item.FriendlyName, cost, gold, cost - gold) });
                    return true;
                }
            }

            if (mode == 0)
            {
                if (!auction.Sold || auction.Expired)
                {
                    if (!CanGainItem(auction.Item))
                    {
                        Enqueue(new S.MarketFail { Reason = 5 });
                        return false;
                    }

                    if (auction.CurrentBuyerInfo != null)
                    {
                        string message = string.Format("You have been outbid on {0}. Refunded {1:#,##0} Gold.", auction.Item.FriendlyName, auction.CurrentBid);

                        Envir.MailCharacter(auction.CurrentBuyerInfo, gold: auction.CurrentBid, customMessage: message);
                    }

                    GainItem(auction.Item);
                    return true;
                }
            }
damianday commented 4 days ago

@damianday still not fixed with your last push tested and this seems to working fine

            if (mode == 2)
            {
                if (auction.Expired)
                {
                    if (!CanGainItem(auction.Item))
                    {
                        Enqueue(new S.MarketFail { Reason = 5 });
                        return false;
                    }

                    GainItem(auction.Item);
                    return true;
                }
            }

            if (mode == 1)
            {
                if (auction.Sold)
                {
                    uint cost = auction.ItemType == MarketItemType.Consign ? auction.Price : auction.CurrentBid;

                    if (!CanGainGold(cost))
                    {
                        Enqueue(new S.MarketFail { Reason = 8 });
                        return false;
                    }

                    uint gold = (uint)Math.Max(0, cost - cost * Globals.Commission);

                    GainGold(gold);
                    Enqueue(new S.MarketSuccess { Message = string.Format("You sold {0} for {1:#,##0} Gold. \nEarnings: {2:#,##0} Gold.\nCommision: {3:#,##0} Gold.‎", auction.Item.FriendlyName, cost, gold, cost - gold) });
                    return true;
                }
            }

            if (mode == 0)
            {
                if (!auction.Sold || auction.Expired)
                {
                    if (!CanGainItem(auction.Item))
                    {
                        Enqueue(new S.MarketFail { Reason = 5 });
                        return false;
                    }

                    if (auction.CurrentBuyerInfo != null)
                    {
                        string message = string.Format("You have been outbid on {0}. Refunded {1:#,##0} Gold.", auction.Item.FriendlyName, auction.CurrentBid);

                        Envir.MailCharacter(auction.CurrentBuyerInfo, gold: auction.CurrentBid, customMessage: message);
                    }

                    GainItem(auction.Item);
                    return true;
                }
            }

This will break normal market functions like taking only one item you purchased