Patch: Refit abuse for empty vehicles
Posted: 12 Sep 2011 06:22
As it stands, only vehicles with a valid cargo and a non-zero capacity can be refitted, even if cargo subtypes are defined. As cargo subtypes are often used for refit tricks like regearing, liveries, changing wagon counts, etc., this means that those things simply can not be done if the vehicle does not carry cargo.
However cargo type and subtype are stored completely independently - the only thing actually preventing a refit of a cargoless vehicle is UI code. So I switched up the UI code. Added some checks, removed some, changed the order of others. Now vehicles with capacities of 0 will allow refitting if and only if they have the cargo suffix callback defined.
At the moment, in the refit window they'll claim to be refitting to "0 passengers" and all the suffixes are preceded by passengers. This is because Passengers and No Cargo are both represented by 0. Of course, if you specify a cargo type with a capacity of 0, you'll get that instead of passengers.
The obvious next-step is to special case the GUI so it doesn't refer to a cargo in this case.
The patch, an example grf and Win32 build are attached.
In addition to the ugly 'Passengers' thing, I'm mostly concerned with not triggering any unintentional side effects with other vehicle sets (Half-implemented features left in, etc.) - ideally every GRF that hasn't been intentionally crafted to take advantage of this should act exactly as they do in trunk. I think multiplayer will be fine, but I didn't check. AIs might be confused by the 0 capacity refits.
Are there any other points of concern?
However cargo type and subtype are stored completely independently - the only thing actually preventing a refit of a cargoless vehicle is UI code. So I switched up the UI code. Added some checks, removed some, changed the order of others. Now vehicles with capacities of 0 will allow refitting if and only if they have the cargo suffix callback defined.
At the moment, in the refit window they'll claim to be refitting to "0 passengers" and all the suffixes are preceded by passengers. This is because Passengers and No Cargo are both represented by 0. Of course, if you specify a cargo type with a capacity of 0, you'll get that instead of passengers.
The obvious next-step is to special case the GUI so it doesn't refer to a cargo in this case.
The patch, an example grf and Win32 build are attached.
In addition to the ugly 'Passengers' thing, I'm mostly concerned with not triggering any unintentional side effects with other vehicle sets (Half-implemented features left in, etc.) - ideally every GRF that hasn't been intentionally crafted to take advantage of this should act exactly as they do in trunk. I think multiplayer will be fine, but I didn't check. AIs might be confused by the 0 capacity refits.
Are there any other points of concern?