Zylleon / MapDesigner

Rimworld mod that allows custom maps
4 stars 4 forks source link

Rivers are not properly scaled on Initial Map on New Game when using anything other than default (250) map size #13

Closed TDarksword closed 1 year ago

TDarksword commented 2 years ago

Not sure if you're aware, but there is a bug with the river generation and the Map Designer settings. Basically the mod always uses a map size of 250x250 for the initial generation (ie on a new world/new map), which causes the river to be misplaced from the settings for anything other map size than the default.

This can easily be seen by setting a river location in the settings to one of the extremes (eg all the way East), then starting a new world. The first map generated will have a different river location to where it will be if you then run the Regenerate Current Map in the debug menu. In the example of all the way East (and a North/South river), for smaller maps, part of the river can actually go off the edge of the map depending on its angle (so it ends up as a N/E river or a S/E river). Larger than default maps it will be closer to the middle than it should be.

Taking a quick look, I think this is tied up with you using Find.World.info.initialMapSize in your code (in RiversStylePatch.cs), this is set to 250 at the start of the game and is not updated to the picked size until after the mapGenerator is run. Specifically its the line immediately after calling the Map Generator in InitNewGame() that updates this. Note CurrentMap also isn't set yet either (about a further 6 lines down in the code).

I think I have a possible fix, which involves using a prefix to pull the actual map size passed to the MapGenerator and setting it to a variable, and then the RiverStyleMethod can pull from this later on. Upon testing this appears to work, and I'm going to see if I can work out how to to a Fork/Pull and then generate the updated code for you. This has been tested on 1.3, and I'll look at testing the 1.2 version when I'm properly pulling from the repository.