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

Rails on slopes are displayed weird #115

Closed
alexey-lukyanenko opened this issue Sep 5, 2021 · 14 comments
Closed

Rails on slopes are displayed weird #115

alexey-lukyanenko opened this issue Sep 5, 2021 · 14 comments
Labels
bug Something isn't working

Comments

@alexey-lukyanenko
Copy link
Contributor

Behavior of train on such slope tile is unpredictable.
image
image
On the last image the rail is straight and train goes ahead regardless of displayed rail shape.

@dzavalishin
Copy link
Owner

This basically means that error is in the display part, not rail state as such...

@dzavalishin dzavalishin added the bug Something isn't working label Sep 11, 2021
@dzavalishin
Copy link
Owner

Repeated it

@dzavalishin
Copy link
Owner

Can it be related to #52? Something is wrong with tile state display in both cases.

@dzavalishin
Copy link
Owner

image

type = 1 - ok, rail
height = 1 - this one is the only candidate to be wrong? Also there's extra field which is not printed here
m1 = 0 - ok, owner
m2 = c - ok, on desert
m3 = 0 - ok, conventional rails
m4 = 0 - pbs reserve, irrelevant
m5 = 2 - ok, track in Y direction

@dzavalishin
Copy link
Owner

dbg: type = 1
dbg: height = 1
dbg: m1 = 0
dbg: m2 = c
dbg: m3 = 0
dbg: m4 = 0
dbg: m5 = 2
dbg: extra = 1
dbg: slope/h = 4/8

Slope type 4 according to tileh.png is just is what we see. It means that there's not a display error, but rail building terraform error

@alexey-lukyanenko
Copy link
Contributor Author

The train can go there without obstacles, so maybe this is the incorrect bits placed...

@dzavalishin
Copy link
Owner

As far as I see train does not check tile form at all, just connection of rails. :) And internally rails are connected ok for such places.

@dzavalishin
Copy link
Owner

in CmdBuildSingleRail():
CheckRailSlope seems to be ok, returns terraform price, so terraforming is assumed
Cmd.CMD_LANDSCAPE_CLEAR does not terraform - just removes trees

I don't see actual terraforming code during rail building. Cost is assumed, but no land changing.
Will debug DrawTile_Track...

@dzavalishin
Copy link
Owner

Current suspect is DrawTrackBits(), for it was rewritten (not identical to C version).

@dzavalishin
Copy link
Owner

image

  • No real terraforming is done. Tile is 'dinamically terraformed' during painting.
  • Fence shows how tile should be painted, but it does not.
  • Error must be in DrawTrackBits(), but rewritten part seems to be correct, at least for this case (tileh == 14)
  • Current suspect is GetRailFoundation()

@dzavalishin
Copy link
Owner

Fixed part of error in GetRailFoundation()

if(bits == TRACK_BIT_DIAG1) return 15+i;
if(bits == TRACK_BIT_DIAG2) return 15+i+1;

This case is painted better:
image

dzavalishin added a commit that referenced this issue Sep 12, 2021
Better handling of tile with tileh == 8 with rails, see:

#115 (comment)
@dzavalishin
Copy link
Owner

OMG, I DID IT! :)
image

@alexey-lukyanenko
Copy link
Contributor Author

Wow!

@dzavalishin
Copy link
Owner

One char fix. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants