|
Micropolis
|
#include <map_type.h>
Public Member Functions | |
| Map (DATA defaultValue) | |
| Map (const Map< DATA, BLKSIZE > &map) | |
| Map & | operator= (const Map< DATA, BLKSIZE > &map) |
| ~Map () | |
| void | fill (DATA val) |
| void | clear () |
| void | set (int x, int y, DATA val) |
| DATA | get (int x, int y) const |
| bool | onMap (int x, int y) const |
| void | worldSet (int x, int y, DATA val) |
| DATA | worldGet (int x, int y) const |
| bool | worldOnMap (int x, int y) const |
| DATA * | getBase () |
| size_t | getTotalByteSize () const |
Public Attributes | |
| const int | MAP_BLOCKSIZE |
| const int | MAP_W |
| Number of clusters in horizontal direction. | |
| const int | MAP_H |
| Number of clusters in vertical direction. | |
Private Attributes | |
| DATA | _mapData [((WORLD_W+BLKSIZE - 1)/BLKSIZE) *((WORLD_H+BLKSIZE - 1)/BLKSIZE)] |
| const DATA | _MAP_DEFAULT_VALUE |
| Default value of a cluster. | |
Generic class for maps in the Micropolis game.
A map is assumed to cover a 2D grid of WORLD_W times WORLD_H positions. A block of positions may be clustered, and represented by a single data value.
| DATA | Data type of a data value. |
| BLKSIZE | Size of the cluster. |
Definition at line 112 of file map_type.h.
Generic map constructor.
| defaultValue | Default value to use for off-map positions, and for clearing the map. |
Definition at line 159 of file map_type.h.
Copy constructor
Definition at line 170 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData, and Map< DATA, BLKSIZE >::MAP_H.
Generic map destructor
Definition at line 197 of file map_type.h.
| void Map< DATA, BLKSIZE >::clear | ( | ) |
Generic clear routine.
Resets all data of the map to _MAP_DEFAULT_VALUE.
Definition at line 222 of file map_type.h.
Referenced by Micropolis::destroyMapArrays(), Micropolis::doPowerScan(), Micropolis::init(), Micropolis::initWillStuff(), and Micropolis::populationDensityScan().
| void Map< DATA, BLKSIZE >::fill | ( | DATA | value | ) |
Generic fill routine.
| value | Value with which to fill the map. |
Definition at line 208 of file map_type.h.
Referenced by Micropolis::simLoadInit().
|
inline |
Return the value of a cluster.
If the coordinate is off the map, the _MAP_DEFAULT_VALUE is returned.
| x | X cluster position (at world position x * MAP_BLOCKSIZE). |
| y | Y cluster position (at world position y * MAP_BLOCKSIZE). |
Definition at line 265 of file map_type.h.
Referenced by Micropolis::decRateOfGrowthMap(), Micropolis::getCrimeRate(), Micropolis::getFireCoverage(), Micropolis::getLandValue(), Micropolis::getPoliceCoverage(), Micropolis::getPollutionDensity(), Micropolis::getPopulationDensity(), Micropolis::getRateOfGrowth(), Micropolis::getTrafficDensity(), smoothDitherMap(), and smoothStationMap().
| DATA * Map< DATA, BLKSIZE >::getBase | ( | ) |
Return the base address of the map data.
Definition at line 233 of file map_type.h.
Referenced by Micropolis::getCrimeRateMapBuffer(), Micropolis::getFireCoverageMapBuffer(), Micropolis::getLandValueMapBuffer(), Micropolis::getPoliceCoverageMapBuffer(), Micropolis::getPollutionDensityMapBuffer(), Micropolis::getPopulationDensityMapBuffer(), Micropolis::getPowerGridMapBuffer(), Micropolis::getRateOfGrowthMapBuffer(), Micropolis::getTrafficDensityMapBuffer(), and Micropolis::populationDensityScan().
|
inline |
Definition at line 138 of file map_type.h.
|
inline |
Verify that cluster coordinates are within map boundaries.
| x | X cluster position (at world position x * MAP_BLOCKSIZE). |
| y | Y cluster position (at world position y * MAP_BLOCKSIZE). |
Definition at line 282 of file map_type.h.
| Map< DATA, BLKSIZE > & Map< DATA, BLKSIZE >::operator= | ( | const Map< DATA, BLKSIZE > & | map | ) |
Assignment operator
Definition at line 184 of file map_type.h.
References Map< DATA, BLKSIZE >::_mapData.
|
inline |
Set the value of a cluster.
If the coordinate is off the map, the value is not stored.
| x | X cluster position (at world position x * MAP_BLOCKSIZE). |
| y | Y cluster position (at world position y * MAP_BLOCKSIZE). |
| value | Value to use. |
Definition at line 248 of file map_type.h.
Referenced by Micropolis::computeComRateMap(), Micropolis::decRateOfGrowthMap(), Micropolis::setCrimeRate(), Micropolis::setFireCoverage(), Micropolis::setLandValue(), Micropolis::setPoliceCoverage(), Micropolis::setPollutionDensity(), Micropolis::setPopulationDensity(), Micropolis::setRateOfGrowth(), Micropolis::setTrafficDensity(), smoothDitherMap(), and smoothStationMap().
|
inline |
Return the value of a cluster.
If the coordinate is off the map, the _MAP_DEFAULT_VALUE is returned.
| x | X world position. |
| y | Y world position. |
Definition at line 316 of file map_type.h.
Referenced by Micropolis::addToTrafficDensityMap(), Micropolis::crimeScan(), Micropolis::decTrafficMap(), Micropolis::doBusSprite(), Micropolis::doComIn(), Micropolis::doCopterSprite(), Micropolis::doFire(), Micropolis::doResIn(), Micropolis::doRoad(), Micropolis::doSpecialZone(), Micropolis::evalCom(), Micropolis::evalRes(), Micropolis::fireZone(), Micropolis::getDensity(), Micropolis::getLandPollutionValue(), Micropolis::getPowerGrid(), Micropolis::getTrafficAverage(), Micropolis::incRateOfGrowth(), Micropolis::setZonePower(), Micropolis::startFireInZone(), and Micropolis::testForConductive().
|
inline |
Verify that world coordinates are within map boundaries.
| x | X world position. |
| y | Y world position. |
Definition at line 335 of file map_type.h.
|
inline |
Set the value of a cluster.
If the coordinate is off the map, the value is not stored.
| x | X world position. |
| y | Y world position. |
| value | Value to use. |
Definition at line 297 of file map_type.h.
Referenced by Micropolis::addToTrafficDensityMap(), Micropolis::crimeScan(), Micropolis::decTrafficMap(), Micropolis::doPowerScan(), Micropolis::doSpecialZone(), Micropolis::fireZone(), Micropolis::incRateOfGrowth(), Micropolis::populationDensityScan(), Micropolis::setPowerGrid(), and Micropolis::startFireInZone().
|
private |
Default value of a cluster.
Definition at line 149 of file map_type.h.
|
private |
Data fields of the map in column-major mode.
Definition at line 146 of file map_type.h.
Referenced by Map< DATA, BLKSIZE >::Map(), and Map< DATA, BLKSIZE >::operator=().
| const int Map< DATA, BLKSIZE >::MAP_BLOCKSIZE |
Size of a cluster in number of world positions.
Definition at line 121 of file map_type.h.
Referenced by Micropolis::crimeScan(), Micropolis::decTrafficMap(), and Micropolis::getTrafficAverage().
| const int Map< DATA, BLKSIZE >::MAP_H |
Number of clusters in vertical direction.
Definition at line 123 of file map_type.h.
Referenced by Micropolis::computeComRateMap(), Micropolis::decRateOfGrowthMap(), Map< DATA, BLKSIZE >::Map(), Micropolis::populationDensityScan(), smoothDitherMap(), and smoothStationMap().
| const int Map< DATA, BLKSIZE >::MAP_W |
Number of clusters in horizontal direction.
Definition at line 122 of file map_type.h.
Referenced by Micropolis::computeComRateMap(), Micropolis::decRateOfGrowthMap(), Micropolis::populationDensityScan(), smoothDitherMap(), and smoothStationMap().