Hopson97 / open-builder

Open "Minecraft-like" game with multiplayer support and Lua scripting support for the both client and server
https://github.com/Hopson97/open-builder/projects/3
GNU General Public License v3.0
703 stars 80 forks source link

Fixed Gameplay::update() #26

Closed human-0 closed 4 years ago

human-0 commented 4 years ago

erase() invalidates the iterator being erased, so that it can no longer be incremented. This results in an error in debug mode, and possibly other behaviours in release mode.

Hopson97 commented 4 years ago

Ah, this loop was adapted from a regular for loop, brain fart meant it wasn't correct.

However, this is not entirely correct. While you are right about the iterator not being incremented in the loop itself, passing the iterator to the erase function will infact increment the iterator.

Otherwise, an if statement that does the increment will suffice.