News:

Simutrans Sites
Know our official sites. Find tools and resources for Simutrans.

Game crashes due to division by 0 immediately after loading save

Started by Ranran, August 15, 2023, 11:53:19 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Ranran

Most Japanese don't believe in religion, but we use Gods as the reason for the event.
In Japan, due to the influence of Buddhism, today is the day when the soul of the dead return from the afterlife. So, my soul also came to the simutrans forum.

At the dead pork meeting it was pointed out that the current simutrans-extended is unplayable.


In Japanese religion, no one believes that the top speed of a road is limited because it is in a city.
This is because in Japan, where there are few areas where humans can live, most people gather in areas where they can live, and the city is amalgamated.
So the Japanese disable this stupid setting.
However, with recent changes simutrans extended no longer allows it. Loading that configuration save will cause a crash immediately.


Now divide by 0 crash in int private_car_destination_finder_t::get_cost().

For some reason w->get_max_speed() now returns 0.
max_speed in weg_t w is 0 for some reason.
As a result const int cost = mpt / ((speed * 167) / 10); divides by 0 and crashes the game.


This symptom was not seen before 14.20.
A quick investigation reveals this commit to be the culprit.
https://github.com/jamespetts/simutrans-extended/commit/4bbb3bd572c0139fb875602d437bfa72788484a4

209CATrus

You know too much regarding Extended code, you're hired.

In defense of city speed limit feature, in Russia (talk about few areas where humans can live heh) maximum speed limit in urbanized areas is 60 km/h, save for few !explicit! (aka marked with a sign) exceptions like 80 on some wider streets.

Also, i haven't seen the code, but maybe you should set the town_road_speed_limit to 200 instead?

209CATrus

Come to think about it, the problem with speed limit in cities stems not from the feature itself (which is technically correct), but from the fact that residential buildings are built in the cities, and cities themselves are silly rectangles. There are no low population areas like villages and private housing sprawls. Just cities and tourist attractions. Then again, even in such case, speed limit is lowered to account for pedestrian crossings, and by the speed limit feature Extended counts every piece of road in city borders as pedestrian crossing.

It sure would be nice to have dedicated pedestrian crossing flags on road pieces to shift from omnipresent speed limits to specific speed limits, but in such case you would need to modify pathfinding algorithm for passengers and/or cargo to account for any obstacle on the way to bus stop or cargo station, including empty tiles or (multitile) buildings. (quick note to whoever unlucky to develop this feature: for the sake of computational performance, you can count every stop as a pedestrian crossing, which is normally the case IRL)

jamespetts

Thank you for the report.

Without a reproduction case saved game, it is difficult to be sure of this, but I have implemented some changes which I hope will fix this. I should be grateful if you could re-test with the next nightly build. Thank you.
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.