-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Server: avoid re-use of recent ParticleSpawner and Sound IDs #14045
Conversation
This improves the reliability when removing and re-adding handles quickly. Looping through the entire ID range avoids collisions caused by any race condition.
u32 free_id = m_particle_spawners_id_last_used; | ||
while (free_id == 0 || m_particle_spawners.find(free_id) != m_particle_spawners.end()) { | ||
if (free_id == m_particle_spawners_id_last_used) | ||
return 0; // full |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is zero a valid id?
I suppose not, would be good to use std::optional<u32>
for the return one day
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I currently do not see any indicator that 0 is a reserved ID - neither on client- nor server-side. However, it will at least be more consistent other the ID assignments like in ActiveObjectMgr where 0 is reserved.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
I didn't find time to test this before, sorry. This introduced a bug: Sound ids are reused to early.
To fix, either revert, or init |
…t#14045) This improves the reliability when removing and re-adding handles quickly. Looping through the entire ID range avoids collisions caused by any race condition.
…t#14045) This improves the reliability when removing and re-adding handles quickly. Looping through the entire ID range avoids collisions caused by any race condition.
This improves the reliability when removing and re-adding handles quickly. Looping through the entire ID range avoids collisions caused by any race condition.
Fixes #14044
To do
This PR is Ready for Review.
How to test