From 1f6f364a56319eabd02c050746fe7df3f55ffee3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 12 May 2020 17:01:17 +0200 Subject: Port member initialization from constructor to declaration (C++11) Using `clang-tidy`'s `modernize-use-default-member-init` check and manual review of the changes, and some extra manual changes that `clang-tidy` failed to do. Also went manually through all of `core` to find occurrences that `clang-tidy` couldn't handle, especially all initializations done in a constructor without using initializer lists. --- main/main_timer_sync.cpp | 7 +------ main/main_timer_sync.h | 10 +++++----- 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'main') diff --git a/main/main_timer_sync.cpp b/main/main_timer_sync.cpp index 9e23a1f5cb..469ef6f20a 100644 --- a/main/main_timer_sync.cpp +++ b/main/main_timer_sync.cpp @@ -193,12 +193,7 @@ float MainTimerSync::get_cpu_idle_step() { return cpu_ticks_elapsed / 1000000.0; } -MainTimerSync::MainTimerSync() : - last_cpu_ticks_usec(0), - current_cpu_ticks_usec(0), - time_accum(0), - time_deficit(0), - fixed_fps(0) { +MainTimerSync::MainTimerSync() { for (int i = CONTROL_STEPS - 1; i >= 0; --i) { typical_physics_steps[i] = i; accumulated_physics_steps[i] = i; diff --git a/main/main_timer_sync.h b/main/main_timer_sync.h index 620d1c747d..2126381c7c 100644 --- a/main/main_timer_sync.h +++ b/main/main_timer_sync.h @@ -43,14 +43,14 @@ struct MainFrameTime { class MainTimerSync { // wall clock time measured on the main thread - uint64_t last_cpu_ticks_usec; - uint64_t current_cpu_ticks_usec; + uint64_t last_cpu_ticks_usec = 0; + uint64_t current_cpu_ticks_usec = 0; // logical game time since last physics timestep - float time_accum; + float time_accum = 0; // current difference between wall clock time and reported sum of idle_steps - float time_deficit; + float time_deficit = 0; // number of frames back for keeping accumulated physics steps roughly constant. // value of 12 chosen because that is what is required to make 144 Hz monitors @@ -64,7 +64,7 @@ class MainTimerSync { // typical value for accumulated_physics_steps[i] is either this or this plus one int typical_physics_steps[CONTROL_STEPS]; - int fixed_fps; + int fixed_fps = 0; protected: // returns the fraction of p_frame_slice required for the timer to overshoot -- cgit v1.2.3