News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

8.x - crash when building elevated monorail

Started by yobbobandana, May 31, 2010, 06:47:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

yobbobandana

Hi,

Great work on simutrans experimental, I really like the added features :).

I found a consistent segfault when building elevated monorails (ones on ground-level work fine). So, umm, I fixed it! Is this the right place to attach a patch?

I used "format-patch" on the latest git, so it should be easy to apply with "git am".

jamespetts

yobbobandana,

hello and welcome to the Simutrans forums! Thank you very much for the bug report and even more for the fix. I don't have access to the computer on which I develop Simutrans to-day, but hope to have time to implement and test it in the source code to-morrow. Looking at the patch itself, however, it looks like a sensible fix, so I imagine that it will probably make its way into the next release of Simutrans-Experimental (8.1). (One query on closer examination, though: does this mean that, in the case of an elevated way built over land owned by the player already, the cost of buying land is not deducted from the cost of building the way? If so, we probably need to find a different method for obtaining a good pointer to the correct ground ("gr") at that point). This looks as though it might fix a crash that a number of other people have reported, too.

Using a .patch (or .diff) file is fine, but the best possible way of doing it is to create your own fork on Github and push your changes there. I can then scan your fork regularly to see whether you've made any other changes, and merge the changes in automatically.

Thank you again very much for your help!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.


yobbobandana

Quote from: sdog on May 31, 2010, 08:09:25 PM
this could also fix the second crash in this posting:
http://forum.simutrans.com/index.php?topic=5179.msg50937#msg50937

I'm having no trouble building bridges with this patch applied so yes I think it might have also fixed that :).

Quote from: jamespetts on May 31, 2010, 07:11:31 PM
(One query on closer examination, though: does this mean that, in the case of an elevated way built over land owned by the player already, the cost of buying land is not deducted from the cost of building the way? If so, we probably need to find a different method for obtaining a good pointer to the correct ground ("gr") at that point).

I assume the cost of buying the land is deducted elsewhere, and that you don't have to buy the land unless you build on it at ground level. It makes sense to me that you wouldn't necessarily have to buy the land, as elevated ways can cross public buildings and landmarks.

After some quick testing though, this land buying cost doesn't seem to be automatically added. In fact when I build an ordinary road across another of my own roads, the "cost" displayed in the tooltip goes into the negative. The actual cost when constructed seems correct, though.

I must admit, I'm still a little lost amidst all the semi-german variable names. As far as I can tell though, the buy-land cost is being applied in "baue_strasse" and "baue_schiene" but not "baue_elevated" and "baue_tunnelboden", so judging by my rudimentary german the behaviour of not modifying the cost for elevated ways seems to be correct :).

jamespetts

yobbobandana,

the deducting the cost of land feature was something that I added very recently: it did not appear in versions before Experimental 8.0, and still does not appear in Standard. Elevated ways have their own fixed prices that are separate from non-elevated ways: the solution might simply be for pakset authors to take into consideration when they set the prices for elevated ways and bridges that the cost of buying land is not to be factored into the construction as it is with ground based ways.

Thank you again for the patch!
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

yobbobandana

Ahh, right! I remember seeing a function that returned the ground tile from a 2d coordinate somewhere...

Here we go.

If you want that code block to also apply to elevated ways, in stead of wrapping it in the "if (gr) { ... } " as I did, you could prepend it with:


if (!gr) {
gr = welt->lookup_kartenboden(koord(route[i].x, route[i].y));
}


That should correctly obtain the ground tile from any elevation and display a discount if you own property on it. I'm not sure if the discount will be properly applied when actually purchasing the way though. The cost calculation chain is still quite opaque to me. Also, it will affect tunnels under the tile, which may not be desirable.

Junna

Is this problem the reason that the bug with crashing when trying to build any elevated structure whatsoever causes crashes is back again? Building elevated railway in pak128.britain.ex causes crashes as well as any monorail/elevated structure based on it in pak128 etc.

It also, as before it was fixed in 7.1, causes crashes with tunnels.

yobbobandana

Quote from: Junna on June 03, 2010, 12:40:05 AM
Is this problem the reason that the bug with crashing when trying to build any elevated structure whatsoever causes crashes is back again? Building elevated railway in pak128.britain.ex causes crashes as well as any monorail/elevated structure based on it in pak128 etc.
Yep, this bug was causing it to crash when building any way that wasn't at ground level (monorails, bridges, tunnels, etc), and with any pakset.

It's fixed in dev now so it should be fixed in the next release.

(not sure if it was the same as the issue in a previous version, probably just a different issue with the same effect. I only just started playing experimental)

jamespetts

The issue is indeed a new one, not a previous issue, and it will be fixed - thanks to Yobbobandana's patch - in the next release, 8.1.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.