From 352a3229cdc8664bc88f9761e56a610f5fbe241d Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Wed, 25 Nov 2015 22:36:57 +0000 Subject: [PATCH] Do not update/redraw windows and viewports in dedicated mode. This has a quite significant performance cost when the result will only be thrown away by the null blitter anyway. No longer call UpdateWindows in main loop, which renders dirty windows and viewports. No longer update vehicle sprites IDs or mark dirty vehicles in viewports. This saved >50% of server CPU time in a test game. --- src/vehicle_base.h | 3 +++ src/video/dedicated_v.cpp | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/vehicle_base.h b/src/vehicle_base.h index db8a1bdf7d..1d4a6fa24f 100644 --- a/src/vehicle_base.h +++ b/src/vehicle_base.h @@ -24,6 +24,7 @@ #include "group_type.h" #include "timetable.h" #include "base_consist.h" +#include "network/network.h" #include #include @@ -1138,6 +1139,8 @@ struct SpecializedVehicle : public Vehicle { */ inline void UpdateViewport(bool force_update, bool update_delta) { + if (_network_dedicated) return; + /* Explicitly choose method to call to prevent vtable dereference - * it gives ~3% runtime improvements in games with many vehicles */ if (update_delta) ((T *)this)->T::UpdateDeltaXY(this->direction); diff --git a/src/video/dedicated_v.cpp b/src/video/dedicated_v.cpp index bfe853e9a0..e55f5621ea 100644 --- a/src/video/dedicated_v.cpp +++ b/src/video/dedicated_v.cpp @@ -315,7 +315,6 @@ void VideoDriver_Dedicated::MainLoop() next_tick = cur_ticks + MILLISECONDS_PER_TICK; GameLoop(); - UpdateWindows(); } /* Don't sleep when fast forwarding (for desync debugging) */