The International Simutrans Forum

 

Author Topic: Fording a river?  (Read 27737 times)

0 Members and 1 Guest are viewing this topic.

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Fording a river?
« on: July 28, 2019, 10:00:34 PM »
Would there be any way to create a 'zero-height bridge' for bridleways so cattle and pack horses could ford a river? 

Offline ACarlotti

  • *
  • Posts: 483
Re: Fording a river?
« Reply #1 on: July 28, 2019, 10:58:24 PM »
It would presumably be like a road/rail level crossing. I don't know how easy it would be to create a road/river crossing - it just depends on how much of the crossing logic has been hard-coded in the game engine.

Offline makie de

  • *
  • Posts: 96
    • Homepage PAK128-German
  • Languages: DE
Re: Fording a river?
« Reply #2 on: July 30, 2019, 05:49:04 PM »
that is possible

Unfortunately, it is not possible to limit which way or which road may cross which type of river. Thus, a motorway may also take a ford through a deep river.

This lack of precise specification is also a problem at crossing between roads and railways. A highway knows no crossing gates.

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2715
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: Fording a river?
« Reply #3 on: July 30, 2019, 06:48:32 PM »
But you can limit the speed of both ways on crossing. Typically it would be road=50, rail=160 for rail crossing, and road=5, water=0 for ford...

Offline makie de

  • *
  • Posts: 96
    • Homepage PAK128-German
  • Languages: DE
Re: Fording a river?
« Reply #4 on: July 30, 2019, 07:14:19 PM »
yes, but as you can see in the screenshot, it is not possible to restrict the crossing to dirt road and small river. The graphics is created for this combination, all other looks funny and illogical     

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Fording a river?
« Reply #5 on: July 30, 2019, 08:30:06 PM »
It would be good to have fords, but there is the problem noted by Mackie that one cannot restrict the road types; however, in one sense, it would not make sense to restrict the road types, since a player could simply manually switch over to the lesser road type anyway just for the ford - and one may then wonder why this is not done automatically. There may be an issue with the way constraints on the forded way, however; I have not looked into this, so I cannot remember whether it is possible to impose such constraints on a ford irrespective of the waytype used to draw the ford accross the river.

Fords in Pak128.Britain-Ex are something that I have wanted to do, but the graphics might be a little tricky.

Offline DrSuperGood

  • Dev Team
  • Devotee
  • *
  • Posts: 2727
  • Languages: EN
Re: Fording a river?
« Reply #6 on: July 30, 2019, 08:30:16 PM »
Each road type would need its own graphics. A motor way could ford a river but it would be in the form of a flat/low bridge over it.

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Fording a river?
« Reply #7 on: July 30, 2019, 09:09:15 PM »
Each road type would need its own graphics. A motor way could ford a river but it would be in the form of a flat/low bridge over it.

That would not work economically, as fords do not cost any more than basic road tiles (and there is no code to allow them to cost more). Thus, for economic accuracy, the automatic river/road crossing can only be modelled as a ford, and not as a bridge.

Offline makie de

  • *
  • Posts: 96
    • Homepage PAK128-German
  • Languages: DE
Re: Fording a river?
« Reply #8 on: July 31, 2019, 08:58:57 AM »
My intention is not to forbid the player insert a piece of dirt road into a Highway and cross a great river with a ford.
The problem is: simutrans do this automatically and you have to destroy the ford and rebuild a bridge. And in addition, the result looks graphically bad.
If there is no ford, simutrans stop building a highway at the river. This is what simutrans should do, if there is no fitting crossing.
The same is for high speed railways, there should not allowed any crossing, same for great river and Highways.
« Last Edit: July 31, 2019, 09:24:52 AM by makie »

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Fording a river?
« Reply #9 on: August 01, 2019, 02:26:29 PM »
The datfiles for crossings currently use syntax as
Code: [Select]
waytype[0]=road
waytype[1]=track
speed[0]=60
speed[1]=100
although I only find those documented in the German dat-file reference.  Apparently, waytype[0] is the superior way when vehicles cross, closing the junior waytype[1] until waytype[0] is clear of approaching vehicles.  (in german: "der zu sichernde Verkehrsweg" is "the secured way".)

For our ford, then, we would like:

Code: [Select]
waytype[0]=road
waytype[1]=water
speed[0]=8
speed[1]=0
But according to crossing_writer.cc, a speed[] of zero is disallowed (starting at code line 99).
It might be possible to change crossing_writer.cc so that speed[1]=0 is allowed when waytype[1] is water; and then change the in-game builder to regard a crossing speed of zero (formerly disallowed) to mean, Regard both speed[n] as upper limits of the waytype[n]; if both the existing way and the new way have a speed less or equal, permit building the crossing.   With the dat definition shown above, this would mean you could only lay bridleways across non-navigable streams; attempting to build a highway across a major river would do nothing as currently.
Thoughts?

Offline Matthew gb

  • *
  • Posts: 227
    • Japan Railway Journal
  • Languages: EN, some ZH, DE & SQ
Re: Fording a river?
« Reply #10 on: August 01, 2019, 05:38:36 PM »
It might be possible to change crossing_writer.cc so that speed[1]=0 is allowed when waytype[1] is water; and then change the in-game builder to regard a crossing speed of zero (formerly disallowed) to mean, Regard both speed[n] as upper limits of the waytype[n]; if both the existing way and the new way have a speed less or equal, permit building the crossing.   With the dat definition shown above, this would mean you could only lay bridleways across non-navigable streams; attempting to build a highway across a major river would do nothing as currently.
Thoughts?

I am not qualified to comment on the technical merits of this proposal, but as a player it seems that this would be a nice bonus, so long as it was explained in pakset documentation.

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2715
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: Fording a river?
« Reply #11 on: August 01, 2019, 07:38:12 PM »
I like that proposal too. That would nicely prevent players from making crossing on high-speed tracks and motorways, as well as fording navigable rivers.

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Fording a river?
« Reply #12 on: August 02, 2019, 03:02:00 PM »
This little modification (one bit to makeobj, the other to main program) permits fords to be constructed only when building bridleways over non-navigable streams and brooks.  Any other construction routes around, as before. (Naturally, if there is a dirt-road ford, that would work as well, based on the crossing's maxspeed; this is left to the pakset designer.)

Edit: In testing, this does not prohibit building a canal through an existing ford; the ford, however, will block the canal from being used, and the player will have to remove or replace the ford with a bridge to permit watercraft passage.

Code: [Select]
diff --git a/bauer/wegbauer.cc b/bauer/wegbauer.cc
index 51b234d10..bc9c8fcb3 100644
--- a/bauer/wegbauer.cc
+++ b/bauer/wegbauer.cc
@@ -460,7 +460,17 @@ bool way_builder_t::check_crossing(const koord zv, const grund_t *bd, waytype_t
                return false;
        }
        // crossing available and ribis ok
-       if(crossing_logic_t::get_crossing(wtyp, w->get_waytype(), 0, 0, welt->get_timeline_year_month())!=NULL) {
+       const crossing_desc_t *crd = crossing_logic_t::get_crossing(wtyp, w->get_waytype(), 0, 0, welt->get_timeline_year_month());
+       if(crd!=NULL) {
+               // special case if crd->maxspeed(1) is zero: require maxspeed of
+               // new way to not exceed crd->maxspeed(0).
+               // This permits very low-speed fords of non-navigable streams.
+               if ((crd->get_maxspeed(1)) == 0 &&
+                       ( (crd->get_maxspeed(0) < desc->get_topspeed()) ||
+                         (w->get_desc()->get_topspeed() > 0) )) {
+                       return false;
+               }
+
                ribi_t::ribi w_ribi = w->get_ribi_unmasked();
                // it is our way we want to cross: can we built a crossing here?
                // both ways must be straight and no ends
diff --git a/descriptor/writer/crossing_writer.cc b/descriptor/writer/crossing_writer.cc
index 03e9951d0..11be4c2fd 100644
--- a/descriptor/writer/crossing_writer.cc
+++ b/descriptor/writer/crossing_writer.cc
@@ -103,7 +103,8 @@ void crossing_writer_t::write_obj(FILE* fp, obj_node_t& parent, tabfileobj_t& ob
        }
        node.write_uint16(fp, uv16, 4);
        uv16 = obj.get_int("speed[1]", 0);
-       if(uv16==0) {
+        // Zero speed permissible for water as secondary type
+       if(uv16==0 && wegtyp2 != water_wt) {
                dbg->fatal( "Crossing", "A maxspeed MUST be given for both ways!");
                exit(1);
        }
« Last Edit: August 02, 2019, 04:48:19 PM by wlindley »

Offline wlindley us

  • Devotee
  • *
  • Posts: 978
    • Hacking for fun and profit since 1977
  • Languages: EN, DE
Re: Fording a river?
« Reply #13 on: August 02, 2019, 04:07:54 PM »
A matching bridleway ford datfile and images for Pak128.Britain-Ex  are here
« Last Edit: August 02, 2019, 04:50:06 PM by wlindley »

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Fording a river?
« Reply #14 on: August 03, 2019, 10:25:20 AM »
W. Lindley - thank you for your work on this. I am concerned that this is a little hackish, however: it depends on the actual underlying speed limit of the river being not more than the speed limit of the crossing road, which seems potentially arbitrary. However, I also note that any other solution would require much more substantial coding.

Do people have any views on the desirability of this implementation of fords as against the desirability of not having possibly anomalous behaviour in any cases where the assumptions about the speed limits of bridleways and/or streams do not hold?

Offline Vladki cz

  • Devotee
  • *
  • Posts: 2715
    • My addons, mostly roadsigns
  • Languages: EN, CS
Re: Fording a river?
« Reply #15 on: August 03, 2019, 10:39:06 AM »
I would prefer a more generic solution. When crossing is built both ways should be checked for  max speed, and crossing forbidden if either way is faster than the crossing.

Offline makie de

  • *
  • Posts: 96
    • Homepage PAK128-German
  • Languages: DE
Re: Fording a river?
« Reply #16 on: August 03, 2019, 12:31:54 PM »
if I had a wish free, I would prefer a test on the name of the way.
Quote
waytype[0]=road
waytype[1]=track
wayname=[0][0]=mud_road
wayname=[0][1]=dirt_road
wayname=[0][2]=lane
wayname=[1][0]=local_train_track
wayname=[1][1]=ancient_track
wayname=[1][2]=slow_train_track
but i need this in standard not in extended  ;)
or in both
That would solve a lot of problems and graphics errors.
Then you could assign the graphic exactly and logically, to the crossings

Offline jamespetts gb

  • Simutrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 18745
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Fording a river?
« Reply #17 on: August 04, 2019, 10:16:26 AM »
This is certainly the sort of thing that does not depend on any of the Extended-specific features and therefore could perfectly well go into Standard.