From 1fa718f491bd14baa7cc5856c761a162bd3ddfd2 Mon Sep 17 00:00:00 2001 From: Vectozavr <60608292+vectozavr@users.noreply.github.com> Date: Wed, 13 Oct 2021 00:18:56 +0700 Subject: [PATCH] Add "final" to all classes from which we dont need to inherit. --- Bonus.h | 2 +- Client.h | 2 +- Player.h | 2 +- PlayerController.h | 2 +- Server.h | 2 +- Shooter.h | 2 +- engine/Camera.h | 2 +- engine/Keyboard.h | 2 +- engine/Matrix4x4.h | 2 +- engine/Mouse.h | 2 +- engine/Plane.h | 2 +- engine/Point4D.h | 2 +- engine/Screen.h | 2 +- engine/Triangle.h | 3 +-- engine/Vec2D.h | 4 ++-- engine/Vec3D.h | 2 +- engine/World.h | 2 +- engine/animation/AColor.h | 2 +- engine/animation/AFunction.h | 2 +- engine/animation/ARotate.h | 2 +- engine/animation/AScale.h | 2 +- engine/animation/ATranslate.h | 2 +- engine/animation/ATranslateToPoint.h | 2 +- engine/animation/AWait.h | 2 +- engine/gui/Button.h | 2 +- engine/gui/Window.h | 2 +- engine/network/ReliableMsg.h | 2 +- engine/network/UDPConnection.h | 3 +-- engine/network/UDPSocket.h | 3 +-- engine/physics/Simplex.h | 2 +- engine/physics/Solver.h | 2 +- weapon/Ak47.h | 2 +- weapon/Gold_Ak47.h | 2 +- weapon/Gun.h | 2 +- weapon/Rifle.h | 2 +- weapon/Shotgun.h | 2 +- 36 files changed, 37 insertions(+), 40 deletions(-) diff --git a/Bonus.h b/Bonus.h index 4c81549..7a082eb 100644 --- a/Bonus.h +++ b/Bonus.h @@ -8,7 +8,7 @@ #include "engine/World.h" #include "Player.h" -class Bonus : public RigidBody { +class Bonus final : public RigidBody { protected: std::string _name; public: diff --git a/Client.h b/Client.h index 77de858..7da3b56 100644 --- a/Client.h +++ b/Client.h @@ -8,7 +8,7 @@ #include "engine/network/ClientUDP.h" #include "Player.h" -class Client : public ClientUDP { +class Client final : public ClientUDP { private: std::map> _players{}; std::shared_ptr _player; diff --git a/Player.h b/Player.h index 53c9c14..97be75d 100644 --- a/Player.h +++ b/Player.h @@ -16,7 +16,7 @@ #include "weapon/Gold_Ak47.h" #include "weapon/Rifle.h" -class Player : public RigidBody{ +class Player final : public RigidBody{ private: double _healthMax = 100; double _health = _healthMax; diff --git a/PlayerController.h b/PlayerController.h index 77e6bfb..2d21001 100644 --- a/PlayerController.h +++ b/PlayerController.h @@ -9,7 +9,7 @@ #include "engine/Keyboard.h" #include "engine/Mouse.h" -class PlayerController { +class PlayerController final { private: std::shared_ptr _player; std::shared_ptr _keyboard; diff --git a/Server.h b/Server.h index 65a35d3..778db21 100644 --- a/Server.h +++ b/Server.h @@ -15,7 +15,7 @@ struct BonusInfo { bool onTheMap = false; }; -class Server : public ServerUDP { +class Server final : public ServerUDP { private: std::map> _players{}; std::map _bonuses{}; diff --git a/Shooter.h b/Shooter.h index 729e119..cc91ff5 100644 --- a/Shooter.h +++ b/Shooter.h @@ -15,7 +15,7 @@ #include "Server.h" -class Shooter : public Engine { +class Shooter final : public Engine { private: std::shared_ptr player; std::shared_ptr playerController; diff --git a/engine/Camera.h b/engine/Camera.h index 69d60fe..95b66db 100644 --- a/engine/Camera.h +++ b/engine/Camera.h @@ -10,7 +10,7 @@ #include "Plane.h" #include "Mesh.h" -class Camera : public Object{ +class Camera final : public Object{ private: Matrix4x4 _S; // screen space matrix Matrix4x4 _P; // projections matrix diff --git a/engine/Keyboard.h b/engine/Keyboard.h index b5b96ef..fe9560c 100644 --- a/engine/Keyboard.h +++ b/engine/Keyboard.h @@ -7,7 +7,7 @@ #include -class Keyboard { +class Keyboard final { private: std::map _tappedKeys; public: diff --git a/engine/Matrix4x4.h b/engine/Matrix4x4.h index 6bbe1e3..5625162 100644 --- a/engine/Matrix4x4.h +++ b/engine/Matrix4x4.h @@ -9,7 +9,7 @@ #include "Point4D.h" #include "Vec3D.h" -class Matrix4x4 { +class Matrix4x4 final { private: std::array, 4> _arr{}; diff --git a/engine/Mouse.h b/engine/Mouse.h index 6101916..f76eb23 100644 --- a/engine/Mouse.h +++ b/engine/Mouse.h @@ -9,7 +9,7 @@ #include #include "Vec2D.h" -class Mouse { +class Mouse final { private: std::shared_ptr _window; diff --git a/engine/Plane.h b/engine/Plane.h index 9c49909..a3b16de 100644 --- a/engine/Plane.h +++ b/engine/Plane.h @@ -8,7 +8,7 @@ #include "Point4D.h" #include "Triangle.h" -class Plane { +class Plane final { private: // You can define plane by defining the points in 3D space Triangle _triangle; diff --git a/engine/Point4D.h b/engine/Point4D.h index 9a1c984..74fa854 100644 --- a/engine/Point4D.h +++ b/engine/Point4D.h @@ -8,7 +8,7 @@ #include #include "Consts.h" -class Point4D { +class Point4D final { private: std::array _arr_point{}; diff --git a/engine/Screen.h b/engine/Screen.h index 55aa506..bcabaf6 100644 --- a/engine/Screen.h +++ b/engine/Screen.h @@ -13,7 +13,7 @@ #include "utils/Time.h" #include "Mouse.h" -class Screen { +class Screen final { private: int _w = 1920; int _h = 1080; diff --git a/engine/Triangle.h b/engine/Triangle.h index 545ea2b..0b92632 100644 --- a/engine/Triangle.h +++ b/engine/Triangle.h @@ -10,12 +10,11 @@ #include "Matrix4x4.h" #include -class Triangle { +class Triangle final { private: sf::Color _color; std::vector _points; public: - Triangle (); Triangle (const Triangle& triangle); Triangle (const Point4D& p1, const Point4D& p2, const Point4D& p3, sf::Color color = {0, 0, 0}); diff --git a/engine/Vec2D.h b/engine/Vec2D.h index 04100ab..d86a01d 100644 --- a/engine/Vec2D.h +++ b/engine/Vec2D.h @@ -9,14 +9,14 @@ #include #include "Point4D.h" -class Vec2D { +class Vec2D final { private: std::array _arr_point{}; public: Vec2D () = default; Vec2D (const Vec2D& vec); - Vec2D (const Point4D& point4D); + explicit Vec2D (const Point4D& point4D); explicit Vec2D (double x, double y = 0.0); Vec2D& operator=(const Vec2D&) = delete; diff --git a/engine/Vec3D.h b/engine/Vec3D.h index d315067..f49a3fb 100644 --- a/engine/Vec3D.h +++ b/engine/Vec3D.h @@ -8,7 +8,7 @@ #include #include "Point4D.h" -class Vec3D { +class Vec3D final { private: std::array _arr_point{}; diff --git a/engine/World.h b/engine/World.h index b1de54d..1fa6875 100644 --- a/engine/World.h +++ b/engine/World.h @@ -9,7 +9,7 @@ #include "Camera.h" #include "physics/RigidBody.h" -class World { +class World final { private: std::map> _objects; public: diff --git a/engine/animation/AColor.h b/engine/animation/AColor.h index fe7d37a..0be6054 100644 --- a/engine/animation/AColor.h +++ b/engine/animation/AColor.h @@ -8,7 +8,7 @@ #include "Animation.h" #include "../Mesh.h" -class AColor : public Animation { +class AColor final : public Animation { private: std::shared_ptr _mesh; diff --git a/engine/animation/AFunction.h b/engine/animation/AFunction.h index 4b8fe28..f5abd45 100644 --- a/engine/animation/AFunction.h +++ b/engine/animation/AFunction.h @@ -9,7 +9,7 @@ #ifndef ENGINE_AFUNCTION_H #define ENGINE_AFUNCTION_H -class AFunction : public Animation { +class AFunction final : public Animation { private: int _calls = 0; int _allCalls = 1; diff --git a/engine/animation/ARotate.h b/engine/animation/ARotate.h index 84335d1..7b15271 100644 --- a/engine/animation/ARotate.h +++ b/engine/animation/ARotate.h @@ -8,7 +8,7 @@ #include "Animation.h" #include "../Object.h" -class ARotate : public Animation { +class ARotate final : public Animation { private: std::shared_ptr _object; diff --git a/engine/animation/AScale.h b/engine/animation/AScale.h index 8cf528f..c4d9926 100644 --- a/engine/animation/AScale.h +++ b/engine/animation/AScale.h @@ -9,7 +9,7 @@ #include "Animation.h" #include "Mesh.h" -class AScale : public Animation { +class AScale final : public Animation { private: std::shared_ptr _mesh; diff --git a/engine/animation/ATranslate.h b/engine/animation/ATranslate.h index 17f2b9d..f3693f2 100644 --- a/engine/animation/ATranslate.h +++ b/engine/animation/ATranslate.h @@ -8,7 +8,7 @@ #include "Animation.h" #include "../Object.h" -class ATranslate : public Animation { +class ATranslate final : public Animation { private: std::shared_ptr _object; diff --git a/engine/animation/ATranslateToPoint.h b/engine/animation/ATranslateToPoint.h index 4ea0a41..de7efc3 100644 --- a/engine/animation/ATranslateToPoint.h +++ b/engine/animation/ATranslateToPoint.h @@ -8,7 +8,7 @@ #include "Animation.h" #include "../Object.h" -class ATranslateToPoint : public Animation { +class ATranslateToPoint final : public Animation { private: std::shared_ptr _object; diff --git a/engine/animation/AWait.h b/engine/animation/AWait.h index 367d725..e45d457 100644 --- a/engine/animation/AWait.h +++ b/engine/animation/AWait.h @@ -7,7 +7,7 @@ #include "Animation.h" -class AWait : public Animation { +class AWait final : public Animation { public: explicit AWait(double duration = 1) { _duration = duration; diff --git a/engine/gui/Button.h b/engine/gui/Button.h index bd04b51..21e4223 100644 --- a/engine/gui/Button.h +++ b/engine/gui/Button.h @@ -14,7 +14,7 @@ struct tPos { int ty; }; -class Button { +class Button final { private: int _x{}; int _y{}; diff --git a/engine/gui/Window.h b/engine/gui/Window.h index 7592e10..679ee4a 100644 --- a/engine/gui/Window.h +++ b/engine/gui/Window.h @@ -12,7 +12,7 @@ #include "../Screen.h" #include "../Mouse.h" -class Window { +class Window final { private: std::string _name; std::string _backTexture; diff --git a/engine/network/ReliableMsg.h b/engine/network/ReliableMsg.h index 38488fa..6a233a7 100644 --- a/engine/network/ReliableMsg.h +++ b/engine/network/ReliableMsg.h @@ -7,7 +7,7 @@ #include -class ReliableMsg +class ReliableMsg final { private: sf::Packet packet; diff --git a/engine/network/UDPConnection.h b/engine/network/UDPConnection.h index 9521583..e5fe12c 100644 --- a/engine/network/UDPConnection.h +++ b/engine/network/UDPConnection.h @@ -7,8 +7,7 @@ #include -class UDPConnection -{ +class UDPConnection final { private: sf::Uint16 _id; sf::IpAddress _ip; diff --git a/engine/network/UDPSocket.h b/engine/network/UDPSocket.h index 8b997da..7ba116c 100644 --- a/engine/network/UDPSocket.h +++ b/engine/network/UDPSocket.h @@ -12,8 +12,7 @@ #include "UDPConnection.h" #include "MsgType.h" -class UDPSocket -{ +class UDPSocket final { private: sf::UdpSocket _socket; sf::Uint16 _nextRelyMsgId; diff --git a/engine/physics/Simplex.h b/engine/physics/Simplex.h index cae6ce7..b02918b 100644 --- a/engine/physics/Simplex.h +++ b/engine/physics/Simplex.h @@ -16,7 +16,7 @@ enum class SimplexType { Tetrahedron }; -struct Simplex { +struct Simplex final { private: std::deque _points{}; diff --git a/engine/physics/Solver.h b/engine/physics/Solver.h index 6392009..d2b95a1 100644 --- a/engine/physics/Solver.h +++ b/engine/physics/Solver.h @@ -7,7 +7,7 @@ #include "RigidBody.h" -class Solver { +class Solver final { public: static void solveCollision(std::shared_ptr obj1, std::shared_ptr obj2, const CollisionPoint& collision); }; diff --git a/weapon/Ak47.h b/weapon/Ak47.h index a9274b4..578bf9f 100644 --- a/weapon/Ak47.h +++ b/weapon/Ak47.h @@ -7,7 +7,7 @@ #include "Weapon.h" -class Ak47 : public Weapon { +class Ak47 final : public Weapon { public: explicit Ak47(int ammo = 100, const std::string& weaponName = "ak47"); }; diff --git a/weapon/Gold_Ak47.h b/weapon/Gold_Ak47.h index 28ddc60..7f2cbae 100644 --- a/weapon/Gold_Ak47.h +++ b/weapon/Gold_Ak47.h @@ -7,7 +7,7 @@ #include "Weapon.h" -class Gold_Ak47 : public Weapon { +class Gold_Ak47 final : public Weapon { public: explicit Gold_Ak47(int ammo = 200, const std::string& weaponName = "gold_ak47") : Weapon(weaponName, "obj/ak47.obj", "obj/gold_ak47_mat.txt", Vec3D{3, 3, 3}, Vec3D{-0.8, 1.3, 0.3}, Vec3D{0, Consts::PI, 0}) { fireSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/weapons/ak47.ogg")); diff --git a/weapon/Gun.h b/weapon/Gun.h index db5a25a..07900c7 100644 --- a/weapon/Gun.h +++ b/weapon/Gun.h @@ -7,7 +7,7 @@ #include "Weapon.h" -class Gun : public Weapon { +class Gun final : public Weapon { public: explicit Gun(int ammo = 30, const std::string& weaponName = "gun"); }; diff --git a/weapon/Rifle.h b/weapon/Rifle.h index eb1e269..8cabfc6 100644 --- a/weapon/Rifle.h +++ b/weapon/Rifle.h @@ -7,7 +7,7 @@ #include "Weapon.h" -class Rifle : public Weapon { +class Rifle final : public Weapon { public: explicit Rifle(int ammo = 5, const std::string& weaponName = "rifle"); }; diff --git a/weapon/Shotgun.h b/weapon/Shotgun.h index e54d0ec..7fc6f6f 100644 --- a/weapon/Shotgun.h +++ b/weapon/Shotgun.h @@ -7,7 +7,7 @@ #include "Weapon.h" -class Shotgun : public Weapon { +class Shotgun final : public Weapon { public: explicit Shotgun(int ammo = 15, const std::string& weaponName = "shotgun"); std::map processFire(std::function(const Vec3D&, const Vec3D&)> rayCastFunction, const Vec3D& position, const Vec3D& direction) override;