Palats / mapshot

Factorio mod to export maps as zoomable html
Apache License 2.0
77 stars 12 forks source link

Should not include pictures of non-generated chunks #31

Open nixxquality opened 1 year ago

nixxquality commented 1 year ago

Thank you for the mod.

I generated a map of a savefile that was made using Factorio World and it looks like this: https://nixx.is-fantabulo.us/ultradeath/

As you can see, there are some monstrous blobs of land that shouldn't be there. In the regular save file that land is unexplored, so it's not generated. My guess is:

  1. Your script takes a peek at a chunk that doesn't exist yet
  2. Factorio generates the piece of land that would usually be there, given the map seed which otherwise is mostly ignored
  3. The screenshot is taken
  4. the Factorio World script now tries to react and put the correct terrain there, but it's too late

The simplest solution I could think of would be to not attempt to look at chunks that don't exist. However, I'm guessing that would result in bad cropping around the edges?

My next idea would be to figure out all the places we need to look at, look at them, give the game some time to generate the chunks fully, and then take the screenshots.

You can get the save yourself at https://nixx.is-fantabulo.us/UltraDeath.zip

Palats commented 1 year ago

Thanks for the report and especially for providing an example!

I guess you refer to the area on the edge of the map along the water & the weird zone below Australia. I'm not sure why it renders those weird half generated areas. I've always seen them (even on simpler maps), but never got to investigate. It might be tricky to fix.

Factorio generation works per chunk (see map structure - a chunk is a bunch of factorio tiles)). And there is a way to know whether a chunk is generated. The mod uses that function to determine the rendering bounding box - i.e., which total rectangular area is going to be rendered. Then it renders for each zoom level a bunch of screenshots to cover that bounding box.

That's where there are 2 cases to cover:

The thing I suspect is that fixing the second case would not be enough, as a lot of screenshots would still fall into the first case. Overall that would require trying a few things out, but I suspect that in the end it would not improve things much.

The case about partial generation is interesting - though if that was the case, it would mean that the next mapshot would have a better result, which I never noticed. Might do with some testing too to verify.

[I don't plan to work on that for now]