From 732845440a15f0c627b6cca08dabff51beac735a Mon Sep 17 00:00:00 2001 From: rubidium Date: Thu, 30 Aug 2007 21:11:12 +0000 Subject: (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. --- src/viewport.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/viewport.cpp') 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); } -- cgit v1.2.3-54-g00ecf