mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-21 17:17:06 +02:00
Replaced public artType member of ArtifactInstance with getter
This commit is contained in:
parent
04ca8aca9f
commit
c98ac01e7a
@ -1055,7 +1055,7 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
|
||||
//FIXME: why are the above possible to be null?
|
||||
|
||||
bool emptySlotFound = false;
|
||||
for(auto slot : artifact->artType->getPossibleSlots().at(target->bearerType()))
|
||||
for(auto slot : artifact->getType()->getPossibleSlots().at(target->bearerType()))
|
||||
{
|
||||
if(target->isPositionFree(slot) && artifact->canBePutAt(target, slot, true)) //combined artifacts are not always allowed to move
|
||||
{
|
||||
@ -1068,7 +1068,7 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
|
||||
}
|
||||
if(!emptySlotFound) //try to put that atifact in already occupied slot
|
||||
{
|
||||
for(auto slot : artifact->artType->getPossibleSlots().at(target->bearerType()))
|
||||
for(auto slot : artifact->getType()->getPossibleSlots().at(target->bearerType()))
|
||||
{
|
||||
auto otherSlot = target->getSlot(slot);
|
||||
if(otherSlot && otherSlot->artifact) //we need to exchange artifact for better one
|
||||
@ -1079,8 +1079,8 @@ void AIGateway::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance
|
||||
{
|
||||
logAi->trace(
|
||||
"Exchange artifacts %s <-> %s",
|
||||
artifact->artType->getNameTranslated(),
|
||||
otherSlot->artifact->artType->getNameTranslated());
|
||||
artifact->getType()->getNameTranslated(),
|
||||
otherSlot->artifact->getType()->getNameTranslated());
|
||||
|
||||
if(!otherSlot->artifact->canBePutAt(artHolder, location.slot, true))
|
||||
{
|
||||
|
@ -267,8 +267,8 @@ bool compareArmyStrength(const CArmedInstance * a1, const CArmedInstance * a2)
|
||||
|
||||
bool compareArtifacts(const CArtifactInstance * a1, const CArtifactInstance * a2)
|
||||
{
|
||||
auto art1 = a1->artType;
|
||||
auto art2 = a2->artType;
|
||||
auto art1 = a1->getType();
|
||||
auto art2 = a2->getType();
|
||||
|
||||
if(art1->getPrice() == art2->getPrice())
|
||||
return art1->valOfBonuses(BonusType::PRIMARY_SKILL) > art2->valOfBonuses(BonusType::PRIMARY_SKILL);
|
||||
|
@ -290,7 +290,7 @@ uint64_t RewardEvaluator::getArmyReward(
|
||||
case Obj::CREATURE_GENERATOR4:
|
||||
return getDwellingArmyValue(ai->cb.get(), target, checkGold);
|
||||
case Obj::ARTIFACT:
|
||||
return evaluateArtifactArmyValue(dynamic_cast<const CGArtifact *>(target)->storedArtifact->artType);
|
||||
return evaluateArtifactArmyValue(dynamic_cast<const CGArtifact *>(target)->storedArtifact->getType());
|
||||
case Obj::HERO:
|
||||
return relations == PlayerRelations::ENEMIES
|
||||
? enemyArmyEliminationRewardRatio * dynamic_cast<const CGHeroInstance *>(target)->getArmyStrength()
|
||||
|
@ -247,8 +247,8 @@ bool compareArmyStrength(const CArmedInstance * a1, const CArmedInstance * a2)
|
||||
|
||||
bool compareArtifacts(const CArtifactInstance * a1, const CArtifactInstance * a2)
|
||||
{
|
||||
auto art1 = a1->artType;
|
||||
auto art2 = a2->artType;
|
||||
auto art1 = a1->getType();
|
||||
auto art2 = a2->getType();
|
||||
|
||||
if(art1->getPrice() == art2->getPrice())
|
||||
return art1->valOfBonuses(BonusType::PRIMARY_SKILL) > art2->valOfBonuses(BonusType::PRIMARY_SKILL);
|
||||
|
@ -92,7 +92,7 @@ std::optional<int> MapObjectsEvaluator::getObjectValue(const CGObjectInstance *
|
||||
else if(obj->ID == Obj::ARTIFACT)
|
||||
{
|
||||
auto artifactObject = dynamic_cast<const CGArtifact *>(obj);
|
||||
switch(artifactObject->storedArtifact->artType->aClass)
|
||||
switch(artifactObject->storedArtifact->getType()->aClass)
|
||||
{
|
||||
case CArtifact::EartClass::ART_TREASURE:
|
||||
return 2000;
|
||||
|
@ -1180,7 +1180,7 @@ void VCAI::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance * ot
|
||||
//FIXME: why are the above possible to be null?
|
||||
|
||||
bool emptySlotFound = false;
|
||||
for(auto slot : artifact->artType->getPossibleSlots().at(target->bearerType()))
|
||||
for(auto slot : artifact->getType()->getPossibleSlots().at(target->bearerType()))
|
||||
{
|
||||
if(target->isPositionFree(slot) && artifact->canBePutAt(target, slot, true)) //combined artifacts are not always allowed to move
|
||||
{
|
||||
@ -1193,7 +1193,7 @@ void VCAI::pickBestArtifacts(const CGHeroInstance * h, const CGHeroInstance * ot
|
||||
}
|
||||
if(!emptySlotFound) //try to put that atifact in already occupied slot
|
||||
{
|
||||
for(auto slot : artifact->artType->getPossibleSlots().at(target->bearerType()))
|
||||
for(auto slot : artifact->getType()->getPossibleSlots().at(target->bearerType()))
|
||||
{
|
||||
auto otherSlot = target->getSlot(slot);
|
||||
if(otherSlot && otherSlot->artifact) //we need to exchange artifact for better one
|
||||
|
@ -71,7 +71,7 @@ bool ArtifactsUIController::askToAssemble(const CGHeroInstance * hero, const Art
|
||||
}
|
||||
|
||||
bool assembleConfirmed = false;
|
||||
MetaString message = MetaString::createFromTextID(art->artType->getDescriptionTextID());
|
||||
MetaString message = MetaString::createFromTextID(art->getType()->getDescriptionTextID());
|
||||
message.appendEOL();
|
||||
message.appendEOL();
|
||||
if(combinedArt->isFused())
|
||||
@ -107,10 +107,10 @@ bool ArtifactsUIController::askToDisassemble(const CGHeroInstance * hero, const
|
||||
|
||||
if(art->hasParts())
|
||||
{
|
||||
if(ArtifactUtils::isSlotBackpack(slot) && !ArtifactUtils::isBackpackFreeSlots(hero, art->artType->getConstituents().size() - 1))
|
||||
if(ArtifactUtils::isSlotBackpack(slot) && !ArtifactUtils::isBackpackFreeSlots(hero, art->getType()->getConstituents().size() - 1))
|
||||
return false;
|
||||
|
||||
MetaString message = MetaString::createFromTextID(art->artType->getDescriptionTextID());
|
||||
MetaString message = MetaString::createFromTextID(art->getType()->getDescriptionTextID());
|
||||
message.appendEOL();
|
||||
message.appendEOL();
|
||||
message.appendRawString(CGI->generaltexth->allTexts[733]); // Do you wish to disassemble this artifact?
|
||||
|
@ -152,7 +152,7 @@ void CArtifactsOfHeroQuickBackpack::setHero(const CGHeroInstance * hero)
|
||||
std::map<const ArtifactID, const CArtifactInstance*> filteredArts;
|
||||
for(auto & slotInfo : curHero->artifactsInBackpack)
|
||||
if(slotInfo.artifact->getTypeId() != artInSlotId && !slotInfo.artifact->isScroll() &&
|
||||
slotInfo.artifact->artType->canBePutAt(curHero, filterBySlot, true))
|
||||
slotInfo.artifact->getType()->canBePutAt(curHero, filterBySlot, true))
|
||||
{
|
||||
filteredArts.insert(std::pair(slotInfo.artifact->getTypeId(), slotInfo.artifact));
|
||||
}
|
||||
|
@ -273,7 +273,7 @@ void CArtifactsOfHeroBase::setSlotData(ArtPlacePtr artPlace, const ArtifactPosit
|
||||
|
||||
// If the artifact is part of at least one combined artifact, add additional information
|
||||
std::map<const ArtifactID, std::vector<ArtifactID>> arts;
|
||||
for(const auto combinedArt : slotInfo->artifact->artType->getPartOf())
|
||||
for(const auto combinedArt : slotInfo->artifact->getType()->getPartOf())
|
||||
{
|
||||
assert(combinedArt->isCombined());
|
||||
arts.try_emplace(combinedArt->getId());
|
||||
|
@ -32,7 +32,7 @@ void CArtifactsOfHeroMarket::clickPressedArtPlace(CComponentHolder & artPlace, c
|
||||
|
||||
if(const auto art = getArt(ownedPlace->slot))
|
||||
{
|
||||
if(onSelectArtCallback && art->artType->isTradable())
|
||||
if(onSelectArtCallback && art->getType()->isTradable())
|
||||
{
|
||||
unmarkSlots();
|
||||
artPlace.selectSlot(true);
|
||||
|
@ -201,7 +201,7 @@ void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr<CTradeableItem> &
|
||||
{
|
||||
if(pickedArtInst->canBePutAt(altarArtifactsStorage))
|
||||
{
|
||||
if(pickedArtInst->artType->isTradable())
|
||||
if(pickedArtInst->getType()->isTradable())
|
||||
{
|
||||
if(altarSlot->id == -1)
|
||||
tradeSlotsMap.try_emplace(altarSlot, pickedArtInst);
|
||||
|
@ -198,7 +198,7 @@ void CWindowWithArtifacts::markPossibleSlots() const
|
||||
continue;
|
||||
|
||||
if(getHeroPickedArtifact() == hero || !std::dynamic_pointer_cast<CArtifactsOfHeroKingdom>(artSet))
|
||||
artSet->markPossibleSlots(pickedArtInst->artType, hero->tempOwner == LOCPLINT->playerID);
|
||||
artSet->markPossibleSlots(pickedArtInst->getType(), hero->tempOwner == LOCPLINT->playerID);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -219,7 +219,7 @@ bool CWindowWithArtifacts::checkSpecialArts(const CArtifactInstance & artInst, c
|
||||
std::vector<std::shared_ptr<CComponent>>(1, std::make_shared<CComponent>(ComponentType::ARTIFACT, ArtifactID(ArtifactID::CATAPULT))));
|
||||
return false;
|
||||
}
|
||||
if(isTrade && !artInst.artType->isTradable())
|
||||
if(isTrade && !artInst.getType()->isTradable())
|
||||
{
|
||||
LOCPLINT->showInfoDialog(CGI->generaltexth->allTexts[21],
|
||||
std::vector<std::shared_ptr<CComponent>>(1, std::make_shared<CComponent>(ComponentType::ARTIFACT, artId)));
|
||||
@ -240,7 +240,7 @@ void CWindowWithArtifacts::setCursorAnimation(const CArtifactInstance & artInst)
|
||||
}
|
||||
else
|
||||
{
|
||||
CCS->curh->dragAndDropCursor(AnimationPath::builtin("artifact"), artInst.artType->getIconIndex());
|
||||
CCS->curh->dragAndDropCursor(AnimationPath::builtin("artifact"), artInst.getType()->getIconIndex());
|
||||
}
|
||||
}
|
||||
|
||||
@ -253,10 +253,10 @@ void CWindowWithArtifacts::putPickedArtifact(const CGHeroInstance & curHero, con
|
||||
|
||||
if(ArtifactUtils::isSlotBackpack(dstLoc.slot))
|
||||
{
|
||||
if(pickedArt->artType->isBig())
|
||||
if(pickedArt->getType()->isBig())
|
||||
{
|
||||
// War machines cannot go to backpack
|
||||
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[153]) % pickedArt->artType->getNameTranslated()));
|
||||
LOCPLINT->showInfoDialog(boost::str(boost::format(CGI->generaltexth->allTexts[153]) % pickedArt->getType()->getNameTranslated()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -732,7 +732,7 @@ ArtifactPosition CArtifactSet::getArtPos(const ArtifactID & aid, bool onlyWorn,
|
||||
for(const auto & artInfo : artifactsInBackpack)
|
||||
{
|
||||
const auto art = artInfo.getArt();
|
||||
if(art && art->artType->getId() == aid)
|
||||
if(art && art->getType()->getId() == aid)
|
||||
return ArtifactPosition(backpackPositionIdx);
|
||||
backpackPositionIdx++;
|
||||
}
|
||||
@ -757,7 +757,7 @@ ArtifactPosition CArtifactSet::getArtPos(const CArtifactInstance * artInst) cons
|
||||
{
|
||||
if(artInst)
|
||||
{
|
||||
for(const auto & slot : artInst->artType->getPossibleSlots().at(bearerType()))
|
||||
for(const auto & slot : artInst->getType()->getPossibleSlots().at(bearerType()))
|
||||
if(getArt(slot) == artInst)
|
||||
return slot;
|
||||
|
||||
@ -805,11 +805,11 @@ CArtifactSet::ArtPlacementMap CArtifactSet::putArtifact(const ArtifactPosition &
|
||||
};
|
||||
|
||||
putToSlot(slot, art, false);
|
||||
if(art->artType->isCombined() && ArtifactUtils::isSlotEquipment(slot))
|
||||
if(art->getType()->isCombined() && ArtifactUtils::isSlotEquipment(slot))
|
||||
{
|
||||
const CArtifactInstance * mainPart = nullptr;
|
||||
for(const auto & part : art->getPartsInfo())
|
||||
if(vstd::contains(part.art->artType->getPossibleSlots().at(bearerType()), slot)
|
||||
if(vstd::contains(part.art->getType()->getPossibleSlots().at(bearerType()), slot)
|
||||
&& (part.slot == ArtifactPosition::PRE_FIRST))
|
||||
{
|
||||
mainPart = part.art;
|
||||
@ -821,7 +821,7 @@ CArtifactSet::ArtPlacementMap CArtifactSet::putArtifact(const ArtifactPosition &
|
||||
if(part.art != mainPart)
|
||||
{
|
||||
auto partSlot = part.slot;
|
||||
if(!part.art->artType->canBePutAt(this, partSlot))
|
||||
if(!part.art->getType()->canBePutAt(this, partSlot))
|
||||
partSlot = ArtifactUtils::getArtAnyPosition(this, part.art->getTypeId());
|
||||
|
||||
assert(ArtifactUtils::isSlotEquipment(partSlot));
|
||||
@ -995,7 +995,7 @@ void CArtifactSet::serializeJsonHero(JsonSerializeFormat & handler)
|
||||
{
|
||||
auto * artifact = ArtifactUtils::createArtifact(artifactID);
|
||||
auto slot = ArtifactPosition::BACKPACK_START + artifactsInBackpack.size();
|
||||
if(artifact->artType->canBePutAt(this, slot))
|
||||
if(artifact->getType()->canBePutAt(this, slot))
|
||||
{
|
||||
auto artsMap = putArtifact(slot, artifact);
|
||||
artifact->addPlacementMap(artsMap);
|
||||
@ -1036,7 +1036,7 @@ void CArtifactSet::serializeJsonSlot(JsonSerializeFormat & handler, const Artifa
|
||||
{
|
||||
auto * artifact = ArtifactUtils::createArtifact(artifactID.toEnum());
|
||||
|
||||
if(artifact->artType->canBePutAt(this, slot))
|
||||
if(artifact->getType()->canBePutAt(this, slot))
|
||||
{
|
||||
auto artsMap = putArtifact(slot, artifact);
|
||||
artifact->addPlacementMap(artsMap);
|
||||
|
@ -20,12 +20,12 @@ VCMI_LIB_NAMESPACE_BEGIN
|
||||
void CCombinedArtifactInstance::addPart(CArtifactInstance * art, const ArtifactPosition & slot)
|
||||
{
|
||||
auto artInst = static_cast<CArtifactInstance*>(this);
|
||||
assert(vstd::contains_if(artInst->artType->getConstituents(),
|
||||
assert(vstd::contains_if(artInst->getType()->getConstituents(),
|
||||
[=](const CArtifact * partType)
|
||||
{
|
||||
return partType->getId() == art->getTypeId();
|
||||
}));
|
||||
assert(art->getParentNodes().size() == 1 && art->getParentNodes().front() == art->artType);
|
||||
assert(art->getParentNodes().size() == 1 && art->getParentNodes().front() == art->getType());
|
||||
partsInfo.emplace_back(art, slot);
|
||||
artInst->attachTo(*art);
|
||||
}
|
||||
@ -77,7 +77,7 @@ void CGrowingArtifactInstance::growingUp()
|
||||
{
|
||||
auto artInst = static_cast<CArtifactInstance*>(this);
|
||||
|
||||
if(artInst->artType->isGrowing())
|
||||
if(artInst->getType()->isGrowing())
|
||||
{
|
||||
|
||||
auto bonus = std::make_shared<Bonus>();
|
||||
@ -86,7 +86,7 @@ void CGrowingArtifactInstance::growingUp()
|
||||
bonus->duration = BonusDuration::COMMANDER_KILLED;
|
||||
artInst->accumulateBonus(bonus);
|
||||
|
||||
for(const auto & bonus : artInst->artType->getBonusesPerLevel())
|
||||
for(const auto & bonus : artInst->getType()->getBonusesPerLevel())
|
||||
{
|
||||
// Every n levels
|
||||
if(artInst->valOfBonuses(BonusType::LEVEL_COUNTER) % bonus.first == 0)
|
||||
@ -94,7 +94,7 @@ void CGrowingArtifactInstance::growingUp()
|
||||
artInst->accumulateBonus(std::make_shared<Bonus>(bonus.second));
|
||||
}
|
||||
}
|
||||
for(const auto & bonus : artInst->artType->getThresholdBonuses())
|
||||
for(const auto & bonus : artInst->getType()->getThresholdBonuses())
|
||||
{
|
||||
// At n level
|
||||
if(artInst->valOfBonuses(BonusType::LEVEL_COUNTER) == bonus.first)
|
||||
@ -125,18 +125,23 @@ CArtifactInstance::CArtifactInstance()
|
||||
|
||||
void CArtifactInstance::setType(const CArtifact * art)
|
||||
{
|
||||
artType = art;
|
||||
artTypeID = art->getId();
|
||||
attachToSource(*art);
|
||||
}
|
||||
|
||||
std::string CArtifactInstance::nodeName() const
|
||||
{
|
||||
return "Artifact instance of " + (artType ? artType->getJsonKey() : std::string("uninitialized")) + " type";
|
||||
return "Artifact instance of " + (getType() ? getType()->getJsonKey() : std::string("uninitialized")) + " type";
|
||||
}
|
||||
|
||||
ArtifactID CArtifactInstance::getTypeId() const
|
||||
{
|
||||
return artType->getId();
|
||||
return artTypeID;
|
||||
}
|
||||
|
||||
const CArtifact * CArtifactInstance::getType() const
|
||||
{
|
||||
return artTypeID.toArtifact();
|
||||
}
|
||||
|
||||
ArtifactInstanceID CArtifactInstance::getId() const
|
||||
@ -151,22 +156,22 @@ void CArtifactInstance::setId(ArtifactInstanceID id)
|
||||
|
||||
bool CArtifactInstance::canBePutAt(const CArtifactSet * artSet, ArtifactPosition slot, bool assumeDestRemoved) const
|
||||
{
|
||||
return artType->canBePutAt(artSet, slot, assumeDestRemoved);
|
||||
return getType()->canBePutAt(artSet, slot, assumeDestRemoved);
|
||||
}
|
||||
|
||||
bool CArtifactInstance::isCombined() const
|
||||
{
|
||||
return artType->isCombined();
|
||||
return getType()->isCombined();
|
||||
}
|
||||
|
||||
bool CArtifactInstance::isScroll() const
|
||||
{
|
||||
return artType->isScroll();
|
||||
return getType()->isScroll();
|
||||
}
|
||||
|
||||
void CArtifactInstance::deserializationFix()
|
||||
{
|
||||
setType(artType);
|
||||
setType(artTypeID.toArtifact());
|
||||
for(PartInfo & part : partsInfo)
|
||||
attachTo(*part.art);
|
||||
}
|
||||
|
@ -73,14 +73,15 @@ protected:
|
||||
void init();
|
||||
|
||||
ArtifactInstanceID id;
|
||||
ArtifactID artTypeID;
|
||||
public:
|
||||
const CArtifact * artType = nullptr;
|
||||
|
||||
CArtifactInstance(const CArtifact * art);
|
||||
CArtifactInstance();
|
||||
void setType(const CArtifact * art);
|
||||
std::string nodeName() const override;
|
||||
ArtifactID getTypeId() const;
|
||||
const CArtifact * getType() const;
|
||||
ArtifactInstanceID getId() const;
|
||||
void setId(ArtifactInstanceID id);
|
||||
|
||||
@ -94,7 +95,7 @@ public:
|
||||
{
|
||||
h & static_cast<CBonusSystemNode&>(*this);
|
||||
h & static_cast<CCombinedArtifactInstance&>(*this);
|
||||
h & artType;
|
||||
h & artTypeID;
|
||||
h & id;
|
||||
BONUS_TREE_DESERIALIZATION_FIX
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ bool CStack::unitHasAmmoCart(const battle::Unit * unit) const
|
||||
const auto * ownerHero = battle->battleGetOwnerHero(unit);
|
||||
if(ownerHero && ownerHero->artifactsWorn.find(ArtifactPosition::MACH2) != ownerHero->artifactsWorn.end())
|
||||
{
|
||||
if(battle->battleGetOwnerHero(unit)->artifactsWorn.at(ArtifactPosition::MACH2).artifact->artType->getId() == ArtifactID::AMMO_CART)
|
||||
if(battle->battleGetOwnerHero(unit)->artifactsWorn.at(ArtifactPosition::MACH2).artifact->getTypeId() == ArtifactID::AMMO_CART)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -303,7 +303,7 @@ BattleInfo * BattleInfo::setupBattle(const int3 & tile, TerrainId terrain, const
|
||||
|
||||
if(nullptr != warMachineArt && hex.isValid())
|
||||
{
|
||||
CreatureID cre = warMachineArt->artType->getWarMachine();
|
||||
CreatureID cre = warMachineArt->getType()->getWarMachine();
|
||||
|
||||
if(cre != CreatureID::NONE)
|
||||
currentBattle->generateNewStack(currentBattle->nextUnitId(), CStackBasicDescriptor(cre, 1), side, SlotID::WAR_MACHINES_SLOT, hex);
|
||||
|
@ -137,18 +137,18 @@ void CGameStateCampaign::trimCrossoverHeroesParameters(const CampaignTravel & tr
|
||||
|
||||
ArtifactLocation al(hero.hero->id, artifactPosition);
|
||||
|
||||
bool takeable = travelOptions.artifactsKeptByHero.count(art->artType->getId());
|
||||
bool takeable = travelOptions.artifactsKeptByHero.count(art->getTypeId());
|
||||
bool locked = hero.hero->getSlot(al.slot)->locked;
|
||||
|
||||
if (!locked && takeable)
|
||||
{
|
||||
logGlobal->debug("Artifact %s from slot %d of hero %s will be transferred to next scenario", art->artType->getJsonKey(), al.slot.getNum(), hero.hero->getHeroTypeName());
|
||||
logGlobal->debug("Artifact %s from slot %d of hero %s will be transferred to next scenario", art->getType()->getJsonKey(), al.slot.getNum(), hero.hero->getHeroTypeName());
|
||||
hero.transferrableArtifacts.push_back(artifactPosition);
|
||||
}
|
||||
|
||||
if (!locked && !takeable)
|
||||
{
|
||||
logGlobal->debug("Removing artifact %s from slot %d of hero %s", art->artType->getJsonKey(), al.slot.getNum(), hero.hero->getHeroTypeName());
|
||||
logGlobal->debug("Removing artifact %s from slot %d of hero %s", art->getType()->getJsonKey(), al.slot.getNum(), hero.hero->getHeroTypeName());
|
||||
gameState->map->removeArtifactInstance(*hero.hero, al.slot);
|
||||
return true;
|
||||
}
|
||||
@ -424,12 +424,12 @@ void CGameStateCampaign::transferMissingArtifacts(const CampaignTravel & travelO
|
||||
{
|
||||
auto * artifact = donorHero->getArt(artLocation);
|
||||
|
||||
logGlobal->debug("Removing artifact %s from slot %d of hero %s for transfer", artifact->artType->getJsonKey(), artLocation.getNum(), donorHero->getHeroTypeName());
|
||||
logGlobal->debug("Removing artifact %s from slot %d of hero %s for transfer", artifact->getType()->getJsonKey(), artLocation.getNum(), donorHero->getHeroTypeName());
|
||||
gameState->map->removeArtifactInstance(*donorHero, artLocation);
|
||||
|
||||
if (receiver)
|
||||
{
|
||||
logGlobal->debug("Granting artifact %s to hero %s for transfer", artifact->artType->getJsonKey(), receiver->getHeroTypeName());
|
||||
logGlobal->debug("Granting artifact %s to hero %s for transfer", artifact->getType()->getJsonKey(), receiver->getHeroTypeName());
|
||||
|
||||
const auto slot = ArtifactUtils::getArtAnyPosition(receiver, artifact->getTypeId());
|
||||
if(ArtifactUtils::isSlotEquipment(slot) || ArtifactUtils::isSlotBackpack(slot))
|
||||
|
@ -775,13 +775,13 @@ void CGArtifact::initObj(vstd::RNG & rand)
|
||||
storedArtifact = ArtifactUtils::createArtifact(ArtifactID());
|
||||
cb->gameState()->map->addNewArtifactInstance(storedArtifact);
|
||||
}
|
||||
if(!storedArtifact->artType)
|
||||
if(!storedArtifact->getType())
|
||||
storedArtifact->setType(getArtifact().toArtifact());
|
||||
}
|
||||
if(ID == Obj::SPELL_SCROLL)
|
||||
subID = 1;
|
||||
|
||||
assert(storedArtifact->artType);
|
||||
assert(storedArtifact->getType());
|
||||
assert(!storedArtifact->getParentNodes().empty());
|
||||
|
||||
//assert(storedArtifact->artType->id == subID); //this does not stop desync
|
||||
@ -825,7 +825,7 @@ void CGArtifact::onHeroVisit(const CGHeroInstance * h) const
|
||||
iw.type = EInfoWindowMode::AUTO;
|
||||
iw.player = h->tempOwner;
|
||||
|
||||
if(storedArtifact->artType->canBePutAt(h))
|
||||
if(storedArtifact->getType()->canBePutAt(h))
|
||||
{
|
||||
switch (ID.toEnum())
|
||||
{
|
||||
|
@ -1208,7 +1208,7 @@ void RemoveObject::applyGs(CGameState *gs)
|
||||
beatenHero->tempOwner = PlayerColor::NEUTRAL; //no one owns beaten hero
|
||||
vstd::erase_if(beatenHero->artifactsInBackpack, [](const ArtSlotInfo& asi)
|
||||
{
|
||||
return asi.artifact->artType->getId() == ArtifactID::GRAIL;
|
||||
return asi.artifact->getTypeId() == ArtifactID::GRAIL;
|
||||
});
|
||||
|
||||
if(beatenHero->visitedTown)
|
||||
@ -1733,7 +1733,7 @@ void BulkEraseArtifacts::applyGs(CGameState *gs)
|
||||
const auto slotInfo = artSet->getSlot(slot);
|
||||
if(slotInfo->locked)
|
||||
{
|
||||
logGlobal->debug("Erasing locked artifact: %s", slotInfo->artifact->artType->getNameTranslated());
|
||||
logGlobal->debug("Erasing locked artifact: %s", slotInfo->artifact->getType()->getNameTranslated());
|
||||
DisassembledArtifact dis;
|
||||
dis.al.artHolder = artHolder;
|
||||
|
||||
@ -1747,12 +1747,12 @@ void BulkEraseArtifacts::applyGs(CGameState *gs)
|
||||
}
|
||||
}
|
||||
assert((dis.al.slot != ArtifactPosition::PRE_FIRST) && "Failed to determine the assembly this locked artifact belongs to");
|
||||
logGlobal->debug("Found the corresponding assembly: %s", artSet->getArt(dis.al.slot)->artType->getNameTranslated());
|
||||
logGlobal->debug("Found the corresponding assembly: %s", artSet->getArt(dis.al.slot)->getType()->getNameTranslated());
|
||||
dis.applyGs(gs);
|
||||
}
|
||||
else
|
||||
{
|
||||
logGlobal->debug("Erasing artifact %s", slotInfo->artifact->artType->getNameTranslated());
|
||||
logGlobal->debug("Erasing artifact %s", slotInfo->artifact->getType()->getNameTranslated());
|
||||
}
|
||||
gs->map->removeArtifactInstance(*artSet, slot);
|
||||
}
|
||||
@ -1840,8 +1840,8 @@ void AssembledArtifact::applyGs(CGameState *gs)
|
||||
break;
|
||||
}
|
||||
|
||||
if(!vstd::contains(combinedArt->artType->getPossibleSlots().at(hero->bearerType()), al.slot)
|
||||
&& vstd::contains(combinedArt->artType->getPossibleSlots().at(hero->bearerType()), slot))
|
||||
if(!vstd::contains(combinedArt->getType()->getPossibleSlots().at(hero->bearerType()), al.slot)
|
||||
&& vstd::contains(combinedArt->getType()->getPossibleSlots().at(hero->bearerType()), slot))
|
||||
al.slot = slot;
|
||||
}
|
||||
else
|
||||
@ -1857,7 +1857,7 @@ void AssembledArtifact::applyGs(CGameState *gs)
|
||||
const auto constituentInstance = hero->getArt(slot);
|
||||
gs->map->removeArtifactInstance(*hero, slot);
|
||||
|
||||
if(!combinedArt->artType->isFused())
|
||||
if(!combinedArt->getType()->isFused())
|
||||
{
|
||||
if(ArtifactUtils::isSlotEquipment(al.slot) && slot != al.slot)
|
||||
combinedArt->addPart(constituentInstance, slot);
|
||||
|
@ -2600,7 +2600,7 @@ bool CGameHandler::moveArtifact(const PlayerColor & player, const ArtifactLocati
|
||||
if((srcSlotInfo && srcSlotInfo->locked) || (dstSlotInfo && dstSlotInfo->locked))
|
||||
COMPLAIN_RET("Cannot move artifact locks.");
|
||||
|
||||
if(isDstSlotBackpack && srcArtifact->artType->isBig())
|
||||
if(isDstSlotBackpack && srcArtifact->getType()->isBig())
|
||||
COMPLAIN_RET("Cannot put big artifacts in backpack!");
|
||||
if(src.slot == ArtifactPosition::MACH4 || dstSlot == ArtifactPosition::MACH4)
|
||||
COMPLAIN_RET("Cannot move catapult!");
|
||||
@ -2625,7 +2625,7 @@ bool CGameHandler::moveArtifact(const PlayerColor & player, const ArtifactLocati
|
||||
}
|
||||
|
||||
auto hero = getHero(dst.artHolder);
|
||||
if(ArtifactUtils::checkSpellbookIsNeeded(hero, srcArtifact->artType->getId(), dstSlot))
|
||||
if(ArtifactUtils::checkSpellbookIsNeeded(hero, srcArtifact->getTypeId(), dstSlot))
|
||||
giveHeroNewArtifact(hero, ArtifactID::SPELLBOOK, ArtifactPosition::SPELLBOOK);
|
||||
|
||||
ma.artsPack0.push_back(BulkMoveArtifacts::LinkedSlots(src.slot, dstSlot));
|
||||
@ -2771,21 +2771,21 @@ bool CGameHandler::manageBackpackArtifacts(const PlayerColor & player, const Obj
|
||||
{
|
||||
makeSortBackpackRequest([](const ArtSlotInfo & inf) -> int32_t
|
||||
{
|
||||
return inf.getArt()->artType->getPossibleSlots().at(ArtBearer::HERO).front().num;
|
||||
return inf.getArt()->getType()->getPossibleSlots().at(ArtBearer::HERO).front().num;
|
||||
});
|
||||
}
|
||||
else if(sortType == ManageBackpackArtifacts::ManageCmd::SORT_BY_COST)
|
||||
{
|
||||
makeSortBackpackRequest([](const ArtSlotInfo & inf) -> int32_t
|
||||
{
|
||||
return inf.getArt()->artType->getPrice();
|
||||
return inf.getArt()->getType()->getPrice();
|
||||
});
|
||||
}
|
||||
else if(sortType == ManageBackpackArtifacts::ManageCmd::SORT_BY_CLASS)
|
||||
{
|
||||
makeSortBackpackRequest([](const ArtSlotInfo & inf) -> int32_t
|
||||
{
|
||||
return inf.getArt()->artType->aClass;
|
||||
return inf.getArt()->getType()->aClass;
|
||||
});
|
||||
}
|
||||
else
|
||||
@ -2924,7 +2924,7 @@ bool CGameHandler::assembleArtifacts(ObjectInstanceID heroID, ArtifactPosition a
|
||||
COMPLAIN_RET("assembleArtifacts: Artifact being attempted to disassemble is fused combined artifact!");
|
||||
|
||||
if(ArtifactUtils::isSlotBackpack(artifactSlot)
|
||||
&& !ArtifactUtils::isBackpackFreeSlots(hero, destArtifact->artType->getConstituents().size() - 1))
|
||||
&& !ArtifactUtils::isBackpackFreeSlots(hero, destArtifact->getType()->getConstituents().size() - 1))
|
||||
COMPLAIN_RET("assembleArtifacts: Artifact being attempted to disassemble but backpack is full!");
|
||||
|
||||
DisassembledArtifact da;
|
||||
@ -3058,11 +3058,11 @@ bool CGameHandler::sellArtifact(const IMarket *m, const CGHeroInstance *h, Artif
|
||||
COMPLAIN_RET_FALSE_IF((!h), "Only hero can sell artifacts!");
|
||||
const CArtifactInstance *art = h->getArtByInstanceId(aid);
|
||||
COMPLAIN_RET_FALSE_IF((!art), "There is no artifact to sell!");
|
||||
COMPLAIN_RET_FALSE_IF((!art->artType->isTradable()), "Cannot sell a war machine or spellbook!");
|
||||
COMPLAIN_RET_FALSE_IF((!art->getType()->isTradable()), "Cannot sell a war machine or spellbook!");
|
||||
|
||||
int resVal = 0;
|
||||
int dump = 1;
|
||||
m->getOffer(art->artType->getId(), rid, dump, resVal, EMarketMode::ARTIFACT_RESOURCE);
|
||||
m->getOffer(art->getType()->getId(), rid, dump, resVal, EMarketMode::ARTIFACT_RESOURCE);
|
||||
|
||||
removeArtifact(ArtifactLocation(h->id, h->getArtPos(art)));
|
||||
giveResource(h->tempOwner, rid, resVal);
|
||||
@ -3686,7 +3686,7 @@ bool CGameHandler::sacrificeArtifact(const IMarket * market, const CGHeroInstanc
|
||||
{
|
||||
if(auto art = artSet->getArtByInstanceId(artInstId))
|
||||
{
|
||||
if(art->artType->isTradable())
|
||||
if(art->getType()->isTradable())
|
||||
{
|
||||
int dmp;
|
||||
int expToGive;
|
||||
@ -3892,7 +3892,7 @@ bool CGameHandler::swapStacks(const StackLocation & sl1, const StackLocation & s
|
||||
bool CGameHandler::putArtifact(const ArtifactLocation & al, const ArtifactInstanceID & id, std::optional<bool> askAssemble)
|
||||
{
|
||||
const auto artInst = getArtInstance(id);
|
||||
assert(artInst && artInst->artType);
|
||||
assert(artInst && artInst->getType());
|
||||
ArtifactLocation dst(al.artHolder, ArtifactPosition::PRE_FIRST);
|
||||
dst.creature = al.creature;
|
||||
auto putTo = getArtSet(al);
|
||||
|
Loading…
Reference in New Issue
Block a user