Add "final" to all classes from which we dont need to inherit.

master
Vectozavr 2021-10-13 00:18:56 +07:00
parent 4dae42a3ef
commit 1fa718f491
36 changed files with 37 additions and 40 deletions

View File

@ -8,7 +8,7 @@
#include "engine/World.h" #include "engine/World.h"
#include "Player.h" #include "Player.h"
class Bonus : public RigidBody { class Bonus final : public RigidBody {
protected: protected:
std::string _name; std::string _name;
public: public:

View File

@ -8,7 +8,7 @@
#include "engine/network/ClientUDP.h" #include "engine/network/ClientUDP.h"
#include "Player.h" #include "Player.h"
class Client : public ClientUDP { class Client final : public ClientUDP {
private: private:
std::map<sf::Uint16, std::shared_ptr<Player>> _players{}; std::map<sf::Uint16, std::shared_ptr<Player>> _players{};
std::shared_ptr<Player> _player; std::shared_ptr<Player> _player;

View File

@ -16,7 +16,7 @@
#include "weapon/Gold_Ak47.h" #include "weapon/Gold_Ak47.h"
#include "weapon/Rifle.h" #include "weapon/Rifle.h"
class Player : public RigidBody{ class Player final : public RigidBody{
private: private:
double _healthMax = 100; double _healthMax = 100;
double _health = _healthMax; double _health = _healthMax;

View File

@ -9,7 +9,7 @@
#include "engine/Keyboard.h" #include "engine/Keyboard.h"
#include "engine/Mouse.h" #include "engine/Mouse.h"
class PlayerController { class PlayerController final {
private: private:
std::shared_ptr<Player> _player; std::shared_ptr<Player> _player;
std::shared_ptr<Keyboard> _keyboard; std::shared_ptr<Keyboard> _keyboard;

View File

@ -15,7 +15,7 @@ struct BonusInfo {
bool onTheMap = false; bool onTheMap = false;
}; };
class Server : public ServerUDP { class Server final : public ServerUDP {
private: private:
std::map<sf::Uint16, std::shared_ptr<Player>> _players{}; std::map<sf::Uint16, std::shared_ptr<Player>> _players{};
std::map<std::string, BonusInfo> _bonuses{}; std::map<std::string, BonusInfo> _bonuses{};

View File

@ -15,7 +15,7 @@
#include "Server.h" #include "Server.h"
class Shooter : public Engine { class Shooter final : public Engine {
private: private:
std::shared_ptr<Player> player; std::shared_ptr<Player> player;
std::shared_ptr<PlayerController> playerController; std::shared_ptr<PlayerController> playerController;

View File

@ -10,7 +10,7 @@
#include "Plane.h" #include "Plane.h"
#include "Mesh.h" #include "Mesh.h"
class Camera : public Object{ class Camera final : public Object{
private: private:
Matrix4x4 _S; // screen space matrix Matrix4x4 _S; // screen space matrix
Matrix4x4 _P; // projections matrix Matrix4x4 _P; // projections matrix

View File

@ -7,7 +7,7 @@
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
class Keyboard { class Keyboard final {
private: private:
std::map<sf::Keyboard::Key, double> _tappedKeys; std::map<sf::Keyboard::Key, double> _tappedKeys;
public: public:

View File

@ -9,7 +9,7 @@
#include "Point4D.h" #include "Point4D.h"
#include "Vec3D.h" #include "Vec3D.h"
class Matrix4x4 { class Matrix4x4 final {
private: private:
std::array<std::array<double, 4>, 4> _arr{}; std::array<std::array<double, 4>, 4> _arr{};

View File

@ -9,7 +9,7 @@
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
#include "Vec2D.h" #include "Vec2D.h"
class Mouse { class Mouse final {
private: private:
std::shared_ptr<sf::RenderWindow> _window; std::shared_ptr<sf::RenderWindow> _window;

View File

@ -8,7 +8,7 @@
#include "Point4D.h" #include "Point4D.h"
#include "Triangle.h" #include "Triangle.h"
class Plane { class Plane final {
private: private:
// You can define plane by defining the points in 3D space // You can define plane by defining the points in 3D space
Triangle _triangle; Triangle _triangle;

View File

@ -8,7 +8,7 @@
#include <array> #include <array>
#include "Consts.h" #include "Consts.h"
class Point4D { class Point4D final {
private: private:
std::array<double, 4> _arr_point{}; std::array<double, 4> _arr_point{};

View File

@ -13,7 +13,7 @@
#include "utils/Time.h" #include "utils/Time.h"
#include "Mouse.h" #include "Mouse.h"
class Screen { class Screen final {
private: private:
int _w = 1920; int _w = 1920;
int _h = 1080; int _h = 1080;

View File

@ -10,12 +10,11 @@
#include "Matrix4x4.h" #include "Matrix4x4.h"
#include <SFML/Graphics.hpp> #include <SFML/Graphics.hpp>
class Triangle { class Triangle final {
private: private:
sf::Color _color; sf::Color _color;
std::vector<Point4D> _points; std::vector<Point4D> _points;
public: public:
Triangle (); Triangle ();
Triangle (const Triangle& triangle); Triangle (const Triangle& triangle);
Triangle (const Point4D& p1, const Point4D& p2, const Point4D& p3, sf::Color color = {0, 0, 0}); Triangle (const Point4D& p1, const Point4D& p2, const Point4D& p3, sf::Color color = {0, 0, 0});

View File

@ -9,14 +9,14 @@
#include <array> #include <array>
#include "Point4D.h" #include "Point4D.h"
class Vec2D { class Vec2D final {
private: private:
std::array<double, 2> _arr_point{}; std::array<double, 2> _arr_point{};
public: public:
Vec2D () = default; Vec2D () = default;
Vec2D (const Vec2D& vec); Vec2D (const Vec2D& vec);
Vec2D (const Point4D& point4D); explicit Vec2D (const Point4D& point4D);
explicit Vec2D (double x, double y = 0.0); explicit Vec2D (double x, double y = 0.0);
Vec2D& operator=(const Vec2D&) = delete; Vec2D& operator=(const Vec2D&) = delete;

View File

@ -8,7 +8,7 @@
#include <array> #include <array>
#include "Point4D.h" #include "Point4D.h"
class Vec3D { class Vec3D final {
private: private:
std::array<double, 3> _arr_point{}; std::array<double, 3> _arr_point{};

View File

@ -9,7 +9,7 @@
#include "Camera.h" #include "Camera.h"
#include "physics/RigidBody.h" #include "physics/RigidBody.h"
class World { class World final {
private: private:
std::map<std::string, std::shared_ptr<RigidBody>> _objects; std::map<std::string, std::shared_ptr<RigidBody>> _objects;
public: public:

View File

@ -8,7 +8,7 @@
#include "Animation.h" #include "Animation.h"
#include "../Mesh.h" #include "../Mesh.h"
class AColor : public Animation { class AColor final : public Animation {
private: private:
std::shared_ptr<Mesh> _mesh; std::shared_ptr<Mesh> _mesh;

View File

@ -9,7 +9,7 @@
#ifndef ENGINE_AFUNCTION_H #ifndef ENGINE_AFUNCTION_H
#define ENGINE_AFUNCTION_H #define ENGINE_AFUNCTION_H
class AFunction : public Animation { class AFunction final : public Animation {
private: private:
int _calls = 0; int _calls = 0;
int _allCalls = 1; int _allCalls = 1;

View File

@ -8,7 +8,7 @@
#include "Animation.h" #include "Animation.h"
#include "../Object.h" #include "../Object.h"
class ARotate : public Animation { class ARotate final : public Animation {
private: private:
std::shared_ptr<Object> _object; std::shared_ptr<Object> _object;

View File

@ -9,7 +9,7 @@
#include "Animation.h" #include "Animation.h"
#include "Mesh.h" #include "Mesh.h"
class AScale : public Animation { class AScale final : public Animation {
private: private:
std::shared_ptr<Mesh> _mesh; std::shared_ptr<Mesh> _mesh;

View File

@ -8,7 +8,7 @@
#include "Animation.h" #include "Animation.h"
#include "../Object.h" #include "../Object.h"
class ATranslate : public Animation { class ATranslate final : public Animation {
private: private:
std::shared_ptr<Object> _object; std::shared_ptr<Object> _object;

View File

@ -8,7 +8,7 @@
#include "Animation.h" #include "Animation.h"
#include "../Object.h" #include "../Object.h"
class ATranslateToPoint : public Animation { class ATranslateToPoint final : public Animation {
private: private:
std::shared_ptr<Object> _object; std::shared_ptr<Object> _object;

View File

@ -7,7 +7,7 @@
#include "Animation.h" #include "Animation.h"
class AWait : public Animation { class AWait final : public Animation {
public: public:
explicit AWait(double duration = 1) { explicit AWait(double duration = 1) {
_duration = duration; _duration = duration;

View File

@ -14,7 +14,7 @@ struct tPos {
int ty; int ty;
}; };
class Button { class Button final {
private: private:
int _x{}; int _x{};
int _y{}; int _y{};

View File

@ -12,7 +12,7 @@
#include "../Screen.h" #include "../Screen.h"
#include "../Mouse.h" #include "../Mouse.h"
class Window { class Window final {
private: private:
std::string _name; std::string _name;
std::string _backTexture; std::string _backTexture;

View File

@ -7,7 +7,7 @@
#include <SFML/Network.hpp> #include <SFML/Network.hpp>
class ReliableMsg class ReliableMsg final
{ {
private: private:
sf::Packet packet; sf::Packet packet;

View File

@ -7,8 +7,7 @@
#include <SFML/Network.hpp> #include <SFML/Network.hpp>
class UDPConnection class UDPConnection final {
{
private: private:
sf::Uint16 _id; sf::Uint16 _id;
sf::IpAddress _ip; sf::IpAddress _ip;

View File

@ -12,8 +12,7 @@
#include "UDPConnection.h" #include "UDPConnection.h"
#include "MsgType.h" #include "MsgType.h"
class UDPSocket class UDPSocket final {
{
private: private:
sf::UdpSocket _socket; sf::UdpSocket _socket;
sf::Uint16 _nextRelyMsgId; sf::Uint16 _nextRelyMsgId;

View File

@ -16,7 +16,7 @@ enum class SimplexType {
Tetrahedron Tetrahedron
}; };
struct Simplex { struct Simplex final {
private: private:
std::deque<Vec3D> _points{}; std::deque<Vec3D> _points{};

View File

@ -7,7 +7,7 @@
#include "RigidBody.h" #include "RigidBody.h"
class Solver { class Solver final {
public: public:
static void solveCollision(std::shared_ptr<RigidBody> obj1, std::shared_ptr<RigidBody> obj2, const CollisionPoint& collision); static void solveCollision(std::shared_ptr<RigidBody> obj1, std::shared_ptr<RigidBody> obj2, const CollisionPoint& collision);
}; };

View File

@ -7,7 +7,7 @@
#include "Weapon.h" #include "Weapon.h"
class Ak47 : public Weapon { class Ak47 final : public Weapon {
public: public:
explicit Ak47(int ammo = 100, const std::string& weaponName = "ak47"); explicit Ak47(int ammo = 100, const std::string& weaponName = "ak47");
}; };

View File

@ -7,7 +7,7 @@
#include "Weapon.h" #include "Weapon.h"
class Gold_Ak47 : public Weapon { class Gold_Ak47 final : public Weapon {
public: 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}) { 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")); fireSound.setBuffer(*ResourceManager::loadSoundBuffer("sound/weapons/ak47.ogg"));

View File

@ -7,7 +7,7 @@
#include "Weapon.h" #include "Weapon.h"
class Gun : public Weapon { class Gun final : public Weapon {
public: public:
explicit Gun(int ammo = 30, const std::string& weaponName = "gun"); explicit Gun(int ammo = 30, const std::string& weaponName = "gun");
}; };

View File

@ -7,7 +7,7 @@
#include "Weapon.h" #include "Weapon.h"
class Rifle : public Weapon { class Rifle final : public Weapon {
public: public:
explicit Rifle(int ammo = 5, const std::string& weaponName = "rifle"); explicit Rifle(int ammo = 5, const std::string& weaponName = "rifle");
}; };

View File

@ -7,7 +7,7 @@
#include "Weapon.h" #include "Weapon.h"
class Shotgun : public Weapon { class Shotgun final : public Weapon {
public: public:
explicit Shotgun(int ammo = 15, const std::string& weaponName = "shotgun"); explicit Shotgun(int ammo = 15, const std::string& weaponName = "shotgun");
std::map<std::string, double> processFire(std::function<std::pair<Vec3D, std::string>(const Vec3D&, const Vec3D&)> rayCastFunction, const Vec3D& position, const Vec3D& direction) override; std::map<std::string, double> processFire(std::function<std::pair<Vec3D, std::string>(const Vec3D&, const Vec3D&)> rayCastFunction, const Vec3D& position, const Vec3D& direction) override;