Filter out multiple enemy messages moving to the same location #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is in regards to the code in Chapter 9: Victory and Defeat. At least, it's where I discovered it.
This fixes an issue with enemies being able to move into the same location at the same time. If you have two enemies like this:
And manipulate them into moving into the center position, they'll both end up occupying the same space. There's no actual check at the time of processing the message that the space is free. I think Legion's parallelism is getting in the way but I'm not sure*.
Also would like to know if I wrote this correctly or if there is a better/more efficient way. Creating that Vec and throwing it away every frame for positions seen seems wasteful but I'm just getting started with rust so maybe not?
*I tried following your very recent article to disable Legion's parallelism and test without this fix, but it still occurs. I still see the program using multiple threads on my computer though so I don't trust that it's actually disabled.