MCPcopy Create free account
hub / github.com/SimHacker/micropolis / smoothStationMap

Function smoothStationMap

MicropolisCore/src/MicropolisEngine/src/scan.cpp:80–104  ·  view source on GitHub ↗

* Smooth a station map. * * Used for smoothing fire station and police station coverage maps. * @param map Map to smooth. */

Source from the content-addressed store, hash-verified

78 * @param map Map to smooth.
79 */
80static void smoothStationMap(MapShort8 *map)
81{
82 short x, y, edge;
83 MapShort8 tempMap(*map);
84
85 for (x = 0; x < tempMap.MAP_W; x++) {
86 for (y = 0; y < tempMap.MAP_H; y++) {
87 edge = 0;
88 if (x > 0) {
89 edge += tempMap.get(x - 1, y);
90 }
91 if (x < tempMap.MAP_W - 1) {
92 edge += tempMap.get(x + 1, y);
93 }
94 if (y > 0) {
95 edge += tempMap.get(x, y - 1);
96 }
97 if (y < tempMap.MAP_H - 1) {
98 edge += tempMap.get(x, y + 1);
99 }
100 edge = tempMap.get(x, y) + edge / 4;
101 map->set(x, y, edge / 2);
102 }
103 }
104}
105
106/**
107 * Make firerate map from firestation map.

Callers 2

fireAnalysisMethod · 0.85
crimeScanMethod · 0.85

Calls 2

setMethod · 0.80
getMethod · 0.45

Tested by

no test coverage detected