From 0b09a7ac6193a4db7b817e8cd4d830e7f1331bd4 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 1 Aug 2015 17:06:06 +0100 Subject: [PATCH 1/2] Add a conditional define for the override keyword. Use of the override keyword can prevent various types of problems when the base method signature is changed, but derived overriding methods are not. This is conditional to maintain compatibility with legacy compilers. --- src/stdafx.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/stdafx.h b/src/stdafx.h index d68605c196..13bc9685d2 100644 --- a/src/stdafx.h +++ b/src/stdafx.h @@ -514,4 +514,15 @@ static inline void free(const void *ptr) #define IGNORE_UNINITIALIZED_WARNING_STOP #endif +/* + * Conditional define for the override keyword. + * Use of the override keyword can prevent various types of problems when the base method signature is changed, but derived overriding methods are not + * This is conditional to maintain compatibility with legacy compilers + */ +#if __cplusplus >= 201103L || defined(__STDCXX_VERSION__) || defined(__GXX_EXPERIMENTAL_CXX0X__) || defined(__GXX_EXPERIMENTAL_CPP0X__) + #define OVERRIDE override +#else + #define OVERRIDE +#endif + #endif /* STDAFX_H */ From 804cfad053ad0b34a0a88ba681e22c845ab01464 Mon Sep 17 00:00:00 2001 From: Jonathan G Rennison Date: Sat, 1 Aug 2015 17:15:25 +0100 Subject: [PATCH 2/2] Add override keywords for tracerestrict GUI code --- src/tracerestrict_gui.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/tracerestrict_gui.cpp b/src/tracerestrict_gui.cpp index 630c3abbd6..cfd9a5eafe 100644 --- a/src/tracerestrict_gui.cpp +++ b/src/tracerestrict_gui.cpp @@ -594,7 +594,7 @@ public: this->ReloadProgramme(); } - virtual void OnClick(Point pt, int widget, int click_count) + virtual void OnClick(Point pt, int widget, int click_count) OVERRIDE { switch (widget) { case TR_WIDGET_INSTRUCTION_LIST: { @@ -778,7 +778,7 @@ public: } } - virtual void OnQueryTextFinished(char *str) + virtual void OnQueryTextFinished(char *str) OVERRIDE { if (StrEmpty(str)) { return; @@ -801,7 +801,7 @@ public: TraceRestrictDoCommandP(tile, track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM); } - virtual void OnDropdownSelect(int widget, int index) + virtual void OnDropdownSelect(int widget, int index) OVERRIDE { TraceRestrictItem item = GetSelected(); if (item == 0 || index < 0 || this->selected_instruction < 1) { @@ -875,7 +875,7 @@ public: } } - virtual void OnPlaceObject(Point pt, TileIndex tile) + virtual void OnPlaceObject(Point pt, TileIndex tile) OVERRIDE { int widget = this->current_placement_widget; this->current_placement_widget = -1; @@ -996,13 +996,13 @@ public: TraceRestrictDoCommandP(this->tile, this->track, TRDCT_MODIFY_ITEM, this->selected_instruction - 1, item, STR_TRACE_RESTRICT_ERROR_CAN_T_MODIFY_ITEM); } - virtual void OnPlaceObjectAbort() + virtual void OnPlaceObjectAbort() OVERRIDE { this->RaiseButtons(); this->current_placement_widget = -1; } - virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) + virtual void UpdateWidgetSize(int widget, Dimension *size, const Dimension &padding, Dimension *fill, Dimension *resize) OVERRIDE { switch (widget) { case TR_WIDGET_INSTRUCTION_LIST: @@ -1012,18 +1012,18 @@ public: } } - virtual void OnResize() + virtual void OnResize() OVERRIDE { /* Update the scroll bar */ this->vscroll->SetCapacityFromWidget(this, TR_WIDGET_INSTRUCTION_LIST); } - virtual void OnPaint() + virtual void OnPaint() OVERRIDE { this->DrawWidgets(); } - virtual void DrawWidget(const Rect &r, int widget) const + virtual void DrawWidget(const Rect &r, int widget) const OVERRIDE { if (widget != TR_WIDGET_INSTRUCTION_LIST) return; @@ -1059,14 +1059,14 @@ public: } } - virtual void OnInvalidateData(int data, bool gui_scope) + virtual void OnInvalidateData(int data, bool gui_scope) OVERRIDE { if (gui_scope) { this->ReloadProgramme(); } } - virtual void SetStringParameters(int widget) const + virtual void SetStringParameters(int widget) const OVERRIDE { switch (widget) { case TR_WIDGET_VALUE_INT: {