(svn r3954) - Explicitly update v->first in TrainConsistChanged() if necessary, as this is far faster than brute forcing it later.

- When loading a game, call TrainConsistChanged() for each train head separately before updating images, as v->first is used extensively in GetTrainImage() for custom graphics. This gives a significant speed improvement on loading a game. 
- Rewrite GetFreeUnitNumber() so that only one loop of vehicles is required. Instead a list of used/unused numbers is created and the first unused number is chosen. This significantly improves performance in large games. 
- Improve game-load times. Backport of r3570-3572 from trunk
This commit is contained in:
Darkvater
2006-03-18 15:22:27 +00:00
parent f75365fcf4
commit 7ddae93da8
2 changed files with 40 additions and 13 deletions

View File

@@ -93,6 +93,9 @@ void TrainConsistChanged(Vehicle* v)
const RailVehicleInfo *rvi_u = RailVehInfo(u->engine_type);
uint16 veh_len;
// Update the v->first cache. This is faster than having to brute force it later.
if (u->first == NULL) u->first = v;
// update the 'first engine'
u->u.rail.first_engine = (v == u) ? INVALID_VEHICLE : first_engine;