diff options
-rw-r--r-- | backend/ArmorObject.h | 2 | ||||
-rw-r--r-- | backend/Enemy.h | 2 | ||||
-rw-r--r-- | backend/GoldObject.h | 2 | ||||
-rw-r--r-- | backend/List.hpp | 3 | ||||
-rw-r--r-- | backend/Location.h | 4 | ||||
-rw-r--r-- | backend/Object.cpp | 15 | ||||
-rw-r--r-- | backend/Object.h | 6 | ||||
-rwxr-xr-x | backend/check | 11 | ||||
-rw-r--r-- | makefile | 8 |
9 files changed, 41 insertions, 12 deletions
diff --git a/backend/ArmorObject.h b/backend/ArmorObject.h index c8223bc..e9c02d2 100644 --- a/backend/ArmorObject.h +++ b/backend/ArmorObject.h @@ -4,7 +4,7 @@ class ArmorObject : public Object { private: - int protection; + int protection = 0; }; diff --git a/backend/Enemy.h b/backend/Enemy.h index 036c5df..dd33090 100644 --- a/backend/Enemy.h +++ b/backend/Enemy.h @@ -1,7 +1,5 @@ #pragma once class Enemy { -private: - }; diff --git a/backend/GoldObject.h b/backend/GoldObject.h index 0f64ce2..f37b7d9 100644 --- a/backend/GoldObject.h +++ b/backend/GoldObject.h @@ -4,5 +4,5 @@ class GoldObject : public Object { private: - int count; + int count = 0; }; diff --git a/backend/List.hpp b/backend/List.hpp index df44f7a..d6c7738 100644 --- a/backend/List.hpp +++ b/backend/List.hpp @@ -1,7 +1,6 @@ #pragma once -#include <cstdlib> -#include <cstdio> +#include <stdlib.h> template <typename T> struct ListLink { diff --git a/backend/Location.h b/backend/Location.h index 94c3eac..1b23c78 100644 --- a/backend/Location.h +++ b/backend/Location.h @@ -2,8 +2,8 @@ class Location { protected: - Location(); - virtual ~Location(); + Location() = default; + virtual ~Location() = default; friend class LocationFactory; }; diff --git a/backend/Object.cpp b/backend/Object.cpp new file mode 100644 index 0000000..300e6ac --- /dev/null +++ b/backend/Object.cpp @@ -0,0 +1,15 @@ +#include <stdlib.h> + +#include "Object.h" + +Object::~Object() { + if (this->name != nullptr) { + free(const_cast<char *>(this->name)); + this->name = nullptr; + } + if (this->description != nullptr) { + free(const_cast<char *>(this->description)); + this->description = nullptr; + } +} + diff --git a/backend/Object.h b/backend/Object.h index 8127f08..789de25 100644 --- a/backend/Object.h +++ b/backend/Object.h @@ -2,11 +2,11 @@ class Object { private: - const char * name; - const char * description; + const char * name = nullptr; + const char * description = nullptr; protected: - Object(); + Object() = default; virtual ~Object(); friend class ObjectFactory; diff --git a/backend/check b/backend/check new file mode 100755 index 0000000..445dbbe --- /dev/null +++ b/backend/check @@ -0,0 +1,11 @@ +#!/bin/sh +for file in *.cpp *.hpp *.h ; do + # non C-style headers + grep -Hn '#include\s*<[^.]\+>' "$file" + # forbidden STL containers + grep -Hn '\<make_unique\>' "$file" + grep -Hn '\<vector\>' "$file" + grep -Hn '\<pair\>' "$file" +done +exit 0 + @@ -1,7 +1,13 @@ .PHONY: FORCE +CXXFLAGS += -std=c++20 +LDFLAGS += -lstdc++ + OBJS += main.o -OBJS += backend/List.o +OBJS += backend/EnemyFactory.o +OBJS += backend/LocationFactory.o +OBJS += backend/ObjectFactory.o +OBJS += backend/Object.o main: $(OBJS) |