mirror of
https://github.com/vcmi/vcmi.git
synced 2024-11-24 08:32:34 +02:00
MoveArtifact struct not used now
This commit is contained in:
parent
5dbe88d9a4
commit
6dd76908bc
@ -48,7 +48,6 @@ public:
|
||||
void visitBulkSmartRebalanceStacks(BulkSmartRebalanceStacks & pack) override;
|
||||
void visitPutArtifact(PutArtifact & pack) override;
|
||||
void visitEraseArtifact(EraseArtifact & pack) override;
|
||||
void visitMoveArtifact(MoveArtifact & pack) override;
|
||||
void visitBulkMoveArtifacts(BulkMoveArtifacts & pack) override;
|
||||
void visitAssembledArtifact(AssembledArtifact & pack) override;
|
||||
void visitDisassembledArtifact(DisassembledArtifact & pack) override;
|
||||
|
@ -296,41 +296,29 @@ void ApplyClientNetPackVisitor::visitEraseArtifact(EraseArtifact & pack)
|
||||
callInterfaceIfPresent(cl, cl.getOwner(pack.al.artHolder), &IGameEventsReceiver::artifactRemoved, pack.al);
|
||||
}
|
||||
|
||||
void ApplyClientNetPackVisitor::visitMoveArtifact(MoveArtifact & pack)
|
||||
{
|
||||
auto moveArtifact = [this, &pack](PlayerColor player) -> void
|
||||
{
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::artifactMoved, pack.src, pack.dst);
|
||||
if(pack.askAssemble)
|
||||
callInterfaceIfPresent(cl, player, &IGameEventsReceiver::askToAssembleArtifact, pack.dst);
|
||||
};
|
||||
|
||||
moveArtifact(pack.interfaceOwner);
|
||||
//if(pack.interfaceOwner != cl.getOwner(pack.dst.artHolder))
|
||||
// moveArtifact(cl.getOwner(pack.dst.artHolder));
|
||||
|
||||
cl.invalidatePaths(); // hero might have equipped/unequipped Angel Wings
|
||||
}
|
||||
|
||||
void ApplyClientNetPackVisitor::visitBulkMoveArtifacts(BulkMoveArtifacts & pack)
|
||||
{
|
||||
auto applyMove = [this, &pack](std::vector<BulkMoveArtifacts::LinkedSlots> & artsPack) -> void
|
||||
const auto dstOwner = cl.getOwner(pack.dstArtHolder);
|
||||
const auto applyMove = [this, &pack, dstOwner](std::vector<BulkMoveArtifacts::LinkedSlots> & artsPack)
|
||||
{
|
||||
for(auto & slotToMove : artsPack)
|
||||
for(const auto & slotToMove : artsPack)
|
||||
{
|
||||
auto srcLoc = ArtifactLocation(pack.srcArtHolder, slotToMove.srcPos);
|
||||
auto dstLoc = ArtifactLocation(pack.dstArtHolder, slotToMove.dstPos);
|
||||
MoveArtifact ma(pack.interfaceOwner, srcLoc, dstLoc, pack.askAssemble);
|
||||
visitMoveArtifact(ma);
|
||||
const auto srcLoc = ArtifactLocation(pack.srcArtHolder, slotToMove.srcPos);
|
||||
const auto dstLoc = ArtifactLocation(pack.dstArtHolder, slotToMove.dstPos);
|
||||
|
||||
callInterfaceIfPresent(cl, pack.interfaceOwner, &IGameEventsReceiver::artifactMoved, srcLoc, dstLoc);
|
||||
if(pack.askAssemble)
|
||||
callInterfaceIfPresent(cl, pack.interfaceOwner, &IGameEventsReceiver::askToAssembleArtifact, dstLoc);
|
||||
if(pack.interfaceOwner != dstOwner)
|
||||
callInterfaceIfPresent(cl, dstOwner, &IGameEventsReceiver::artifactMoved, srcLoc, dstLoc);
|
||||
|
||||
cl.invalidatePaths(); // hero might have equipped/unequipped Angel Wings
|
||||
}
|
||||
};
|
||||
|
||||
auto srcOwner = cl.getOwner(pack.srcArtHolder);
|
||||
auto dstOwner = cl.getOwner(pack.dstArtHolder);
|
||||
|
||||
// Begin a session of bulk movement of arts. It is not necessary but useful for the client optimization.
|
||||
callInterfaceIfPresent(cl, srcOwner, &IGameEventsReceiver::bulkArtMovementStart, pack.artsPack0.size() + pack.artsPack1.size());
|
||||
if(srcOwner != dstOwner)
|
||||
callInterfaceIfPresent(cl, pack.interfaceOwner, &IGameEventsReceiver::bulkArtMovementStart, pack.artsPack0.size() + pack.artsPack1.size());
|
||||
if(pack.interfaceOwner != dstOwner)
|
||||
callInterfaceIfPresent(cl, dstOwner, &IGameEventsReceiver::bulkArtMovementStart, pack.artsPack0.size() + pack.artsPack1.size());
|
||||
|
||||
applyMove(pack.artsPack0);
|
||||
|
@ -176,9 +176,9 @@ void CArtifactsOfHeroQuickBackpack::setHero(const CGHeroInstance * hero)
|
||||
initAOHbackpack(requiredSlots, false);
|
||||
auto artPlace = backpack.begin();
|
||||
for(auto & art : filteredArts)
|
||||
setSlotData(*artPlace++, curHero->getSlotByInstance(art.second));
|
||||
setSlotData(*artPlace++, curHero->getArtPos(art.second));
|
||||
for(auto & art : filteredScrolls)
|
||||
setSlotData(*artPlace++, curHero->getSlotByInstance(art.second));
|
||||
setSlotData(*artPlace++, curHero->getArtPos(art.second));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -221,7 +221,7 @@ void CAltarArtifacts::onSlotClickPressed(const std::shared_ptr<CTradeableItem> &
|
||||
else if(altarSlot->id != -1)
|
||||
{
|
||||
assert(tradeSlotsMap.at(altarSlot));
|
||||
const auto slot = altarArtifacts->getSlotByInstance(tradeSlotsMap.at(altarSlot));
|
||||
const auto slot = altarArtifacts->getArtPos(tradeSlotsMap.at(altarSlot));
|
||||
assert(slot != ArtifactPosition::PRE_FIRST);
|
||||
LOCPLINT->cb->swapArtifacts(ArtifactLocation(heroArts->altarId, slot),
|
||||
ArtifactLocation(hero->id, GH.isKeyboardCtrlDown() ? ArtifactPosition::FIRST_AVAILABLE : ArtifactPosition::TRANSITION_POS));
|
||||
|
@ -741,19 +741,6 @@ std::vector<ArtifactPosition> CArtifactSet::getBackpackArtPositions(const Artifa
|
||||
return result;
|
||||
}
|
||||
|
||||
ArtifactPosition CArtifactSet::getArtPos(const CArtifactInstance *art) const
|
||||
{
|
||||
for(auto i : artifactsWorn)
|
||||
if(i.second.artifact == art)
|
||||
return i.first;
|
||||
|
||||
for(int i = 0; i < artifactsInBackpack.size(); i++)
|
||||
if(artifactsInBackpack[i].artifact == art)
|
||||
return ArtifactPosition::BACKPACK_START + i;
|
||||
|
||||
return ArtifactPosition::PRE_FIRST;
|
||||
}
|
||||
|
||||
const CArtifactInstance * CArtifactSet::getArtByInstanceId(const ArtifactInstanceID & artInstId) const
|
||||
{
|
||||
for(auto i : artifactsWorn)
|
||||
@ -767,7 +754,7 @@ const CArtifactInstance * CArtifactSet::getArtByInstanceId(const ArtifactInstanc
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const ArtifactPosition CArtifactSet::getSlotByInstance(const CArtifactInstance * artInst) const
|
||||
const ArtifactPosition CArtifactSet::getArtPos(const CArtifactInstance * artInst) const
|
||||
{
|
||||
if(artInst)
|
||||
{
|
||||
|
@ -207,11 +207,10 @@ public:
|
||||
/// Looks for equipped artifact with given ID and returns its slot ID or -1 if none
|
||||
/// (if more than one such artifact lower ID is returned)
|
||||
ArtifactPosition getArtPos(const ArtifactID & aid, bool onlyWorn = true, bool allowLocked = true) const;
|
||||
ArtifactPosition getArtPos(const CArtifactInstance *art) const;
|
||||
const ArtifactPosition getArtPos(const CArtifactInstance * art) const;
|
||||
std::vector<ArtifactPosition> getAllArtPositions(const ArtifactID & aid, bool onlyWorn, bool allowLocked, bool getAll) const;
|
||||
std::vector<ArtifactPosition> getBackpackArtPositions(const ArtifactID & aid) const;
|
||||
const CArtifactInstance * getArtByInstanceId(const ArtifactInstanceID & artInstId) const;
|
||||
const ArtifactPosition getSlotByInstance(const CArtifactInstance * artInst) const;
|
||||
/// Search for constituents of assemblies in backpack which do not have an ArtifactPosition
|
||||
const CArtifactInstance * getHiddenArt(const ArtifactID & aid) const;
|
||||
const CArtifactInstance * getAssemblyByConstituent(const ArtifactID & aid) const;
|
||||
|
@ -284,6 +284,10 @@ CArtifactSet * CNonConstInfoCallback::getArtSet(const ArtifactLocation & loc)
|
||||
return hero;
|
||||
}
|
||||
}
|
||||
else if(auto army = getArmyInstance(loc.artHolder))
|
||||
{
|
||||
return army->getStackPtr(loc.creature.value());
|
||||
}
|
||||
else if(auto market = dynamic_cast<CGArtifactsAltar*>(getObjInstance(loc.artHolder)))
|
||||
{
|
||||
return market;
|
||||
|
@ -54,6 +54,7 @@ namespace GameConstants
|
||||
constexpr int ALTAR_ARTIFACTS_SLOTS = 22;
|
||||
constexpr int TOURNAMENT_RULES_DD_MAP_TILES_THRESHOLD = 144*144*2; //map tiles count threshold for 2 dimension door casts with tournament rules
|
||||
constexpr int KINGDOM_WINDOW_HEROES_SLOTS = 4;
|
||||
constexpr int INFO_WINDOW_ARTIFACTS_MAX_ITEMS = 14;
|
||||
}
|
||||
|
||||
VCMI_LIB_NAMESPACE_END
|
||||
|
@ -78,7 +78,6 @@ public:
|
||||
virtual void visitBulkSmartRebalanceStacks(BulkSmartRebalanceStacks & pack) {}
|
||||
virtual void visitPutArtifact(PutArtifact & pack) {}
|
||||
virtual void visitEraseArtifact(EraseArtifact & pack) {}
|
||||
virtual void visitMoveArtifact(MoveArtifact & pack) {}
|
||||
virtual void visitBulkMoveArtifacts(BulkMoveArtifacts & pack) {}
|
||||
virtual void visitAssembledArtifact(AssembledArtifact & pack) {}
|
||||
virtual void visitDisassembledArtifact(DisassembledArtifact & pack) {}
|
||||
|
@ -338,11 +338,6 @@ void EraseArtifact::visitTyped(ICPackVisitor & visitor)
|
||||
visitor.visitEraseArtifact(*this);
|
||||
}
|
||||
|
||||
void MoveArtifact::visitTyped(ICPackVisitor & visitor)
|
||||
{
|
||||
visitor.visitMoveArtifact(*this);
|
||||
}
|
||||
|
||||
void BulkMoveArtifacts::visitTyped(ICPackVisitor & visitor)
|
||||
{
|
||||
visitor.visitBulkMoveArtifacts(*this);
|
||||
@ -1794,17 +1789,6 @@ void EraseArtifact::applyGs(CGameState *gs)
|
||||
art->removeFrom(*artSet, al.slot);
|
||||
}
|
||||
|
||||
void MoveArtifact::applyGs(CGameState * gs)
|
||||
{
|
||||
auto srcHero = gs->getArtSet(src);
|
||||
auto dstHero = gs->getArtSet(dst);
|
||||
assert(srcHero);
|
||||
assert(dstHero);
|
||||
auto art = srcHero->getArt(src.slot);
|
||||
assert(art && art->canBePutAt(dstHero, dst.slot));
|
||||
art->move(*srcHero, src.slot, *dstHero, dst.slot);
|
||||
}
|
||||
|
||||
void BulkMoveArtifacts::applyGs(CGameState * gs)
|
||||
{
|
||||
const auto bulkArtsRemove = [](std::vector<LinkedSlots> & artsPack, CArtifactSet & artSet)
|
||||
@ -1861,7 +1845,7 @@ void AssembledArtifact::applyGs(CGameState *gs)
|
||||
return art->getId() == builtArt->getId();
|
||||
}));
|
||||
|
||||
const auto transformedArtSlot = hero->getSlotByInstance(transformedArt);
|
||||
const auto transformedArtSlot = hero->getArtPos(transformedArt);
|
||||
auto * combinedArt = new CArtifactInstance(builtArt);
|
||||
gs->map->addNewArtifactInstance(combinedArt);
|
||||
|
||||
|
@ -1025,30 +1025,6 @@ struct DLL_LINKAGE EraseArtifact : CArtifactOperationPack
|
||||
}
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE MoveArtifact : CArtifactOperationPack
|
||||
{
|
||||
MoveArtifact() = default;
|
||||
MoveArtifact(const PlayerColor & interfaceOwner, const ArtifactLocation & src, const ArtifactLocation & dst, bool askAssemble = true)
|
||||
: interfaceOwner(interfaceOwner), src(src), dst(dst), askAssemble(askAssemble)
|
||||
{
|
||||
}
|
||||
PlayerColor interfaceOwner;
|
||||
ArtifactLocation src;
|
||||
ArtifactLocation dst;
|
||||
bool askAssemble = true;
|
||||
|
||||
void applyGs(CGameState * gs);
|
||||
void visitTyped(ICPackVisitor & visitor) override;
|
||||
|
||||
template <typename Handler> void serialize(Handler & h)
|
||||
{
|
||||
h & interfaceOwner;
|
||||
h & src;
|
||||
h & dst;
|
||||
h & askAssemble;
|
||||
}
|
||||
};
|
||||
|
||||
struct DLL_LINKAGE BulkMoveArtifacts : CArtifactOperationPack
|
||||
{
|
||||
struct LinkedSlots
|
||||
|
@ -112,7 +112,6 @@ void registerTypesClientPacks(Serializer &s)
|
||||
s.template registerType<CPackForClient, CArtifactOperationPack>();
|
||||
s.template registerType<CArtifactOperationPack, PutArtifact>();
|
||||
s.template registerType<CArtifactOperationPack, EraseArtifact>();
|
||||
s.template registerType<CArtifactOperationPack, MoveArtifact>();
|
||||
s.template registerType<CArtifactOperationPack, AssembledArtifact>();
|
||||
s.template registerType<CArtifactOperationPack, DisassembledArtifact>();
|
||||
s.template registerType<CArtifactOperationPack, BulkMoveArtifacts>();
|
||||
|
@ -2956,7 +2956,7 @@ bool CGameHandler::switchArtifactsCostume(const PlayerColor & player, const Obje
|
||||
{
|
||||
bma.artsPack0.emplace_back(BulkMoveArtifacts::LinkedSlots
|
||||
{
|
||||
artSet->getSlotByInstance(artFittingSet.getArt(availableArts.front())),
|
||||
artSet->getArtPos(artFittingSet.getArt(availableArts.front())),
|
||||
artPos.first
|
||||
});
|
||||
artFittingSet.removeArtifact(availableArts.front());
|
||||
@ -3921,7 +3921,7 @@ bool CGameHandler::sacrificeArtifact(const IMarket * m, const CGHeroInstance * h
|
||||
int expToGive;
|
||||
m->getOffer(art->getTypeId(), 0, dmp, expToGive, EMarketMode::ARTIFACT_EXP);
|
||||
expSum += expToGive;
|
||||
removeArtifact(ArtifactLocation(altarObj->id, altarObj->getSlotByInstance(art)));
|
||||
removeArtifact(ArtifactLocation(altarObj->id, altarObj->getArtPos(art)));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -348,6 +348,7 @@ void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle)
|
||||
|
||||
const auto addArtifactToTransfer = [&](const ArtifactPosition & srcSlot, const CArtifactInstance * art)
|
||||
{
|
||||
assert(art);
|
||||
const auto dstSlot = ArtifactUtils::getArtAnyPosition(&artFittingSet, art->getTypeId());
|
||||
if(dstSlot != ArtifactPosition::PRE_FIRST)
|
||||
{
|
||||
@ -371,8 +372,7 @@ void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle)
|
||||
}
|
||||
for(const auto & artSlot : finishingBattle->loserHero->artifactsInBackpack)
|
||||
{
|
||||
const auto art = artSlot.getArt();
|
||||
if(art->getTypeId() != ArtifactID::GRAIL)
|
||||
if(const auto art = artSlot.getArt(); art->getTypeId() != ArtifactID::GRAIL)
|
||||
addArtifactToTransfer(finishingBattle->loserHero->getArtPos(art), art);
|
||||
}
|
||||
sendArtifacts();
|
||||
@ -399,31 +399,27 @@ void BattleResultProcessor::endBattleConfirm(const CBattleInfoCallback & battle)
|
||||
sendArtifacts();
|
||||
}
|
||||
}
|
||||
|
||||
if (arts.size()) //display loot
|
||||
// Display loot
|
||||
if(!arts.empty())
|
||||
{
|
||||
InfoWindow iw;
|
||||
iw.player = finishingBattle->winnerHero->tempOwner;
|
||||
iw.text.appendLocalString(EMetaText::GENERAL_TXT, 30); //You have captured enemy artifact
|
||||
|
||||
iw.text.appendLocalString (EMetaText::GENERAL_TXT, 30); //You have captured enemy artifact
|
||||
|
||||
for (auto art : arts) //TODO; separate function to display loot for various objects?
|
||||
for(auto art : arts) //TODO; separate function to display loot for various objects?
|
||||
{
|
||||
if (art->artType->getId() == ArtifactID::SPELL_SCROLL)
|
||||
if(art->isScroll())
|
||||
iw.components.emplace_back(ComponentType::SPELL_SCROLL, art->getScrollSpellID());
|
||||
else
|
||||
iw.components.emplace_back(ComponentType::ARTIFACT, art->artType->getId());
|
||||
iw.components.emplace_back(ComponentType::ARTIFACT, art->getTypeId());
|
||||
|
||||
if (iw.components.size() >= 14)
|
||||
if(iw.components.size() >= GameConstants::INFO_WINDOW_ARTIFACTS_MAX_ITEMS)
|
||||
{
|
||||
gameHandler->sendAndApply(&iw);
|
||||
iw.components.clear();
|
||||
}
|
||||
}
|
||||
if (iw.components.size())
|
||||
{
|
||||
gameHandler->sendAndApply(&iw);
|
||||
}
|
||||
gameHandler->sendAndApply(&iw);
|
||||
}
|
||||
//Eagle Eye secondary skill handling
|
||||
if (!cs.spells.empty())
|
||||
|
Loading…
Reference in New Issue
Block a user