浏览代码

Rename ambiguos 'clear' to 'clearSlots'

A lot of map objects inherit from CCreatureSet and as result - get
clean() method that resets object army
Ivan Savenko 2 年之前
父节点
当前提交
e57f8742cd

+ 1 - 1
AI/Nullkiller/Analyzers/ArmyManager.cpp

@@ -170,7 +170,7 @@ std::vector<SlotInfo> ArmyManager::getBestArmy(const IBonusBearer * armyCarrier,
 
 		std::vector<SlotInfo> newArmy;
 		uint64_t newValue = 0;
-		newArmyInstance.clear();
+		newArmyInstance.clearSlots();
 
 		for(auto & slot : sortedSlots)
 		{

+ 4 - 4
lib/CCreatureSet.cpp

@@ -445,7 +445,7 @@ void CCreatureSet::setStackExp(const SlotID & slot, TExpType exp)
 	stacks[slot]->experience = exp;
 }
 
-void CCreatureSet::clear()
+void CCreatureSet::clearSlots()
 {
 	while(!stacks.empty())
 	{
@@ -533,12 +533,12 @@ void CCreatureSet::changeStackCount(const SlotID & slot, TQuantity toAdd)
 
 CCreatureSet::~CCreatureSet()
 {
-	clear();
+	clearSlots();
 }
 
 void CCreatureSet::setToArmy(CSimpleArmy &src)
 {
-	clear();
+	clearSlots();
 	while(src)
 	{
 		auto i = src.army.begin();
@@ -1050,7 +1050,7 @@ void CStackBasicDescriptor::serializeJson(JsonSerializeFormat & handler)
 	}
 }
 
-void CSimpleArmy::clear()
+void CSimpleArmy::clearSlots()
 {
 	army.clear();
 }

+ 3 - 3
lib/CCreatureSet.h

@@ -181,7 +181,7 @@ using TCreatureQueue = std::priority_queue<TPairCreatureSlot, std::vector<TPairC
 class IArmyDescriptor
 {
 public:
-	virtual void clear() = 0;
+	virtual void clearSlots() = 0;
 	virtual bool setCreature(SlotID slot, CreatureID cre, TQuantity count) = 0;
 };
 
@@ -190,7 +190,7 @@ class DLL_LINKAGE CSimpleArmy : public IArmyDescriptor
 {
 public:
 	TSimpleSlots army;
-	void clear() override;
+	void clearSlots() override;
 	bool setCreature(SlotID slot, CreatureID cre, TQuantity count) override;
 	operator bool() const;
 
@@ -226,7 +226,7 @@ public:
 
 	void addToSlot(const SlotID & slot, const CreatureID & cre, TQuantity count, bool allowMerging = true); //Adds stack to slot. Slot must be empty or with same type creature
 	void addToSlot(const SlotID & slot, CStackInstance * stack, bool allowMerging = true); //Adds stack to slot. Slot must be empty or with same type creature
-	void clear() override;
+	void clearSlots() override;
 	void setFormation(bool tight);
 	CArmedInstance *castToArmyObj();
 

+ 1 - 1
lib/NetPacks.h

@@ -335,7 +335,7 @@ struct DLL_LINKAGE SetAvailableHero : public CPackForClient
 {
 	SetAvailableHero()
 	{
-		army.clear();
+		army.clearSlots();
 	}
 	void applyGs(CGameState * gs);
 

+ 1 - 1
lib/mapObjects/CBank.cpp

@@ -58,7 +58,7 @@ std::string CBank::getHoverText(PlayerColor player) const
 void CBank::setConfig(const BankConfig & config)
 {
 	bc = std::make_unique<BankConfig>(config);
-	clear(); // remove all stacks, if any
+	clearSlots(); // remove all stacks, if any
 
 	for(const auto & stack : config.guards)
 		setCreature (SlotID(stacksCount()), stack.type->getId(), stack.count);

+ 1 - 1
mapeditor/inspector/rewardswidget.cpp

@@ -222,7 +222,7 @@ bool RewardsWidget::commitChanges()
 		pandora->resources = ResourceSet();
 		pandora->artifacts.clear();
 		pandora->spells.clear();
-		pandora->creatures.clear();
+		pandora->creatures.clearSlots();
 		
 		for(int row = 0; row < rewards; ++row)
 		{

+ 2 - 2
server/HeroPoolProcessor.cpp

@@ -112,7 +112,7 @@ void HeroPoolProcessor::onHeroEscaped(const PlayerColor & color, const CGHeroIns
 	sah.slotID = selectSlotForRole(color, sah.roleID);
 	sah.player = color;
 	sah.hid = hero->subID;
-	sah.army.clear();
+	sah.army.clearSlots();
 	sah.army.setCreature(SlotID(0), hero->type->initialArmy.at(0).creature, 1);
 
 	gameHandler->sendAndApply(&sah);
@@ -148,7 +148,7 @@ void HeroPoolProcessor::selectNewHeroForSlot(const PlayerColor & color, TavernHe
 		else
 		{
 			sah.roleID = TavernSlotRole::SINGLE_UNIT;
-			sah.army.clear();
+			sah.army.clearSlots();
 			sah.army.setCreature(SlotID(0), newHero->type->initialArmy[0].creature, 1);
 		}
 	}