FreeMoney.FreeMoneyModule.processLandBuy C# (CSharp) Method

processLandBuy() private method

private processLandBuy ( Object osender, EventManager e ) : void
osender Object
e EventManager
return void
        private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
        {
            if (!m_active)
                return;

            if (e.parcelPrice == 0)
                return;

            IClientAPI user = null;
            Scene scene = null;

            // Find the user's controlling client.
            lock (m_scenes) {
                foreach (Scene sc in m_scenes) {
                    ScenePresence av = sc.GetScenePresence (e.agentId);

                    if ((av != null) && (av.IsChildAgent == false)) {
                        // Found the client,
                        // and their root scene.
                        user = av.ControllingClient;
                        scene = sc;
                    }
                }
            }

            if (scene == null || user == null) {
                m_log.Error ("[FreeMoney] Unable to find scene or user! Aborting transaction.");
                return;
            }

            string email;

            if ((e.parcelOwnerID == e.groupId) || e.groupOwned) {
                if (m_allowGroups) {
                    if (!GetEmail (scene.RegionInfo.ScopeID, e.parcelOwnerID, out email)) {
                        m_log.Warn ("[FreeMoney] Unknown email address of group " + e.parcelOwnerID);
                        return;
                    }
                } else {
                    m_log.Warn ("[FreeMoney] Purchases of group owned land is disabled.");
                    return;
                }
            } else {
                if (!GetEmail (scene.RegionInfo.ScopeID, e.parcelOwnerID, out email)) {
                    m_log.Warn ("[FreeMoney] Unknown email address of user " + e.parcelOwnerID);
                    return;
                }
            }

            m_log.Info ("[FreeMoney] Start: " + e.agentId + " wants to buy land from " + e.parcelOwnerID +
                        " with email " + email + " costing " + m_gridCurrencySmallDenominationText +" " + e.parcelPrice);

            FreeMoneyTransaction txn;
            txn = new FreeMoneyTransaction (e.agentId, e.parcelOwnerID, email, e.parcelPrice, scene,
                                         "Buy Land", FreeMoneyTransaction.InternalTransactionType.Land, e);

            // Add transaction to queue
            lock (m_transactionsInProgress)
                m_transactionsInProgress.Add (txn.TxID, txn);

            string baseUrl = m_scenes[0].RegionInfo.ExternalHostName + ":" + m_scenes[0].RegionInfo.HttpPort;

            // If we're definitely going to use Bitcoin for this transaction, go ahead and initialize it and show the page page.
            // Otherwise, show an intermediate page to choose the payment type, and only initialize for Bitcoin if they choose it.
            string pageName = "pp";
            if (m_directToBitcoin) {
                InitializeBitcoinTransaction(txn, baseUrl);
                pageName = "btcgo";
            }

            user.SendLoadURL ("FreeMoney", txn.ObjectID, txn.To, false, "Confirm payment?", "http://" +
                              baseUrl + "/"+pageName+"/?txn=" + txn.TxID);
        }