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

[PATCH] Avoid calling the train collision all the time at the expense of memory #541

Closed
DorpsGek opened this issue Jan 12, 2007 · 8 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

madman2003 opened the ticket and wrote:

The beheaviour of this patch is fairly simple:

A TrackBits is stored of currently occupied segments is stored in the map, the first engine activates it, the last one removes it.

Once an already existing trackbit is activated again, a overload bit is activated, which will make trains actively check for collisions.

Once a vehicle leaves the tile or is destroyed, it is reset.

This modification requires a byte sized m7.

Under normal curcomstances the CheckTrainCollision() function is not called, testing suggest quite an improvement (60% vs 50% cpu usage on a map with 900-1000 trains).

What do you think?

Known/possible problems:

If a vehicle is at the beginning of a tile, another vehicle will have to actually enter the tile before it collides.

Attachments

Reported version: trunk
Operating system: All


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

Rubidium wrote:

You only need 6 bits for the trackbits, so you can move the bit you would add to m6 to m7. The two other bits are only flags for special cases.

Furthermore: this data needs to be stored in the savegame for the simple reason that it needs to be in-sync in multiplayer games, or you need to rebuild that data when loading a savegame, but then it is more complex to set the overflow bit as two vehicles on a tile might be from the same train, but they may not be. Also, have you thought about what happens when loading a savegame?

Then you might have the possibilities that trains can go through eachother for a short time.

(I have not yet tested the patch or so, only read it)


This comment was imported from FlySpray: https://bugs.openttd.org/task/541#comment822

@DorpsGek
Copy link
Member Author

madman2003 wrote:

You were right about the savegame stuff, i fixed that (for new games), not sure about old ones.


This comment was imported from FlySpray: https://bugs.openttd.org/task/541#comment823

@DorpsGek
Copy link
Member Author

madman2003 wrote:

Tunnel and bridge handling is not working right, trying to fix that.


This comment was imported from FlySpray: https://bugs.openttd.org/task/541#comment824

@DorpsGek
Copy link
Member Author

madman2003 wrote:

This should be working better, moving the warning bit in to m7 remains.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/541#comment825

@DorpsGek
Copy link
Member Author

madman2003 wrote:

I meant, moving the warning bit in m6(bit2) to m7 remains.


This comment was imported from FlySpray: https://bugs.openttd.org/task/541#comment826

@DorpsGek
Copy link
Member Author

madman2003 wrote:

After finding out that m7 has too much overhead (game gets slower, on the largest map there is a 10 MiB memory increase, due to padding bytes), i made a simpler version, which takes away the bulk of the collision checking.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/541#comment827

@DorpsGek
Copy link
Member Author

madman2003 wrote:

This task can be closed, as it's outdated.


This comment was imported from FlySpray: https://bugs.openttd.org/task/541#comment1305

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Out of date

Something else with the same (or even better) characteristics has been committed to trunk (r10111).


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

@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 6, 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