aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authorNao Pross <naopross@thearcway.org>2018-02-17 22:08:18 +0100
committerNao Pross <naopross@thearcway.org>2018-02-17 22:08:18 +0100
commit7ec2e0fbd6c53faa52ca0e6f2e8e172d3556c81d (patch)
tree3ce33e8d1b83e3adf9b7998fbfc206014e9250e7 /src/main
parentAdd all warning and thread them as errors (diff)
downloadSubconscious-old-7ec2e0fbd6c53faa52ca0e6f2e8e172d3556c81d.tar.gz
Subconscious-old-7ec2e0fbd6c53faa52ca0e6f2e8e172d3556c81d.zip
Fix all warnings (errors with -Werror)
Diffstat (limited to 'src/main')
-rw-r--r--src/main/cpp/Bullet.cpp2
-rw-r--r--src/main/cpp/Map.cpp5
-rw-r--r--src/main/cpp/MeleeWeapon.cpp2
-rw-r--r--src/main/cpp/RangedWeapon.cpp9
-rw-r--r--src/main/cpp/Stick.cpp3
-rw-r--r--src/main/headers/Actor.hpp2
-rw-r--r--src/main/headers/Bullet.hpp3
-rw-r--r--src/main/headers/Item.hpp2
-rw-r--r--src/main/headers/Stick.hpp2
9 files changed, 21 insertions, 9 deletions
diff --git a/src/main/cpp/Bullet.cpp b/src/main/cpp/Bullet.cpp
index c856213..412b5ef 100644
--- a/src/main/cpp/Bullet.cpp
+++ b/src/main/cpp/Bullet.cpp
@@ -1,6 +1,6 @@
#include "Bullet.hpp"
-bool Bullet::decreaseAmount(int qnt)
+bool Bullet::decreaseAmount(unsigned qnt)
{
if (_amount >= qnt) {
_amount = _amount - qnt;
diff --git a/src/main/cpp/Map.cpp b/src/main/cpp/Map.cpp
index 3cb1b9d..d192b3b 100644
--- a/src/main/cpp/Map.cpp
+++ b/src/main/cpp/Map.cpp
@@ -24,6 +24,11 @@ const std::vector<Tile>& Map::tiles() const
bool Map::moveActor(Tile &from, Tile &to)
{
+ if (to.actor() != nullptr)
+ return false;
+
to.actor(from.actor());
from.clearActor();
+
+ return true;
}
diff --git a/src/main/cpp/MeleeWeapon.cpp b/src/main/cpp/MeleeWeapon.cpp
index 8c7ffce..5dd0c0d 100644
--- a/src/main/cpp/MeleeWeapon.cpp
+++ b/src/main/cpp/MeleeWeapon.cpp
@@ -5,7 +5,7 @@
#include <string>
MeleeWeapon::MeleeWeapon(Type t, const std::string &name, bool throwable)
-: Weapon(Item::Type::MELEEWEAPON, name), type(t), _throwable(throwable)
+ : Weapon(Item::Type::MELEEWEAPON, name), type(t), _throwable(throwable)
{
}
diff --git a/src/main/cpp/RangedWeapon.cpp b/src/main/cpp/RangedWeapon.cpp
index 21feae4..6f24666 100644
--- a/src/main/cpp/RangedWeapon.cpp
+++ b/src/main/cpp/RangedWeapon.cpp
@@ -14,20 +14,25 @@ bool RangedWeapon::use(Actor &user, Actor &actor)
actor.damage(user.attack() + _damage - actor.defence());
_charged = false;
}
+
+ return true;
}
bool RangedWeapon::reload(Actor &actor)
{
//TODO add bullet type
std::list<Item*> inventory = actor.inventory();
- for (Item* item : inventory) {
+ for (Item *item : inventory) {
if (item->type == Item::Type::BULLET) {
//TODO get the bullet
- //Bullet* bullet = dynamic_cast <Bullet*> (item);
+ // Bullet *bullet = dynamic_cast <Bullet*> (item);
break;
}
}
+ // TODO remove
+ return true;
+
/*
if (bullet->decreaseAmount(1)) {
_charged = true;
diff --git a/src/main/cpp/Stick.cpp b/src/main/cpp/Stick.cpp
index bc67ccb..0dd7190 100644
--- a/src/main/cpp/Stick.cpp
+++ b/src/main/cpp/Stick.cpp
@@ -7,5 +7,6 @@ Stick::Stick(const std::string &name, int maxUses) : Item(Item::Type::STICK, nam
bool Stick::use(Actor &user, Actor &actor)
{
-
+ // TODO remove placeholder
+ return true;
}
diff --git a/src/main/headers/Actor.hpp b/src/main/headers/Actor.hpp
index 90535b1..1e160f6 100644
--- a/src/main/headers/Actor.hpp
+++ b/src/main/headers/Actor.hpp
@@ -9,8 +9,8 @@
class Actor
{
public:
- const unsigned maxHp;
const std::string name;
+ const unsigned maxHp;
Actor() = delete;
virtual ~Actor();
diff --git a/src/main/headers/Bullet.hpp b/src/main/headers/Bullet.hpp
index 6ab5dbe..b12c614 100644
--- a/src/main/headers/Bullet.hpp
+++ b/src/main/headers/Bullet.hpp
@@ -2,12 +2,13 @@
#define BULLET_HPP
#include "Item.hpp"
+#include "RangedWeapon.hpp"
class Bullet : protected Item
{
public:
virtual bool use(RangedWeapon &weapon);
- virtual bool decreaseAmount(int qnt);
+ virtual bool decreaseAmount(unsigned qnt);
};
#endif
diff --git a/src/main/headers/Item.hpp b/src/main/headers/Item.hpp
index 56f8733..ce0c921 100644
--- a/src/main/headers/Item.hpp
+++ b/src/main/headers/Item.hpp
@@ -31,7 +31,7 @@ protected:
const std::string _name;
- Item(Type t, const std::string &name) : _name(name), type(t) {}
+ Item(Type t, const std::string &name) : type(t), _name(name) {}
};
#endif
diff --git a/src/main/headers/Stick.hpp b/src/main/headers/Stick.hpp
index 724e36d..6421560 100644
--- a/src/main/headers/Stick.hpp
+++ b/src/main/headers/Stick.hpp
@@ -6,7 +6,7 @@
class Stick : public Item
{
public:
- Stick(const std::string &name);
+ Stick(const std::string &name, int maxUses);
bool use(Actor &user, Actor &actor);
protected: