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 | 732845440a15f0c627b6cca08dabff51beac735a (patch) | |
tree | b205fc9b323290f091d73bfe7f40c7ed002d44cc /src/viewport.cpp | |
parent | 5ff81aca1873824af8b00eeb74ddedfce9dfef4a (diff) | |
download | openttd-732845440a15f0c627b6cca08dabff51beac735a.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/viewport.cpp')
-rw-r--r-- | src/viewport.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/viewport.cpp b/src/viewport.cpp index e7a432d36..50297c1c5 100644 --- a/src/viewport.cpp +++ b/src/viewport.cpp @@ -1786,13 +1786,13 @@ static void CheckClickOnLandscape(const ViewPort *vp, int x, int y) static void SafeShowTrainViewWindow(const Vehicle* v) { - if (!IsFrontEngine(v)) v = GetFirstVehicleInChain(v); + if (!IsFrontEngine(v)) v = v->First(); ShowVehicleViewWindow(v); } static void SafeShowRoadVehViewWindow(const Vehicle *v) { - if (!IsRoadVehFront(v)) v = GetFirstVehicleInChain(v); + if (!IsRoadVehFront(v)) v = v->First(); ShowVehicleViewWindow(v); } |