www.pudn.com > uoth_src.zip > Filter.h
#ifndef DSSI_FILTER_H
#define DSSI_FILTER_H
//-----------------------------------------------------------------------------
//
// @doc
//
// @module Filter.h - Treasure and region filtering |
//
// This module contains the treasure and region filtering support.
//
// Copyright (c) 2002 - Descartes Systems Sciences, Inc.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Neither the name of Descartes Systems Sciences, Inc nor the names of
// its contributors may be used to endorse or promote products derived
// from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
// @end
//
// $History: ExpatImpl.h $
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// Required include files
//
//-----------------------------------------------------------------------------
#include "uoth.h"
//-----------------------------------------------------------------------------
//
// Forward definitions
//
//-----------------------------------------------------------------------------
class CMapCounts;
class CFilterDlg;
//-----------------------------------------------------------------------------
//
// Class definition
//
//-----------------------------------------------------------------------------
class CFilter
{
// @access Constructors and destructors
public:
// @cmember General constructor
CFilter ();
// @cmember General destructor
~CFilter ();
// @cmember Public methods
public:
// @cmember Update the filter flags
void Update ();
// @cmember Is the map count in the filter
bool IsMapCountInFilter (const CMapCounts *pCount) const;
// @cmember Public inline methods
public:
// @cmember Does the treasure have a map
bool DoesTreasureHaveMap (int nTreasure) const
{
if (nTreasure < 0 || nTreasure >= m_nTreasures)
return false;
else
return m_pfTreasureHasMap [nTreasure];
}
// @cmember Does the region have a map
bool DoesRegionHaveMap (int nRegion) const
{
if (nRegion < 0 || nRegion >= m_nRegions)
return false;
else
return m_pfRegionHasMap [nRegion];
}
// @cmember Is the level in the filter
bool IsLevelInFilter (int nLevel) const
{
if (nLevel <= 0 || nLevel > Max_Level)
return false;
else
return m_afLevels [nLevel - 1];
}
// @cmember Is the tack filter enabled
bool IsTackFilterEnabled () const
{
return m_fEnableTackFilter;
}
// @cmember Is the mine filter enabled
bool IsMineFilterEnabled () const
{
return m_fEnableMineFilter;
}
// @cmember copy operator
const CFilter &operator = (const CFilter &src)
{
if (m_pfTreasureHasMap)
delete [] m_pfTreasureHasMap;
if (m_pfRegionHasMap)
delete [] m_pfRegionHasMap;
m_fEnableLevelFilter = src .m_fEnableLevelFilter;
m_fEnableMineFilter = src .m_fEnableMineFilter;
m_fEnableTackFilter = src .m_fEnableTackFilter;
m_nTreasures = src .m_nTreasures;
m_nRegions = src .m_nRegions;
memcpy (m_afLevels, src .m_afLevels, sizeof (m_afLevels));
if (m_nTreasures > 0)
{
m_pfTreasureHasMap = new bool [m_nTreasures];
memcpy (m_pfTreasureHasMap, src .m_pfTreasureHasMap,
m_nTreasures * sizeof (bool));
}
else
m_pfTreasureHasMap = NULL;
if (m_nRegions > 0)
{
m_pfRegionHasMap = new bool [m_nRegions];
memcpy (m_pfRegionHasMap, src .m_pfRegionHasMap,
m_nRegions * sizeof (bool));
}
else
m_pfRegionHasMap = NULL;
return *this;
}
// @access Protected methods
protected:
// @access Protected variables
protected:
// @cmember Has map flags for treasures
bool *m_pfTreasureHasMap;
// @cmember Number of treasures in the array
int m_nTreasures;
// @cmember Has map flags for regions
bool *m_pfRegionHasMap;
// @cmember Number of regions
int m_nRegions;
// @cmember List of levels included
bool m_afLevels [Max_Level];
// @cmember True if enabled level filtering
bool m_fEnableLevelFilter;
// @cmember Only include treasure that I have maps
bool m_fEnableMineFilter;
// @cmember Only show tacks owned by me
bool m_fEnableTackFilter;
friend class CFilterDlg;
};
#endif // DSSI_FILTER_H