Skip to content

Commit

Permalink
[fixed] Attachments being destroyed when added to a BE enhanced item …
Browse files Browse the repository at this point in the history
…that already has 6 skill enhancing mods - Mantis #8116/8034

Change-Id: I3ebbd29845974168c9baa60a84dd259b02003d2f
  • Loading branch information
Hakry committed Aug 8, 2021
1 parent 40b2264 commit dc3b3c4
Showing 1 changed file with 25 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -148,46 +148,43 @@ int WearableObjectImplementation::socketsUsed() const {
}
}

void WearableObjectImplementation::applyAttachment(CreatureObject* player,
Attachment* attachment) {
void WearableObjectImplementation::applyAttachment(CreatureObject* player, Attachment* attachment) {
if (!isASubChildOf(player))
return;

if (socketsLeft() > 0) {
if (socketsLeft() > 0 && wearableSkillMods.size() < 6) {
Locker locker(player);

if (isEquipped()) {
removeSkillModsFrom(player);
}

if (wearableSkillMods.size() < 6) {
HashTable<String, int>* mods = attachment->getSkillMods();
HashTableIterator<String, int> iterator = mods->iterator();
HashTable<String, int>* mods = attachment->getSkillMods();
HashTableIterator<String, int> iterator = mods->iterator();

String statName;
int newValue;
String statName;
int newValue;

SortedVector< ModSortingHelper > sortedMods;
for( int i = 0; i < mods->size(); i++){
iterator.getNextKeyAndValue(statName, newValue);
sortedMods.put( ModSortingHelper( statName, newValue));
}
SortedVector< ModSortingHelper > sortedMods;
for( int i = 0; i < mods->size(); i++){
iterator.getNextKeyAndValue(statName, newValue);
sortedMods.put( ModSortingHelper( statName, newValue));
}

// Select the next mod in the SEA, sorted high-to-low. If that skill mod is already on the
// wearable, with higher or equal value, don't apply and continue. Break once one mod
// is applied.
for (int i = 0; i < sortedMods.size(); i++ ) {
String modName = sortedMods.elementAt(i).getKey();
int modValue = sortedMods.elementAt(i).getValue();

int existingValue = -26;
if (wearableSkillMods.contains(modName))
existingValue = wearableSkillMods.get(modName);

// Select the next mod in the SEA, sorted high-to-low. If that skill mod is already on the
// wearable, with higher or equal value, don't apply and continue. Break once one mod
// is applied.
for( int i = 0; i < sortedMods.size(); i++ ) {
String modName = sortedMods.elementAt(i).getKey();
int modValue = sortedMods.elementAt(i).getValue();

int existingValue = -26;
if(wearableSkillMods.contains(modName))
existingValue = wearableSkillMods.get(modName);

if( modValue > existingValue) {
wearableSkillMods.put( modName, modValue );
break;
}
if (modValue > existingValue) {
wearableSkillMods.put( modName, modValue );
break;
}
}

Expand Down

0 comments on commit dc3b3c4

Please sign in to comment.