ronancpl / HeavenMS

An improved server based on MapleSolaxia (v83 MapleStory private server)
GNU Affero General Public License v3.0
1.03k stars 742 forks source link

changeStatPool method incorrectly calls hpmp update trigger in MapleCharacterAbstractObject #518

Closed CanIGetaPR closed 5 years ago

CanIGetaPR commented 5 years ago

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();
                }
ronancpl commented 5 years ago

Affirmative.

ronancpl commented 5 years ago

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.

ronancpl commented 5 years ago

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