From b1627f515879e0af300d7136cb46576b27ba9848 Mon Sep 17 00:00:00 2001 From: animus Date: Fri, 16 Jan 2026 23:14:58 +0200 Subject: [PATCH] Remove redundant virtual keywords This commit performs code cleanup to improve code clarity and consistency: Remove redundant 'virtual' keywords from methods that are already marked with 'final' or 'override', as well as reducing redundant 'override final's to 'final'. --- source/gui/Scripting/JSInterface_GUIProxy.h | 24 ++++---- .../gui/Scripting/JSInterface_GUIProxy_impl.h | 8 +-- source/gui/SettingTypes/MouseEventMask.cpp | 4 +- .../components/tests/test_TerritoryManager.h | 56 +++++++++---------- source/simulation2/system/LocalTurnManager.h | 2 +- 5 files changed, 47 insertions(+), 47 deletions(-) diff --git a/source/gui/Scripting/JSInterface_GUIProxy.h b/source/gui/Scripting/JSInterface_GUIProxy.h index b8089ba4d2..c798cbffba 100644 --- a/source/gui/Scripting/JSInterface_GUIProxy.h +++ b/source/gui/Scripting/JSInterface_GUIProxy.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -169,52 +169,52 @@ protected: // BaseProxyHandler interface below // Handler for `object.x` - virtual bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId id, JS::MutableHandleValue vp) const override final; + bool get(JSContext* cx, JS::HandleObject proxy, JS::HandleValue receiver, JS::HandleId id, JS::MutableHandleValue vp) const final; // Handler for `object.x = y;` - virtual bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue vp, + bool set(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::HandleValue vp, JS::HandleValue receiver, JS::ObjectOpResult& result) const final; // Handler for `delete object.x;` - virtual bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult& result) const override final; + bool delete_(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::ObjectOpResult& result) const final; // The following methods are not provided by BaseProxyHandler. // We provide defaults that do nothing (some raise JS exceptions). - virtual bool getOwnPropertyDescriptor(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::MutableHandle> desc) const override final; + bool getOwnPropertyDescriptor(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, JS::MutableHandle> desc) const final; // Throw an exception is JS code attempts defining a property. - virtual bool defineProperty(JSContext*, JS::HandleObject /*proxy*/, JS::HandleId, + bool defineProperty(JSContext*, JS::HandleObject /*proxy*/, JS::HandleId, JS::Handle, JS::ObjectOpResult& /*result*/) const override { return false; } - virtual bool ownPropertyKeys(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const override final; + bool ownPropertyKeys(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleIdVector props) const final; // Nothing to enumerate. - virtual bool enumerate(JSContext*, JS::HandleObject /*proxy*/, + bool enumerate(JSContext*, JS::HandleObject /*proxy*/, JS::MutableHandleIdVector /*props*/) const override { return true; } // Throw an exception is JS attempts to query the prototype. - virtual bool getPrototypeIfOrdinary(JSContext*, JS::HandleObject /*proxy*/, bool* /*isOrdinary*/, + bool getPrototypeIfOrdinary(JSContext*, JS::HandleObject /*proxy*/, bool* /*isOrdinary*/, JS::MutableHandleObject /*protop*/) const override { return false; } // Throw an exception - no prototype to set. - virtual bool setImmutablePrototype(JSContext*, JS::HandleObject /*proxy*/, + bool setImmutablePrototype(JSContext*, JS::HandleObject /*proxy*/, bool* /*succeeded*/) const override { return false; } // We are not extensible. - virtual bool preventExtensions(JSContext*, JS::HandleObject /*proxy*/, + bool preventExtensions(JSContext*, JS::HandleObject /*proxy*/, JS::ObjectOpResult& /*result*/) const override { return true; } - virtual bool isExtensible(JSContext*, JS::HandleObject /*proxy*/, bool* extensible) const override + bool isExtensible(JSContext*, JS::HandleObject /*proxy*/, bool* extensible) const override { *extensible = false; return true; diff --git a/source/gui/Scripting/JSInterface_GUIProxy_impl.h b/source/gui/Scripting/JSInterface_GUIProxy_impl.h index 86bf177f92..9ee4e55338 100644 --- a/source/gui/Scripting/JSInterface_GUIProxy_impl.h +++ b/source/gui/Scripting/JSInterface_GUIProxy_impl.h @@ -87,23 +87,23 @@ class MapCache : public GUIProxyProps public: virtual ~MapCache() {}; - virtual bool has(const std::string& name) const override + bool has(const std::string& name) const override { return m_Functions.find(name) != m_Functions.end(); } - virtual JSObject* get(const std::string& name) const override + JSObject* get(const std::string& name) const override { return m_Functions.at(name).get(); } - virtual bool setFunction(const ScriptRequest& rq, const std::string& name, JSFunction* function) override + bool setFunction(const ScriptRequest& rq, const std::string& name, JSFunction* function) override { m_Functions[name].init(rq.cx, JS_GetFunctionObject(function)); return true; } - virtual std::vector getPropsNames() const override + std::vector getPropsNames() const override { std::vector result; result.reserve(m_Functions.size()); diff --git a/source/gui/SettingTypes/MouseEventMask.cpp b/source/gui/SettingTypes/MouseEventMask.cpp index 7bac7d6114..2b4a1b88ee 100644 --- a/source/gui/SettingTypes/MouseEventMask.cpp +++ b/source/gui/SettingTypes/MouseEventMask.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -141,7 +141,7 @@ public: return mask; } - virtual bool IsMouseOver(const CVector2D& mousePos, const CRect& objectSize) const override + bool IsMouseOver(const CVector2D& mousePos, const CRect& objectSize) const override { if (m_Data.empty()) return false; diff --git a/source/simulation2/components/tests/test_TerritoryManager.h b/source/simulation2/components/tests/test_TerritoryManager.h index 7d9fbda6ed..29b8dfd435 100644 --- a/source/simulation2/components/tests/test_TerritoryManager.h +++ b/source/simulation2/components/tests/test_TerritoryManager.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2025 Wildfire Games. +/* Copyright (C) 2026 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -64,35 +64,35 @@ public: // Test data Grid m_PassabilityGrid; - virtual pass_class_t GetPassabilityClass(const std::string&) const override { return 0; } - virtual const Grid& GetPassabilityGrid() override { return m_PassabilityGrid; } + pass_class_t GetPassabilityClass(const std::string&) const override { return 0; } + const Grid& GetPassabilityGrid() override { return m_PassabilityGrid; } // Irrelevant part of the mock. - virtual void GetPassabilityClasses(std::map&) const override {} - virtual void GetPassabilityClasses(std::map&, std::map&) const override {} - virtual entity_pos_t GetClearance(pass_class_t) const override { return entity_pos_t::FromInt(1); } - virtual entity_pos_t GetMaximumClearance() const override { return entity_pos_t::FromInt(1); } - virtual const GridUpdateInformation& GetAIPathfinderDirtinessInformation() const override { static GridUpdateInformation gridInfo; return gridInfo; } - virtual void FlushAIPathfinderDirtinessInformation() override {} - virtual Grid ComputeShoreGrid(bool = false) override { return Grid {}; } - virtual u32 ComputePathAsync(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, entity_id_t) override { return 1; } - virtual void ComputePathImmediate(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, WaypointPath&) const override {} - virtual u32 ComputeShortPathAsync(entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, bool, entity_id_t, entity_id_t) override { return 1; } - virtual WaypointPath ComputeShortPathImmediate(const ShortPathRequest&) const override { return WaypointPath(); } - virtual void SetDebugPath(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override {} - virtual bool IsGoalReachable(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override { return false; } - virtual std::vector DistributeAround(std::vector, entity_pos_t, entity_pos_t) const override { return {}; } - virtual bool CheckMovement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t) const override { return false; } - virtual ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t, bool = false) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; } - virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; } - virtual ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t, bool) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; } - virtual void SetDebugOverlay(bool) override {} - virtual void SetHierDebugOverlay(bool) override {} - virtual void SendRequestedPaths() override {} - virtual void StartProcessingMoves(bool) override {} - virtual void UpdateGrid() override {} - virtual void GetDebugData(u32&, double&, Grid&) const override {} - virtual void SetAtlasOverlay(bool, pass_class_t = 0) override {} + void GetPassabilityClasses(std::map&) const override {} + void GetPassabilityClasses(std::map&, std::map&) const override {} + entity_pos_t GetClearance(pass_class_t) const override { return entity_pos_t::FromInt(1); } + entity_pos_t GetMaximumClearance() const override { return entity_pos_t::FromInt(1); } + const GridUpdateInformation& GetAIPathfinderDirtinessInformation() const override { static GridUpdateInformation gridInfo; return gridInfo; } + void FlushAIPathfinderDirtinessInformation() override {} + Grid ComputeShoreGrid(bool = false) override { return Grid {}; } + u32 ComputePathAsync(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, entity_id_t) override { return 1; } + void ComputePathImmediate(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, WaypointPath&) const override {} + u32 ComputeShortPathAsync(entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t, bool, entity_id_t, entity_id_t) override { return 1; } + WaypointPath ComputeShortPathImmediate(const ShortPathRequest&) const override { return WaypointPath(); } + void SetDebugPath(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override {} + bool IsGoalReachable(entity_pos_t, entity_pos_t, const PathGoal&, pass_class_t) override { return false; } + std::vector DistributeAround(std::vector, entity_pos_t, entity_pos_t) const override { return {}; } + bool CheckMovement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t) const override { return false; } + ICmpObstruction::EFoundationCheck CheckUnitPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, pass_class_t, bool = false) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; } + ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; } + ICmpObstruction::EFoundationCheck CheckBuildingPlacement(const IObstructionTestFilter&, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_pos_t, entity_id_t, pass_class_t, bool) const override { return ICmpObstruction::FOUNDATION_CHECK_SUCCESS; } + void SetDebugOverlay(bool) override {} + void SetHierDebugOverlay(bool) override {} + void SendRequestedPaths() override {} + void StartProcessingMoves(bool) override {} + void UpdateGrid() override {} + void GetDebugData(u32&, double&, Grid&) const override {} + void SetAtlasOverlay(bool, pass_class_t = 0) override {} }; class MockPlayerMgrTerrMan : public ICmpPlayerManager diff --git a/source/simulation2/system/LocalTurnManager.h b/source/simulation2/system/LocalTurnManager.h index c7086f85b0..35ad4382c5 100644 --- a/source/simulation2/system/LocalTurnManager.h +++ b/source/simulation2/system/LocalTurnManager.h @@ -43,7 +43,7 @@ public: protected: void NotifyFinishedOwnCommands(u32 turn) override; - virtual void NotifyFinishedUpdate(u32 turn, const UpdateCallback& sendEventToAll) override; + void NotifyFinishedUpdate(u32 turn, const UpdateCallback& sendEventToAll) override; }; #endif // INCLUDED_LOCALTURNMANAGER