mirror of
https://github.com/celisej567/mcpe.git
synced 2026-01-04 14:09:47 +03:00
Revert "* Improve the entity ID system, and add priority system. We should no longer have clashes."
This reverts commit 1b97875dd6.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include "Player.hpp"
|
||||
#include "world/level/Level.hpp"
|
||||
|
||||
EntityIDSet Entity::s_EntityIDs;
|
||||
int Entity::entityCounter;
|
||||
Random Entity::sharedRandom;
|
||||
|
||||
void Entity::_init()
|
||||
@@ -56,7 +56,6 @@ void Entity::_init()
|
||||
field_D5 = false;
|
||||
field_D6 = true;
|
||||
field_D8 = 1;
|
||||
m_EntityID = 0;
|
||||
}
|
||||
|
||||
Entity::Entity(Level* pLevel)
|
||||
@@ -64,7 +63,7 @@ Entity::Entity(Level* pLevel)
|
||||
_init();
|
||||
|
||||
m_pLevel = pLevel;
|
||||
m_EntityID = allocateEntityId();
|
||||
m_EntityID = ++entityCounter;
|
||||
setPos(0, 0, 0);
|
||||
}
|
||||
|
||||
@@ -1065,31 +1064,3 @@ bool Entity::operator==(const Entity& other) const
|
||||
{
|
||||
return m_EntityID == other.m_EntityID;
|
||||
}
|
||||
|
||||
bool Entity::isUnimportant()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int Entity::allocateEntityId()
|
||||
{
|
||||
int id = 1;
|
||||
|
||||
// TODO: could be improved? While a static monotonically increasing integer
|
||||
// is okay, as long as entities with non-standard entity IDs start to get
|
||||
// added you run into issues with clashing IDs, because Level::addEntity
|
||||
// will actually remove the old entity with the same ID.
|
||||
while (s_EntityIDs.find(id) != s_EntityIDs.end())
|
||||
id++;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
void Entity::releaseEntityId(int id)
|
||||
{
|
||||
EntityIDSet::iterator it = s_EntityIDs.find(id);
|
||||
if (it == s_EntityIDs.end())
|
||||
return;
|
||||
|
||||
s_EntityIDs.erase(it);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user