+extern void try_thing_proliferation(struct Thing * t)
+{
+ struct ThingType * tt = get_thing_type(t->type);
+ if (tt->proliferate)
+ {
+ if (1 == tt->proliferate || 1 == (rrand() % tt->proliferate))
+ {
+ struct yx_uint8 candidates[6];
+ uint8_t n_candidates = 0;
+ char dirs[7] = "dxswed";
+ struct yx_uint8 start = t->pos;
+ uint8_t i;
+ for (i = 0; i < strlen(dirs); i++)
+ {
+ if ( mv_yx_in_dir_legal(dirs[i], &start)
+ && '.' == world.map.cells[start.y*world.map.length+start.x])
+ {
+ uint8_t drop = 0;
+ if (tt->lifepoints)
+ {
+ for (t = world.things; t; t = t->next)
+ {
+ if ( t->lifepoints
+ && start.y == t->pos.y && start.x == t->pos.x)
+ {
+ drop = 1;
+ }
+ }
+ }
+ if (!drop)
+ {
+ candidates[n_candidates] = start;
+ n_candidates++;
+ }
+ }
+ }
+ if (!n_candidates)
+ {
+ return;
+ }
+ i = rrand() % n_candidates;
+ add_thing(-1, tt->id, candidates[i].y, candidates[i].x);
+ }
+ }
+}
+
+
+