1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-20 20:23:03 +02:00

Remove more redundant virtual specifiers

`grep -nr "virtual " | grep -v googletest | grep " override" | grep -v overriden > ../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(":",2)
        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)
```
This commit is contained in:
Alexander Wilms 2024-02-13 15:21:30 +01:00
parent 7cf5e317a4
commit 678cacbd25
44 changed files with 76 additions and 76 deletions

View File

@ -25,8 +25,8 @@ namespace Goals
{
}
virtual Goals::TGoalVec decompose() const override;
virtual std::string toString() const override;
Goals::TGoalVec decompose() const override;
std::string toString() const override;
bool operator==(const BuildingBehavior & other) const override
{
return true;

View File

@ -24,8 +24,8 @@ namespace Goals
{
}
virtual Goals::TGoalVec decompose() const override;
virtual std::string toString() const override;
Goals::TGoalVec decompose() const override;
std::string toString() const override;
bool operator==(const BuyArmyBehavior & other) const override
{
return true;

View File

@ -48,8 +48,8 @@ namespace Goals
specificObjects = true;
}
virtual Goals::TGoalVec decompose() const override;
virtual std::string toString() const override;
Goals::TGoalVec decompose() const override;
std::string toString() const override;
CaptureObjectsBehavior & ofType(int type)
{

View File

@ -29,7 +29,7 @@ namespace Goals
}
TGoalVec decompose() const override;
virtual std::string toString() const override;
std::string toString() const override;
bool operator==(const ClusterBehavior & other) const override
{

View File

@ -29,8 +29,8 @@ namespace Goals
{
}
virtual Goals::TGoalVec decompose() const override;
virtual std::string toString() const override;
Goals::TGoalVec decompose() const override;
std::string toString() const override;
bool operator==(const DefenceBehavior & other) const override
{

View File

@ -26,7 +26,7 @@ namespace Goals
}
TGoalVec decompose() const override;
virtual std::string toString() const override;
std::string toString() const override;
bool operator==(const GatherArmyBehavior & other) const override
{

View File

@ -26,7 +26,7 @@ namespace Goals
}
TGoalVec decompose() const override;
virtual std::string toString() const override;
std::string toString() const override;
bool operator==(const RecruitHeroBehavior & other) const override
{

View File

@ -26,7 +26,7 @@ namespace Goals
}
TGoalVec decompose() const override;
virtual std::string toString() const override;
std::string toString() const override;
bool operator==(const StartupBehavior & other) const override
{

View File

@ -26,7 +26,7 @@ namespace Goals
}
TGoalVec decompose() const override;
virtual std::string toString() const override;
std::string toString() const override;
bool operator==(const StayAtTownBehavior & other) const override
{

View File

@ -702,7 +702,7 @@ int32_t RewardEvaluator::getGoldReward(const CGObjectInstance * target, const CG
class HeroExchangeEvaluator : public IEvaluationContextBuilder
{
public:
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::HERO_EXCHANGE)
return;
@ -719,7 +719,7 @@ public:
class ArmyUpgradeEvaluator : public IEvaluationContextBuilder
{
public:
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::ARMY_UPGRADE)
return;
@ -736,7 +736,7 @@ public:
class StayAtTownManaRecoveryEvaluator : public IEvaluationContextBuilder
{
public:
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::STAY_AT_TOWN)
return;
@ -771,7 +771,7 @@ void addTileDanger(EvaluationContext & evaluationContext, const int3 & tile, uin
class DefendTownEvaluator : public IEvaluationContextBuilder
{
public:
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::DEFEND_TOWN)
return;
@ -821,7 +821,7 @@ private:
public:
ExecuteHeroChainEvaluationContextBuilder(const Nullkiller * ai) : ai(ai) {}
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::EXECUTE_HERO_CHAIN)
return;
@ -879,7 +879,7 @@ class ClusterEvaluationContextBuilder : public IEvaluationContextBuilder
public:
ClusterEvaluationContextBuilder(const Nullkiller * ai) {}
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::UNLOCK_CLUSTER)
return;
@ -926,7 +926,7 @@ public:
class ExchangeSwapTownHeroesContextBuilder : public IEvaluationContextBuilder
{
public:
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::EXCHANGE_SWAP_TOWN_HEROES)
return;
@ -954,7 +954,7 @@ private:
public:
DismissHeroContextBuilder(const Nullkiller * ai) : ai(ai) {}
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::DISMISS_HERO)
return;
@ -974,7 +974,7 @@ public:
class BuildThisEvaluationContextBuilder : public IEvaluationContextBuilder
{
public:
virtual void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
void buildEvaluationContext(EvaluationContext & evaluationContext, Goals::TSubgoal task) const override
{
if(task->goalType != Goals::BUILD_STRUCTURE)
return;

View File

@ -40,7 +40,7 @@ namespace Goals
BuildThis(BuildingID Bid, const CGTownInstance * tid);
bool operator==(const BuildThis & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
void accept(AIGateway * ai) override;
};
}

View File

@ -38,7 +38,7 @@ namespace Goals
bool operator==(const BuyArmy & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
void accept(AIGateway * ai) override;
};

View File

@ -92,7 +92,7 @@ namespace Goals
bool isElementar() const override { return true; }
virtual HeroPtr getHero() const override { return AbstractGoal::hero; }
HeroPtr getHero() const override { return AbstractGoal::hero; }
int getHeroExchangeCount() const override { return 0; }
};

View File

@ -35,8 +35,8 @@ namespace Goals
}
bool operator==(const CaptureObject & other) const override;
virtual Goals::TGoalVec decompose() const override;
virtual std::string toString() const override;
Goals::TGoalVec decompose() const override;
std::string toString() const override;
bool hasHash() const override { return true; }
uint64_t getHash() const override;
};

View File

@ -29,8 +29,8 @@ namespace Goals
{
}
virtual Goals::TGoalVec decompose() const override;
virtual std::string toString() const override;
Goals::TGoalVec decompose() const override;
std::string toString() const override;
bool hasHash() const override { return true; }
uint64_t getHash() const override;

View File

@ -27,7 +27,7 @@ namespace Goals
}
bool operator==(const Composition & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
void accept(AIGateway * ai) override;
Composition & addNext(const AbstractGoal & goal);
Composition & addNext(TSubgoal goal);

View File

@ -37,7 +37,7 @@ namespace Goals
return true;
}
virtual std::string toString() const override
std::string toString() const override
{
return "Invalid";
}

View File

@ -43,7 +43,7 @@ namespace Goals
return true;
}
virtual std::string toString() const override;
std::string toString() const override;
void accept(AIGateway * ai) override;
};
}

View File

@ -27,7 +27,7 @@ namespace Goals
StayAtTown(const CGTownInstance * town, AIPath & path);
bool operator==(const StayAtTown & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
void accept(AIGateway * ai) override;
float getMovementWasted() const { return movementWasted; }
};

View File

@ -30,7 +30,7 @@ namespace Goals
ArmyUpgrade(const CGHeroInstance * targetMain, const CGObjectInstance * upgrader, const ArmyUpgradeInfo & upgrade);
bool operator==(const ArmyUpgrade & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
uint64_t getUpgradeValue() const { return upgradeValue; }
uint64_t getInitialArmyValue() const { return initialValue; }

View File

@ -31,7 +31,7 @@ namespace Goals
DefendTown(const CGTownInstance * town, const HitMapInfo & treat, const CGHeroInstance * defender);
bool operator==(const DefendTown & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
const HitMapInfo & getTreat() const { return treat; }

View File

@ -29,7 +29,7 @@ namespace Goals
}
bool operator==(const HeroExchange & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
uint64_t getReinforcementArmyStrength() const;
};

View File

@ -37,7 +37,7 @@ namespace Goals
}
bool operator==(const UnlockCluster & other) const override;
virtual std::string toString() const override;
std::string toString() const override;
std::shared_ptr<ObjectCluster> getCluster() const { return cluster; }
const AIPath & getPathToCenter() { return pathToCenter; }
};

View File

@ -188,7 +188,7 @@ public:
bool selectFirstActor();
bool selectNextActor();
virtual std::vector<CGPathNode *> getInitialNodes() override;
std::vector<CGPathNode *> getInitialNodes() override;
virtual std::vector<CGPathNode *> calculateNeighbours(
const PathNodeInfo & source,

View File

@ -40,7 +40,7 @@ namespace AIPathfinding
bool canAct(const AIPathNode * source) const override;
virtual std::string toString() const override;
std::string toString() const override;
};
class WaterWalkingAction : public AdventureCastAction

View File

@ -30,7 +30,7 @@ namespace AIPathfinding
void execute(const CGHeroInstance * hero) const override;
virtual std::string toString() const override;
std::string toString() const override;
};
}

View File

@ -38,7 +38,7 @@ namespace AIPathfinding
const ChainActor * getActor(const ChainActor * sourceActor) const override;
virtual std::string toString() const override;
std::string toString() const override;
private:
int32_t getManaCost(const CGHeroInstance * hero) const;
@ -60,11 +60,11 @@ namespace AIPathfinding
void execute(const CGHeroInstance * hero) const override;
virtual Goals::TSubgoal decompose(const CGHeroInstance * hero) const override;
Goals::TSubgoal decompose(const CGHeroInstance * hero) const override;
const ChainActor * getActor(const ChainActor * sourceActor) const override;
virtual std::string toString() const override;
std::string toString() const override;
const CGObjectInstance * targetObject() const override;
};

View File

@ -30,11 +30,11 @@ namespace AIPathfinding
bool canAct(const AIPathNode * node) const override;
virtual Goals::TSubgoal decompose(const CGHeroInstance * hero) const override;
Goals::TSubgoal decompose(const CGHeroInstance * hero) const override;
void execute(const CGHeroInstance * hero) const override;
virtual std::string toString() const override;
std::string toString() const override;
};
}

View File

@ -31,7 +31,7 @@ namespace AIPathfinding
void execute(const CGHeroInstance * hero) const override;
virtual std::string toString() const override;
std::string toString() const override;
};
}

View File

@ -136,7 +136,7 @@ private:
public:
ObjectActor(const CGObjectInstance * obj, const CCreatureSet * army, uint64_t chainMask, int initialTurn);
virtual std::string toString() const override;
std::string toString() const override;
const CGObjectInstance * getActorObject() const override;
};
@ -154,7 +154,7 @@ private:
public:
DwellingActor(const CGDwelling * dwelling, uint64_t chainMask, bool waitForGrowth, int dayOfWeek);
~DwellingActor();
virtual std::string toString() const override;
std::string toString() const override;
protected:
int getInitialTurn(bool waitForGrowth, int dayOfWeek);
@ -168,7 +168,7 @@ private:
public:
TownGarrisonActor(const CGTownInstance * town, uint64_t chainMask);
virtual std::string toString() const override;
std::string toString() const override;
};
}

View File

@ -87,7 +87,7 @@ public:
void initialize(const PathfinderOptions & options, const CGameState * gs) override;
virtual std::vector<CGPathNode *> getInitialNodes() override;
std::vector<CGPathNode *> getInitialNodes() override;
virtual std::vector<CGPathNode *> calculateNeighbours(
const PathNodeInfo & source,

View File

@ -25,6 +25,6 @@ namespace AIPathfinding
{
}
virtual Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
};
}

View File

@ -40,7 +40,7 @@ namespace AIPathfinding
{
}
virtual Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
virtual void applyOnDestination(
const CGHeroInstance * hero,
@ -66,6 +66,6 @@ namespace AIPathfinding
{
}
virtual Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
};
}

View File

@ -27,6 +27,6 @@ namespace AIPathfinding
{
}
virtual Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
Goals::TSubgoal whatToDo(const HeroPtr & hero) const override;
};
}

View File

@ -70,8 +70,8 @@ public:
const std::string & identifier,
size_t index) override;
virtual const std::vector<std::string> & getTypeNames() const override;
virtual std::vector<JsonNode> loadLegacyData() override;
const std::vector<std::string> & getTypeNames() const override;
std::vector<JsonNode> loadLegacyData() override;
};
VCMI_LIB_NAMESPACE_END

View File

@ -127,7 +127,7 @@ public:
ArtPlacementMap putArtifact(ArtifactPosition pos, CArtifactInstance * art) override;//from CArtifactSet
void removeArtifact(ArtifactPosition pos) override;
ArtBearer::ArtBearer bearerType() const override; //from CArtifactSet
virtual std::string nodeName() const override; //from CBonusSystemnode
std::string nodeName() const override; //from CBonusSystemnode
void deserializationFix();
PlayerColor getOwner() const override;
};

View File

@ -185,7 +185,7 @@ public:
//objects
const CGObjectInstance * getObj(ObjectInstanceID objid, bool verbose = true) const override;
virtual std::vector <const CGObjectInstance * > getBlockingObjs(int3 pos)const;
virtual std::vector <const CGObjectInstance * > getVisitableObjs(int3 pos, bool verbose = true) const override;
std::vector <const CGObjectInstance * > getVisitableObjs(int3 pos, bool verbose = true) const override;
virtual std::vector <const CGObjectInstance * > getFlaggableObjects(int3 pos) const;
virtual const CGObjectInstance * getTopObj (int3 pos) const;
virtual PlayerColor getOwner(ObjectInstanceID heroID) const;

View File

@ -150,17 +150,17 @@ public:
void battleNewRound(const BattleID & battleID) override;
void battleCatapultAttacked(const BattleID & battleID, const CatapultAttack & ca) override;
void battleStart(const BattleID & battleID, const CCreatureSet *army1, const CCreatureSet *army2, int3 tile, const CGHeroInstance *hero1, const CGHeroInstance *hero2, bool side, bool replayAllowed) override;
virtual void battleStacksAttacked(const BattleID & battleID, const std::vector<BattleStackAttacked> & bsa, bool ranged) override;
void battleStacksAttacked(const BattleID & battleID, const std::vector<BattleStackAttacked> & bsa, bool ranged) override;
void actionStarted(const BattleID & battleID, const BattleAction &action) override;
void battleNewRoundFirst(const BattleID & battleID) override;
void actionFinished(const BattleID & battleID, const BattleAction &action) override;
void battleStacksEffectsSet(const BattleID & battleID, const SetStackEffect & sse) override;
virtual void battleObstaclesChanged(const BattleID & battleID, const std::vector<ObstacleChanges> & obstacles) override;
virtual void battleStackMoved(const BattleID & battleID, const CStack * stack, std::vector<BattleHex> dest, int distance, bool teleport) override;
void battleObstaclesChanged(const BattleID & battleID, const std::vector<ObstacleChanges> & obstacles) override;
void battleStackMoved(const BattleID & battleID, const CStack * stack, std::vector<BattleHex> dest, int distance, bool teleport) override;
void battleAttack(const BattleID & battleID, const BattleAttack *ba) override;
void battleSpellCast(const BattleID & battleID, const BattleSpellCast *sc) override;
void battleEnd(const BattleID & battleID, const BattleResult *br, QueryID queryID) override;
virtual void battleUnitsChanged(const BattleID & battleID, const std::vector<UnitChanges> & units) override;
void battleUnitsChanged(const BattleID & battleID, const std::vector<UnitChanges> & units) override;
void saveGame(BinarySerializer & h) override;
void loadGame(BinaryDeserializer & h) override;

View File

@ -69,8 +69,8 @@ public:
RiverTypeHandler();
virtual const std::vector<std::string> & getTypeNames() const override;
virtual std::vector<JsonNode> loadLegacyData() override;
const std::vector<std::string> & getTypeNames() const override;
std::vector<JsonNode> loadLegacyData() override;
};
VCMI_LIB_NAMESPACE_END

View File

@ -59,8 +59,8 @@ public:
RoadTypeHandler();
virtual const std::vector<std::string> & getTypeNames() const override;
virtual std::vector<JsonNode> loadLegacyData() override;
const std::vector<std::string> & getTypeNames() const override;
std::vector<JsonNode> loadLegacyData() override;
};
VCMI_LIB_NAMESPACE_END

View File

@ -107,8 +107,8 @@ public:
const std::string & identifier,
size_t index) override;
virtual const std::vector<std::string> & getTypeNames() const override;
virtual std::vector<JsonNode> loadLegacyData() override;
const std::vector<std::string> & getTypeNames() const override;
std::vector<JsonNode> loadLegacyData() override;
};
VCMI_LIB_NAMESPACE_END

View File

@ -48,7 +48,7 @@ public:
}
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
virtual std::string toString() const override;
std::string toString() const override;
JsonNode toJsonNode() const override;
};
@ -61,7 +61,7 @@ public:
}
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
virtual std::string toString() const override;
std::string toString() const override;
JsonNode toJsonNode() const override;
};
@ -74,7 +74,7 @@ public:
}
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
virtual std::string toString() const override;
std::string toString() const override;
JsonNode toJsonNode() const override;
};
@ -97,7 +97,7 @@ public:
}
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus> & b, const CBonusSystemNode & context) const override;
virtual std::string toString() const override;
std::string toString() const override;
JsonNode toJsonNode() const override;
};
@ -110,7 +110,7 @@ public:
}
std::shared_ptr<Bonus> createUpdatedBonus(const std::shared_ptr<Bonus>& b, const CBonusSystemNode& context) const override;
virtual std::string toString() const override;
std::string toString() const override;
JsonNode toJsonNode() const override;
};

View File

@ -34,7 +34,7 @@ public:
void initialize(const PathfinderOptions & options, const CGameState * gs) override;
virtual ~NodeStorage() = default;
virtual std::vector<CGPathNode *> getInitialNodes() override;
std::vector<CGPathNode *> getInitialNodes() override;
virtual std::vector<CGPathNode *> calculateNeighbours(
const PathNodeInfo & source,

View File

@ -27,8 +27,8 @@ public:
std::vector<JsonNode> loadLegacyData() override;
/// loads single object into game. Scope is namespace of this object, same as name of source mod
virtual void loadObject(std::string scope, std::string name, const JsonNode & data) override;
virtual void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
void loadObject(std::string scope, std::string name, const JsonNode & data) override;
void loadObject(std::string scope, std::string name, const JsonNode & data, size_t index) override;
void afterLoadFinalization() override;