1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Apply suggested changes next part

This commit is contained in:
SoundSSGood 2022-11-10 20:48:19 +02:00
parent 30db38c0fe
commit 6e5932c016
4 changed files with 16 additions and 21 deletions

View File

@ -2591,7 +2591,8 @@ void CPlayerInterface::artifactMoved(const ArtifactLocation &src, const Artifact
if (artWin)
artWin->artifactMoved(src, dst);
}
GH.objsToBlit.back()->redraw();
if(!GH.objsToBlit.empty())
GH.objsToBlit.back()->redraw();
}
void CPlayerInterface::artifactPossibleAssembling(const ArtifactLocation & dst)

View File

@ -285,20 +285,9 @@ void MoveArtifact::applyCl(CClient *cl)
void BulkMoveArtifacts::applyCl(CClient * cl)
{
auto & movingArts = artsPack0;
for(auto & slotToMove : movingArts)
auto applyMove = [this, cl](std::vector<LinkedSlots> & artsPack) -> void
{
auto srcLoc = ArtifactLocation(srcArtHolder, slotToMove.srcPos);
auto dstLoc = ArtifactLocation(dstArtHolder, slotToMove.dstPos);
callInterfaceIfPresent(cl, srcLoc.owningPlayer(), &IGameEventsReceiver::artifactMoved, srcLoc, dstLoc);
if (srcLoc.owningPlayer() != dstLoc.owningPlayer())
callInterfaceIfPresent(cl, dstLoc.owningPlayer(), &IGameEventsReceiver::artifactMoved, srcLoc, dstLoc);
}
if(swap)
{
movingArts = artsPack1;
for(auto & slotToMove : movingArts)
for(auto & slotToMove : artsPack)
{
auto srcLoc = ArtifactLocation(srcArtHolder, slotToMove.srcPos);
auto dstLoc = ArtifactLocation(dstArtHolder, slotToMove.dstPos);
@ -306,7 +295,11 @@ void BulkMoveArtifacts::applyCl(CClient * cl)
if(srcLoc.owningPlayer() != dstLoc.owningPlayer())
callInterfaceIfPresent(cl, dstLoc.owningPlayer(), &IGameEventsReceiver::artifactMoved, srcLoc, dstLoc);
}
}
};
applyMove(artsPack0);
if(swap)
applyMove(artsPack1);
}
void AssembledArtifact::applyCl(CClient *cl)

View File

@ -1029,8 +1029,9 @@ struct BulkMoveArtifacts : CArtifactOperationPack
TArtHolder srcArtHolder;
TArtHolder dstArtHolder;
BulkMoveArtifacts() {}
BulkMoveArtifacts(TArtHolder srcArtHolder, TArtHolder dstArtHolder, bool swap)
BulkMoveArtifacts()
: swap(false) {}
BulkMoveArtifacts(TArtHolder srcArtHolder, TArtHolder dstArtHolder, bool swap)
: srcArtHolder(srcArtHolder), dstArtHolder(dstArtHolder), swap(swap) {}
void applyCl(CClient * cl);
@ -2248,10 +2249,10 @@ struct BulkExchangeArtifacts : public CPackForServer
ObjectInstanceID dstHero;
bool swap;
BulkExchangeArtifacts() = default;
BulkExchangeArtifacts()
: swap(false) {}
BulkExchangeArtifacts(ObjectInstanceID srcHero, ObjectInstanceID dstHero, bool swap)
: srcHero(srcHero), dstHero(dstHero), swap(swap)
{}
: srcHero(srcHero), dstHero(dstHero), swap(swap) {}
bool applyGh(CGameHandler * gh);
template <typename Handler> void serialize(Handler & h, const int version)

View File

@ -1097,7 +1097,6 @@ DLL_LINKAGE void MoveArtifact::applyGs(CGameState * gs)
DLL_LINKAGE void BulkMoveArtifacts::applyGs(CGameState * gs)
{
int numBackpackArtifactsMoved = 0;
if(swap)
{
// Swap
@ -1144,6 +1143,7 @@ DLL_LINKAGE void BulkMoveArtifacts::applyGs(CGameState * gs)
else
{
// Move
int numBackpackArtifactsMoved = 0;
for(auto & slot : artsPack0)
{
// When an object gets removed from the backpack, the backpack shrinks