Skip to content

Commit 7a88325

Browse files
committed
Core: Fix some accidental copies during iteration
1 parent e612d35 commit 7a88325

3 files changed

Lines changed: 10 additions & 8 deletions

File tree

src/map/ai/helpers/targetfind.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,11 +390,13 @@ void CTargetFind::addAllInRange(CBattleEntity* PTarget, float radius, ALLEGIANCE
390390
if (PTarget->objtype == TYPE_PC)
391391
{
392392
CCharEntity* PChar = static_cast<CCharEntity*>(PTarget);
393-
for (auto& spawnList : { PChar->SpawnPCList, PChar->SpawnPETList })
393+
for (const auto* spawnList : { &PChar->SpawnPCList, &PChar->SpawnPETList })
394394
{
395-
FOR_EACH_PAIR_CAST_SECOND(CBattleEntity*, PBattleEntity, spawnList)
395+
FOR_EACH_PAIR_CAST_SECOND(CBattleEntity*, PBattleEntity, *spawnList)
396396
{
397-
if (PBattleEntity && isWithinArea(&(PBattleEntity->loc.p)) && !PBattleEntity->isDead() &&
397+
if (PBattleEntity &&
398+
isWithinArea(&(PBattleEntity->loc.p)) &&
399+
!PBattleEntity->isDead() &&
398400
PBattleEntity->allegiance == ALLEGIANCE_TYPE::PLAYER)
399401
{
400402
m_targets.emplace_back(PBattleEntity);

src/map/ai/states/petskill_state.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ CPetSkillState::CPetSkillState(CPetEntity* PEntity, uint16 targid, uint16 wsid)
7373
.actionid = static_cast<uint32_t>(FourCC::SkillUse),
7474
.targets = {
7575
{
76-
.actorId = PTarget->id,
77-
.results = {
76+
.actorId = PTarget->id,
77+
.results = {
7878
{
79-
.param = m_PSkill->getMobSkillID() > 0 ? m_PSkill->getMobSkillID() : m_PSkill->getID(),
80-
.messageID = m_PSkill->getMobSkillID() > 0 ? MsgBasic::ReadiesWeaponskill : MsgBasic::ReadiesSkill,
79+
.param = m_PSkill->getMobSkillID() > 0 ? m_PSkill->getMobSkillID() : m_PSkill->getID(),
80+
.messageID = m_PSkill->getMobSkillID() > 0 ? MsgBasic::ReadiesWeaponskill : MsgBasic::ReadiesSkill,
8181
},
8282
},
8383
},

src/map/zone.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -771,7 +771,7 @@ bool CZone::CheckMobsPathedBack()
771771
bool allMobsHomeAndHealed = true;
772772
if (m_zoneEntities && m_zoneEntities->GetMobList().size() > 0)
773773
{
774-
EntityList_t mobListMap = m_zoneEntities->GetMobList();
774+
const auto& mobListMap = m_zoneEntities->GetMobList();
775775
for (const auto& pair : mobListMap)
776776
{
777777
CMobEntity* mob = dynamic_cast<CMobEntity*>(pair.second);

0 commit comments

Comments
 (0)