1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-11-25 22:42:04 +02:00

Fixed artifact screens so only local changes are made. Some ugly const casting, for now.

This commit is contained in:
OnionKnight
2010-02-05 22:28:31 +00:00
parent 5fe80d89ef
commit 137ab65a13
8 changed files with 95 additions and 127 deletions

View File

@@ -2522,45 +2522,6 @@ bool CGameHandler::swapArtifacts(si32 srcHeroID, si32 destHeroID, ui16 srcSlot,
return true;
}
/**
* Sets a hero artifact slot to contain a specific artifact.
*
* @param artID ID of an artifact or -1 for no artifact.
*/
bool CGameHandler::setArtifact(si32 heroID, ui16 slot, int artID)
{
const CGHeroInstance *hero = gs->getHero(heroID);
if (artID != -1) {
const CArtifact &artifact = VLC->arth->artifacts[artID];
if (slot < 19 && !vstd::contains(artifact.possibleSlots, slot)) {
complain("Artifact does not fit!");
return false;
}
if (slot >= 19 && artifact.isBig()) {
complain("Cannot put big artifacts in backpack!");
return false;
}
}
if (slot == 16) {
complain("Cannot alter catapult slot!");
return false;
}
// Perform the exchange.
SetHeroArtifacts sha;
sha.hid = heroID;
sha.artifacts = hero->artifacts;
sha.artifWorn = hero->artifWorn;
sha.setArtAtPos(slot, artID);
sendAndApply(&sha);
return true;
}
bool CGameHandler::buyArtifact( ui32 hid, si32 aid )
{
CGHeroInstance *hero = gs->getHero(hid);