1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Merge pull request #2733 from SoundSSGood/empty-bulk-move-fix

Arts bulk move crash fixed
This commit is contained in:
Ivan Savenko 2023-09-03 22:06:57 +03:00 committed by GitHub
commit 7ccc8605ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -306,14 +306,13 @@ void ApplyClientNetPackVisitor::visitBulkMoveArtifacts(BulkMoveArtifacts & pack)
}
};
ArtifactLocation srcLoc(pack.srcArtHolder, pack.artsPack0.front().srcPos);
ArtifactLocation dstLoc(pack.dstArtHolder, pack.artsPack0.front().dstPos);
auto srcOwner = std::get<ConstTransitivePtr<CGHeroInstance>>(pack.srcArtHolder)->tempOwner;
auto dstOwner = std::get<ConstTransitivePtr<CGHeroInstance>>(pack.dstArtHolder)->tempOwner;
// Begin a session of bulk movement of arts. It is not necessary but useful for the client optimization.
callInterfaceIfPresent(cl, srcLoc.owningPlayer(), &IGameEventsReceiver::bulkArtMovementStart, pack.artsPack0.size() + pack.artsPack1.size());
if (srcLoc.owningPlayer() != dstLoc.owningPlayer())
callInterfaceIfPresent(cl, dstLoc.owningPlayer(), &IGameEventsReceiver::bulkArtMovementStart, pack.artsPack0.size() + pack.artsPack1.size());
callInterfaceIfPresent(cl, srcOwner, &IGameEventsReceiver::bulkArtMovementStart, pack.artsPack0.size() + pack.artsPack1.size());
if(srcOwner != dstOwner)
callInterfaceIfPresent(cl, dstOwner, &IGameEventsReceiver::bulkArtMovementStart, pack.artsPack0.size() + pack.artsPack1.size());
applyMove(pack.artsPack0);
if(pack.swap)