mirror of
https://github.com/celisej567/mcpe.git
synced 2026-09-23 20:09:46 +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);
|
||||
}
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <unordered_set>
|
||||
#include "client/common/AABB.hpp"
|
||||
#include "client/common/Vec3.hpp"
|
||||
#include "world/level/Material.hpp"
|
||||
@@ -40,22 +39,19 @@ struct EntityPos
|
||||
EntityPos()
|
||||
{
|
||||
m_yaw = 0, m_pitch = 0;
|
||||
m_bHasRot = false, m_bHasPos = false;
|
||||
m_bHasRot, m_bHasPos;
|
||||
};
|
||||
|
||||
EntityPos(const Vec3& pos)
|
||||
{
|
||||
m_pos = pos;
|
||||
m_yaw = m_pitch = 0;
|
||||
m_bHasPos = true;
|
||||
m_bHasRot = false;
|
||||
}
|
||||
|
||||
EntityPos(float yaw, float pitch)
|
||||
{
|
||||
m_yaw = yaw;
|
||||
m_pitch = pitch;
|
||||
m_bHasPos = false;
|
||||
m_bHasRot = true;
|
||||
}
|
||||
|
||||
@@ -69,8 +65,6 @@ struct EntityPos
|
||||
}
|
||||
};
|
||||
|
||||
typedef std::unordered_set<int> EntityIDSet;
|
||||
|
||||
class Entity
|
||||
{
|
||||
private:
|
||||
@@ -140,7 +134,6 @@ public:
|
||||
virtual void markHurt();
|
||||
virtual void burn(int);
|
||||
virtual void lavaHurt();
|
||||
virtual bool isUnimportant();
|
||||
|
||||
int hashCode();
|
||||
|
||||
@@ -154,12 +147,8 @@ public:
|
||||
(m_pos.z - z) * (m_pos.z - z);
|
||||
}
|
||||
|
||||
private:
|
||||
int allocateEntityId();
|
||||
void releaseEntityId(int);
|
||||
static EntityIDSet s_EntityIDs;
|
||||
//static int entityCounter;
|
||||
public:
|
||||
static int entityCounter;
|
||||
static Random sharedRandom;
|
||||
|
||||
Vec3 m_pos;
|
||||
|
||||
Reference in New Issue
Block a user