11-12-2013, 01:34 AM
The condition in the third line is unclear and probably buggy. Use parenthesis to indicate the proper order of evaluation, the OR versus the AND.
The IsDestroyed() function has a slightly different meaning. It returns false throughout the object's lifetime, until the Destroy() function is called. The Destroy() function doesn't destroy the object, it only sets a flag that the object should be destroyed (because other objects may be still referencing this player). Since then, the IsDestroyed() function returns true, although the object is still perfectly valid. Then in a well-defined point in time the object is actually deleted, and all calls to it will lead to undefined behavior (crash, if you're lucky).
The IsDestroyed() function has a slightly different meaning. It returns false throughout the object's lifetime, until the Destroy() function is called. The Destroy() function doesn't destroy the object, it only sets a flag that the object should be destroyed (because other objects may be still referencing this player). Since then, the IsDestroyed() function returns true, although the object is still perfectly valid. Then in a well-defined point in time the object is actually deleted, and all calls to it will lead to undefined behavior (crash, if you're lucky).