ronancpl/HeavenMS

changeStatPool method incorrectly calls hpmp update trigger in MapleCharacterAbstractObject

Closed this issue · 3 comments

There is code here when you do the stat update:

                if (newAp >= 0) {
                    setRemainingAp(newAp);
                    statUpdates.put(MapleStat.AVAILABLEAP, remainingAp);
                }

                poolUpdate = true;  // recalc stats

However, poolUpdate only does the HpMp trigger, there is no AP trigger:

             if (poolUpdate) {
                    dispatchHpmpPoolUpdated();
                }

Affirmative.

Oh, unfortunately, that was an expected case... That code sect expects a call for MapleCharacter::recalcLocalStats(), which is postponed to happen in here:

            @Override
            public void onHpmpPoolUpdate() {
                List<Pair<MapleStat, Integer>> hpmpupdate = recalcLocalStats();

To overcome this roundabout measure, perhaps another solution would be to refactor out AbstractMapleCharacterObject, thus making the stat business logic within MapleCharacter.

In another wind, to avoid the misuse of onHpmpPoolUpdate(), creating a new listener to carry out the AP stat update may suit it better.