1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-01-26 03:52:01 +02:00

Any bugs when transferring artifacts should be fixed now.

This commit is contained in:
OnionKnight 2010-02-25 00:17:52 +00:00
parent 3a76d72b69
commit 0086bbbe8c
2 changed files with 13 additions and 4 deletions

View File

@ -496,7 +496,7 @@ DLL_EXPORT void SetHeroArtifacts::setArtAtPos(ui16 pos, int art)
{
if(pos<19)
VLC->arth->unequipArtifact(artifWorn, pos);
else
else if (pos - 19 < artifacts.size())
artifacts.erase(artifacts.begin() + (pos - 19));
}
else

View File

@ -2566,14 +2566,19 @@ bool CGameHandler::swapArtifacts(si32 srcHeroID, si32 destHeroID, ui16 srcSlot,
const CArtifact *srcArtifact = srcHero->getArt(srcSlot);
const CArtifact *destArtifact = destHero->getArt(destSlot);
if (srcArtifact == NULL) {
complain("No artifact to swap!");
return false;
}
SetHeroArtifacts sha;
sha.hid = srcHeroID;
sha.artifacts = srcHero->artifacts;
sha.artifWorn = srcHero->artifWorn;
// Combinational artifacts needs to be removed first so they don't get denied movement because of their own locks.
if (srcHeroID == destHeroID && srcSlot < 19) {
VLC->arth->unequipArtifact(sha.artifWorn, srcSlot);
if (srcHeroID == destHeroID && srcSlot < 19 && destSlot < 19) {
sha.setArtAtPos(srcSlot, -1);
if (sha.artifWorn.find(destSlot) == sha.artifWorn.end())
destArtifact = NULL;
}
@ -2603,11 +2608,15 @@ bool CGameHandler::swapArtifacts(si32 srcHeroID, si32 destHeroID, ui16 srcSlot,
}
// If dest does not fit in src, put it in dest's backpack instead.
if (srcHeroID == destHeroID) // To avoid stumbling on own locks, remove artifact first.
sha.setArtAtPos(destSlot, -1);
bool destFits = !destArtifact || srcSlot >= 19 || destArtifact->fitsAt(sha.artifWorn, srcSlot);
if (srcHeroID == destHeroID && destArtifact)
sha.setArtAtPos(destSlot, destArtifact->id);
sha.setArtAtPos(srcSlot, -1);
if (destSlot < 19 && (destArtifact || srcSlot < 19) && destFits)
sha.setArtAtPos(srcSlot, destHero->getArtAtPos(destSlot));
sha.setArtAtPos(srcSlot, destArtifact ? destArtifact->id : -1);
// Internal hero artifact arrangement.
if(srcHero == destHero) {