summaryrefslogtreecommitdiff
path: root/train_cmd.c
diff options
context:
space:
mode:
authorcelestar <celestar@openttd.org>2005-03-29 11:19:10 +0000
committercelestar <celestar@openttd.org>2005-03-29 11:19:10 +0000
commitc68cfdeecaccbd3979e920ec424f98375e0f9e3d (patch)
treec9bca484f8c447d1e5c5e7e8827b416361992ea3 /train_cmd.c
parent3a8665f796876a7dd346887cae7d7df4808ee4d4 (diff)
downloadopenttd-c68cfdeecaccbd3979e920ec424f98375e0f9e3d.tar.xz
(svn r2105) -Codechange: Added a cache for the first vehicle of a chain to increase performance, especially with many long trains
Diffstat (limited to 'train_cmd.c')
-rw-r--r--train_cmd.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/train_cmd.c b/train_cmd.c
index 512930b28..0a49aea89 100644
--- a/train_cmd.c
+++ b/train_cmd.c
@@ -736,6 +736,14 @@ int32 CmdMoveRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2)
dst_head = NULL;
if (dst != NULL) dst_head = GetFirstVehicleInChain(dst);
+ /* clear the ->first cache */
+ {
+ Vehicle *u;
+
+ for (u = src_head; u != NULL; u = u->next) u->first = NULL;
+ for (u = dst_head; u != NULL; u = u->next) u->first = NULL;
+ }
+
/* check if all vehicles in the source train are stopped */
if (CheckTrainStoppedInDepot(src_head) < 0)
return CMD_ERROR;
@@ -939,6 +947,9 @@ int32 CmdSellRailWagon(int x, int y, uint32 flags, uint32 p1, uint32 p2)
// when selling an attached locomotive. we need to delete its window.
if (v->subtype == TS_Front_Engine) {
+ Vehicle *u;
+
+ for (u = v; u != NULL; u = u->next) u->first = NULL;
DeleteWindowById(WC_VEHICLE_VIEW, v->index);
// rearrange all vehicles that follow to separate lines.