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

All semaphores get converted to electric signals when loading savegames from v15 to v20 #5731

Closed
DorpsGek opened this issue Sep 3, 2013 · 2 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Sep 3, 2013

adf88 opened the ticket and wrote:

In r2499 (SL v15) map array has been extended in a way that signal type got 1 extra bit for the early PBS'es. To be able to do this signal variant bit had to be moved. In r3472 (SL 21) the early PBS'es were removed and map array changes were reverted.

There is a piece of code in the afterload.cpp (around line 1217) which tries to fix bits when loading a savegame from that period of time:

/* convert PBS signals to combo-signals */
(HasBit(_m[t].m2, 2)) SetSignalType(t, TRACK_X, SIGTYPE_COMBO);

/* the signal variant back */
SetSignalVariant(t, TRACK_X, HasBit(_m[t].m2, 3) ? SIG_SEMAPHORE : SIG_ELECTRIC);
ClrBit(_m[t].m2, 3);

You can see SetSignalType and SetSignalVariant. BUT these two functions changed since then, twice! We have new versions operating on different bits! Currently signal type occupies 3 bits, not 2. Also signal variant bits changed again to bit 3. One of undesired effects of this faulty conversion is wrong signal variant - all signals get converted to electric variant.

I'm attaching three files:
- patch to fix the issue
- a test savegame file saved with r3420 (somewhere between saveload v15 and v20)
- screenshots showing what happens when loading attached .sav file (LEFT: trunk r3420, CENTER: current trunk, RIGHT: patched trunk)

Attachments

Reported version: trunk
Operating system: All


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

DorpsGek commented Sep 3, 2013

adf88 wrote:

See also #5732

HISTORY OF SIGNAL TYPE/VARIANT BITS

r13932 sl 100
add PBS signal type
signal variant:
m2 [6] -> [7]
m2 [2] -> [3]
signal type:
m2 [0..1] -> [0..2]
m2 [4..5] -> [4..6]

r10006 sl 64
allow different signals on single tile
signal type:
m2 [0..1] -> [0..1, 4..5]
signal variant:
m2 [2] -> [2, 6]

r8935 sl 48
some optimizations
signal type:
m4 [0..1] -> m2 [0..1]
signal variant:
m4 [2] -> m2 [2]

r3472 sl 21
remove PBS signal type
signal type:
m4 [0..2] -> [0..1]
signal variant:
m4 [3] -> [2]

sl 15
add PBS signal type
signal type:
m4 [0..1] -> [0..2]
signal variant:
m4 [2] -> [3]


This comment was imported from FlySpray: https://bugs.openttd.org/task/5731#comment12582

@DorpsGek
Copy link
Member Author

DorpsGek commented Nov 8, 2013

Rubidium closed the ticket.

Reason for closing: Fixed

In r25954. Thanks for the patches


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

@DorpsGek DorpsGek closed this as completed Nov 8, 2013
@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) 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/)
Projects
None yet
Development

No branches or pull requests

1 participant