1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-01 17:38:41 +00:00

Generic CAO cleanups and renames for clarification

* Use enum for GENERIC_CMD_*
* Rename m_attachements to attachement_parent_ids (public member and clearer name)
* Rename GENERIC_CMD_SET_ATTACHMENT to GENERIC_CMD_ATTACH_TO
* USHRT_MAX + 1 buffer sizes to prevent overflows as @kahrl suggested
* Remove unneccessary m_id from GenericCAO (shadowing protected superclass member for no reason) as @kahrl suggested
This commit is contained in:
est31 2015-06-20 03:20:06 +02:00
parent 40226e5274
commit dd91b3d6fb
8 changed files with 26 additions and 25 deletions

View file

@ -543,7 +543,6 @@ GenericCAO::GenericCAO(IGameDef *gamedef, ClientEnvironment *env):
//
m_is_player(false),
m_is_local_player(false),
m_id(0),
//
m_smgr(NULL),
m_irr(NULL),
@ -747,7 +746,7 @@ ClientActiveObject* GenericCAO::getParent()
{
ClientActiveObject *obj = NULL;
u16 attached_id = m_env->m_attachements[getId()];
u16 attached_id = m_env->attachement_parent_ids[getId()];
if ((attached_id != 0) &&
(attached_id != getId())) {
@ -764,12 +763,12 @@ void GenericCAO::removeFromScene(bool permanent)
for(std::vector<u16>::iterator ci = m_children.begin();
ci != m_children.end(); ci++)
{
if (m_env->m_attachements[*ci] == getId()) {
m_env->m_attachements[*ci] = 0;
if (m_env->attachement_parent_ids[*ci] == getId()) {
m_env->attachement_parent_ids[*ci] = 0;
}
}
m_env->m_attachements[getId()] = 0;
m_env->attachement_parent_ids[getId()] = 0;
LocalPlayer* player = m_env->getLocalPlayer();
if (this == player->parent) {
@ -1111,7 +1110,7 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
for(std::vector<u16>::iterator ci = m_children.begin();
ci != m_children.end();)
{
if (m_env->m_attachements[*ci] != getId()) {
if (m_env->attachement_parent_ids[*ci] != getId()) {
ci = m_children.erase(ci);
continue;
}
@ -1669,9 +1668,9 @@ void GenericCAO::processMessage(const std::string &data)
m_bone_position[bone] = core::vector2d<v3f>(position, rotation);
updateBonePosition();
} else if (cmd == GENERIC_CMD_SET_ATTACHMENT) {
} else if (cmd == GENERIC_CMD_ATTACH_TO) {
u16 parentID = readS16(is);
m_env->m_attachements[getId()] = parentID;
m_env->attachement_parent_ids[getId()] = parentID;
GenericCAO *parentobj = m_env->getGenericCAO(parentID);
if (parentobj) {