1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-03-31 22:05:10 +02:00

Remove incorrect destructors - fl::Engine is responsible for these

This commit is contained in:
Dydzio 2018-08-06 19:47:08 +02:00
parent 2079ae6190
commit e89c7eeba4
2 changed files with 1 additions and 39 deletions

View File

@ -278,22 +278,6 @@ float TacticalAdvantageEngine::getTacticalAdvantage(const CArmedInstance * we, c
return output; return output;
} }
TacticalAdvantageEngine::~TacticalAdvantageEngine()
{
//TODO: smart pointers?
delete ourWalkers;
delete ourShooters;
delete ourFlyers;
delete enemyWalkers;
delete enemyShooters;
delete enemyFlyers;
delete ourSpeed;
delete enemySpeed;
delete bankPresent;
delete castleWalls;
delete threat;
}
//std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec) //std::shared_ptr<AbstractGoal> chooseSolution (std::vector<std::shared_ptr<AbstractGoal>> & vec)
Goals::TSubgoal FuzzyHelper::chooseSolution(Goals::TGoalVec vec) Goals::TSubgoal FuzzyHelper::chooseSolution(Goals::TGoalVec vec)
@ -427,14 +411,6 @@ void HeroMovementGoalEngineBase::setSharedFuzzyVariables(Goals::AbstractGoal & g
} }
} }
HeroMovementGoalEngineBase::~HeroMovementGoalEngineBase()
{
delete strengthRatio;
delete heroStrength;
delete turnDistance;
delete missionImportance;
}
float FuzzyHelper::evaluate(Goals::VisitTile & g) float FuzzyHelper::evaluate(Goals::VisitTile & g)
{ {
return visitTileEngine.evaluate(g); return visitTileEngine.evaluate(g);
@ -553,11 +529,6 @@ GetObjEngine::GetObjEngine()
configure(); configure();
} }
GetObjEngine::~GetObjEngine()
{
delete objectValue;
}
float GetObjEngine::evaluate(Goals::AbstractGoal & goal) float GetObjEngine::evaluate(Goals::AbstractGoal & goal)
{ {
auto g = dynamic_cast<Goals::GetObj &>(goal); auto g = dynamic_cast<Goals::GetObj &>(goal);
@ -603,10 +574,6 @@ VisitTileEngine::VisitTileEngine() //so far no VisitTile-specific variables that
configure(); configure();
} }
VisitTileEngine::~VisitTileEngine()
{
}
float VisitTileEngine::evaluate(Goals::AbstractGoal & goal) float VisitTileEngine::evaluate(Goals::AbstractGoal & goal)
{ {
auto g = dynamic_cast<Goals::VisitTile &>(goal); auto g = dynamic_cast<Goals::VisitTile &>(goal);

View File

@ -16,7 +16,7 @@ class CArmedInstance;
class CBank; class CBank;
struct SectorMap; struct SectorMap;
class engineBase class engineBase //subclasses create fuzzylite variables with "new" that are not freed - this is desired as fl::Engine wants to destroy these...
{ {
protected: protected:
fl::Engine engine; fl::Engine engine;
@ -31,9 +31,7 @@ class TacticalAdvantageEngine : public engineBase
{ {
public: public:
TacticalAdvantageEngine(); TacticalAdvantageEngine();
float getTacticalAdvantage(const CArmedInstance * we, const CArmedInstance * enemy); //returns factor how many times enemy is stronger than us float getTacticalAdvantage(const CArmedInstance * we, const CArmedInstance * enemy); //returns factor how many times enemy is stronger than us
~TacticalAdvantageEngine();
private: private:
fl::InputVariable * ourWalkers, *ourShooters, *ourFlyers, *enemyWalkers, *enemyShooters, *enemyFlyers; fl::InputVariable * ourWalkers, *ourShooters, *ourFlyers, *enemyWalkers, *enemyShooters, *enemyFlyers;
fl::InputVariable * ourSpeed, *enemySpeed; fl::InputVariable * ourSpeed, *enemySpeed;
@ -48,7 +46,6 @@ public:
HeroMovementGoalEngineBase(); HeroMovementGoalEngineBase();
virtual float evaluate(Goals::AbstractGoal & goal) = 0; virtual float evaluate(Goals::AbstractGoal & goal) = 0;
virtual ~HeroMovementGoalEngineBase();
protected: protected:
void setSharedFuzzyVariables(Goals::AbstractGoal & goal); void setSharedFuzzyVariables(Goals::AbstractGoal & goal);
@ -67,7 +64,6 @@ class VisitTileEngine : public HeroMovementGoalEngineBase
{ {
public: public:
VisitTileEngine(); VisitTileEngine();
~VisitTileEngine();
float evaluate(Goals::AbstractGoal & goal) override; float evaluate(Goals::AbstractGoal & goal) override;
}; };
@ -75,7 +71,6 @@ class GetObjEngine : public HeroMovementGoalEngineBase
{ {
public: public:
GetObjEngine(); GetObjEngine();
~GetObjEngine();
float evaluate(Goals::AbstractGoal & goal) override; float evaluate(Goals::AbstractGoal & goal) override;
protected: protected:
fl::InputVariable * objectValue; fl::InputVariable * objectValue;