NLMISC::CEntityId CNewIdBuilder::getNewEntityId()
{
uint32 now = NLMISC::CTime::getSecondsSince1970();
if (now > mCreateIdLastTime)
{
mCreateIdLastTime = now;
mShortId = 0;
}
if (mShortId >= MAX_ID_PER_SEC)
{
++mCreateIdLastTime;
mShortId = 0;
nlwarning("getNewEntityId typeId = [%d] diff = [%d]", mTypeId, (mCreateIdLastTime - now));
}
uint32 fullId = (uint32)(mCreateIdLastTime<<5) + mShortId;
++mShortId;
return NLMISC::CEntityId(mTypeId, fullId);
}
{
uint32 now = NLMISC::CTime::getSecondsSince1970();
if (now > mCreateIdLastTime)
{
mCreateIdLastTime = now;
mShortId = 0;
}
if (mShortId >= MAX_ID_PER_SEC)
{
++mCreateIdLastTime;
mShortId = 0;
nlwarning("getNewEntityId typeId = [%d] diff = [%d]", mTypeId, (mCreateIdLastTime - now));
}
uint32 fullId = (uint32)(mCreateIdLastTime<<5) + mShortId;
++mShortId;
return NLMISC::CEntityId(mTypeId, fullId);
}