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

Method fireZone

MicropolisCore/src/MicropolisEngine/src/simulate.cpp:1343–1381  ·  view source on GitHub ↗

* Handle a zone on fire. * * Decreases rate of growth of the zone, and makes remaining tiles bulldozable. * * @param pos Position of the zone on fire. * @param ch Character of the zone. */

Source from the content-addressed store, hash-verified

1341 * @param ch Character of the zone.
1342 */
1343void Micropolis::fireZone(const Position &pos, MapValue ch)
1344{
1345 short XYmax;
1346
1347 int value = rateOfGrowthMap.worldGet(pos.posX, pos.posY);
1348 value = clamp(value - 20, -200, 200);
1349 rateOfGrowthMap.worldSet(pos.posX, pos.posY, value);
1350
1351 ch = ch & LOMASK;
1352
1353 if (ch < PORTBASE) {
1354 XYmax = 2;
1355 } else {
1356 if (ch == AIRPORT) {
1357 XYmax = 5;
1358 } else {
1359 XYmax = 4;
1360 }
1361 }
1362
1363 // Make remaining tiles of the zone bulldozable
1364 for (short x = -1; x < XYmax; x++) {
1365 for (short y = -1; y < XYmax; y++) {
1366
1367 short xTem = pos.posX + x;
1368 short yTem = pos.posY + y;
1369
1370 if (!testBounds(xTem, yTem)) {
1371 continue;
1372 }
1373
1374 if ((MapTile)(map[xTem][yTem] & LOMASK) >= ROADBASE) {
1375 /* post release */
1376 map[xTem][yTem] |= BULLBIT;
1377 }
1378
1379 }
1380 }
1381}
1382
1383
1384/**

Callers

nothing calls this directly

Calls 4

clampFunction · 0.85
testBoundsFunction · 0.85
worldGetMethod · 0.80
worldSetMethod · 0.80

Tested by

no test coverage detected