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

Newgrf GetVehicle cargoclass #6182

Closed
DorpsGek opened this issue Dec 4, 2014 · 1 comment
Closed

Newgrf GetVehicle cargoclass #6182

DorpsGek opened this issue Dec 4, 2014 · 1 comment
Labels
component: NewGRF This issue is related to NewGRFs flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Dec 4, 2014

The_Dude opened the ticket and wrote:

Hi,
I wanted to decide whether wagon can be attached depending on its cargo class (callback 1D), but if I use it on wagon, that is not defined in newgrf (I have set only with trains), game crashes.

The reason is in newgrf_engine.cpp, static uint32 VehicleGetVariable, line about 611, variable 0x47

return (cs->classes << 16) | (cs->weight << 8) | e->GetGRF()->cargo_map[cargo_type];

It wants to access wagon's GRF, which is not defined since it is original wagon, so it returns NULL and than it wants to get some NULL property.

It pretty kills the way to get cargo class of non GRF wagon/vehicle, because there is no other variable for it.

Something like

uint8 cargotype = e->GetGRF() != NULL ? e->GetGRF()->cargo_map[cargo_type] : 0xFF;
return (cs->classes << 16) | (cs->weight << 8) | cargotype;

would be nice. I think it should not crash at least.

I can provide some savegame, crashlog and newgrf upon request.

Reported version: trunk
Operating system: All


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

DorpsGek commented Dec 7, 2014

frosch closed the ticket.

Reason for closing: Fixed

in r27075


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

@DorpsGek DorpsGek closed this as completed Dec 7, 2014
@DorpsGek DorpsGek added flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) component: NewGRF This issue is related to NewGRFs bug labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: NewGRF This issue is related to NewGRFs flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant