Fix onSpawn return false and missing creature id errors
Co-Authored-By: Forgee [email protected] Special thanks to @MillhioreBT for her advice on where to put monster->decrementReferenceCounter();
Pull Request Prelude
- [x] I have followed proper The Forgotten Server code styling.
- [x] I have read and understood the contribution guidelines before making this PR.
- [x] I am aware that this PR may be closed if the above-mentioned criteria are not fulfilled.
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.
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?
Just out of curiosity, why is the
spawnMonstermethod creating astd::unique_pointerto 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