Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite tunnel / bridge enter tile proc #4177

Closed
DorpsGek opened this issue Oct 22, 2010 · 7 comments
Closed

Rewrite tunnel / bridge enter tile proc #4177

DorpsGek opened this issue Oct 22, 2010 · 7 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay

Comments

@DorpsGek
Copy link
Member

Hirundo opened the ticket and wrote:

Patches are against r21007, though they should apply against any recent revision.

The function VehicleEnter_TunnelBridge is used to determine when a vehicle enters or leaves a wormhole. This function currently works in a very opaque manner. The position of the vehicle on the tile (fractional coordinates) is compared to certain magic values, and if these match a certain action (enter / leave wormhole, play sound) is taken. This results in a lot of duplicated information, and it's not clear exactly what happens when. Cleaning up this code should help any effort towards e.g. custom bridge heads.

Attached is a series of patches that attempts to clean up the code. The first two patches basically just clean up existing code without any significant changes to the way it works. In the third patch, the concept of 'frame' is introduced. This is basically equivalent to RoadVehicle::frame, which is the number of steps the vehicle has moved since entering the tile. Many of the coordinates, used to enter / exit a tunnel or bridge, can be defined much more easily (independent of movement direction) when expressed in terms of the frame number. This frame number is then applied to respectively train tunnels, road tunnels and bridges in the last three patches.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/4177
@DorpsGek
Copy link
Member Author

Krille wrote:

The first two patches have been committed as r21012 and r21013.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4177#comment8975

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 9, 2010

Hirundo wrote:

Attached is a new series of patches that apply to r21124.
There have been no changes to the code except those to accommodate for r21079.

Also attached is a text file attempting to explain the relationship between the old and new code.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4177#comment9051

@DorpsGek
Copy link
Member Author

Rubidium wrote:

Please check the patches for trailing whitespace next time; both 1 and 2 contained some trailing whitespace which the commit hook (luckily) caught.

The road tunnel stuff is interesting, especially as the road vehicles seem to be hidden a bit too early on the NW to SE tunnel entrance.


This comment was imported from FlySpray: https://bugs.openttd.org/task/4177#comment9065

@DorpsGek
Copy link
Member Author

Rubidium wrote:

I've been messing a bit with the numbers and as far as I can see the attached diff seems to work fine. But I've only tested a very small set of vehicles (one RV and two trains). Don't know whether there are problems with it; it's just some messing with numbers while being slightly sleepy.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4177#comment9066

@DorpsGek
Copy link
Member Author

Rubidium wrote:

The previous diff does work fine for new games with the old rail vehicles. However, it fails for some maglev and monorail tunnel entrances (those where you can't see into the tunnel). It furthermore fails just after loading some savegames, e.g. the original intro game.

The attached diff should be better with that respect.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4177#comment9072

@DorpsGek
Copy link
Member Author

Rubidium wrote:

The previous diff did break loading of some savegames. The attached diff should be even better, though it's getting increasingly complex savegame material to mess with.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4177#comment9078

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Implemented

Also a further unification of the 'visibility' tables


This comment was imported from FlySpray: https://bugs.openttd.org/task/4177

@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) Vehicles patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) patch from FlySpray This issue is in fact a Patch, but imported from FlySrpay
Projects
None yet
Development

No branches or pull requests

1 participant