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

Method treeSplash

MicropolisCore/src/MicropolisEngine/src/generate.cpp:300–326  ·  view source on GitHub ↗

* Splash a bunch of trees down near (\a xloc, \a yloc). * * Amount of trees is controlled by Micropolis::terrainTreeLevel. * @param xloc Horizontal position of starting point for splashing trees. * @param yloc Vertical position of starting point for splashing trees. * @note Trees are not smoothed. * @bug Function generates trees even if Micropolis::terrainTreeLevel is 0. */

Source from the content-addressed store, hash-verified

298 * @bug Function generates trees even if Micropolis::terrainTreeLevel is 0.
299 */
300void Micropolis::treeSplash(short xloc, short yloc)
301{
302 short numTrees;
303
304 if (terrainTreeLevel < 0) {
305 numTrees = getRandom(150) + 50;
306 } else {
307 numTrees = getRandom(100 + (terrainTreeLevel * 2)) + 50;
308 }
309
310 Position treePos(xloc, yloc);
311
312 while (numTrees > 0) {
313 Direction2 dir = (Direction2)(DIR2_NORTH + getRandom(7));
314 treePos.move(dir);
315
316 if (!treePos.testBounds()) {
317 return;
318 }
319
320 if ((map[treePos.posX][treePos.posY] & LOMASK) == DIRT) {
321 map[treePos.posX][treePos.posY] = WOODS | BLBNBIT;
322 }
323
324 numTrees--;
325 }
326}
327
328
329/** Splash trees around the world. */

Callers

nothing calls this directly

Calls 2

moveMethod · 0.45
testBoundsMethod · 0.45

Tested by

no test coverage detected