(svn r15617) -Change [FS#2694]: vehicle variables 40-43 weren't cached (though spec stated they are). Caching these variables can yield a 10+% speed increase when those vehicle variables are queried often.

This commit is contained in:
rubidium
2009-03-04 23:32:23 +00:00
parent 890c5e3ae4
commit c0d71b84f9
4 changed files with 103 additions and 61 deletions

View File

@@ -257,11 +257,13 @@ void TrainConsistChanged(Vehicle *v, bool same_length)
/* Set user defined data to its default value */
u->u.rail.user_def_data = rvi_u->user_def_data;
u->cache_valid = 0;
}
for (Vehicle *u = v; u != NULL; u = u->Next()) {
/* Update user defined data (must be done before other properties) */
u->u.rail.user_def_data = GetVehicleProperty(u, 0x25, u->u.rail.user_def_data);
u->cache_valid = 0;
}
for (Vehicle *u = v; u != NULL; u = u->Next()) {
@@ -347,6 +349,7 @@ void TrainConsistChanged(Vehicle *v, bool same_length)
if (!same_length) u->u.rail.cached_veh_length = veh_len;
v->u.rail.cached_total_length += u->u.rail.cached_veh_length;
u->cache_valid = 0;
}
/* store consist weight/max speed in cache */