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

Method zonePlop

MicropolisCore/src/MicropolisEngine/src/zone.cpp:352–388  ·  view source on GitHub ↗

* Put down a 3x3 zone around the center tile at \a pos.. * @param base Tile number of the top-left tile. @see MapTileCharacters * @return Build was a success. * @bug This function allows partial on-map construction. Is that intentional? No! */

Source from the content-addressed store, hash-verified

350 * @bug This function allows partial on-map construction. Is that intentional? No!
351 */
352bool Micropolis::zonePlop(const Position &pos, int base)
353{
354 short z, x;
355 static const short Zx[9] = {-1, 0, 1,-1, 0, 1,-1, 0, 1};
356 static const short Zy[9] = {-1,-1,-1, 0, 0, 0, 1, 1, 1};
357
358 for (z = 0; z < 9; z++) { /* check for fire */
359 int xx = pos.posX + Zx[z];
360 int yy = pos.posY + Zy[z];
361
362 if (testBounds(xx, yy)) {
363 x = map[xx][yy] & LOMASK;
364
365 if ((x >= FLOOD) && (x < ROADBASE)) {
366 return false;
367 }
368
369 }
370
371 }
372
373 for (z = 0; z < 9; z++) {
374 int xx = pos.posX + Zx[z];
375 int yy = pos.posY + Zy[z];
376
377 if (testBounds(xx, yy)) {
378 map[xx][yy] = base + BNCNBIT;
379 }
380
381 base++;
382 }
383
384 setZonePower(pos);
385 map[pos.posX][pos.posY] |= ZONEBIT + BULLBIT;
386
387 return true;
388}
389
390/**
391 * Count the number of single tile houses in a residential zone.

Callers

nothing calls this directly

Calls 1

testBoundsFunction · 0.85

Tested by

no test coverage detected