The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: ceeac on July 04, 2020, 01:30:03 PM

Title: Fix for crash when there is no climate available for a height
Post by: ceeac on July 04, 2020, 01:30:03 PM
This patch fixes a crash which occurs when generating a map with the attached map parameters.
Title: Re: Fix for crash when there is no climate available for a height
Post by: prissi on July 04, 2020, 02:50:44 PM
This should never happen, since just before all tie with single or no climates are handled. Moreover, climate from height arrz is set to emperate, if there is no climate at all. I will investigate further.
Title: Re: Fix for crash when there is no climate available for a height
Post by: kierongreen on July 04, 2020, 06:53:19 PM
I encountered this error also thanks for fixing ceeac
Title: Re: Fix for crash when there is no climate available for a height
Post by: prissi on July 05, 2020, 01:42:04 PM
Yes, but this is fixing symptoms, the real error happened elsewhere before.
Title: Re: Fix for crash when there is no climate available for a height
Post by: Dwachs on July 09, 2020, 06:42:35 PM
I committed this fix (with small change) in r9164. Symptons are cured...
Title: Re: Fix for crash when there is no climate available for a height
Post by: prissi on July 10, 2020, 01:59:03 PM
I think I fixed the original bug in r9167
Title: Re: Fix for crash when there is no climate available for a height
Post by: kierongreen on July 13, 2020, 04:40:28 PM
I'm still getting issues here - when you increase the water level in the landscape settings window the climate setting heights aren't updated correctly. As a result out of bounds array accesses were occurring which didn't generate an exception immediately but corrupted zeiger and viewport pointers causing issues later. This patch handles this window more robustly to ensure that negative values aren't passed as an array offset, and also addresses what I think is an issue relating to an incorrect height - on one comparison the difference from groundwater was used rather than the absolute height value. Should be ok to commit just putting it here first to check people are happy with it - if I don't hear any negatives will commit tomorrow.
Title: Re: Fix for crash when there is no climate available for a height
Post by: prissi on July 14, 2020, 02:51:19 PM
Changing the groundwater height should lead to all bad effects also with existing maps, since the lookup of climates by height after a change of groundwater level without recalculating the table will lead to wrong offsets anyway. Changing climates was never a good idea after starting a game
Title: Re: Fix for crash when there is no climate available for a height
Post by: kierongreen on July 14, 2020, 03:36:21 PM
Quote from: prissi on July 14, 2020, 02:51:19 PM
Changing the groundwater height should lead to all bad effects also with existing maps, since the lookup of climates by height after a change of groundwater level without recalculating the table will lead to wrong offsets anyway. Changing climates was never a good idea after starting a game
To be clear the errors I was getting was when creating a new map with a different groundwater height from that previously used in settings. The climate window appeared to update climate boundaries but didn't actually apply these values to settings, hence when the new map creation began some climates had negative offsets relative to groundwater, which then caused an out of bounds memory write. The patch forces changes to the values in the GUI to be written to settings.
Title: Re: Fix for crash when there is no climate available for a height
Post by: prissi on July 15, 2020, 12:00:41 AM
Ahh, thanks, I misunderstood. Still you report got me think about the above issue as well.