The International Simutrans Forum

 

Author Topic: [Patch] Enforcing weight limits (Superseded)  (Read 9823 times)

0 Members and 1 Guest are viewing this topic.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
[Patch] Enforcing weight limits (Superseded)
« on: December 23, 2008, 06:58:58 PM »
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.
« Last Edit: January 10, 2009, 06:00:16 PM by jamespetts »

Offline jbode

  • Devotees (Inactive)
  • *
  • Posts: 84
Re: [Patch] Enforcing weight limits
« Reply #1 on: December 23, 2008, 09:41:05 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

Offline Fabio

  • Devotee
  • Administrator
  • *
  • Posts: 2898
  • The Pak128 Guy
    • Visit me on Facebook
  • Languages: EN, IT, RO, FR
Re: [Patch] Enforcing weight limits
« Reply #2 on: December 24, 2008, 08:02:39 AM »
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.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] Enforcing weight limits
« Reply #3 on: December 24, 2008, 09:07:16 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).

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10663
  • Languages: De,EN,JP
Re: [Patch] Enforcing weight limits
« Reply #4 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.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] Enforcing weight limits
« Reply #5 on: December 24, 2008, 12:34:16 PM »
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).

Offline prissi

  • Developer
  • Administrator
  • *
  • Posts: 10663
  • Languages: De,EN,JP
Re: [Patch] Enforcing weight limits
« Reply #6 on: December 24, 2008, 09:26:15 PM »
This is done by running the vehicle all over the track (can_go_this_tile or so in simvehicle.cc)

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] Enforcing weight limits
« Reply #7 on: December 25, 2008, 05:19:16 PM »
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.
« Last Edit: December 25, 2008, 05:26:30 PM by jamespetts »

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [Patch] Enforcing weight limits
« Reply #8 on: January 07, 2009, 09:41:47 AM »
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.

Offline jamespetts

  • Simutrans-Extended project coordinator
  • Administrator
  • *
  • Posts: 20805
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: [Patch] Enforcing weight limits
« Reply #9 on: January 07, 2009, 10:42:14 AM »
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...

Offline z9999

  • Devotees (Inactive)
  • *
  • Posts: 848
Re: [Patch] Enforcing weight limits
« Reply #10 on: January 07, 2009, 12:03:11 PM »
Thanks, jamespetts. :)