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

Method doMeltdown

MicropolisCore/src/MicropolisEngine/src/simulate.cpp:1668–1706  ·  view source on GitHub ↗

* Perform a nuclear melt-down disaster * @param pos Position of the nuclear power plant that melts. */

Source from the content-addressed store, hash-verified

1666 * @param pos Position of the nuclear power plant that melts.
1667 */
1668void Micropolis::doMeltdown(const Position &pos)
1669{
1670 makeExplosion(pos.posX - 1, pos.posY - 1);
1671 makeExplosion(pos.posX - 1, pos.posY + 2);
1672 makeExplosion(pos.posX + 2, pos.posY - 1);
1673 makeExplosion(pos.posX + 2, pos.posY + 2);
1674
1675 // Whole power plant is at fire
1676 for (int x = pos.posX - 1; x < pos.posX + 3; x++) {
1677 for (int y = pos.posY - 1; y < pos.posY + 3; y++) {
1678 map[x][y] = randomFire();
1679 }
1680 }
1681
1682 // Add lots of radiation tiles around the plant
1683 for (int z = 0; z < 200; z++) {
1684
1685 int x = pos.posX - 20 + getRandom(40);
1686 int y = pos.posY - 15 + getRandom(30);
1687
1688 if (!testBounds(x, y)) { // Ignore off-map positions
1689 continue;
1690 }
1691
1692 MapValue t = map[x][y];
1693
1694 if (t & ZONEBIT) {
1695 continue; // Ignore zones
1696 }
1697
1698 if ((t & BURNBIT) || t == DIRT) {
1699 map[x][y] = RADTILE; // Make tile radio-active
1700 }
1701
1702 }
1703
1704 // Report disaster to the user
1705 sendMessage(MESSAGE_NUCLEAR_MELTDOWN, pos.posX, pos.posY, true, true);
1706}
1707
1708
1709////////////////////////////////////////////////////////////////////////

Callers

nothing calls this directly

Calls 1

testBoundsFunction · 0.85

Tested by

no test coverage detected