mirror of
https://github.com/vcmi/vcmi.git
synced 2024-12-24 22:14:36 +02:00
Apply suggestions from code review
Co-authored-by: Nordsoft91 <nordsoft@yahoo.com>
This commit is contained in:
parent
f2afd9e831
commit
b9087e2d63
@ -1469,7 +1469,7 @@ void CArtifactFittingSet::setNewArtSlot(ArtifactPosition slot, CArtifactInstance
|
||||
asi.locked = locked;
|
||||
}
|
||||
|
||||
void CArtifactFittingSet::putArtifact(ArtifactPosition pos, CArtifactInstance * art)
|
||||
void CArtifactFittingSet::putArtifact(ArtifactPosition pos, CArtifactInstance & art)
|
||||
{
|
||||
if (art->canBeDisassembled() && (pos < ArtifactPosition::AFTER_LAST))
|
||||
{
|
||||
|
@ -1144,8 +1144,7 @@ DLL_LINKAGE void BulkMoveArtifacts::applyGs(CGameState * gs)
|
||||
else
|
||||
{
|
||||
// Move
|
||||
auto & artsPack = artsPack0;
|
||||
for (auto & slot : artsPack)
|
||||
for (auto & slot : artsPack0)
|
||||
{
|
||||
// When an object gets removed from the backpack, the backpack shrinks
|
||||
// so all the following indices will be affected. Thus, we need to update
|
||||
@ -1769,17 +1768,12 @@ DLL_LINKAGE void EntitiesChanged::applyGs(CGameState * gs)
|
||||
|
||||
const CArtifactInstance * ArtSlotInfo::getArt() const
|
||||
{
|
||||
if (artifact)
|
||||
{
|
||||
if (!locked)
|
||||
return artifact;
|
||||
else
|
||||
if(locked)
|
||||
{
|
||||
logNetwork->warn("ArtifactLocation::getArt: This location is locked!");
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
return nullptr;
|
||||
return artifact;
|
||||
}
|
||||
|
||||
CArtifactSet * BulkMoveArtifacts::getSrcHolderArtSet()
|
||||
|
@ -3988,7 +3988,7 @@ bool CGameHandler::bulkSwapArtifacts(ObjectInstanceID leftHero, ObjectInstanceID
|
||||
auto & slotsRightLeft = ma.artsPack1;
|
||||
|
||||
auto moveArtsWorn = [this](const CGHeroInstance * srcHero, const CGHeroInstance * dstHero,
|
||||
std::vector<BulkMoveArtifacts::LinkedSlots> * slots) -> void
|
||||
std::vector<BulkMoveArtifacts::LinkedSlots> & slots) -> void
|
||||
{
|
||||
for (auto & artifact : srcHero->artifactsWorn)
|
||||
{
|
||||
@ -3996,7 +3996,7 @@ bool CGameHandler::bulkSwapArtifacts(ObjectInstanceID leftHero, ObjectInstanceID
|
||||
continue;
|
||||
if (!ArtifactUtils::isArtRemovable(artifact))
|
||||
continue;
|
||||
slots->push_back(BulkMoveArtifacts::LinkedSlots(artifact.first, artifact.first));
|
||||
slots.push_back(BulkMoveArtifacts::LinkedSlots(artifact.first, artifact.first));
|
||||
|
||||
if (ArtifactUtils::checkSpellbookIsNeeded(dstHero, artifact.second.getArt()->artType->id, artifact.first))
|
||||
giveHeroNewArtifact(dstHero, VLC->arth->objects[ArtifactID::SPELLBOOK], ArtifactPosition::SPELLBOOK);
|
||||
@ -4010,13 +4010,13 @@ bool CGameHandler::bulkSwapArtifacts(ObjectInstanceID leftHero, ObjectInstanceID
|
||||
for (auto & slotInfo : pleftHero->artifactsInBackpack)
|
||||
{
|
||||
auto slot = pleftHero->getArtPos(slotInfo.artifact);
|
||||
slotsLeftRight->push_back(BulkMoveArtifacts::LinkedSlots(slot, slot));
|
||||
slotsLeftRight.push_back(BulkMoveArtifacts::LinkedSlots(slot, slot));
|
||||
}
|
||||
// Move over artifacts that are in backpack rightHero -> leftHero
|
||||
for (auto & slotInfo : prightHero->artifactsInBackpack)
|
||||
{
|
||||
auto slot = prightHero->getArtPos(slotInfo.artifact);
|
||||
slotsRightLeft->push_back(BulkMoveArtifacts::LinkedSlots(slot, slot));
|
||||
slotsRightLeft.push_back(BulkMoveArtifacts::LinkedSlots(slot, slot));
|
||||
}
|
||||
sendAndApply(&ma);
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user