forked from mirror/OpenTTD
(svn r6424) -Codechange: [autoreplace] removed a loop though all vehicles from each time the window is redrawn
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
This commit is contained in:
14
openttd.c
14
openttd.c
@@ -1456,6 +1456,20 @@ bool AfterLoadGame(void)
|
||||
|
||||
if (!CheckSavegameVersion(27)) AfterLoadStations();
|
||||
|
||||
{
|
||||
/* Set up the engine count for all players */
|
||||
Player *players[MAX_PLAYERS];
|
||||
int i;
|
||||
const Vehicle *v;
|
||||
|
||||
for (i = 0; i < MAX_PLAYERS; i++) players[i] = GetPlayer(i);
|
||||
|
||||
FOR_ALL_VEHICLES(v) {
|
||||
if (!IsEngineCountable(v)) continue;
|
||||
players[v->owner]->num_engines[v->engine_type]++;
|
||||
}
|
||||
}
|
||||
|
||||
/* Time starts at 0 instead of 1920.
|
||||
* Account for this in older games by adding an offset */
|
||||
if (CheckSavegameVersion(31)) {
|
||||
|
Reference in New Issue
Block a user