The International Simutrans Forum

 

Author Topic: Fix for crash when there is no climate available for a height  (Read 889 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeac

  • Devotee
  • *
  • Posts: 259
This patch fixes a crash which occurs when generating a map with the attached map parameters.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10674
  • Languages: De,EN,JP
Re: Fix for crash when there is no climate available for a height
« Reply #1 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.

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
Re: Fix for crash when there is no climate available for a height
« Reply #2 on: July 04, 2020, 06:53:19 PM »
I encountered this error also thanks for fixing ceeac

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10674
  • Languages: De,EN,JP
Re: Fix for crash when there is no climate available for a height
« Reply #3 on: July 05, 2020, 01:42:04 PM »
Yes, but this is fixing symptoms, the real error happened elsewhere before.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4878
  • Languages: EN, DE, AT
Re: Fix for crash when there is no climate available for a height
« Reply #4 on: July 09, 2020, 06:42:35 PM »
I committed this fix (with small change) in r9164. Symptons are cured...

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10674
  • Languages: De,EN,JP
Re: Fix for crash when there is no climate available for a height
« Reply #5 on: July 10, 2020, 01:59:03 PM »
I think I fixed the original bug in r9167

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
Re: Fix for crash when there is no climate available for a height
« Reply #6 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10674
  • Languages: De,EN,JP
Re: Fix for crash when there is no climate available for a height
« Reply #7 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

Offline kierongreen

  • Dev Team, Coder/patcher
  • Devotee
  • *
  • Posts: 2346
Re: Fix for crash when there is no climate available for a height
« Reply #8 on: July 14, 2020, 03:36:21 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.

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10674
  • Languages: De,EN,JP
Re: Fix for crash when there is no climate available for a height
« Reply #9 on: July 15, 2020, 12:00:41 AM »
Ahh, thanks, I misunderstood. Still you report got me think about the above issue as well.