mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-16 10:19:47 +02:00
522cb571b3
`grep -nr virtual | grep -v googletest | grep override > ../redundant_virtual.txt` ```python import os with open("../redundant_virtual.txt") as f: for line in f: print() line: str = line.strip() print(line) tmp = line.split(":") file = tmp[0].strip() code = tmp[-1].strip() print(file) print(code) new_code = code.replace("virtual ", "", 1) # https://superuser.com/a/802490/578501 command = f"export FIND='{code}' && export REPLACE='{new_code}' && ruby -p -i -e \"gsub(ENV['FIND'], ENV['REPLACE'])\" {file}" os.system(command) ```
90 lines
1.9 KiB
C++
90 lines
1.9 KiB
C++
/*
|
|
* CGoal.h, part of VCMI engine
|
|
*
|
|
* Authors: listed in file AUTHORS in main folder
|
|
*
|
|
* License: GNU General Public License v2.0 or later
|
|
* Full text of license available in license.txt file, in main folder
|
|
*
|
|
*/
|
|
#pragma once
|
|
|
|
#include "AbstractGoal.h"
|
|
#include "../FuzzyHelper.h"
|
|
#include "../VCAI.h"
|
|
|
|
struct HeroPtr;
|
|
class VCAI;
|
|
|
|
namespace Goals
|
|
{
|
|
template<typename T> class DLL_EXPORT CGoal : public AbstractGoal
|
|
{
|
|
public:
|
|
CGoal<T>(EGoals goal = INVALID) : AbstractGoal(goal)
|
|
{
|
|
priority = 0;
|
|
isElementar = false;
|
|
isAbstract = false;
|
|
value = 0;
|
|
aid = -1;
|
|
objid = -1;
|
|
resID = -1;
|
|
tile = int3(-1, -1, -1);
|
|
town = nullptr;
|
|
}
|
|
|
|
OSETTER(bool, isElementar)
|
|
OSETTER(bool, isAbstract)
|
|
OSETTER(float, priority)
|
|
OSETTER(int, value)
|
|
OSETTER(int, resID)
|
|
OSETTER(int, objid)
|
|
OSETTER(int, aid)
|
|
OSETTER(int3, tile)
|
|
OSETTER(HeroPtr, hero)
|
|
OSETTER(CGTownInstance *, town)
|
|
OSETTER(int, bid)
|
|
|
|
void accept(VCAI * ai) override
|
|
{
|
|
ai->tryRealize(static_cast<T &>(*this)); //casting enforces template instantiation
|
|
}
|
|
|
|
float accept(FuzzyHelper * f) override
|
|
{
|
|
return f->evaluate(static_cast<T &>(*this)); //casting enforces template instantiation
|
|
}
|
|
|
|
CGoal<T> * clone() const override
|
|
{
|
|
return new T(static_cast<T const &>(*this)); //casting enforces template instantiation
|
|
}
|
|
TSubgoal iAmElementar() const
|
|
{
|
|
TSubgoal ptr;
|
|
|
|
ptr.reset(clone());
|
|
ptr->setisElementar(true);
|
|
|
|
return ptr;
|
|
}
|
|
template<typename Handler> void serialize(Handler & h)
|
|
{
|
|
h & static_cast<AbstractGoal &>(*this);
|
|
//h & goalType & isElementar & isAbstract & priority;
|
|
//h & value & resID & objid & aid & tile & hero & town & bid;
|
|
}
|
|
|
|
bool operator==(const AbstractGoal & g) const override
|
|
{
|
|
if(goalType != g.goalType)
|
|
return false;
|
|
|
|
return (*this) == (static_cast<const T &>(g));
|
|
}
|
|
|
|
virtual bool operator==(const T & other) const = 0;
|
|
};
|
|
}
|