It got one known issue though. The top bar got a plural issue so expect to see stuff like "1 trains" until we figure out why it behaves this way
Added the button to the depot windows. Made the autoreplace button bigger while I was moving some widgets anyway
Made road vehicle depot windows start with one more row to make room for the buttons
This will prevent some reallocations when sorting vehicle list windows
It also prevents moving the whole array into a new one each time the list is generated/updated (it used to make the list in one array and then move it into another one each time)
Also ensured that neither GenerateVehicleSortList() or BuildDepotVehicleList() will never allocate lists longer than the total number of vehicles in the game
It's right below the sell button (sell whole chain button for trains)
It's still missing a sprite. That one will be added as soon as anybody draws something we can use
To make room for this button, all depots except train depots now opens with an additional row and can't be resized shorter than that
This will ensure that you can always get the same list when checking for vehicles in a depot (no need to duplicate code for each place, that needs such a list)
Since the vehicles are only looped once for each redraw, drawing speed is around twice as fast (measured to be 114%-121% faster depending on the number of vehicles in the game)
We should only reach this error() if there is a bug, that would otherwise make the vehicles carry a different type of cargo without telling the user
This also kills the warning added in r6464 (oops)
added an error popup in the game if autoreplace fails to refit
Since it's only triggered by conditions bugs can trigger, it works kind of like a non-fatal assert in builds without asserts
To do this, the player struct contains an array, that contains the count of each engine type that the player owns
Those arrays are updated each time a vehicle is build or deleted and is calculated on load (it's not saved)
It's possible to access the arrays outside of the autoreplace GUI, so feel free to read from them in other patches as well
-Fix: [autoreplace] fixed a very rare failure when building an engine could cost more than the player could pay before selling the old one
this happened when the replacing the front cost so much that the the rear end didn't have enough money to build as expected
now the estimate keeps track of the price for the wagons/engines in front of the unit it's currently looking at
-Codechange: [autoreplace] added function to learn if and what cargo type to refit to. Needed to allow the estimation to tell refit costs
DestinationID being a union of these types is just hassle without benefit and cannot be handled correctly everywhere because of local lack of information
turned out to be a failure to run the wagon remoral code if the player didn't have enough money to do the replace after the replace took place
the cost animation failed to show in this condition as well
Now the test is not run anymore after the replace took place
-Codechange: unified the code for mass goto depot to avoid duplicated code
-Fix: Vehicles already on the way to depots will not be cancelled by mass goto depot (made it really hard to send all vehicles at once)
this list is also used by mass goto depot to ensure that they use the same vehicles
right now only the list of all vehicles use this for goto depot, but eventually all the types will use this
it's located in the vehicle list screen and does the same as in the shared orders window (send all vehicles in list to a depot)
it will still not inform the player if a vehicle failed to find a depot, so don't take for granted that all of them go
-Codechange: DestroyVehicle is called by DeleteVehicle to remove all things where a vehicle depends on.
Last 2 changes to prepare for new pool system. Not pretty now, will be soon.
-Codechange: introduced DestinationID, which is in fact an union of several types
Used in Order struct, so no longer StationID is abused for all targets.
Hangars are a big exception, as they use a station-id with GOTO_DEPOT (go figure)
-Codechange: IsValidXXXID now also checks if XXX is really valid, not if the number is within range
Both changes again in preperation of the new mem-pool system, which requires this.
IsValidXXXID is not a bit less pretty, but that will be cleaned up after the new mem-pool system
-Codechange: use IsValidXXX where ever possible
Note: both changes to prepare for new pool system, which needs those changes.
For every pool there are 2 ugly lines, which will be removed when done
implementing new pool system.
Based on FS#13 by blathijs, partly implemented.
The game date subsystem now allows someone to start in the year 0 and continue
up to the year 5 000 000. However, you currently cannot build anything before
1920 as there is no newgrf support for dates before 1920 or after 2090 yet.
now they will quickly go to a depot if set to be replaced
the tradeoff is that a vehicle set to be replaced and without a depot in the orders will forget about the orders and head for a depot. If the replace fails (lack of money), it will exit and try to head for the depot again
also all vehicles of that type will rush to the depots at once, risking causing traffic jams. This is because there is no way to even it out like normal depot visits offers
Tip: add a depot to the orders of all vehicles, set it to service only and it will always be skipped unless the vehicle is set to be replaced. This should help on the jam issue and if the replace fails, the vehicle will go though a whole round of the orders and make more money before trying again
-Cleanup: fix whitespace related coding style issues in date.[ch]
-Cleanup: make original comments doxygen compatible and remove/change outdated comments