performing a land search

This code is still tied to a form, I will be removing the form checks, or maybe not. This code performs an actual land search with the previous specifications.

        void PerformSearch()        {

            // todo: at least some checkboxes must be there

// select a preset

if (chkRotatePreset.Checked)

            {

                CurrentPreset++;

                if (CurrentPreset > cboPreset.Items.Count)

                {

                    CurrentPreset = 0;

                }

cboPreset.SelectedIndex = CurrentPreset;

}

ResetLandSearch();

            lstSearch.Items.Clear();

            lstBuy.Items.Clear();

int.TryParse(cboBuyArea.Text, out LS.qualifyarea);

            int.TryParse(cboBuyPrice.Text, out LS.qualifyprice);

            double.TryParse(cboBuyRate.Text, out LS.qualifyrate);

int.TryParse(cboArea.Text, out LS.maxarea);

            int.TryParse(cboPrice.Text, out LS.maxprice);

if (chkArea.Checked) { LS.limitarea = true; }

            if (chkPrice.Checked) { LS.limitprice = true; }

//

switch (cboType.SelectedIndex)

            {

                case 0: // All Types

                    LS.mainland = true;

                    LS.auction = true;

                    LS.estate = true;

                    LS.newbie = true;

                    break;

case 1:  // Auction

                    LS.mainland = false;

                    LS.auction = true;

                    LS.estate = false;

                    LS.newbie = false;

                    break;

case 2:  // For Sale - Mainland

                    LS.mainland = true;

                    LS.auction = false;

                    LS.estate = false;

                    LS.newbie = false;

                    break;

case 3: // For Sale - Estate

                    LS.mainland = false;

                    LS.auction = false;

                    LS.estate = true;

                    LS.newbie = false;

                    break;

case 4: // First Land

                    LS.mainland = false;

                    LS.auction = false;

                    LS.estate = false;

                    LS.newbie = true;

break;

default: // All Types

                    LS.mainland = true;

                    LS.auction = true;

                    LS.estate = true;

                    LS.newbie = true;

                    break;

            }

//

switch (cboRating.SelectedIndex)

            {

                case 0: // PG & Mature

                    LS.matureonly = false;

                    LS.pgonly = false;

                    break;

case 1: // PG only

                    LS.matureonly = false;

                    LS.pgonly = true;

                    break;

case 2: // Mature only

                    LS.matureonly = true;

                    LS.pgonly = false;

                    break;

default: // PG & Mature

                    LS.matureonly = false;

                    LS.pgonly = false;

                    break;

            }

if (LS.estate) { LS.dstf = LS.dstf | DirectoryManager.SearchTypeFlags.Estate; }

            if (LS.mainland) { LS.dstf = LS.dstf | DirectoryManager.SearchTypeFlags.Mainland; }

            if (LS.newbie) { LS.dstf = LS.dstf | DirectoryManager.SearchTypeFlags.Newbie; }

            if (LS.auction) { LS.dstf = LS.dstf | DirectoryManager.SearchTypeFlags.Auction; }

// todo: cleanly handle dirfindflags or break out into multiple search voids

// sort type is not working correctly

// dwell sort does not return results

// sorting

            LS.sorttype = cboSort.SelectedIndex;

switch (LS.sorttype)

            {

                case 0: LS.dff = LS.dff | DirectoryManager.DirFindFlags.AreaSort; break;

                case 1: LS.dff = LS.dff | DirectoryManager.DirFindFlags.DwellSort; break;

                case 2: LS.dff = LS.dff | DirectoryManager.DirFindFlags.NameSort; break;

                case 3: LS.dff = LS.dff | DirectoryManager.DirFindFlags.PerMeterSort; break;

                case 4: LS.dff = LS.dff | DirectoryManager.DirFindFlags.PricesSort; break;

                default: break;

            }

LS.sortdescending = chkSort.Checked;

if (LS.sortdescending == false) { LS.dff = LS.dff | DirectoryManager.DirFindFlags.SortAsc; }

// query specifications

if (LS.limitarea) { LS.dff = LS.dff | DirectoryManager.DirFindFlags.LimitByArea; }

            if (LS.limitprice) { LS.dff = LS.dff | DirectoryManager.DirFindFlags.LimitByPrice; }

if (LS.matureonly) { LS.dff = LS.dff | DirectoryManager.DirFindFlags.MatureSimsOnly; }

            if (LS.pgonly) { LS.dff = LS.dff | DirectoryManager.DirFindFlags.PgSimsOnly; }

//

LS.queryID = Client.Directory.StartLandSearch(LS.dff, LS.dstf, LS.maxprice, LS.maxarea, LS.queryPointer);

//  StartLandSearchEx(LS.maxarea, LS.maxprice, LS.sorttype, LS.estate, LS.newbie, LS.mainland, LS.limitarea, LS.limitprice, LS.matureonly, LS.pgonly, 0);

            //  StartLandSearchEx(32, 200, 4, true, false, true, true, true, false, false);

            //StartLandSearchEx(32, 1000, 4, true, false, true, true, true, false, false);

//

}

Leave a Reply