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

Fix #209: Sign-extend value before cargo_profit callback result calculation #212

Closed
wants to merge 1 commit into from

Conversation

@glx22
Copy link
Contributor

@glx22 glx22 commented Apr 24, 2021

NML does apply some calculation before returning the cargo_profit callback result.
But it does it on a 15bit signed value stored in 32bit without sign-extending, so of course the result for negative is wrong.

It's fixed in this PR by applying sign-extension to the 15bit value before doing other calculation.

Of course another option would be to just remove all this strange magical stuff ;)

@PeterN
Copy link
Member

@PeterN PeterN commented Apr 24, 2021

+1 here for removing this strange mapping. I can't see that it serves any purpose. Compatibility may be an issue, not sure how to find out how well used this callback is.

Loading

@PeterN
Copy link
Member

@PeterN PeterN commented Jun 1, 2021

I put feelers out on the NewGRF forum about this callback and... https://www.tt-forums.net/viewtopic.php?f=68&t=88938

Nothing.

Loading

@andythenorth
Copy link
Contributor

@andythenorth andythenorth commented Jul 10, 2021

Per #193 (comment) Tyler intends to use cargo_profit cb.

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants