-
-
Notifications
You must be signed in to change notification settings - Fork 958
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
Feature: When filtering purchase list by cargo type, make buy button perform a refit if required. #7301
Conversation
Well played, "works" with clang, but nothing else. Oops! |
6187c03
to
61fef5d
Compare
Is it possible to run a test-execute when selecting a vehicle, so stuff like _returned_refit_capacity can be shown? |
Good idea, that should allow the true cost to be shown as well. |
This might also fix one of the things Samu has been complaining about repeatedly, that NoAI can't query the cost or capacity of a refit without purchasing? Although that would require a new API to purchase a vehicle already refitted too. |
Hmm, one issue is that the query requires a depot to operate from, so will only work on a purchase list window from a depot. |
Using AITestMode() it's possible to query the cost I think, so it should be possible to add a new parameter to ScriptVehicle::BuildVehicle(). But for the capacity a new function similar to ScriptVehicle::GetRefitCapacity() will be needed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you check if autoreplace and clone work? BuildReplacementVehicle
and CmdCloneVehicle
both call CmdBuildVehicle
and make separate refits later. As they pass 0 for the cargo type, the vehicles would be refitted to passengers first unless I misread the code somewhere.
AIs should be able to use this feature with PeterN#1 |
4f416fa
to
f89b003
Compare
@michicc Good catch. I've looked to see whether we can just use the buy & refit functionality for these but they try to preserve cargo subtype, so it's not really feasible. I have updated the calls so they don't do a refit. |
New functionality, when filtering from a depot view, the extra cost and the refitted cargo capacity are now shown. |
f89b003
to
2f0f344
Compare
2f0f344
to
89bc9aa
Compare
Rebased due to conflict. |
This solves a user-experience issue where purchasing a vehicle ends up with the 'wrong' cargo type.
This turned out to be quite nasty to implement as testing a refit cost requires a vehicle to be present. This is achieved similarly to how autoreplace works, by buying the vehicle and then selling it again, if in test mode.