forgottenserver icon indicating copy to clipboard operation
forgottenserver copied to clipboard

Fix onSpawn return false and missing creature id errors

Open Codinablack opened this issue 3 years ago • 2 comments

Co-Authored-By: Forgee [email protected] Special thanks to @MillhioreBT for her advice on where to put monster->decrementReferenceCounter();

Pull Request Prelude

Changes Proposed

[#4086] [#4077]

This fixes the monster not being assigned a creature id during "onSpawn" event, it safely removes the monster if returned false, and fixes the problem of returning false with onSpawn breaking the internal spawn check system.

Spent much time finding #4086 when trying to solve #4077, but it was a problem unknown and this pr has been tested pretty well, no errors found.

Codinablack avatar Apr 20 '22 03:04 Codinablack

Just out of curiosity, why is the spawnMonster method creating a std::unique_pointer to immediately release the ownership of the stored object? Why bother creating an auto managed pointer if it is not going to be used at all? Am I missing something?

amatria avatar Apr 21 '22 11:04 amatria

Just out of curiosity, why is the spawnMonster method creating a std::unique_pointer to immediately release the ownership of the stored object? Why bother creating an auto managed pointer if it is not going to be used at all? Am I missing something?

To avoid memory leaks, when placeCreature fails

nekiro avatar Apr 21 '22 11:04 nekiro