Transport Tycoon Forums

The place to talk about Transport Tycoon
It is currently Fri May 24, 2019 1:58 pm

All times are UTC




Post new topic  Reply to topic  [ 8 posts ] 
Author Message
PostPosted: Fri Apr 26, 2019 2:12 pm 
Offline
Engineer
Engineer

Joined: Wed Feb 22, 2012 12:21 pm
Posts: 20
Location: Ukraine
There is no need to do some catastrophic changes to current OpenTTD code to make possible to build stations on bridges and in tunnels.
How?
Just consider existing objects as both: bridge and station (or tunnel and station).
How?
.. 1. Let consider both ends (entrances) to bridge (or tunnel) as tiles of station that define coverage area (look at the attached pictures). [Edited 20190503: Actually, these 2 tiles are station tiles only.]
If this two tiles are too far one from another, so system will disable to build such station because of parameter 'Maximum station spread', else player can build it.
.. 2. Platform length is length of whole that bridge (or tunnel), including both of its ends (entrances).
.. 3. There is no need to make some new graphics for such bridge-stations (tunnel-station) - just use existing graphics for bridge (or tunnel). Maybe add some small label attached to one or both ends (entrances) of bridge (tunnel). It can be standard (existing) label of station. This means station graphics is completely invisible, except of its label (if it isn't joined with other station tiles). Or it can be implemented as additional types of bridges (with the same characteristics as the same bridges but with some different graphics, f.e. with platform on the bridge).

I think this suggestion is easy to implement in existing OpenTTD code because no new objects needed - just use existing objects ( <20% of work ).

And when this will be implemented, it will fulfill almost all needs ( >80% of result ) of players, who wants (so strong) to have stations on bridges and in tunnels ( https://www.tt-forums.net/viewtopic.php?p=745470#p745470 , https://www.tt-forums.net/viewtopic.php?f=32&t=40606&hilit=station+bridge+tunnel , https://www.tt-forums.net/viewtopic.php?f=32&t=45680&hilit=station+bridge+tunnel ).

So, that's why it is so natural.

OpenTTD Developers, please, I ask you with very much hope: please, give us this feature! People are waiting for it so much time! It will be incredible progress for OpenTTD 3D-world!

Image

Image


Attachments:
bridge as a station.png [563.44 KiB]
Not downloaded yet
tunnel as a station.png [831.48 KiB]
Not downloaded yet


Last edited by TopTechDreamer on Fri May 03, 2019 3:17 pm, edited 1 time in total.
Top
   
PostPosted: Fri Apr 26, 2019 3:36 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Jan 22, 2005 7:31 pm
Posts: 6511
Location: Wakefield, West Yorkshire
This would be a really neat feature, and would replicate real life stations (ie: London Blackfriars is built upon a bridge in central London, over the River Thames).

I suspect this is going to be a lot of code though, rather than the on the surface "just flag it as a station".

_________________
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!


Top
   
PostPosted: Fri Apr 26, 2019 3:59 pm 
Offline
OpenTTD Developer
OpenTTD Developer
User avatar

Joined: Wed Nov 07, 2007 10:44 pm
Posts: 9266
Location: Sol d
The main issue is: anything between tunnel entrances and bridge heads does not exist on the map. It's just an illusion, a wormhole for trains. An illusion which would need to become reality. So indeed there's much more to it than "just allow other graphics" or "attach a label". It completely breaks with the existing concepts, both how it is currently done from the player side as well as internally in the code of how stations are built.

That doesn't mean it's not possible. But it is definitely not just adding a flag "this is a station" and it's all done and set.

_________________
Image
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML


Top
   
PostPosted: Fri Apr 26, 2019 6:26 pm 
Offline
Engineer
Engineer

Joined: Wed Feb 22, 2012 12:21 pm
Posts: 20
Location: Ukraine
planetmaker wrote:
The main issue is: anything between tunnel entrances and bridge heads does not exist on the map. ... as well as internally in the code of how stations are built.

That doesn't mean it's not possible. But it is definitely not just adding a flag "this is a station" and it's all done and set.

Yes, of course, it is.
But all the objects required are presented. So, it looks like a possibility to get wanted results by changing procedures only without changing objects.
Nothing exists between bridge entrances (and tunnel entrances), but transport runs through bridges (and tunnels) and even stops in these objects (f.e. when it breaks down).
I don't know how code defines platform length for every case of station layout but...
it seems the hardest task here is #2: to bind (to join, to link, to connect) bridge length (or tunnel length) with platform length.


Top
   
PostPosted: Fri Apr 26, 2019 9:06 pm 
Offline
Tycoon
Tycoon
User avatar

Joined: Sat Jan 22, 2005 7:31 pm
Posts: 6511
Location: Wakefield, West Yorkshire
I asasume if the entrances are essentailly wormholes. it knows where the start and end points of that wormhole are, to work out what needs to be 'station' between them in a straight line (given bridges & tunnels can't be built diagonally, like stations anyway)

_________________
Image
Worst Behaved IRC Member of 2008, 2009 & 2010 - Go Me!


Top
   
PostPosted: Sat Apr 27, 2019 6:33 am 
Offline
Route Supervisor
Route Supervisor
User avatar

Joined: Wed Jan 08, 2003 11:09 pm
Posts: 480
Location: Denmark
Part of the problem would also be that the station has (almost) no physical tile presence. Several parts of the code will currently scan the map looking for tiles of Station type, but if stations can suddenly be on tiles with "nothing" on them that changes a lot of core assumptions.


Top
   
PostPosted: Sat Apr 27, 2019 1:24 pm 
Offline
Engineer
Engineer

Joined: Wed Feb 22, 2012 12:21 pm
Posts: 20
Location: Ukraine
Bridges (and tunnels) have 2 'real' tiles - the entrances, that take place on the map,
and 'imaginary' part - between that 2 'real' tiles.

Suggestion is: we can do the same way with a station:
.. 1. 'Real' tiles of station are 'real' tiles of bridge - its entrances. Actually these 2 tiles are station tiles only. And they define station properties, f.e. its coverage area and so on.
.. 2. Exception is - this bridge-station (or tunnel-station) platform length parameter: it includes both 'real' and 'imaginary' parts of the bridge (tunnel).

Again: only 2 tiles are 'real' station tiles (the bridge|tunnel entrances), so the main problem is restriction of platform length parameter.


Top
   
PostPosted: Wed May 08, 2019 12:37 am 
Offline
Engineer
Engineer

Joined: Wed Feb 22, 2012 12:21 pm
Posts: 20
Location: Ukraine
Search in source code of OpenTTD shows that it is built so smart that it is possible to understand the code and to find how to implement "Existing objects bridges and tunnels as stations" feature (https://www.tt-forums.net/viewtopic.php?p=1221065#p1221065) :
Let's think about this topic. Trains interact with stations. It means that point 1 above is necessary, i.e.

1. we need to associate (to bind, to link) bridge entrances (bridge ramps or tunnel ends) with some our station.
To do this we need to know StationID, because this property defines the station in the list of all stations. So can we attach this StationID index to any tile with bridge (or tunnel) entrance? - YES WE CAN! - Look at some source-files:
Attachment:

/* Because all objects are linked with map: with each tile on the map is linked some object. */
map_type.h contains:
Code:
struct Tile {
   byte   type;        ///< The type (bits 4..7), bridges (2..3), rainforest/desert (0..1)
   byte   height;      ///< The height of the northern corner.
   uint16 m2;          ///< Primarily used for indices to towns, industries and stations
   byte   m1;          ///< Primarily used for ownership information
   byte   m3;          ///< General purpose
   byte   m4;          ///< General purpose
   byte   m5;          ///< General purpose
};

In the existing code Tile->type can not be a station and a bridge (or a tunnel) at the same time - look inside tile_type.h :
Code:
/**
 * The different types of tiles.
 *
 * Each tile belongs to one type, according whatever is build on it.
 *
 * @note A railway with a crossing street is marked as MP_ROAD.
 */
enum TileType {
   MP_CLEAR,               ///< A tile without any structures, i.e. grass, rocks, farm fields etc.
   MP_RAILWAY,             ///< A railway
   MP_ROAD,                ///< A tile with road (or tram tracks)
   MP_HOUSE,               ///< A house by a town
   MP_TREES,               ///< Tile got trees
   MP_STATION,             ///< A tile of a station
   MP_WATER,               ///< Water tile
   MP_VOID,                ///< Invisible tiles at the SW and SE border
   MP_INDUSTRY,            ///< Part of an industry
   MP_TUNNELBRIDGE,        ///< Tunnel entry/exit and bridge heads
   MP_OBJECT,              ///< Contains objects such as transmitters and owned land
};

This means
/* (for any TileIndex t) IsTileType(t, MP_STATION) && IsTileType(t, MP_TUNNELBRIDGE) == false */

But where is StationID here? - docs\landscape.html explains details:
Attachment:
docs landscape.html and landscape_grid.html .zip [10.28 KiB]
Downloaded 5 times

5. Station tiles:
...
m2: index into the array of stations /* Exactly this contains StationID if ( Tile->type == MP_STATION ). */
...
9. Tunnel / bridge:
...
/* No m2 at all! */
...
docs\landscape_grid.html explains further:
The variable (uint16) Tile->m2 is not used if ( Tile->type == MP_TUNNELBRIDGE ) !!! This means that we have this possibility to attach some StationID value TO ANY Tile that contains ends (entrances) of bridge or tunnel !!!

Then we can modify function from station_map.h , for example:
Code:
static inline StationID GetStationIndex(TileIndex t)
{
   assert(IsTileType(t, MP_STATION) || IsTileType(t, MP_TUNNELBRIDGE));       // <-- changed
   return (StationID)_m[t].m2;
}

And so on: we can consider ( Tile->type == MP_TUNNELBRIDGE ) as IsTileType(t, MP_STATION) everywhere, where GetStationIndex(TileIndex t) > 0. (I.e. StationID == 0 means "no station here" == bridge or tunnel without any station inside.)
Code:
   if ( IsTileType(t, MP_STATION) || ( IsTileType(t, MP_TUNNELBRIDGE) && (StationID)_m[t].m2 > 0 ) );


It (above) was an answer to point 1 from this topic. These possibilities allow us to solve "economical" aspect of train-station interaction (vehicle-station interaction), because "economical" interaction works through the StationID.


//********************************************************************************************//
2. This point 2 is "physical" aspect of train-station interaction.
There are several functions (in the existing code) that describe this "physical" aspect, for example:
in train_cmd.cpp are
Code:
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length)

and
Code:
int Train::GetCurrentMaxSpeed() const

These two use some other functions from other source code files, for example:
Code:
/* virtual */ uint Station::GetPlatformLength(TileIndex tile) const

and
Code:
/* virtual */ uint Station::GetPlatformLength(TileIndex tile, DiagDirection dir) const

from station.cpp.
Because in the function GetTrainStopLocation(...) are defined values of variables *station_length and *station_ahead by using GetPlatformLength(...):
Code:
int GetTrainStopLocation(StationID station_id, TileIndex tile, const Train *v, int *station_ahead, int *station_length)
{
   const Station *st = Station::Get(station_id);
   *station_ahead  = st->GetPlatformLength(tile, DirToDiagDir(v->direction)) * TILE_SIZE;
   *station_length = st->GetPlatformLength(tile) * TILE_SIZE;
...

Here we need DiagDirection dir, but we already have it: A) as DirToDiagDir(v->direction) and B) as GetTunnelBridgeDirection(tile) and so on, because there are also:
Code:
static inline bool IsBridgeAbove(TileIndex t)
{
   return GB(_m[t].type, 2, 2) != 0;
}

and
Code:
static inline Axis GetBridgeAxis(TileIndex t)
{
   assert(IsBridgeAbove(t));
   return (Axis)(GB(_m[t].type, 2, 2) - 1);
}

and
Code:
TileIndex GetNorthernBridgeEnd(TileIndex t);
TileIndex GetSouthernBridgeEnd(TileIndex t);
TileIndex GetOtherBridgeEnd(TileIndex t);

from bridge_map.h and bridge_map.cpp .
For tunnels we need to know z-coordinate and we can get it from train data: v->z_pos as well as v->direction. So we have not only x- and y-coordinates of tile (under the bridge or above the [several] tunnels), but also z-coordinate (and even heading direction) of train (inside the tunnel or bridge), that allow us to know, wich exactly tunnel has that train inside.
From vehicle_base.h :
Code:
/** %Vehicle data structure. */
struct Vehicle : VehiclePool::PoolItem<&_vehicle_pool>, BaseVehicle, BaseConsist {
...
public:
...
   int32 x_pos;                        ///< x coordinate.
   int32 y_pos;                        ///< y coordinate.
   int32 z_pos;                        ///< z coordinate.
   DirectionByte direction;            ///< facing
...

This means we can define values of variables *station_length and *station_ahead and also values of all other "physical" parameters for any train inside any tunnel-station or bridge-station.

It (above) was an answer to point 2 from this topic. These possibilities allow us to solve "physical" aspect of train-station interaction (including the speed of loading/unloading).

//********************************************************************************************//
3. User interface needs to get one or two buttons like "Convert bridge (or tunnel) to a bridge-station (or a tunnel-station)".
And graphics needs to have sprites of bridge ramps and of tunnel entrances with symbol "S" written on them - to differ them (with stations inside) from traditional bridge and tunnel entrances (without stations inside).


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 8 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000-2019 phpBB Limited

Copyright © Owen Rudge/The Transport Tycoon Forums 2001-2019.
Hosted by Zernebok Hosting.