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

Method makeFlood

MicropolisCore/src/MicropolisEngine/src/disasters.cpp:336–367  ·  view source on GitHub ↗

* Flood many tiles * @todo Use Direction and some form of XYPosition class here */

Source from the content-addressed store, hash-verified

334 * @todo Use Direction and some form of XYPosition class here
335 */
336void Micropolis::makeFlood()
337{
338 static const short Dx[4] = { 0, 1, 0, -1 };
339 static const short Dy[4] = { -1, 0, 1, 0 };
340 short xx, yy, c;
341 short z, t, x, y;
342
343 for (z = 0; z < 300; z++) {
344 x = getRandom(WORLD_W - 1);
345 y = getRandom(WORLD_H - 1);
346 c = map[x][y] & LOMASK;
347
348 if (c > CHANNEL && c <= WATER_HIGH) { /* if riveredge */
349 for (t = 0; t < 4; t++) {
350 xx = x + Dx[t];
351 yy = y + Dy[t];
352 if (testBounds(xx, yy)) {
353 c = map[xx][yy];
354
355 /* tile is floodable */
356 if (c == DIRT
357 || (c & (BULLBIT | BURNBIT)) == (BULLBIT | BURNBIT)) {
358 map[xx][yy] = FLOOD;
359 floodCount = 30;
360 sendMessage(MESSAGE_FLOODING_REPORTED, xx, yy, true);
361 return;
362 }
363 }
364 }
365 }
366 }
367}
368
369
370/**

Callers 3

buttonFlood_ClickMethod · 0.45
__init__Method · 0.45

Calls 1

testBoundsFunction · 0.85

Tested by

no test coverage detected