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

Method makeEarthquake

MicropolisCore/src/MicropolisEngine/src/disasters.cpp:247–271  ·  view source on GitHub ↗

Change random tiles to fire or dirt as result of the earthquake */

Source from the content-addressed store, hash-verified

245
246/** Change random tiles to fire or dirt as result of the earthquake */
247void Micropolis::makeEarthquake()
248{
249 short x, y, z;
250
251 int strength = getRandom(700) + 300; // strength/duration of the earthquake
252
253 doEarthquake(strength);
254
255 sendMessage(MESSAGE_EARTHQUAKE, cityCenterX, cityCenterY, true);
256
257 for (z = 0; z < strength; z++) {
258 x = getRandom(WORLD_W - 1);
259 y = getRandom(WORLD_H - 1);
260
261 if (vulnerable(map[x][y])) {
262
263 if ((z & 0x3) != 0) { // 3 of 4 times reduce to rubble
264 map[x][y] = randomRubble();
265 } else {
266 // 1 of 4 times start fire
267 map[x][y] = randomFire();
268 }
269 }
270 }
271}
272
273
274/** Start a fire at a random place, random disaster or scenario */

Callers 3

__init__Method · 0.45

Calls 1

randomRubbleFunction · 0.85

Tested by

no test coverage detected