bug in Samples code
Posted: Fri Aug 18, 2017 5:19 pm
In Samples/2.0/Common/include/GameEntity.h, there is the following code:
It is used in GameEntityManager::removeGameEntity, which has the following line:
This doesn't work. (See, for example, https://stackoverflow.com/questions/141 ... to-objects.)
I suggest removing the deceptive overloaded operator < and replacing it with this function:
Then in GameEntityManager::removeGameEntity, write
Note that none of the samples ever call GameEntityManager::removeGameEntity, but for someone attempting to build on the framework presented in the tutorial this bug will be a problem.
Code: Select all
bool operator < ( const GameEntity *_r ) const
{
return mId < _r->mId;
}Code: Select all
GameEntityVec::iterator itor = std::lower_bound( mGameEntities[toRemove->mType].begin(),
mGameEntities[toRemove->mType].end(),
toRemove );I suggest removing the deceptive overloaded operator < and replacing it with this function:
Code: Select all
static bool Compare(const GameEntity *_l, const GameEntity *_r)
{
return _l->mId < _r->mId;
}Code: Select all
GameEntityVec::iterator itor = std::lower_bound( mGameEntities[toRemove->mType].begin(),
mGameEntities[toRemove->mType].end(),
toRemove,
GameEntity::Compare);