News:

Simutrans Wiki Manual
The official on-line manual for Simutrans. Read and contribute.

[Patch] Enforcing weight limits (Superseded)

Started by jamespetts, December 23, 2008, 06:58:58 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jamespetts

Attached is a patch which enforces the "max_weight" property already found in waytype .dat files based on the loaded weight of the vehicle. It does not prevent an overweight vehicle from using a weight limited route, but simply makes the vehicle/train much slower (by a factor of 3 if it is within 10% of the limit, otherwise by a factor of 10) when passing over the weight limited route. It also displays a message next to the vehicle with a yellow background, stating, "Vehicle %s is too heavy for this route: speed limited.", where "%s" is the name of the vehicle.

Edit: I have now implemented weight limits in the GUI, so that weight limits for railway track and roads are visible: (1) as a tooltip in the purchasing menu; and (2) in the statistics box. A revised patch is attached. Note that the previous patch did not include a crucial file, and therefore would not have worked.

Also, I have noticed that, whilst a weight limit parameter is included for plain track and road, is it not, somewhat oddly, included for bridges or tunnels: it is for bridges, in particular, that weight limits are likely to be useful. I shall have to set about adding that to bridges, but that will involve a re-versioning of the pak files.

As ever, any feedback would be appreciated :-)

Edit: This patch is now superseded by the one that can be found here, which also incorporates the improvements to cornering.
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.

jbode

Quote from: jamespetts on December 23, 2008, 06:58:58 PM
Also, I have noticed that, whilst a weight limit parameter is included for plain track and road, is it not, somewhat oddly, included for bridges or tunnels: it is for bridges, in particular, that weight limits are likely to be useful. I shall have to set about adding that to bridges, but that will involve a re-versioning of the pak files.

... thats a side effect of thinking ... most of the time not thought of ;) , ugly isn't it?

SCNR ... - Jörg

Fabio

Quote from: jamespetts on December 23, 2008, 06:58:58 PM
I shall have to set about adding that to bridges, but that will involve a re-versioning of the pak files.

What about setting weight limit = 0 or not indicated to unlimited? so this would imply changes only for the future packs, not for the pre-compiled ones.

jamespetts

Quote from: fabio on December 24, 2008, 08:02:39 AM
What about setting weight limit = 0 or not indicated to unlimited? so this would imply changes only for the future packs, not for the pre-compiled ones.

The Paks will still need to be re-versioned, but the old paks will be able to be used: this is the standard way of doing things, which does involve, as you suggest, detecting if a pak is of an older version, and giving a default value (of 999 is the custom for weight limits).
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.

prissi

This must be enforced by the search function, otherwise trains would not go on non-limited track whioch is just parralel. Adjusting this is needed (and bridges) before inclusion.

jamespetts

Quote from: prissi on December 24, 2008, 10:34:04 AM
This must be enforced by the search function, otherwise trains would not go on non-limited track whioch is just parralel. Adjusting this is needed (and bridges) before inclusion.

Ahh, interesting. It could be done manually with waypoints, but I suppose that that would be tedious and difficult for newer players. Where in the code is the part of the search algorithm that deals with electrification? If I found that, I could copy the code (although I would have to alter it to allow it on overweight track as a fallback).
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.

prissi

This is done by running the vehicle all over the track (can_go_this_tile or so in simvehicle.cc)

jamespetts

#7
Prissi,

thank you very much for your help. What I have done is use the waggon_t::gib_costen and automobile_t::gib_costen functions to dissuade the routing system from routing over weight limited track if the vehicle is overweight by adding a cost of 40 if the vehicle is overweight. That way, it will not refuse to route if the way is too heavy (intended, so as not to make it too difficult for players, who might get confused as to why the vehicle is not routing), but it will try to find other routes if it can. I thought that this was the simplest and computationally cheapest way of doing it. I have tested it, and it works: it will take a longer route over a hill instead of route over flat weight restricted track.

I will upload the patch once I have added weight restrictions for bridges and tunnels.
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.

z9999

Sorry, a stupid question.

What is weight limits ?
A vehicle ? a convoi ? or on a tile ? - which means that if each vehicle's length is 8, sum of 2 vehicles.

jamespetts

Weight limits are enforced per vehicle, since, in a convoy/train, the weight would be spread out over a number of axles. In real railways, weight limits are per axle...
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.

z9999