1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-12-01 23:12:49 +02:00

CCombinedArtifactInstance refactoring

This commit is contained in:
SoundSSGood
2023-06-18 15:21:35 +03:00
parent 7aef0f404b
commit 07c811dd67
8 changed files with 99 additions and 165 deletions

View File

@@ -6806,17 +6806,12 @@ bool CGameHandler::giveHeroNewArtifact(const CGHeroInstance * h, const CArtifact
COMPLAIN_RET_FALSE_IF(!artType->canBePutAt(h, pos, false), "Cannot put artifact in that slot!");
}
CArtifactInstance * newArtInst = nullptr;
if(artType->canBeDisassembled())
newArtInst = new CCombinedArtifactInstance();
else
newArtInst = new CArtifactInstance();
auto * newArtInst = new CArtifactInstance();
newArtInst->artType = artType; // *NOT* via settype -> all bonus-related stuff must be done by NewArtifact apply
NewArtifact na;
na.art = newArtInst;
sendAndApply(&na); // -> updates a!!!, will create a on other machines
sendAndApply(&na); // -> updates newArtInst!!!
if(giveHeroArtifact(h, newArtInst, pos))
return true;