diff options
author | rubidium <rubidium@openttd.org> | 2007-08-30 21:11:12 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-30 21:11:12 +0000 |
commit | aba867d78dd52154bb7874a6998a3002dab57684 (patch) | |
tree | b205fc9b323290f091d73bfe7f40c7ed002d44cc /src/depot_gui.cpp | |
parent | 8a6cc3aa104b5f8631dcb74343dcd68ffa3308ec (diff) | |
download | openttd-aba867d78dd52154bb7874a6998a3002dab57684.tar.xz |
(svn r11011) -Fix [FS#1129]: GetFirstVehicleInChain did change the game state while being marked const.
-Codechange: do not brute force determine the first vehicle in the chain or previous vehicle, but do it by properly accounting the previous and first pointers when updating the next pointer. This gives a performance increase of about 15% when there are a lot of vehicles in the game.
Diffstat (limited to 'src/depot_gui.cpp')
-rw-r--r-- | src/depot_gui.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp index 0ca889b78..318ee3f3d 100644 --- a/src/depot_gui.cpp +++ b/src/depot_gui.cpp @@ -359,7 +359,7 @@ static int GetVehicleFromDepotWndPt(const Window *w, int x, int y, Vehicle **veh while (v != NULL && (x -= v->u.rail.cached_veh_length) >= 0) v = v->Next(); /* if an articulated part was selected, find its parent */ - while (v != NULL && IsArticulatedPart(v)) v = GetPrevVehicleInChain(v); + while (v != NULL && IsArticulatedPart(v)) v = v->Previous(); d->wagon = v; @@ -398,7 +398,7 @@ static void TrainDepotMoveVehicle(Vehicle *wagon, VehicleID sel, Vehicle *head) if (wagon == NULL) { if (head != NULL) wagon = GetLastVehicleInChain(head); } else { - wagon = GetPrevVehicleInChain(wagon); + wagon = wagon->Previous(); if (wagon == NULL) return; } @@ -475,7 +475,7 @@ static void HandleCloneVehClick(const Vehicle *v, const Window *w) if (v == NULL) return; if (v->HasFront() && !v->IsPrimaryVehicle()) { - v = GetFirstVehicleInChain(v); + v = v->First(); /* Do nothing when clicking on a train in depot with no loc attached */ if (v->type == VEH_TRAIN && !IsFrontEngine(v)) return; } |