Пример #1
0
 public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
 {
 }
Пример #2
0
 public void SendDirLandReply(OpenMetaverse.UUID queryID, DirLandReplyData[] data)
 {
 }
        public void DirLandQuery(IClientAPI remoteClient, UUID queryID,
                uint queryFlags, uint searchType, int price, int area,
                int queryStart)
        {
            Hashtable ReqHash = new Hashtable();
            ReqHash["flags"] = queryFlags.ToString();
            ReqHash["type"] = searchType.ToString();
            ReqHash["price"] = price.ToString();
            ReqHash["area"] = area.ToString();
            ReqHash["query_start"] = queryStart.ToString();

            Hashtable result = GenericXMLRPCRequest(ReqHash,
                    "dir_land_query");

            if (!Convert.ToBoolean(result["success"]))
            {
                remoteClient.SendAgentAlertMessage(
                        result["errorMessage"].ToString(), false);
                return;
            }

            ArrayList dataArray = (ArrayList)result["data"];
            int count = 0;

            /* Count entries in dataArray with valid region name to */
            /* prevent allocating data array with too many entries. */
            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                if (d["name"] != null)
                    ++count;
            }

            if (count > 100)
                count = 101;

            DirLandReplyData[] data = new DirLandReplyData[count];

            int i = 0;

            foreach (Object o in dataArray)
            {
                Hashtable d = (Hashtable)o;

                if (d["name"] == null)
                    continue;

                data[i] = new DirLandReplyData();
                data[i].parcelID = new UUID(d["parcel_id"].ToString());
                data[i].name = d["name"].ToString();
                data[i].auction = Convert.ToBoolean(d["auction"]);
                data[i].forSale = Convert.ToBoolean(d["for_sale"]);
                data[i].salePrice = Convert.ToInt32(d["sale_price"]);
                data[i].actualArea = Convert.ToInt32(d["area"]);

                if (++i >= count)
                    break;
            }

            remoteClient.SendDirLandReply(queryID, data);
        }
Пример #4
0
 public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
 {
     throw new System.NotImplementedException();
 }
        public void DirLandQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags, uint searchType, int price, int area,
                int queryStart)
        {
            //m_log.DebugFormat("[LAND SEARCH]: In Land Search, queryFlag = " + queryFlags.ToString("X"));
            string query = String.Empty;
            int count = MAX_RESULTS + 1;    // +1 so that the viewer knows to enable the NEXT button (it seems)
            int queryEnd = queryStart + count - 1;  // 0-based
            int i = 0;
            string sqlTerms = String.Empty;

            if ((queryFlags & ((uint)DirFindFlags.NameSort|(uint)DirFindFlags.AreaSort|(uint)DirFindFlags.PricesSort|(uint)DirFindFlags.PerMeterSort)) == 0)
            {
                // No sort options specified.  Substitute price per meter sort for Land Sales.
                queryFlags |= (uint)DirFindFlags.PerMeterSort;
                queryFlags |= (uint)DirFindFlags.SortAsc;
            }

            bool checkPriceFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.LimitByPrice);
            bool checkAreaFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.LimitByArea);
            bool checkPGFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludePG);
            bool checkMatureFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludeMature);
            bool checkAdultFlag = Convert.ToBoolean(queryFlags & (uint)DirFindFlags.IncludeAdult);

            //sqlTerms = "select parcelUUID, parcelname, area, saleprice from parcelsales";
            sqlTerms = "select land.UUID, land.RegionUUID, land.Name, land.Area, land.SalePrice, regionsettings.maturity from land LEFT JOIN regionsettings ON land.RegionUUID=regionsettings.regionUUID";

            // Limit "Land Sales" returns to parcels for sale.
            sqlTerms += " where (LandFlags & " + ((int)ParcelFlags.ForSale).ToString() + ")";
            // Limit "Land Sales" returns to parcels visible in search.
            sqlTerms += " and (LandFlags & " + ((int)ParcelFlags.ShowDirectory).ToString() + ")";

            if (!(checkPGFlag || checkMatureFlag || checkAdultFlag))
            {
                // nothing to search for
                remoteClient.SendAgentAlertMessage("You must specify a search with at least one maturity level checked.", false);
                remoteClient.SendDirLandReply(queryID, new DirLandReplyData[1]);
                return;
            }

            if (searchType == 2)
            {
                remoteClient.SendAgentAlertMessage("Auctions not available.", false);
                remoteClient.SendDirLandReply(queryID, new DirLandReplyData[1]);
                return;
            } 
            /*else if (searchType == 8)
            {
                sqlTerms += " AND parentestate='1' ";
            }
            else if (searchType == 16)
            {
                sqlTerms += " AND parentestate>'1' ";
            }*/

            int maturities = 0;
            sqlTerms += " and (";
            if (checkPGFlag)
            {
                sqlTerms += "regionsettings.maturity='0'";
                maturities++;
            }
            if (checkMatureFlag)
            {
                if (maturities > 0) sqlTerms += " or ";
                sqlTerms += "regionsettings.maturity='1'";
                maturities++;
            }
            if (checkAdultFlag)
            {
                if (maturities > 0) sqlTerms += " or ";
                sqlTerms += "regionsettings.maturity='2'";
                maturities++;
            }
            sqlTerms += ")";

            if (checkPriceFlag && (price > 0))
            {
                sqlTerms += " and (land.SalePrice<=" + Convert.ToString(price) + " AND land.SalePrice >= 1) ";
            }

            if (checkAreaFlag && (area > 0))
            {
                sqlTerms += " and land.Area>=" + Convert.ToString(area);
            }

            string order = ((queryFlags & (uint)DirFindFlags.SortAsc) != 0) ? "ASC" : "DESC";
            string norder = ((queryFlags & (uint)DirFindFlags.SortAsc) == 0) ? "ASC" : "DESC";
            if ((queryFlags & (uint)DirFindFlags.NameSort) != 0)
            {
                sqlTerms += " order by land.Name " + order;
            }
            else if ((queryFlags & (uint)DirFindFlags.PerMeterSort) != 0)
            {
                sqlTerms += " and land.Area > 0 order by land.SalePrice / land.Area " + order + ", land.SalePrice " + order + ", land.Area " + norder + ", land.Name ASC";
            }
            else if ((queryFlags & (uint)DirFindFlags.PricesSort) != 0)
            {
                sqlTerms += " order by land.SalePrice " + order + ", land.Area " + norder + ", land.Name ASC";
            }
            else if ((queryFlags & (uint)DirFindFlags.AreaSort) != 0)
            {
                sqlTerms += " order by land.Area " + order + ", land.SalePrice ASC, land.Name ASC";
            }

            Dictionary<string, object> parms = new Dictionary<string, object>();
            query = sqlTerms;   // nothing extra to add anymore
//            m_log.Debug("Query is: " + query);
            List<Dictionary<string, string>> results;
            using (ISimpleDB db = _connFactory.GetConnection())
            {
                List<UUID> regionsToInclude = UpdateRegionsList(db);
                results = DoLandQueryAndCombine(remoteClient, db, query, parms, queryFlags, queryStart, queryEnd, regionsToInclude);
            }
            if (results.Count < count)
                count = results.Count;  // no Next button
            if (count < 1)
                count = 1;  // a single empty DirLandReplyData will just cause the viewer to report no results found.
            DirLandReplyData[] data = new DirLandReplyData[count];
            foreach (Dictionary<string, string> row in results)
            {
                bool forSale = true;
                bool auction = false;
                data[i] = new DirLandReplyData();
                data[i].parcelID = new UUID(row["UUID"]);
                data[i].name = row["Name"].ToString();
                data[i].auction = auction;
                data[i].forSale = forSale;
                data[i].salePrice = Convert.ToInt32(row["SalePrice"]);
                data[i].actualArea = Convert.ToInt32(row["Area"]);
                i++;
                if (i >= count)
                    break;
            }

            remoteClient.SendDirLandReply(queryID, data);
        }
        public void HandleMapItemRequest(IClientAPI remoteClient, uint flags,
                                                 uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
        {
            //The following constant appears to be from GridLayerType enum
            //defined in OpenMetaverse/GridManager.cs of libopenmetaverse.
            if (itemtype == 7) //(land sales)
            {
                int tc = Environment.TickCount;
                Hashtable ReqHash = new Hashtable();

                //The flags are: SortAsc (1 << 15), PerMeterSort (1 << 17)
                ReqHash["flags"] = "163840";
                ReqHash["type"] = "4294967295"; //This is -1 in 32 bits
                ReqHash["price"] = "0";
                ReqHash["area"] = "0";
                ReqHash["query_start"] = "0";

                Hashtable result = GenericXMLRPCRequest(ReqHash,
                                                        "dir_land_query");

                if (!Convert.ToBoolean(result["success"]))
                {
                    remoteClient.SendAgentAlertMessage(
                        result["errorMessage"].ToString(), false);
                    return;
                }

                ArrayList dataArray = (ArrayList)result["data"];

                int count = dataArray.Count;
                if (count > 100)
                    count = 101;

                DirLandReplyData[] Landdata = new DirLandReplyData[count];

                int i = 0;
                string[] ParcelLandingPoint = new string[count];
                string[] ParcelRegionUUID = new string[count];
                foreach (Object o in dataArray)
                {
                    Hashtable d = (Hashtable)o;

                    if (d["name"] == null)
                        continue;
                    Landdata[i] = new DirLandReplyData();
                    Landdata[i].parcelID = new UUID(d["parcel_id"].ToString());
                    Landdata[i].name = d["name"].ToString();
                    Landdata[i].auction = Convert.ToBoolean(d["auction"]);
                    Landdata[i].forSale = Convert.ToBoolean(d["for_sale"]);
                    Landdata[i].salePrice = Convert.ToInt32(d["sale_price"]);
                    Landdata[i].actualArea = Convert.ToInt32(d["area"]);
                    ParcelLandingPoint[i] = d["landing_point"].ToString();
                    ParcelRegionUUID[i] = d["region_UUID"].ToString();
                    i++;
                    if (i >= count)
                        break;
                }

                List<mapItemReply> mapitems = new List<mapItemReply>();
                uint locX = 0;
                uint locY = 0;

                i = 0;
                foreach (DirLandReplyData landDir in Landdata)
                {
                    foreach (Scene scene in m_Scenes)
                    {
                        if (scene.RegionInfo.RegionID.ToString() == ParcelRegionUUID[i])
                        {
                            locX = scene.RegionInfo.RegionLocX;
                            locY = scene.RegionInfo.RegionLocY;
                            break;
                        }
                    }
                    string[] landingpoint = ParcelLandingPoint[i].Split('/');
                    mapItemReply mapitem = new mapItemReply();
                    mapitem.x = (uint)(locX + Convert.ToDecimal(landingpoint[0]));
                    mapitem.y = (uint)(locY + Convert.ToDecimal(landingpoint[1]));
                    mapitem.id = landDir.parcelID;
                    mapitem.name = landDir.name;
                    mapitem.Extra = landDir.actualArea;
                    mapitem.Extra2 = landDir.salePrice;
                    mapitems.Add(mapitem);
                    i++;
                }
                remoteClient.SendMapItemReply(mapitems.ToArray(), itemtype, flags);
                mapitems.Clear();
            }
        }