FaceDeer / settlements

Minetest mod that adds small settlements to mapgen
MIT License
5 stars 2 forks source link

Building/settlement placement issues #5

Open tuedel opened 4 years ago

tuedel commented 4 years ago

Below are some bugs/oddities I found while playing around with your latest code (@ 8b9749abd5c2e510e29d5bbff52a45e1bb09fa3f).

  1. Buildings sometimes spawn inside rivers (using the valleys mapgen, I suspect you're not using it. Probably easy to fix though.) screenshot_20200125_134319 screenshot_20200125_134837 screenshot_20200125_150356

  2. Mer settlements sometimes spawn inside caves below the sea. screenshot_20200125_133247

  3. Settlements get generated without a single building. In some cases it seems likely that no suitable surface was found, while in others there definitely should have been enough free space to build on. screenshot_20200125_135627 screenshot_20200125_164806

  4. Buildings sometimes spawn inside each other and/or have missing parts. screenshot_20200125_132806 screenshot_20200125_133056 screenshot_20200125_150641

  5. Settlements sometimes get cut off at mapblock borders (supposedly, didn't check the coordinates). This one could likely be an engine issue, because default trees are affected as well: screenshot_20200125_151119

PS: Great work on this! I'd been thinking about doing something similar to this mod for a while, but you beat me to it :smile: Any reason you didn't make use of your excellent mapgen_helper lib for the rewrite?

FaceDeer commented 4 years ago

Seems I was too cavalier about using "am I above or below y=0?" to determine whether buildings were under water. I'll add some checks for that.

The no-building settlements are odd, there's a check in the code specifically intended to prevent settlements that weren't able to build... heh. I just checked, and the code is:

if number_built == 1 then
    return nil
end

Well, that's silly. 0-building settlements are allowed after all. Should be easy to fix. :)

Not sure how that buildings-inside-buildings thing could be possible with just one settlement, the initial building layout pass does mutual overlap detection quite stringently and I've never seen it go awry. Might you have two settlements in the same mapchunk?

As for the decapitated village, yeah, I'm not sure that's something I did given how the trees are also cut off. In theory a building taller than 16 nodes tall could get its top cut off (there's a 16-node border around mapchunks where stuff can be built "outside" the chunk and still survive) but all the schematics should be shorter than that. Weird. I haven't tested this mod with the valleys mapgen before though, so I'll do some poking around in there and see if I can replicate this stuff reliably.

The reason I didn't use mapgen_helper was just because I was starting from an existing mod and everything was already self-contained, so I didn't think of using additional libraries as I tore down and rebuilt stuff. Slipped my mind, in other words. :) Ironically, I just finished splitting a new library out of this one - https://github.com/FaceDeer/named_waypoints , I'll be updating this mod to depend on that one shortly.

FaceDeer commented 4 years ago

I have a working theory about some of this. I think the code that's analyzing the heightmap to determine "is this area too hilly for a settlement?" isn't working right with Valleys mapgen, and so settlements are being placed in rougher terrain than was the case with my v7 mapgen testing. That's resulting in the "find the ground surface" code climbing up through taller hills than it was tested with and placing buildings outside the safe zone. I just found a settlement where a bunch of buildings had been placed inside a cave in the hillside, which is actually pretty cool even though it shouldn't have happened.

Perhaps the overlapping buildings are due to settlements thinking "ground level" is present in two map chunks that are vertically stacked? That might cause it to generate buildings twice, each time thinking "aha, I'm the mapchunk whose center point is a ground level, surely I'm the only one that's true for." Haven't actually seen it happen yet but that makes some sense.

Fortunately, the heightfield code is an area of particular interest for me to revamp anyway - I want to adapt this mod to work inside giant caverns someday, where mapgen doesn't give a convenient hightfield to work with anyway.